actioncenter: Reduce usage of transforms and cleanup

Simplify positioning of some components by avoiding transforms and using
simple anchors to improve performance. Also cleanup unused properties.
This commit is contained in:
Devin Lin 2024-10-29 20:30:09 -07:00
parent 159e3bb3a6
commit 35b1128d1d
5 changed files with 30 additions and 65 deletions

View file

@ -168,18 +168,14 @@ Item {
readonly property real intendedWidth: 360
property real offsetRatio: quickSettings.height / root.height
anchors.topMargin: Math.min(root.actionDrawer.offset * offsetRatio - quickSettings.height, 0)
anchors.top: parent.top
anchors.right: parent.right
actionDrawer: root.actionDrawer
quickSettingsModel: root.quickSettingsModel
fullScreenHeight: root.height
transform: Translate {
id: translate
property real offsetRatio: quickSettings.height / root.height
y: Math.min(root.actionDrawer.offset * offsetRatio - quickSettings.height, 0)
}
}
}
}

View file

@ -53,6 +53,10 @@ Item {
MobileShell.QuickSettingsDrawer {
id: quickSettings
z: 1 // ensure it's above notifications
// physically move the drawer when between closed <-> pinned mode
readonly property real offsetHeight: actionDrawer.openToPinnedMode ? minimizedQuickSettingsOffset : maximizedQuickSettingsOffset
anchors.topMargin: Math.min(root.actionDrawer.offset - offsetHeight, 0)
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
@ -91,13 +95,6 @@ Item {
return (quickSettings.maxAddedHeight * effectProgress) + Math.max(0, Math.min(quickSettings.maxAddedHeight, root.actionDrawer.offset - minimizedQuickSettingsOffset));
}
}
// physically move the drawer when between closed <-> pinned mode
transform: Translate {
id: translate
readonly property real offsetHeight: actionDrawer.openToPinnedMode ? minimizedQuickSettingsOffset : maximizedQuickSettingsOffset
y: Math.min(root.actionDrawer.offset - offsetHeight, 0)
}
}
MobileShell.NotificationsWidget {
@ -119,8 +116,7 @@ Item {
onBackgroundClicked: root.actionDrawer.close();
anchors {
top: quickSettings.top
topMargin: quickSettings.height + translate.y
top: quickSettings.bottom
bottom: parent.bottom
left: parent.left
right: parent.right

View file

@ -23,15 +23,9 @@ Item {
clip: true
required property var actionDrawer
required property int mode
property QS.QuickSettingsModel quickSettingsModel
enum Mode {
Pages,
ScrollView
}
readonly property real columns: Math.round(Math.min(6, Math.max(3, width / intendedColumnWidth)))
readonly property real columnWidth: Math.floor(width / columns)
readonly property int minimizedColumns: Math.round(Math.min(8, Math.max(5, width / intendedMinimizedColumnWidth)))
@ -44,7 +38,6 @@ Item {
readonly property real intendedMinimizedColumnWidth: Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing
readonly property real minimizedRowHeight: Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing
property real minimizedViewProgress: 0
property real fullViewProgress: 1
readonly property int columnCount: Math.floor(width/columnWidth)
@ -69,7 +62,7 @@ Item {
function resetSwipeView() {
if (root.mode === QuickSettings.Pages) {
pageLoader.item.view.currentIndex = 0;
swipeView.currentIndex = 0;
}
}
@ -84,44 +77,13 @@ Item {
}
}
// view when fully open
ColumnLayout {
id: fullView
opacity: root.fullViewProgress
visible: opacity !== 0
transform: Translate { y: (1 - fullView.opacity) * root.rowHeight }
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
// Dynamically loads the appropriate view
Loader {
id: pageLoader
Layout.fillWidth: true
Layout.minimumHeight: rowCount * rowHeight
asynchronous: true
sourceComponent: swipeViewComponent
}
BrightnessItem {
Layout.bottomMargin: Kirigami.Units.smallSpacing * 2
Layout.leftMargin: Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.smallSpacing
Layout.fillWidth: true
}
}
// view when in minimized mode
RowLayout {
id: minimizedView
spacing: 0
opacity: root.minimizedViewProgress
visible: opacity !== 0
transform: Translate { y: (1 - minimizedView.opacity) * -root.rowHeight }
opacity: 1 - root.fullViewProgress
anchors.topMargin: root.fullViewProgress * -height
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
@ -157,12 +119,19 @@ Item {
}
}
// Loads portrait and landscape quick settings view
Component {
id: swipeViewComponent
// view when fully open
ColumnLayout {
id: fullView
opacity: root.fullViewProgress
anchors.top: minimizedView.bottom
anchors.left: parent.left
anchors.right: parent.right
// Quick settings view
ColumnLayout {
readonly property var view: swipeView
Layout.fillWidth: true
Layout.minimumHeight: rowCount * rowHeight
SwipeView {
id: swipeView
@ -226,6 +195,14 @@ Item {
}
}
}
// Brightness slider
BrightnessItem {
Layout.bottomMargin: Kirigami.Units.smallSpacing * 2
Layout.leftMargin: Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.smallSpacing
Layout.fillWidth: true
}
}
// Quick setting component

View file

@ -96,10 +96,8 @@ MobileShell.BaseItem {
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.fillWidth: true
mode: QuickSettings.Pages
actionDrawer: root.actionDrawer
quickSettingsModel: root.quickSettingsModel
minimizedViewProgress: 1 - root.minimizedToFullProgress
fullViewProgress: root.minimizedToFullProgress
height: root.minimizedQuickSettingsHeight + root.addedHeight
width: parent.width

View file

@ -82,7 +82,6 @@ MobileShell.BaseItem {
MobileShell.QuickSettings {
id: quickSettings
mode: QuickSettings.ScrollView
quickSettingsModel: root.quickSettingsModel
width: column.width
implicitHeight: quickSettings.fullHeight
@ -93,8 +92,7 @@ MobileShell.BaseItem {
Layout.maximumWidth: column.width
actionDrawer: root.actionDrawer
minimizedViewProgress: 0
fullViewProgress: 1
fullViewProgress: 1.0
}
Item { Layout.fillHeight: true }