mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-07-31 00:34:45 +00:00
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:
parent
159e3bb3a6
commit
35b1128d1d
5 changed files with 30 additions and 65 deletions
|
|
@ -168,18 +168,14 @@ Item {
|
||||||
|
|
||||||
readonly property real intendedWidth: 360
|
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.top: parent.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
actionDrawer: root.actionDrawer
|
actionDrawer: root.actionDrawer
|
||||||
quickSettingsModel: root.quickSettingsModel
|
quickSettingsModel: root.quickSettingsModel
|
||||||
fullScreenHeight: root.height
|
fullScreenHeight: root.height
|
||||||
|
|
||||||
transform: Translate {
|
|
||||||
id: translate
|
|
||||||
property real offsetRatio: quickSettings.height / root.height
|
|
||||||
y: Math.min(root.actionDrawer.offset * offsetRatio - quickSettings.height, 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,10 @@ Item {
|
||||||
MobileShell.QuickSettingsDrawer {
|
MobileShell.QuickSettingsDrawer {
|
||||||
id: quickSettings
|
id: quickSettings
|
||||||
z: 1 // ensure it's above notifications
|
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.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
@ -91,13 +95,6 @@ Item {
|
||||||
return (quickSettings.maxAddedHeight * effectProgress) + Math.max(0, Math.min(quickSettings.maxAddedHeight, root.actionDrawer.offset - minimizedQuickSettingsOffset));
|
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 {
|
MobileShell.NotificationsWidget {
|
||||||
|
|
@ -119,8 +116,7 @@ Item {
|
||||||
onBackgroundClicked: root.actionDrawer.close();
|
onBackgroundClicked: root.actionDrawer.close();
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: quickSettings.top
|
top: quickSettings.bottom
|
||||||
topMargin: quickSettings.height + translate.y
|
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,9 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
required property var actionDrawer
|
required property var actionDrawer
|
||||||
required property int mode
|
|
||||||
|
|
||||||
property QS.QuickSettingsModel quickSettingsModel
|
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 columns: Math.round(Math.min(6, Math.max(3, width / intendedColumnWidth)))
|
||||||
readonly property real columnWidth: Math.floor(width / columns)
|
readonly property real columnWidth: Math.floor(width / columns)
|
||||||
readonly property int minimizedColumns: Math.round(Math.min(8, Math.max(5, width / intendedMinimizedColumnWidth)))
|
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 intendedMinimizedColumnWidth: Kirigami.Units.gridUnit * 4 + Kirigami.Units.smallSpacing
|
||||||
readonly property real minimizedRowHeight: 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
|
property real fullViewProgress: 1
|
||||||
|
|
||||||
readonly property int columnCount: Math.floor(width/columnWidth)
|
readonly property int columnCount: Math.floor(width/columnWidth)
|
||||||
|
|
@ -69,7 +62,7 @@ Item {
|
||||||
|
|
||||||
function resetSwipeView() {
|
function resetSwipeView() {
|
||||||
if (root.mode === QuickSettings.Pages) {
|
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
|
// view when in minimized mode
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: minimizedView
|
id: minimizedView
|
||||||
spacing: 0
|
spacing: 0
|
||||||
opacity: root.minimizedViewProgress
|
opacity: 1 - root.fullViewProgress
|
||||||
visible: opacity !== 0
|
|
||||||
transform: Translate { y: (1 - minimizedView.opacity) * -root.rowHeight }
|
|
||||||
|
|
||||||
|
anchors.topMargin: root.fullViewProgress * -height
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
@ -157,12 +119,19 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads portrait and landscape quick settings view
|
// view when fully open
|
||||||
Component {
|
ColumnLayout {
|
||||||
id: swipeViewComponent
|
id: fullView
|
||||||
|
opacity: root.fullViewProgress
|
||||||
|
|
||||||
|
anchors.top: minimizedView.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
// Quick settings view
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
readonly property var view: swipeView
|
Layout.fillWidth: true
|
||||||
|
Layout.minimumHeight: rowCount * rowHeight
|
||||||
|
|
||||||
SwipeView {
|
SwipeView {
|
||||||
id: 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
|
// Quick setting component
|
||||||
|
|
|
||||||
|
|
@ -96,10 +96,8 @@ MobileShell.BaseItem {
|
||||||
Layout.topMargin: Kirigami.Units.smallSpacing
|
Layout.topMargin: Kirigami.Units.smallSpacing
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
mode: QuickSettings.Pages
|
|
||||||
actionDrawer: root.actionDrawer
|
actionDrawer: root.actionDrawer
|
||||||
quickSettingsModel: root.quickSettingsModel
|
quickSettingsModel: root.quickSettingsModel
|
||||||
minimizedViewProgress: 1 - root.minimizedToFullProgress
|
|
||||||
fullViewProgress: root.minimizedToFullProgress
|
fullViewProgress: root.minimizedToFullProgress
|
||||||
height: root.minimizedQuickSettingsHeight + root.addedHeight
|
height: root.minimizedQuickSettingsHeight + root.addedHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ MobileShell.BaseItem {
|
||||||
MobileShell.QuickSettings {
|
MobileShell.QuickSettings {
|
||||||
id: quickSettings
|
id: quickSettings
|
||||||
|
|
||||||
mode: QuickSettings.ScrollView
|
|
||||||
quickSettingsModel: root.quickSettingsModel
|
quickSettingsModel: root.quickSettingsModel
|
||||||
width: column.width
|
width: column.width
|
||||||
implicitHeight: quickSettings.fullHeight
|
implicitHeight: quickSettings.fullHeight
|
||||||
|
|
@ -93,8 +92,7 @@ MobileShell.BaseItem {
|
||||||
Layout.maximumWidth: column.width
|
Layout.maximumWidth: column.width
|
||||||
|
|
||||||
actionDrawer: root.actionDrawer
|
actionDrawer: root.actionDrawer
|
||||||
minimizedViewProgress: 0
|
fullViewProgress: 1.0
|
||||||
fullViewProgress: 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { Layout.fillHeight: true }
|
Item { Layout.fillHeight: true }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue