actiondrawer: Share quick settings model between landscape and portrait

Don't recreate the quick settings model when switching between landscape
and portrait. This should improve the performance of screen rotation.
This commit is contained in:
Devin Lin 2024-07-27 11:02:48 -04:00
parent 2961fa7ea7
commit 8ca80841d2
6 changed files with 27 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
Item {
id: root
@ -28,6 +29,11 @@ Item {
*/
property var notificationModelType: MobileShell.NotificationsModelType.NotificationsModel
/**
* The model for the quick settings.
*/
property var quickSettingsModel: QS.QuickSettingsModel {}
/**
* The notification settings object to be used in the notification widget.
*/
@ -261,6 +267,7 @@ Item {
actionDrawer: root
width: root.width
height: root.height
quickSettingsModel: root.quickSettingsModel
}
}
@ -270,6 +277,7 @@ Item {
actionDrawer: root
width: root.width
height: root.height
quickSettingsModel: root.quickSettingsModel
}
}
}

View file

@ -15,6 +15,7 @@ import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasma5support 2.0 as P5Support
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
@ -23,6 +24,7 @@ Item {
id: root
required property var actionDrawer
property QS.QuickSettingsModel quickSettingsModel
property alias notificationsWidget: notificationWidget
@ -169,6 +171,7 @@ Item {
anchors.right: parent.right
actionDrawer: root.actionDrawer
quickSettingsModel: root.quickSettingsModel
fullScreenHeight: root.height
transform: Translate {

View file

@ -12,6 +12,7 @@ import QtQuick.Window 2.2
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
@ -20,6 +21,7 @@ Item {
id: root
required property var actionDrawer
property QS.QuickSettingsModel quickSettingsModel
property alias notificationsWidget: notificationWidget
@ -56,6 +58,7 @@ Item {
anchors.right: parent.right
actionDrawer: root.actionDrawer
quickSettingsModel: root.quickSettingsModel
// opacity and move animation (disabled when openToPinnedMode is false)
property real offsetDist: actionDrawer.offset - minimizedQuickSettingsOffset

View file

@ -25,6 +25,8 @@ Item {
required property var actionDrawer
required property int mode
property QS.QuickSettingsModel quickSettingsModel
enum Mode {
Pages,
ScrollView
@ -45,8 +47,6 @@ Item {
property real minimizedViewProgress: 0
property real fullViewProgress: 1
readonly property QS.QuickSettingsModel quickSettingsModel: QS.QuickSettingsModel {}
readonly property int columnCount: Math.floor(width/columnWidth)
readonly property int rowCount: {
let totalRows = Math.ceil(quickSettingsCount / columnCount);

View file

@ -13,6 +13,7 @@ import org.kde.ksvg 1.0 as KSvg
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
* Quick settings drawer pulled down from the top (for portrait mode).
@ -23,6 +24,8 @@ MobileShell.BaseItem {
required property var actionDrawer
property QS.QuickSettingsModel quickSettingsModel
/**
* The amount of height to add to the panel (increasing the height of the quick settings area).
*/
@ -95,6 +98,7 @@ MobileShell.BaseItem {
mode: QuickSettings.Pages
actionDrawer: root.actionDrawer
quickSettingsModel: root.quickSettingsModel
minimizedViewProgress: 1 - root.minimizedToFullProgress
fullViewProgress: root.minimizedToFullProgress
height: root.minimizedQuickSettingsHeight + root.addedHeight

View file

@ -12,6 +12,7 @@ import org.kde.kirigami 2.12 as Kirigami
import org.kde.ksvg 1.0 as KSvg
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
* Quick settings panel for landscape view (right sidebar).
@ -22,6 +23,11 @@ MobileShell.BaseItem {
required property var actionDrawer
property QS.QuickSettingsModel quickSettingsModel
/**
* The height of the entire screen the panel opens in.
*/
required property real fullScreenHeight
/**
@ -75,6 +81,7 @@ MobileShell.BaseItem {
id: quickSettings
mode: QuickSettings.ScrollView
quickSettingsModel: root.quickSettingsModel
width: column.width
implicitHeight: quickSettings.fullHeight