From 2d1610aaa23de3d815e879e7d605a27f472ed91c Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 18 Mar 2023 22:06:48 -0700 Subject: [PATCH] mobileshell: Add constants singleton to reduce dependency on mobileshellstate --- components/mobileshell/mobileshellplugin.cpp | 1 + .../qml/actiondrawer/quicksettings/QuickSettings.qml | 1 - .../quicksettings/QuickSettingsDrawer.qml | 3 +-- components/mobileshell/qml/components/Constants.qml | 12 ++++++++++++ components/mobileshell/qml/components/PopupMenu.qml | 3 +-- components/mobileshell/qml/statusbar/StatusBar.qml | 9 +++++---- components/mobileshell/qml/volumeosd/VolumeOSD.qml | 2 -- components/mobileshell/resources.qrc | 1 + components/mobileshellstate/qml/TopPanelControls.qml | 1 - containments/panel/package/contents/ui/main.qml | 5 ----- containments/taskpanel/package/contents/ui/main.qml | 3 +-- 11 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 components/mobileshell/qml/components/Constants.qml diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index a6e9f962..97dc0e59 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -46,6 +46,7 @@ void MobileShellPlugin::registerTypes(const char *uri) // /components qmlRegisterSingletonType(resolvePath("components/AppLaunch.qml"), uri, 1, 0, "AppLaunch"); qmlRegisterType(resolvePath("components/BaseItem.qml"), uri, 1, 0, "BaseItem"); + qmlRegisterSingletonType(resolvePath("components/Constants.qml"), uri, 1, 0, "Constants"); qmlRegisterType(resolvePath("components/ExtendedAbstractButton.qml"), uri, 1, 0, "ExtendedAbstractButton"); qmlRegisterType(resolvePath("components/Flickable.qml"), uri, 1, 0, "Flickable"); qmlRegisterType(resolvePath("components/GridView.qml"), uri, 1, 0, "GridView"); diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml index f997b41c..963699f4 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml @@ -13,7 +13,6 @@ import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS -import org.kde.plasma.private.mobileshell.state as MobileShellState import "../../components" as Components import "../../components/util.js" as Util diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml index 8c25b43c..7be95181 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml @@ -13,7 +13,6 @@ import Qt5Compat.GraphicalEffects import org.kde.kirigami 2.12 as Kirigami import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "../../statusbar" as StatusBar import "../../components" as Components @@ -80,7 +79,7 @@ Components.BaseItem { StatusBar.StatusBar { id: statusBar Layout.fillWidth: true - Layout.preferredHeight: MobileShellState.TopPanelControls.panelHeight + PlasmaCore.Units.gridUnit * 0.8 + Layout.preferredHeight: Components.Constants.topPanelHeight + PlasmaCore.Units.gridUnit * 0.8 colorGroup: PlasmaCore.Theme.NormalColorGroup backgroundColor: "transparent" diff --git a/components/mobileshell/qml/components/Constants.qml b/components/mobileshell/qml/components/Constants.qml new file mode 100644 index 00000000..3b74ec8f --- /dev/null +++ b/components/mobileshell/qml/components/Constants.qml @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2023 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +import QtQuick + +import org.kde.plasma.core as PlasmaCore + +pragma Singleton + +QtObject { + readonly property real topPanelHeight: PlasmaCore.Units.gridUnit + PlasmaCore.Units.smallSpacing +} diff --git a/components/mobileshell/qml/components/PopupMenu.qml b/components/mobileshell/qml/components/PopupMenu.qml index b2399590..286af372 100644 --- a/components/mobileshell/qml/components/PopupMenu.qml +++ b/components/mobileshell/qml/components/PopupMenu.qml @@ -9,7 +9,6 @@ import QtQuick.Layouts import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.nanoshell as NanoShell -import org.kde.plasma.private.mobileshell.state as MobileShellState import org.kde.kirigami as Kirigami @@ -59,7 +58,7 @@ NanoShell.FullScreenOverlay { transform: Translate { x: 0 - y: (containerItem.coordinates.y <= overlay.height/2 ? relatedTo.height : -containerItem.height) - MobileShellState.TopPanelControls.panelHeight + y: (containerItem.coordinates.y <= overlay.height/2 ? relatedTo.height : -containerItem.height) - Constants.topPanelHeight } PlasmaComponents.Menu { diff --git a/components/mobileshell/qml/statusbar/StatusBar.qml b/components/mobileshell/qml/statusbar/StatusBar.qml index 7ca460de..6477b056 100644 --- a/components/mobileshell/qml/statusbar/StatusBar.qml +++ b/components/mobileshell/qml/statusbar/StatusBar.qml @@ -19,6 +19,7 @@ import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "indicators" as Indicators import "../dataproviders" as DataProviders +import "../components" as Components Item { id: root @@ -122,9 +123,9 @@ Item { RowLayout { id: row Layout.fillWidth: true - Layout.maximumHeight: MobileShellState.TopPanelControls.panelHeight - control.topPadding - control.bottomPadding + Layout.maximumHeight: Components.Constants.topPanelHeight - control.topPadding - control.bottomPadding spacing: 0 - + // clock ClockText { visible: root.showTime @@ -175,7 +176,7 @@ Item { Layout.fillHeight: true Layout.preferredWidth: height } - Indicators.BluetoothIndicator { + Indicators.BluetoothIndicator { Layout.fillHeight: true Layout.preferredWidth: height } @@ -184,7 +185,7 @@ Item { Layout.fillHeight: true Layout.preferredWidth: height } - Indicators.VolumeIndicator { + Indicators.VolumeIndicator { Layout.fillHeight: true Layout.preferredWidth: height } diff --git a/components/mobileshell/qml/volumeosd/VolumeOSD.qml b/components/mobileshell/qml/volumeosd/VolumeOSD.qml index e56cfd9c..b6c65601 100644 --- a/components/mobileshell/qml/volumeosd/VolumeOSD.qml +++ b/components/mobileshell/qml/volumeosd/VolumeOSD.qml @@ -20,8 +20,6 @@ import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState -import org.kde.kirigami as Kirigami - import "../dataproviders" as DataProviders Window { diff --git a/components/mobileshell/resources.qrc b/components/mobileshell/resources.qrc index 8f4b3ebd..bec3a550 100644 --- a/components/mobileshell/resources.qrc +++ b/components/mobileshell/resources.qrc @@ -22,6 +22,7 @@ qml/components/AppLaunch.qml qml/components/BaseItem.qml + qml/components/Constants.qml qml/components/ExtendedAbstractButton.qml qml/components/Flickable.qml qml/components/GridView.qml diff --git a/components/mobileshellstate/qml/TopPanelControls.qml b/components/mobileshellstate/qml/TopPanelControls.qml index aa569a9e..6a140644 100644 --- a/components/mobileshellstate/qml/TopPanelControls.qml +++ b/components/mobileshellstate/qml/TopPanelControls.qml @@ -21,7 +21,6 @@ QtObject { signal closeActionDrawer() signal openActionDrawer() property bool inSwipe: false - property real panelHeight: PlasmaCore.Units.gridUnit + PlasmaCore.Units.smallSpacing // set and updated in panel containment property bool actionDrawerVisible: false property var notificationsWidget: null // updated in panel containment } diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index d87a2e97..978adda5 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -44,11 +44,6 @@ Item { //BEGIN API implementation - Binding { - target: MobileShellState.TopPanelControls - property: "panelHeight" - value: root.height - } Binding { target: MobileShellState.TopPanelControls property: "inSwipe" diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 8c4a1148..bd48a12d 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -17,7 +17,6 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings -import org.kde.plasma.private.mobileshell.state as MobileShellState import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin PlasmaCore.ColorScope { @@ -47,7 +46,7 @@ PlasmaCore.ColorScope { readonly property real intendedWindowThickness: navigationPanelHeight readonly property real intendedWindowLength: isInLandscapeNavPanelMode ? Screen.height : Screen.width - readonly property real intendedWindowOffset: isInLandscapeNavPanelMode ? MobileShellState.TopPanelControls.panelHeight : 0; // offset for top panel + readonly property real intendedWindowOffset: isInLandscapeNavPanelMode ? Components.Constants.topPanelHeight : 0; // offset for top panel readonly property int intendedWindowLocation: isInLandscapeNavPanelMode ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen