From 7d3bf397506bb7fa5cba6608f083a327312d5ad4 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 11 Nov 2022 11:21:12 -0500 Subject: [PATCH] mobileshell: Refactor and extract state to mobileshellstate plugin This avoids mixing plasmashell state with our MobileShell component library (which really shouldn't have state at all). --- CMakeLists.txt | 1 + README.md | 1 + components/CMakeLists.txt | 1 + components/mobileshell/CMakeLists.txt | 1 + components/mobileshell/mobileshellplugin.cpp | 15 +--- components/mobileshell/qml/Shell.qml | 47 ---------- .../quicksettings/QuickSettings.qml | 7 +- .../quicksettings/QuickSettingsDelegate.qml | 5 +- .../quicksettings/QuickSettingsDrawer.qml | 3 +- .../QuickSettingsFullDelegate.qml | 4 +- .../QuickSettingsMinimizedDelegate.qml | 4 +- .../mobileshell/qml/components/Haptics.qml | 32 ------- .../qml/components/HapticsEffectWrapper.qml | 12 --- .../qml/components/StartupFeedback.qml | 9 +- .../{VolumeProvider.qml => AudioProvider.qml} | 19 ++-- .../{BatteryProvider.qml => BatteryInfo.qml} | 3 - .../qml/dataproviders/BluetoothInfo.qml | 58 +++++++++++++ .../qml/dataproviders/BluetoothProvider.qml | 44 ---------- ...gthProvider.qml => SignalStrengthInfo.qml} | 11 +-- .../mobileshell/qml/homescreen/HomeScreen.qml | 15 ++-- .../qml/navigationpanel/NavigationPanel.qml | 5 +- .../mobileshell/qml/osd/volume/VolumeOSD.qml | 3 +- .../mobileshell/qml/statusbar/StatusBar.qml | 9 +- .../statusbar/indicators/BatteryIndicator.qml | 3 +- .../indicators/BluetoothIndicator.qml | 3 +- .../indicators/SignalStrengthIndicator.qml | 4 +- .../statusbar/indicators/VolumeIndicator.qml | 2 +- .../mobileshell/qml/taskswitcher/TaskList.qml | 9 +- .../qml/taskswitcher/TaskSwitcher.qml | 11 +-- .../qml/taskswitcher/TaskSwitcherState.qml | 5 +- .../qml/widgets/krunner/KRunnerWidget.qml | 9 +- .../mediacontrols/MediaControlsWidget.qml | 3 +- components/mobileshell/resources.qrc | 15 +--- components/mobileshell/shellutil.cpp | 14 ++- components/mobileshell/shellutil.h | 5 ++ components/mobileshellstate/CMakeLists.txt | 40 +++++++++ .../mobileshellstateplugin.cpp | 23 +++++ .../mobileshellstate/mobileshellstateplugin.h | 18 ++++ .../qml/HomeScreenControls.qml | 9 +- components/mobileshellstate/qml/Shell.qml | 87 +++++++++++++++++++ .../qml/TaskPanelControls.qml | 0 .../qml/TopPanelControls.qml | 2 +- components/mobileshellstate/qmldir | 6 ++ components/mobileshellstate/resources.qrc | 14 +++ .../package/contents/ui/HomeDelegate.qml | 5 +- .../folio/package/contents/ui/HomeScreen.qml | 21 ++--- .../package/contents/ui/LauncherRepeater.qml | 3 +- .../ui/appdrawer/GridViewAppDrawer.qml | 3 +- .../folio/package/contents/ui/main.qml | 13 +-- .../contents/ui/FavoritesAppDelegate.qml | 3 +- .../package/contents/ui/GridAppList.qml | 3 +- .../package/contents/ui/HomeScreen.qml | 10 +-- .../halcyon/package/contents/ui/main.qml | 11 +-- .../panel/package/contents/ui/main.qml | 13 +-- .../contents/ui/NavigationPanelComponent.qml | 7 +- .../taskpanel/package/contents/ui/main.qml | 26 +++--- look-and-feel/contents/lockscreen/Keypad.qml | 4 +- quicksettings/audio/contents/ui/main.qml | 4 +- quicksettings/battery/contents/ui/main.qml | 6 +- .../donotdisturb/contents/ui/main.qml | 9 +- .../record/package/contents/ui/main.qml | 3 +- .../screenshot/package/contents/ui/main.qml | 5 +- 62 files changed, 438 insertions(+), 302 deletions(-) delete mode 100644 components/mobileshell/qml/Shell.qml delete mode 100644 components/mobileshell/qml/components/Haptics.qml delete mode 100644 components/mobileshell/qml/components/HapticsEffectWrapper.qml rename components/mobileshell/qml/dataproviders/{VolumeProvider.qml => AudioProvider.qml} (90%) rename components/mobileshell/qml/dataproviders/{BatteryProvider.qml => BatteryInfo.qml} (97%) create mode 100644 components/mobileshell/qml/dataproviders/BluetoothInfo.qml delete mode 100644 components/mobileshell/qml/dataproviders/BluetoothProvider.qml rename components/mobileshell/qml/dataproviders/{SignalStrengthProvider.qml => SignalStrengthInfo.qml} (50%) create mode 100644 components/mobileshellstate/CMakeLists.txt create mode 100644 components/mobileshellstate/mobileshellstateplugin.cpp create mode 100644 components/mobileshellstate/mobileshellstateplugin.h rename components/{mobileshell => mobileshellstate}/qml/HomeScreenControls.qml (77%) create mode 100644 components/mobileshellstate/qml/Shell.qml rename components/{mobileshell => mobileshellstate}/qml/TaskPanelControls.qml (100%) rename components/{mobileshell => mobileshellstate}/qml/TopPanelControls.qml (82%) create mode 100644 components/mobileshellstate/qmldir create mode 100644 components/mobileshellstate/resources.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt index 75f5750c..9ca75294 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED Core Qml Quick + Feedback ) if (QT_MAJOR_VERSION STREQUAL "5") if (QUICK_COMPILER) diff --git a/README.md b/README.md index 4bcd4c65..f1cb1b2b 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Dependencies: * Plasma Nano * Kirigami * Kirigami Addons +* Qt Feedback To start the phone homescreen in a window, run: ``` diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8e7904bd..77824c32 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -4,3 +4,4 @@ add_subdirectory(mmplugin) add_subdirectory(mobileshell) +add_subdirectory(mobileshellstate) diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index 0499652c..72b89567 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -38,6 +38,7 @@ target_link_libraries(mobileshellplugin Qt::Qml Qt::Gui Qt::Quick + Qt::Feedback KF5::ConfigWidgets # for KStandardAction KF5::KIOGui KF5::Plasma diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index 972a20f7..bcd8b402 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -73,15 +73,14 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterType(resolvePath("components/Flickable.qml"), uri, 1, 0, "Flickable"); qmlRegisterType(resolvePath("components/GridView.qml"), uri, 1, 0, "GridView"); qmlRegisterType(resolvePath("components/ListView.qml"), uri, 1, 0, "ListView"); - qmlRegisterSingletonType(resolvePath("components/Haptics.qml"), uri, 1, 0, "Haptics"); qmlRegisterType(resolvePath("components/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback"); qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator"); // /dataproviders - qmlRegisterSingletonType(resolvePath("dataproviders/BatteryProvider.qml"), uri, 1, 0, "BatteryProvider"); - qmlRegisterSingletonType(resolvePath("dataproviders/BluetoothProvider.qml"), uri, 1, 0, "BluetoothProvider"); - qmlRegisterSingletonType(resolvePath("dataproviders/SignalStrengthProvider.qml"), uri, 1, 0, "SignalStrengthProvider"); - qmlRegisterSingletonType(resolvePath("dataproviders/VolumeProvider.qml"), uri, 1, 0, "VolumeProvider"); + qmlRegisterType(resolvePath("dataproviders/BatteryInfo.qml"), uri, 1, 0, "BatteryInfo"); + qmlRegisterType(resolvePath("dataproviders/BluetoothInfo.qml"), uri, 1, 0, "BluetoothInfo"); + qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo"); + qmlRegisterSingletonType(resolvePath("dataproviders/AudioProvider.qml"), uri, 1, 0, "AudioProvider"); // /homescreen qmlRegisterType(resolvePath("homescreen/HomeScreen.qml"), uri, 1, 0, "HomeScreen"); @@ -102,10 +101,4 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterType(resolvePath("widgets/mediacontrols/MediaControlsWidget.qml"), uri, 1, 0, "MediaControlsWidget"); qmlRegisterType(resolvePath("widgets/notifications/NotificationsWidget.qml"), uri, 1, 0, "NotificationsWidget"); qmlRegisterType(resolvePath("widgets/notifications/NotificationsModelType.qml"), uri, 1, 0, "NotificationsModelType"); - - // / - qmlRegisterSingletonType(resolvePath("HomeScreenControls.qml"), uri, 1, 0, "HomeScreenControls"); - qmlRegisterSingletonType(resolvePath("Shell.qml"), uri, 1, 0, "Shell"); - qmlRegisterSingletonType(resolvePath("TaskPanelControls.qml"), uri, 1, 0, "TaskPanelControls"); - qmlRegisterSingletonType(resolvePath("TopPanelControls.qml"), uri, 1, 0, "TopPanelControls"); } diff --git a/components/mobileshell/qml/Shell.qml b/components/mobileshell/qml/Shell.qml deleted file mode 100644 index 6d476a39..00000000 --- a/components/mobileshell/qml/Shell.qml +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Devin Lin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -import QtQuick 2.15 -import QtQuick.Window 2.15 - -pragma Singleton - -/** - * Provides access to the homescreen plasmoid containment within the shell. - */ -QtObject { - id: delegate - - /** - * Top margin from the screen edge where application windows would display. - */ - readonly property real topMargin: TopPanelControls.panelHeight - - /** - * Bottom margin from the screen edge where application windows would display. - */ - readonly property real bottomMargin: TaskPanelControls.isPortrait ? TaskPanelControls.panelHeight : 0 - - /** - * Left margin from the screen edge where application windows would display. - */ - readonly property real leftMargin: 0 - - /** - * Right margin from the screen edge where application windows would display. - */ - readonly property real rightMargin: !TaskPanelControls.isPortrait ? TaskPanelControls.panelWidth : 0 - - /** - * Orientation of the mobile device. - */ - readonly property int orientation: TaskPanelControls.isPortrait ? Shell.Portrait : Shell.Landscape - - enum Orientation { - Landscape, - Portrait - } -} diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml index dd0ea2fc..a06f2607 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettings.qml @@ -13,6 +13,7 @@ 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 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "../../components" as Components import "../../components/util.js" as Util @@ -46,7 +47,7 @@ Item { readonly property int columnCount: Math.floor(width/columnWidth) readonly property int rowCount: { let totalRows = Math.ceil(quickSettingsCount / columnCount); - let isPortrait = MobileShell.Shell.orientation === MobileShell.Shell.Portrait; + let isPortrait = MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait; let maxRows = 5; // more than 5 is just disorienting let targetRows = Math.floor(Window.height * (isPortrait ? 0.65 : 0.8) / rowHeight); return Math.min(maxRows, Math.min(totalRows, targetRows)); @@ -56,7 +57,7 @@ Item { readonly property int quickSettingsCount: quickSettingsModel.count function resetSwipeView() { - if (MobileShell.Shell.orientation === MobileShell.Shell.Portrait) { + if (MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait) { pageLoader.item.view.currentIndex = 0; } } @@ -91,7 +92,7 @@ Item { Layout.minimumHeight: rowCount * rowHeight asynchronous: true - sourceComponent: MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? swipeViewComponent : scrollViewComponent + sourceComponent: MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait ? swipeViewComponent : scrollViewComponent } BrightnessItem { diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDelegate.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDelegate.qml index fa0bdf44..e8942932 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDelegate.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDelegate.qml @@ -13,6 +13,7 @@ import org.kde.kirigami 2.12 as Kirigami import org.kde.plasma.core 2.0 as PlasmaCore 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.plasma.components 3.0 as PlasmaComponents import "../../components" as Components @@ -65,7 +66,7 @@ Components.BaseItem { root.toggleFunction(); } else if (root.settingsCommand && !root.restrictedPermissions) { closeRequested(); - MobileShell.HomeScreenControls.openAppLaunchAnimation( + MobileShellState.Shell.openAppLaunchAnimation( root.icon, root.text, iconItem.Kirigami.ScenePosition.x + iconItem.width/2, @@ -78,7 +79,7 @@ Components.BaseItem { function delegatePressAndHold() { if (root.settingsCommand && !root.restrictedPermissions) { closeRequested(); - MobileShell.HomeScreenControls.openAppLaunchAnimation( + MobileShellState.Shell.openAppLaunchAnimation( root.icon, root.text, iconItem.Kirigami.ScenePosition.x + iconItem.width/2, diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml index 43f1546b..d6f46f53 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsDrawer.qml @@ -14,6 +14,7 @@ import org.kde.kirigami 2.12 as Kirigami import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "../../statusbar" as StatusBar import "../../components" as Components @@ -79,7 +80,7 @@ Components.BaseItem { StatusBar.StatusBar { id: statusBar Layout.fillWidth: true - Layout.preferredHeight: MobileShell.TopPanelControls.panelHeight + PlasmaCore.Units.gridUnit * 0.8 + Layout.preferredHeight: MobileShellState.TopPanelControls.panelHeight + PlasmaCore.Units.gridUnit * 0.8 colorGroup: PlasmaCore.Theme.NormalColorGroup backgroundColor: "transparent" diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsFullDelegate.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsFullDelegate.qml index 96ee1c10..d760da92 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsFullDelegate.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsFullDelegate.qml @@ -58,10 +58,10 @@ QuickSettingsDelegate { contentItem: MouseArea { id: mouseArea - onPressed: MobileShell.Haptics.buttonVibrate() + onPressed: MobileShell.ShellUtil.buttonVibrate() onClicked: root.delegateClick() onPressAndHold: { - MobileShell.Haptics.buttonVibrate(); + MobileShell.ShellUtil.buttonVibrate(); root.delegatePressAndHold(); } diff --git a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsMinimizedDelegate.qml b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsMinimizedDelegate.qml index 00989622..2fe50094 100644 --- a/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsMinimizedDelegate.qml +++ b/components/mobileshell/qml/actiondrawer/quicksettings/QuickSettingsMinimizedDelegate.qml @@ -55,10 +55,10 @@ QuickSettingsDelegate { contentItem: MouseArea { id: mouseArea - onPressed: MobileShell.Haptics.buttonVibrate(); + onPressed: MobileShell.ShellUtil.buttonVibrate(); onClicked: root.delegateClick() onPressAndHold: { - MobileShell.Haptics.buttonVibrate(); + MobileShell.ShellUtil.buttonVibrate(); root.delegatePressAndHold(); } diff --git a/components/mobileshell/qml/components/Haptics.qml b/components/mobileshell/qml/components/Haptics.qml deleted file mode 100644 index 2da7dd88..00000000 --- a/components/mobileshell/qml/components/Haptics.qml +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Devin Lin -// SPDX-License-Identifier: GPL-2.0-or-later - -import QtQuick 2.15 - -import org.kde.plasma.private.mobileshell 1.0 as MobileShell - -pragma Singleton - -/** - * Singleton object for triggering vibrations in the shell. - */ - -QtObject { - id: root - - function buttonVibrate() { - if (MobileShell.MobileShellSettings.vibrationsEnabled) { - if (hapticsEffect.status == Loader.Ready) { - hapticsEffect.item.intensity = MobileShell.MobileShellSettings.vibrationIntensity; - hapticsEffect.item.duration = MobileShell.MobileShellSettings.vibrationDuration; - hapticsEffect.item.start(); - } - } - } - - Component.onCompleted: { - hapticsEffect.setSource("HapticsEffectWrapper.qml"); - } - - property var hapticsEffect: Loader {} -} diff --git a/components/mobileshell/qml/components/HapticsEffectWrapper.qml b/components/mobileshell/qml/components/HapticsEffectWrapper.qml deleted file mode 100644 index 07c671c5..00000000 --- a/components/mobileshell/qml/components/HapticsEffectWrapper.qml +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Devin Lin -// SPDX-License-Identifier: GPL-2.0-or-later - -import QtQuick 2.15 -import QtFeedback 5.0 - -/** - * Private component that wraps a QtFeedback HapticsEffect, so that we can optionally load - * this component. - */ - -HapticsEffect {} diff --git a/components/mobileshell/qml/components/StartupFeedback.qml b/components/mobileshell/qml/components/StartupFeedback.qml index 5b28f9bf..073d11dc 100644 --- a/components/mobileshell/qml/components/StartupFeedback.qml +++ b/components/mobileshell/qml/components/StartupFeedback.qml @@ -12,6 +12,7 @@ import org.kde.kirigami 2.13 as Kirigami 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 /** * Component that animates an app opening from a location. @@ -40,7 +41,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind background.state = "open"; - MobileShell.HomeScreenControls.taskSwitcher.minimizeAll(); + MobileShellState.HomeScreenControls.taskSwitcher.minimizeAll(); } function close() { @@ -55,7 +56,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind // close when homescreen requested Connections { - target: MobileShell.HomeScreenControls + target: MobileShellState.HomeScreenControls function onOpenHomeScreen() { background.state = "closed"; } @@ -168,7 +169,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind ScriptAction { script: { // close the app drawer after it isn't visible - MobileShell.HomeScreenControls.resetHomeScreenPosition(); + MobileShellState.HomeScreenControls.resetHomeScreenPosition(); } } } @@ -224,7 +225,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind ScriptAction { script: { // close the app drawer after it isn't visible - MobileShell.HomeScreenControls.resetHomeScreenPosition(); + MobileShellState.HomeScreenControls.resetHomeScreenPosition(); } } } diff --git a/components/mobileshell/qml/dataproviders/VolumeProvider.qml b/components/mobileshell/qml/dataproviders/AudioProvider.qml similarity index 90% rename from components/mobileshell/qml/dataproviders/VolumeProvider.qml rename to components/mobileshell/qml/dataproviders/AudioProvider.qml index 6dc021fd..e43ba666 100644 --- a/components/mobileshell/qml/dataproviders/VolumeProvider.qml +++ b/components/mobileshell/qml/dataproviders/AudioProvider.qml @@ -24,15 +24,15 @@ QtObject { */ property bool bindShortcuts: false - property bool isVisible: paSinkModel.preferredSink && paSinkModel.preferredSink.muted + readonly property bool isVisible: paSinkModel.preferredSink && paSinkModel.preferredSink.muted - property string icon: paSinkModel.preferredSink && !isDummyOutput(paSinkModel.preferredSink) - ? iconName(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted) - : iconName(0, true) + readonly property string icon: paSinkModel.preferredSink && !isDummyOutput(paSinkModel.preferredSink) + ? iconName(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted) + : iconName(0, true) + + readonly property int maxVolumeValue: Math.round(100 * PulseAudio.NormalVolume / 100.0) + readonly property int volumeStep: Math.round(5 * PulseAudio.NormalVolume / 100.0) - property bool volumeFeedback: true - property int maxVolumeValue: Math.round(100 * PulseAudio.NormalVolume / 100.0) - property int volumeStep: Math.round(5 * PulseAudio.NormalVolume / 100.0) property int volumeValue readonly property string dummyOutputName: "auto_null" @@ -75,9 +75,6 @@ QtObject { } function playFeedback(sinkIndex) { - if (!volumeFeedback){ - return; - } if (sinkIndex == undefined) { sinkIndex = paSinkModel.preferredSink.index; } @@ -113,8 +110,6 @@ QtObject { playFeedback(); } - - function muteVolume() { if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { return; diff --git a/components/mobileshell/qml/dataproviders/BatteryProvider.qml b/components/mobileshell/qml/dataproviders/BatteryInfo.qml similarity index 97% rename from components/mobileshell/qml/dataproviders/BatteryProvider.qml rename to components/mobileshell/qml/dataproviders/BatteryInfo.qml index fb0da8e3..3679467e 100644 --- a/components/mobileshell/qml/dataproviders/BatteryProvider.qml +++ b/components/mobileshell/qml/dataproviders/BatteryInfo.qml @@ -12,8 +12,6 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PW -pragma Singleton - Item { property bool isVisible: pmSource.data["Battery"]["Has Cumulative"] property int percent: pmSource.data["Battery"]["Percent"] @@ -24,4 +22,3 @@ Item { connectedSources: ["Battery", "AC Adapter"] } } - diff --git a/components/mobileshell/qml/dataproviders/BluetoothInfo.qml b/components/mobileshell/qml/dataproviders/BluetoothInfo.qml new file mode 100644 index 00000000..9ad8f81a --- /dev/null +++ b/components/mobileshell/qml/dataproviders/BluetoothInfo.qml @@ -0,0 +1,58 @@ +/* + SPDX-FileCopyrightText: 2021 Devin Lin + SPDX-FileCopyrightText: 2019 Marco Martin + SPDX-FileCopyrightText: 2013-2017 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +import QtQuick 2.2 +import QtQuick.Layouts 1.4 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.bluezqt 1.0 as BluezQt + +QtObject { + id: root + readonly property bool isVisible: BluezQt.Manager.bluetoothOperational + readonly property string icon: deviceConnected ? "preferences-system-bluetooth-activated" : "preferences-system-bluetooth" + + property bool deviceConnected: false + + function updateStatus() { + let connectedDevices = []; + + for (var i = 0; i < BluezQt.Manager.devices.length; ++i) { + var device = BluezQt.Manager.devices[i]; + if (device.connected) { + connectedDevices.push(device); + } + } + + root.deviceConnected = connectedDevices.length > 0; + } + + property var connections: Connections { + target: BluezQt.Manager + + function onDeviceAdded() { + root.updateStatus(); + } + function onDeviceRemoved() { + root.updateStatus(); + } + function onDeviceChanged() { + root.updateStatus(); + } + function onBluetoothBlockedChanged() { + root.updateStatus(); + } + function onBluetoothOperationalChanged() { + root.updateStatus(); + } + } + + Component.onCompleted: { + updateStatus(); + } +} + diff --git a/components/mobileshell/qml/dataproviders/BluetoothProvider.qml b/components/mobileshell/qml/dataproviders/BluetoothProvider.qml deleted file mode 100644 index 267b4437..00000000 --- a/components/mobileshell/qml/dataproviders/BluetoothProvider.qml +++ /dev/null @@ -1,44 +0,0 @@ -/* - SPDX-FileCopyrightText: 2021 Devin Lin - SPDX-FileCopyrightText: 2019 Marco Martin - SPDX-FileCopyrightText: 2013-2017 Jan Grulich - - SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL -*/ - -import QtQuick 2.2 -import QtQuick.Layouts 1.4 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.bluezqt 1.0 as BluezQt - -pragma Singleton - -QtObject { - property bool isVisible: BluezQt.Manager.bluetoothOperational - property string icon: deviceConnected ? "preferences-system-bluetooth-activated" : "preferences-system-bluetooth" - - property bool deviceConnected : false - - function updateStatus() { - var connectedDevices = []; - - for (var i = 0; i < BluezQt.Manager.devices.length; ++i) { - var device = BluezQt.Manager.devices[i]; - if (device.connected) { - connectedDevices.push(device); - } - } - deviceConnected = connectedDevices.length > 0; - } - - Component.onCompleted: { - BluezQt.Manager.deviceAdded.connect(updateStatus); - BluezQt.Manager.deviceRemoved.connect(updateStatus); - BluezQt.Manager.deviceChanged.connect(updateStatus); - BluezQt.Manager.bluetoothBlockedChanged.connect(updateStatus); - BluezQt.Manager.bluetoothOperationalChanged.connect(updateStatus); - - updateStatus(); - } -} - diff --git a/components/mobileshell/qml/dataproviders/SignalStrengthProvider.qml b/components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml similarity index 50% rename from components/mobileshell/qml/dataproviders/SignalStrengthProvider.qml rename to components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml index bdef18ce..25c368f0 100644 --- a/components/mobileshell/qml/dataproviders/SignalStrengthProvider.qml +++ b/components/mobileshell/qml/dataproviders/SignalStrengthInfo.qml @@ -9,14 +9,11 @@ import QtQuick 2.1 import org.kde.plasma.mm 1.0 -pragma Singleton - QtObject { + readonly property string icon: "network-mobile-" + Math.floor(SignalIndicator.strength / 20) * 20 - property string icon: "network-mobile-" + Math.floor(SignalIndicator.strength / 20) * 20 - - property string label: SignalIndicator.simLocked ? i18n("SIM Locked") : SignalIndicator.name - - property bool showIndicator: SignalIndicator.modemAvailable + readonly property string label: SignalIndicator.simLocked ? i18n("SIM Locked") : SignalIndicator.name + + readonly property bool showIndicator: SignalIndicator.modemAvailable } diff --git a/components/mobileshell/qml/homescreen/HomeScreen.qml b/components/mobileshell/qml/homescreen/HomeScreen.qml index 5eefc409..e344a7e0 100644 --- a/components/mobileshell/qml/homescreen/HomeScreen.qml +++ b/components/mobileshell/qml/homescreen/HomeScreen.qml @@ -11,6 +11,7 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState /** * The base homescreen component, implementing features that simplify @@ -47,14 +48,14 @@ Item { //BEGIN API implementation Connections { - target: MobileShell.HomeScreenControls + target: MobileShellState.HomeScreenControls function onOpenHomeScreen() { if (!MobileShell.WindowUtil.allWindowsMinimized) { itemContainer.zoomIn(); } - MobileShell.HomeScreenControls.resetHomeScreenPosition(); + MobileShellState.HomeScreenControls.resetHomeScreenPosition(); taskSwitcher.visible = false; // will trigger homescreen open taskSwitcher.minimizeAll(); @@ -82,13 +83,13 @@ Item { Plasmoid.onScreenChanged: { if (plasmoid.screen == 0) { - MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; - MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; + MobileShellState.HomeScreenControls.taskSwitcher = taskSwitcher; + MobileShellState.HomeScreenControls.homeScreenWindow = root.Window.window; } } Window.onWindowChanged: { if (plasmoid.screen == 0) { - MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; + MobileShellState.HomeScreenControls.homeScreenWindow = root.Window.window; } } @@ -97,8 +98,8 @@ Item { Component.onCompleted: { // set API variables if (plasmoid.screen == 0) { - MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; - MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; + MobileShellState.HomeScreenControls.taskSwitcher = taskSwitcher; + MobileShellState.HomeScreenControls.homeScreenWindow = root.Window.window; } } diff --git a/components/mobileshell/qml/navigationpanel/NavigationPanel.qml b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml index e8d73e63..bcb9bbd0 100644 --- a/components/mobileshell/qml/navigationpanel/NavigationPanel.qml +++ b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml @@ -16,6 +16,7 @@ import org.kde.kquickcontrolsaddons 2.0 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 Item { id: root @@ -65,7 +66,7 @@ Item { startMouseY = oldMouseY = mouse.y; activeButton = icons.childAt(mouse.x, mouse.y); if (activeButton && activeButton.enabled) { - MobileShell.Haptics.buttonVibrate(); + MobileShell.ShellUtil.buttonVibrate(); } } @@ -96,7 +97,7 @@ Item { activeButton = null; root.taskSwitcher.show(false); } else if (taskSwitcher.tasksCount === 0) { // no tasks, let's scroll up the homescreen instead - MobileShell.HomeScreenControls.requestRelativeScroll(Qt.point(mouse.x - oldMouseX, mouse.y - oldMouseY)); + MobileShellState.HomeScreenControls.requestRelativeScroll(Qt.point(mouse.x - oldMouseX, mouse.y - oldMouseY)); } oldMouseY = mouse.y; diff --git a/components/mobileshell/qml/osd/volume/VolumeOSD.qml b/components/mobileshell/qml/osd/volume/VolumeOSD.qml index 92a48f79..f1b799ff 100644 --- a/components/mobileshell/qml/osd/volume/VolumeOSD.qml +++ b/components/mobileshell/qml/osd/volume/VolumeOSD.qml @@ -18,6 +18,7 @@ import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtra 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 2.12 as Kirigami @@ -171,7 +172,7 @@ NanoShell.FullScreenOverlay { onClicked: { let coords = mapToItem(flickable, 0, 0); - MobileShell.HomeScreenControls.openAppLaunchAnimation("audio-volume-high", i18n("Audio Settings"), coords.x, coords.y, PlasmaCore.Units.iconSizes.medium); + MobileShellState.Shell.openAppLaunchAnimation("audio-volume-high", i18n("Audio Settings"), coords.x, coords.y, PlasmaCore.Units.iconSizes.medium); MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_pulseaudio"); } } diff --git a/components/mobileshell/qml/statusbar/StatusBar.qml b/components/mobileshell/qml/statusbar/StatusBar.qml index 9a813bac..60a54424 100644 --- a/components/mobileshell/qml/statusbar/StatusBar.qml +++ b/components/mobileshell/qml/statusbar/StatusBar.qml @@ -15,6 +15,7 @@ import QtGraphicalEffects 1.12 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "indicators" as Indicators @@ -121,7 +122,7 @@ Item { RowLayout { id: row Layout.fillWidth: true - Layout.maximumHeight: MobileShell.TopPanelControls.panelHeight - control.topPadding - control.bottomPadding + Layout.maximumHeight: MobileShellState.TopPanelControls.panelHeight - control.topPadding - control.bottomPadding spacing: 0 // clock @@ -211,10 +212,14 @@ Item { color: PlasmaCore.ColorScope.disabledTextColor font.pixelSize: root.smallerTextPixelSize } + Item { Layout.fillWidth: true } + PlasmaComponents.Label { + property var signalStrengthInfo: MobileShell.SignalStrengthInfo {} + visible: root.showTime - text: MobileShell.SignalStrengthProvider.label + text: signalStrengthInfo.label color: PlasmaCore.ColorScope.disabledTextColor font.pixelSize: root.smallerTextPixelSize horizontalAlignment: Qt.AlignRight diff --git a/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml b/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml index e24f2bb7..ba0aea97 100644 --- a/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/BatteryIndicator.qml @@ -14,8 +14,9 @@ import org.kde.plasma.workspace.components 2.0 as PW import org.kde.plasma.private.mobileshell 1.0 as MobileShell RowLayout { - property MobileShell.BatteryProvider provider: MobileShell.BatteryProvider + readonly property var provider: MobileShell.BatteryInfo {} property real textPixelSize: PlasmaCore.Units.gridUnit * 0.6 + visible: provider.isVisible PW.BatteryIcon { diff --git a/components/mobileshell/qml/statusbar/indicators/BluetoothIndicator.qml b/components/mobileshell/qml/statusbar/indicators/BluetoothIndicator.qml index 92b85e42..949779d7 100644 --- a/components/mobileshell/qml/statusbar/indicators/BluetoothIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/BluetoothIndicator.qml @@ -16,7 +16,8 @@ import org.kde.bluezqt 1.0 as BluezQt PlasmaCore.IconItem { id: connectionIcon - property MobileShell.BluetoothProvider provider: MobileShell.BluetoothProvider + + readonly property var provider: MobileShell.BluetoothInfo {} source: provider.icon colorGroup: PlasmaCore.ColorScope.colorGroup diff --git a/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml b/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml index a21d5e0d..5f3064ea 100644 --- a/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/SignalStrengthIndicator.qml @@ -13,10 +13,10 @@ import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell Item { - property MobileShell.SignalStrengthProvider provider: MobileShell.SignalStrengthProvider - required property InternetIndicator internetIndicator + readonly property var provider: MobileShell.SignalStrengthInfo {} + // check if the internet indicator icon is a mobile data related one readonly property bool isInternetIndicatorMobileData: internetIndicator && internetIndicator.icon && internetIndicator.icon.startsWith('network-mobile-') diff --git a/components/mobileshell/qml/statusbar/indicators/VolumeIndicator.qml b/components/mobileshell/qml/statusbar/indicators/VolumeIndicator.qml index ccec78b7..daedfa7b 100644 --- a/components/mobileshell/qml/statusbar/indicators/VolumeIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/VolumeIndicator.qml @@ -14,7 +14,7 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell PlasmaCore.IconItem { id: paIcon - property MobileShell.VolumeProvider provider: MobileShell.VolumeProvider + readonly property var provider: MobileShell.AudioProvider Layout.fillHeight: true Layout.preferredWidth: height diff --git a/components/mobileshell/qml/taskswitcher/TaskList.qml b/components/mobileshell/qml/taskswitcher/TaskList.qml index 2eaa55cd..fdb59a75 100644 --- a/components/mobileshell/qml/taskswitcher/TaskList.qml +++ b/components/mobileshell/qml/taskswitcher/TaskList.qml @@ -10,8 +10,7 @@ import QtQuick.Layouts 1.1 import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.core 2.1 as PlasmaCore 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 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState Item { id: root @@ -21,13 +20,13 @@ Item { // account for system header and footer offset (center the preview image) readonly property real taskY: { - let headerHeight = MobileShell.Shell.topMargin; - let footerHeight = MobileShell.Shell.bottomMargin; + let headerHeight = MobileShellState.Shell.topMargin; + let footerHeight = MobileShellState.Shell.bottomMargin; let diff = headerHeight - footerHeight; let baseY = (taskSwitcher.height / 2) - (taskSwitcherState.taskHeight / 2) - (taskSwitcherState.taskHeaderHeight / 2) - return baseY + diff / 2 - MobileShell.TopPanelControls.panelHeight; + return baseY + diff / 2 - MobileShellState.TopPanelControls.panelHeight; } transform: Scale { diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index ad13aa1a..689f0b1d 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -15,6 +15,7 @@ import org.kde.plasma.core 2.1 as PlasmaCore 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 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "../components" as Components @@ -58,7 +59,7 @@ Item { } // update API property - onVisibleChanged: MobileShell.HomeScreenControls.taskSwitcherVisible = visible; + onVisibleChanged: MobileShellState.HomeScreenControls.taskSwitcherVisible = visible; // keep track of task list events property int oldTasksCount: tasksCount @@ -200,10 +201,10 @@ Item { // provide shell margins anchors.fill: parent - anchors.leftMargin: MobileShell.Shell.leftMargin - anchors.rightMargin: MobileShell.Shell.rightMargin - anchors.bottomMargin: MobileShell.Shell.bottomMargin - anchors.topMargin: MobileShell.Shell.topMargin + anchors.leftMargin: MobileShellState.Shell.leftMargin + anchors.rightMargin: MobileShellState.Shell.rightMargin + anchors.bottomMargin: MobileShellState.Shell.bottomMargin + anchors.topMargin: MobileShellState.Shell.topMargin FlickContainer { id: flickable diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml index 4e661f3a..5b51d574 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml @@ -9,6 +9,7 @@ import QtQuick 2.15 import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState /** * State object for the task switcher. @@ -76,8 +77,8 @@ QtObject { // ~~ measurement constants ~~ // dimensions of a real window on the screen - readonly property real windowHeight: taskSwitcher.height - MobileShell.Shell.topMargin - MobileShell.Shell.bottomMargin - readonly property real windowWidth: taskSwitcher.width - MobileShell.Shell.leftMargin - MobileShell.Shell.rightMargin + readonly property real windowHeight: taskSwitcher.height - MobileShellState.Shell.topMargin - MobileShellState.Shell.bottomMargin + readonly property real windowWidth: taskSwitcher.width - MobileShellState.Shell.leftMargin - MobileShellState.Shell.rightMargin // dimensions of the task previews readonly property real previewHeight: windowHeight * scalingFactor diff --git a/components/mobileshell/qml/widgets/krunner/KRunnerWidget.qml b/components/mobileshell/qml/widgets/krunner/KRunnerWidget.qml index 6afd424d..39fd1731 100644 --- a/components/mobileshell/qml/widgets/krunner/KRunnerWidget.qml +++ b/components/mobileshell/qml/widgets/krunner/KRunnerWidget.qml @@ -15,6 +15,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.milou 0.1 as Milou import org.kde.kirigami 2.19 as Kirigami @@ -75,10 +76,10 @@ Item { id: flickable anchors.fill: parent - anchors.topMargin: MobileShell.Shell.topMargin - anchors.bottomMargin: MobileShell.Shell.bottomMargin - anchors.leftMargin: MobileShell.Shell.leftMargin - anchors.rightMargin: MobileShell.Shell.rightMargin + anchors.topMargin: MobileShellState.Shell.topMargin + anchors.bottomMargin: MobileShellState.Shell.bottomMargin + anchors.leftMargin: MobileShellState.Shell.leftMargin + anchors.rightMargin: MobileShellState.Shell.rightMargin contentHeight: flickable.height + root.closedContentY + 999999 contentY: root.closedContentY diff --git a/components/mobileshell/qml/widgets/mediacontrols/MediaControlsWidget.qml b/components/mobileshell/qml/widgets/mediacontrols/MediaControlsWidget.qml index 62771813..d9f80e72 100644 --- a/components/mobileshell/qml/widgets/mediacontrols/MediaControlsWidget.qml +++ b/components/mobileshell/qml/widgets/mediacontrols/MediaControlsWidget.qml @@ -12,6 +12,7 @@ import QtQuick.Controls 2.15 as QQC2 import org.kde.kirigami 2.12 as Kirigami import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.extras 2.0 as PlasmaExtras @@ -75,7 +76,7 @@ Item { onClicked: { MobileShell.ShellUtil.launchApp(modelData.desktopEntry + ".desktop"); - MobileShell.TopPanelControls.closeActionDrawer(); + MobileShellState.Shell.closeActionDrawer(); } Components.BaseItem { diff --git a/components/mobileshell/resources.qrc b/components/mobileshell/resources.qrc index 128960de..6e447ddb 100644 --- a/components/mobileshell/resources.qrc +++ b/components/mobileshell/resources.qrc @@ -24,18 +24,16 @@ qml/components/ExtendedAbstractButton.qml qml/components/Flickable.qml qml/components/GridView.qml - qml/components/Haptics.qml - qml/components/HapticsEffectWrapper.qml qml/components/ListView.qml qml/components/MarqueeLabel.qml qml/components/StartupFeedback.qml qml/components/util.js qml/components/VelocityCalculator.qml - qml/dataproviders/BatteryProvider.qml - qml/dataproviders/BluetoothProvider.qml - qml/dataproviders/SignalStrengthProvider.qml - qml/dataproviders/VolumeProvider.qml + qml/dataproviders/BatteryInfo.qml + qml/dataproviders/BluetoothInfo.qml + qml/dataproviders/SignalStrengthInfo.qml + qml/dataproviders/AudioProvider.qml qml/homescreen/HomeScreen.qml @@ -89,10 +87,5 @@ qml/widgets/notifications/ThumbnailStrip.qml qml/widgets/notifications/util.js - qml/HomeScreenControls.qml - qml/Shell.qml - qml/TaskPanelControls.qml - qml/TopPanelControls.qml - diff --git a/components/mobileshell/shellutil.cpp b/components/mobileshell/shellutil.cpp index 0be9b330..877f6921 100644 --- a/components/mobileshell/shellutil.cpp +++ b/components/mobileshell/shellutil.cpp @@ -7,6 +7,7 @@ */ #include "shellutil.h" +#include "mobileshellsettings.h" #include "windowutil.h" #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include @@ -25,8 +27,8 @@ ShellUtil::ShellUtil(QObject *parent) : QObject{parent} - , m_launchingApp{nullptr} , m_localeConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)} + , m_launchingApp{nullptr} { m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig); @@ -131,3 +133,13 @@ void ShellUtil::clearLaunchingApp() m_launchingApp = nullptr; Q_EMIT isLaunchingAppChanged(); } + +void ShellUtil::buttonVibrate() +{ + if (MobileShellSettings::self()->vibrationsEnabled()) { + QFeedbackHapticsEffect rumble; + rumble.setDuration(MobileShellSettings::self()->vibrationDuration()); + rumble.setIntensity(MobileShellSettings::self()->vibrationIntensity()); + rumble.start(); + } +} diff --git a/components/mobileshell/shellutil.h b/components/mobileshell/shellutil.h index d6b426c5..909c0340 100644 --- a/components/mobileshell/shellutil.h +++ b/components/mobileshell/shellutil.h @@ -81,6 +81,11 @@ public: */ Q_INVOKABLE void clearLaunchingApp(); + /** + * Initiates a vibration event, meant for a button. + */ + Q_INVOKABLE void buttonVibrate(); + Q_SIGNALS: void isSystem24HourFormatChanged(); void isLaunchingAppChanged(); diff --git a/components/mobileshellstate/CMakeLists.txt b/components/mobileshellstate/CMakeLists.txt new file mode 100644 index 00000000..ec561c44 --- /dev/null +++ b/components/mobileshellstate/CMakeLists.txt @@ -0,0 +1,40 @@ +# SPDX-FileCopyrightText: 2022 Devin Lin +# SPDX-License-Identifier: GPL-2.0-or-later + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +set(mobileshellstateplugin_SRCS + mobileshellstateplugin.cpp +) +if (QT_MAJOR_VERSION STREQUAL "5") + if(QUICK_COMPILER) + qtquick_compiler_add_resources(RESOURCES resources.qrc) + else() + qt5_add_resources(RESOURCES resources.qrc) + endif() +else() + qt_add_resources(RESOURCES resources.qrc) +endif() +add_library(mobileshellstateplugin SHARED ${mobileshellstateplugin_SRCS} ${RESOURCES}) + +target_link_libraries(mobileshellstateplugin + PUBLIC + Qt::Core + PRIVATE + Qt::DBus + Qt::Qml + Qt::Gui + Qt::Quick + KF5::Plasma + KF5::I18n + KF5::Notifications + KF5::PlasmaQuick +) + +# we compiled the qml files, just install qmldir +install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell/state) + +ecm_generate_qmltypes(org.kde.plasma.private.mobileshell.state 1.0 DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell/state) +install(TARGETS mobileshellstateplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell/state) + diff --git a/components/mobileshellstate/mobileshellstateplugin.cpp b/components/mobileshellstate/mobileshellstateplugin.cpp new file mode 100644 index 00000000..03b1d1a2 --- /dev/null +++ b/components/mobileshellstate/mobileshellstateplugin.cpp @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2021 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "mobileshellstateplugin.h" + +#include +#include + +QUrl resolvePath(std::string str) +{ + return QUrl("qrc:/org/kde/plasma/private/mobileshell/state/qml/" + QString::fromStdString(str)); +} + +void MobileShellStatePlugin::registerTypes(const char *uri) +{ + Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobileshell.state")); + + // / + qmlRegisterSingletonType(resolvePath("HomeScreenControls.qml"), uri, 1, 0, "HomeScreenControls"); + qmlRegisterSingletonType(resolvePath("Shell.qml"), uri, 1, 0, "Shell"); + qmlRegisterSingletonType(resolvePath("TaskPanelControls.qml"), uri, 1, 0, "TaskPanelControls"); + qmlRegisterSingletonType(resolvePath("TopPanelControls.qml"), uri, 1, 0, "TopPanelControls"); +} diff --git a/components/mobileshellstate/mobileshellstateplugin.h b/components/mobileshellstate/mobileshellstateplugin.h new file mode 100644 index 00000000..45dd3db9 --- /dev/null +++ b/components/mobileshellstate/mobileshellstateplugin.h @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2022 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +#include +#include + +class MobileShellStatePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) override; +}; diff --git a/components/mobileshell/qml/HomeScreenControls.qml b/components/mobileshellstate/qml/HomeScreenControls.qml similarity index 77% rename from components/mobileshell/qml/HomeScreenControls.qml rename to components/mobileshellstate/qml/HomeScreenControls.qml index 91e69cd6..5d6aaaab 100644 --- a/components/mobileshell/qml/HomeScreenControls.qml +++ b/components/mobileshellstate/qml/HomeScreenControls.qml @@ -1,9 +1,6 @@ -/* - * SPDX-FileCopyrightText: 2020 Marco Martin - * SPDX-FileCopyrightText: 2021 Devin Lin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ +// SPDX-FileCopyrightText: 2020 Marco Martin +// SPDX-FileCopyrightText: 2021 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later import QtQuick 2.12 import QtQuick.Window 2.2 diff --git a/components/mobileshellstate/qml/Shell.qml b/components/mobileshellstate/qml/Shell.qml new file mode 100644 index 00000000..19a28283 --- /dev/null +++ b/components/mobileshellstate/qml/Shell.qml @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: 2022 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +pragma Singleton + +/** + * Provides access to common functions within the shell. Only available within the plasmashell process. + */ +QtObject { + id: delegate + + /** + * Top margin from the screen edge where application windows would display. + */ + readonly property real topMargin: TopPanelControls.panelHeight + + /** + * Bottom margin from the screen edge where application windows would display. + */ + readonly property real bottomMargin: TaskPanelControls.isPortrait ? TaskPanelControls.panelHeight : 0 + + /** + * Left margin from the screen edge where application windows would display. + */ + readonly property real leftMargin: 0 + + /** + * Right margin from the screen edge where application windows would display. + */ + readonly property real rightMargin: !TaskPanelControls.isPortrait ? TaskPanelControls.panelWidth : 0 + + /** + * Orientation of the mobile device. + */ + readonly property int orientation: TaskPanelControls.isPortrait ? Shell.Portrait : Shell.Landscape + + enum Orientation { + Landscape, + Portrait + } + + /** + * Whether the task switcher is open. + */ + readonly property bool taskSwitcherVisible: HomeScreenControls.taskSwitcherVisible + + /** + * Whether the homescreen is currently visible. + */ + readonly property bool homeScreenVisible: HomeScreenControls.homeScreenVisible + + /** + * Whether the action drawer is currently open. + */ + readonly property bool actionDrawerVisible: TopPanelControls.actionDrawerVisible + + /** + * Open the app launch screen with animation parameters. + */ + function openAppLaunchAnimation(splashIcon: string, title: string, x: real, y: real, sourceIconSize: real) { + HomeScreenControls.openAppLaunchAnimation(splashIcon, title, x, y, sourceIconSize); + } + + /** + * Close the app launch screen. + */ + function closeAppLaunchAnimation() { + HomeScreenControls.closeAppLaunchAnimation(); + } + + /** + * Open the action drawer. + */ + function openActionDrawer() { + TopPanelControls.openActionDrawer(); + } + + /** + * Close the action drawer, if it is open. + */ + function closeActionDrawer() { + TopPanelControls.closeActionDrawer(); + } +} diff --git a/components/mobileshell/qml/TaskPanelControls.qml b/components/mobileshellstate/qml/TaskPanelControls.qml similarity index 100% rename from components/mobileshell/qml/TaskPanelControls.qml rename to components/mobileshellstate/qml/TaskPanelControls.qml diff --git a/components/mobileshell/qml/TopPanelControls.qml b/components/mobileshellstate/qml/TopPanelControls.qml similarity index 82% rename from components/mobileshell/qml/TopPanelControls.qml rename to components/mobileshellstate/qml/TopPanelControls.qml index 2c66eaac..b9de1d19 100644 --- a/components/mobileshell/qml/TopPanelControls.qml +++ b/components/mobileshellstate/qml/TopPanelControls.qml @@ -21,7 +21,7 @@ QtObject { signal closeActionDrawer() signal openActionDrawer() property bool inSwipe: false - property real panelHeight: PlasmaCore.Units.gridUnit // set and updated in panel containment + property real panelHeight: PlasmaCore.Units.gridUnit + PlasmaCore.Units.smallSpacing // set and updated in panel containment property bool actionDrawerVisible: false property var notificationsWidget // updated in panel containment } diff --git a/components/mobileshellstate/qmldir b/components/mobileshellstate/qmldir new file mode 100644 index 00000000..a6700d6c --- /dev/null +++ b/components/mobileshellstate/qmldir @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2021-2022 Devin Lin +# SPDX-License-Identifier: GPL-2.0-or-later + +module org.kde.plasma.private.mobileshell.state + +plugin mobileshellstateplugin diff --git a/components/mobileshellstate/resources.qrc b/components/mobileshellstate/resources.qrc new file mode 100644 index 00000000..5e3c829b --- /dev/null +++ b/components/mobileshellstate/resources.qrc @@ -0,0 +1,14 @@ + + + + qml/HomeScreenControls.qml + qml/Shell.qml + qml/TaskPanelControls.qml + qml/TopPanelControls.qml + + + + diff --git a/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml b/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml index 652af3e8..4244ef2e 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeDelegate.qml @@ -16,6 +16,7 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.phone.homescreen.default 1.0 as HomeScreenLib import "private" as Private @@ -50,7 +51,7 @@ ContainmentLayoutManager.ItemContainer { return; } - if (!MobileShell.HomeScreenControls.taskSwitcherVisible) { + if (!MobileShellState.Shell.taskSwitcherVisible) { HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate); } else { HomeScreenLib.DesktopModel.unsetMinimizedDelegate(index, delegate); @@ -88,7 +89,7 @@ ContainmentLayoutManager.ItemContainer { } } Connections { - target: MobileShell.HomeScreenControls + target: MobileShellState.Shell function onTaskSwitcherVisibleChanged() { syncDelegateGeometry(); } diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml index 191f7ddc..1e299374 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml @@ -20,6 +20,7 @@ import "appdrawer" import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.phone.homescreen.default 1.0 as HomeScreenLib Item { @@ -34,8 +35,8 @@ Item { appDrawerFlickable: appDrawer.flickable - availableScreenHeight: height - MobileShell.Shell.bottomMargin - availableScreenWidth: width - MobileShell.Shell.leftMargin - MobileShell.Shell.rightMargin + availableScreenHeight: height - MobileShellState.Shell.bottomMargin + availableScreenWidth: width - MobileShellState.Shell.leftMargin - MobileShellState.Shell.rightMargin appDrawerBottomOffset: favoriteStrip.height } @@ -74,10 +75,10 @@ Item { // account for panels anchors.fill: parent - anchors.topMargin: MobileShell.Shell.topMargin - anchors.bottomMargin: MobileShell.Shell.bottomMargin - anchors.leftMargin: MobileShell.Shell.leftMargin - anchors.rightMargin: MobileShell.Shell.rightMargin + anchors.topMargin: MobileShellState.Shell.topMargin + anchors.bottomMargin: MobileShellState.Shell.bottomMargin + anchors.leftMargin: MobileShellState.Shell.leftMargin + anchors.rightMargin: MobileShellState.Shell.rightMargin // animation when app drawer is being shown opacity: root.appDrawer ? 1 - root.appDrawer.openFactor : 1 @@ -132,10 +133,10 @@ Item { homeScreenState: root.homeScreenState // account for panels - topPadding: MobileShell.Shell.topMargin - bottomPadding: MobileShell.Shell.bottomMargin - leftPadding: MobileShell.Shell.leftMargin - rightPadding: MobileShell.Shell.rightMargin + topPadding: MobileShellState.Shell.topMargin + bottomPadding: MobileShellState.Shell.bottomMargin + leftPadding: MobileShellState.Shell.leftMargin + rightPadding: MobileShellState.Shell.rightMargin } } } diff --git a/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml b/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml index 848721df..6d5c2f70 100644 --- a/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml +++ b/containments/homescreens/folio/package/contents/ui/LauncherRepeater.qml @@ -15,6 +15,7 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.phone.homescreen.default 1.0 as HomeScreenLib import org.kde.kirigami 2.14 as Kirigami @@ -105,7 +106,7 @@ Repeater { onLaunch: (x, y, icon, title) => { if (icon !== "") { - MobileShell.HomeScreenControls.openAppLaunchAnimation( + MobileShellState.Shell.openAppLaunchAnimation( icon, title, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, diff --git a/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml b/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml index 23b736de..2da5c5f2 100644 --- a/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml +++ b/containments/homescreens/folio/package/contents/ui/appdrawer/GridViewAppDrawer.qml @@ -17,6 +17,7 @@ import org.kde.kirigami 2.10 as Kirigami 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.phone.homescreen.default 1.0 as HomeScreenLib import "../private" @@ -69,7 +70,7 @@ AbstractAppDrawer { } onLaunch: (x, y, icon, title, storageId) => { if (icon !== "") { - MobileShell.HomeScreenControls.openAppLaunchAnimation( + MobileShellState.Shell.openAppLaunchAnimation( icon, title, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, diff --git a/containments/homescreens/folio/package/contents/ui/main.qml b/containments/homescreens/folio/package/contents/ui/main.qml index eacc1417..44eeb0e9 100644 --- a/containments/homescreens/folio/package/contents/ui/main.qml +++ b/containments/homescreens/folio/package/contents/ui/main.qml @@ -14,6 +14,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.phone.homescreen.default 1.0 as HomeScreenLib MobileShell.HomeScreen { @@ -45,13 +46,13 @@ MobileShell.HomeScreen { // - minimize windows (only if we are in an app) // - open app drawer // - close app drawer and, if necessary, restore windows - if (!plasmoid.nativeInterface.showingDesktop && !MobileShell.HomeScreenControls.homeScreenVisible - || MobileShell.TopPanelControls.actionDrawerVisible + if (!plasmoid.nativeInterface.showingDesktop && !MobileShellState.Shell.homeScreenVisible + || MobileShellState.Shell.actionDrawerVisible || searchWidget.isOpen ) { // Always close action drawer - if (MobileShell.TopPanelControls.actionDrawerVisible) { - MobileShell.TopPanelControls.closeActionDrawer(); + if (MobileShellState.Shell.actionDrawerVisible) { + MobileShellState.Shell.closeActionDrawer(); } // Always close the search widget as well @@ -88,7 +89,7 @@ MobileShell.HomeScreen { // close search component when task switcher is shown or hidden Connections { - target: MobileShell.HomeScreenControls.taskSwitcher + target: MobileShellState.HomeScreenControls.taskSwitcher function onVisibleChanged() { searchWidget.close(); } @@ -114,7 +115,7 @@ MobileShell.HomeScreen { Connections { target: HomeScreenLib.ApplicationListModel function onLaunchError(msg) { - MobileShell.HomeScreenControls.closeAppLaunchAnimation() + MobileShellState.Shell.closeAppLaunchAnimation() } } } diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml index 9a7bc966..7db3cb3d 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml @@ -12,6 +12,7 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.phone.homescreen.halcyon 1.0 as Halcyon import org.kde.kirigami 2.19 as Kirigami @@ -79,7 +80,7 @@ Item { function launchAppWithAnim(x: int, y: int, source, title: string, storageId: string) { if (source !== "") { - MobileShell.HomeScreenControls.openAppLaunchAnimation( + MobileShellState.Shell.openAppLaunchAnimation( source, title, iconLoader.Kirigami.ScenePosition.x + iconLoader.width/2, diff --git a/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml b/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml index 5500e2d2..6c1f2b11 100644 --- a/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml +++ b/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml @@ -14,6 +14,7 @@ import org.kde.kirigami 2.10 as Kirigami 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.phone.homescreen.halcyon 1.0 as Halcyon MobileShell.GridView { @@ -76,7 +77,7 @@ MobileShell.GridView { onLaunch: (x, y, icon, title, storageId) => { if (icon !== "") { - MobileShell.HomeScreenControls.openAppLaunchAnimation( + MobileShellState.Shell.openAppLaunchAnimation( icon, title, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, diff --git a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml index ad9be51b..7f1fd940 100644 --- a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml @@ -13,7 +13,7 @@ import org.kde.plasma.components 3.0 as PC3 import org.kde.draganddrop 2.0 as DragDrop import org.kde.kirigami 2.19 as Kirigami -import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.phone.homescreen.halcyon 1.0 as Halcyon Item { @@ -42,10 +42,10 @@ Item { interactive: root.interactive anchors.fill: parent - anchors.topMargin: MobileShell.Shell.topMargin - anchors.bottomMargin: MobileShell.Shell.bottomMargin - anchors.leftMargin: MobileShell.Shell.leftMargin - anchors.rightMargin: MobileShell.Shell.rightMargin + anchors.topMargin: MobileShellState.Shell.topMargin + anchors.bottomMargin: MobileShellState.Shell.bottomMargin + anchors.leftMargin: MobileShellState.Shell.leftMargin + anchors.rightMargin: MobileShellState.Shell.rightMargin Item { height: swipeView.height diff --git a/containments/homescreens/halcyon/package/contents/ui/main.qml b/containments/homescreens/halcyon/package/contents/ui/main.qml index abf62556..36c4d168 100644 --- a/containments/homescreens/halcyon/package/contents/ui/main.qml +++ b/containments/homescreens/halcyon/package/contents/ui/main.qml @@ -10,6 +10,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.phone.homescreen.halcyon 1.0 as Halcyon MobileShell.HomeScreen { @@ -44,13 +45,13 @@ MobileShell.HomeScreen { // - minimize windows (only if we are in an app) // - open app drawer // - close app drawer and, if necessary, restore windows - if (!plasmoid.nativeInterface.showingDesktop && !MobileShell.HomeScreenControls.homeScreenVisible - || MobileShell.TopPanelControls.actionDrawerVisible + if (!plasmoid.nativeInterface.showingDesktop && !MobileShellState.Shell.homeScreenVisible + || MobileShellState.Shell.actionDrawerVisible || search.isOpen ) { // Always close action drawer - if (MobileShell.TopPanelControls.actionDrawerVisible) { - MobileShell.TopPanelControls.closeActionDrawer(); + if (MobileShellState.Shell.actionDrawerVisible) { + MobileShellState.Shell.closeActionDrawer(); } // Always close the search widget as well @@ -86,7 +87,7 @@ MobileShell.HomeScreen { // close search component when task switcher is shown or hidden Connections { - target: MobileShell.HomeScreenControls.taskSwitcher + target: MobileShellState.HomeScreenControls.taskSwitcher function onVisibleChanged() { search.close(); } diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index 1a611e80..70f076ab 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -18,6 +18,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 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.taskmanager 0.1 as TaskManager import org.kde.notificationmanager 1.0 as NotificationManager @@ -44,29 +45,29 @@ Item { //BEGIN API implementation Binding { - target: MobileShell.TopPanelControls + target: MobileShellState.TopPanelControls property: "panelHeight" value: root.height } Binding { - target: MobileShell.TopPanelControls + target: MobileShellState.TopPanelControls property: "inSwipe" value: drawer.actionDrawer.dragging } Binding { - target: MobileShell.TopPanelControls + target: MobileShellState.TopPanelControls property: "actionDrawerVisible" value: drawer.visible } Binding { - target: MobileShell.TopPanelControls + target: MobileShellState.TopPanelControls property: "notificationsWidget" value: drawer.actionDrawer.notificationsWidget } Connections { - target: MobileShell.TopPanelControls + target: MobileShellState.TopPanelControls function onStartSwipe() { swipeArea.startSwipe(); @@ -89,7 +90,7 @@ Item { Component.onCompleted: { // we want to bind global volume shortcuts here - MobileShell.VolumeProvider.bindShortcuts = true; + MobileShell.AudioProvider.bindShortcuts = true; } TaskManager.VirtualDesktopInfo { diff --git a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml index dc48aac2..3425ceac 100644 --- a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml +++ b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml @@ -13,6 +13,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.workspace.keyboardlayout 1.0 as Keyboards import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState MobileShell.NavigationPanel { id: root @@ -73,7 +74,7 @@ MobileShell.NavigationPanel { iconSizeFactor: 1 onTriggered: { - MobileShell.HomeScreenControls.openHomeScreen(); + MobileShellState.HomeScreenControls.openHomeScreen(); MobileShell.WindowUtil.allWindowsMinimizedChanged(); } } @@ -101,11 +102,11 @@ MobileShell.NavigationPanel { if (root.taskSwitcher.tasksModel.activeTask !== 0) { root.taskSwitcher.tasksModel.requestClose(root.taskSwitcher.tasksModel.activeTask); } - MobileShell.HomeScreenControls.closeAppLaunchAnimation(); + MobileShellState.Shell.closeAppLaunchAnimation(); } else if (MobileShell.ShellUtil.isLaunchingApp) { // cancel the launching of the app - MobileShell.HomeScreenControls.closeAppLaunchAnimation(); + MobileShellState.Shell.closeAppLaunchAnimation(); MobileShell.ShellUtil.cancelLaunchingApp(); } } diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 6f4504e3..597528e8 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -17,7 +17,7 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell -import org.kde.plasma.phone.taskpanel 1.0 as TaskPanel +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState PlasmaCore.ColorScope { id: root @@ -40,7 +40,7 @@ PlasmaCore.ColorScope { // plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component plasmoid.Window.window.offset = Qt.binding(() => { - return (MobileShell.Shell.orientation === MobileShell.Shell.Landscape) ? MobileShell.TopPanelControls.panelHeight : 0; + return (MobileShellState.Shell.orientation === MobileShellState.Shell.Landscape) ? MobileShellState.TopPanelControls.panelHeight : 0; }); plasmoid.Window.window.thickness = Qt.binding(() => { // height of panel: @@ -49,18 +49,18 @@ PlasmaCore.ColorScope { return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Units.gridUnit * 2 : 8 }); plasmoid.Window.window.length = Qt.binding(() => { - return MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? Screen.width : Screen.height; + return MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait ? Screen.width : Screen.height; }); plasmoid.Window.window.maximumLength = Qt.binding(() => { - return MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? Screen.width : Screen.height; + return MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait ? Screen.width : Screen.height; }); plasmoid.Window.window.minimumLength = Qt.binding(() => { - return MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? Screen.width : Screen.height; + return MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait ? Screen.width : Screen.height; }); plasmoid.Window.window.location = Qt.binding(() => { - if (MobileShell.Shell.orientation === MobileShell.Shell.Portrait) { + if (MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait) { return PlasmaCore.Types.BottomEdge; - } else if (MobileShell.Shell.orientation === MobileShell.Shell.Landscape) { + } else if (MobileShellState.Shell.orientation === MobileShellState.Shell.Landscape) { return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge } }); @@ -81,17 +81,17 @@ PlasmaCore.ColorScope { //BEGIN API implementation Binding { - target: MobileShell.TaskPanelControls + target: MobileShellState.TaskPanelControls property: "isPortrait" value: Screen.width <= Screen.height } Binding { - target: MobileShell.TaskPanelControls + target: MobileShellState.TaskPanelControls property: "panelHeight" value: MobileShell.MobileShellSettings.navigationPanelEnabled ? root.height : 0 } Binding { - target: MobileShell.TaskPanelControls + target: MobileShellState.TaskPanelControls property: "panelWidth" value: MobileShell.MobileShellSettings.navigationPanelEnabled ? root.width : 0 } @@ -99,7 +99,7 @@ PlasmaCore.ColorScope { Connections { target: MobileShell.WindowUtil function onAllWindowsMinimizedChanged() { - MobileShell.HomeScreenControls.homeScreenVisible = MobileShell.WindowUtil.allWindowsMinimized + MobileShellState.HomeScreenControls.homeScreenVisible = MobileShell.WindowUtil.allWindowsMinimized } } @@ -142,7 +142,7 @@ PlasmaCore.ColorScope { Component { id: navigationPanel NavigationPanelComponent { - taskSwitcher: MobileShell.HomeScreenControls.taskSwitcher + taskSwitcher: MobileShellState.HomeScreenControls.taskSwitcher opaqueBar: root.opaqueBar } } @@ -151,7 +151,7 @@ PlasmaCore.ColorScope { Component { id: navigationGesture MobileShell.NavigationGestureArea { - taskSwitcher: MobileShell.HomeScreenControls.taskSwitcher + taskSwitcher: MobileShellState.HomeScreenControls.taskSwitcher } } diff --git a/look-and-feel/contents/lockscreen/Keypad.qml b/look-and-feel/contents/lockscreen/Keypad.qml index 002a1df5..5a2b18ad 100644 --- a/look-and-feel/contents/lockscreen/Keypad.qml +++ b/look-and-feel/contents/lockscreen/Keypad.qml @@ -147,7 +147,7 @@ Rectangle { onPressedChanged: { if (pressed) { - MobileShell.Haptics.buttonVibrate(); + MobileShell.ShellUtil.buttonVibrate(); } } @@ -162,7 +162,7 @@ Rectangle { } onPressAndHold: { if (modelData === "R") { - MobileShell.Haptics.buttonVibrate(); + MobileShell.ShellUtil.buttonVibrate(); passwordBar.clear(); } } diff --git a/quicksettings/audio/contents/ui/main.qml b/quicksettings/audio/contents/ui/main.qml index e675ef6c..431d3311 100644 --- a/quicksettings/audio/contents/ui/main.qml +++ b/quicksettings/audio/contents/ui/main.qml @@ -8,10 +8,10 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell MobileShell.QuickSetting { text: i18n("Sound") icon: "audio-speakers-symbolic" - status: i18n("%1%", MobileShell.VolumeProvider.volumeValue) + status: i18n("%1%", MobileShell.AudioProvider.volumeValue) enabled: false settingsCommand: "plasma-open-settings kcm_pulseaudio" function toggle() { - MobileShell.VolumeProvider.showVolumeOverlay() + MobileShell.AudioProvider.showVolumeOverlay() } } diff --git a/quicksettings/battery/contents/ui/main.qml b/quicksettings/battery/contents/ui/main.qml index 02985f25..4aa0295f 100644 --- a/quicksettings/battery/contents/ui/main.qml +++ b/quicksettings/battery/contents/ui/main.qml @@ -6,9 +6,11 @@ import QtQuick 2.15 import org.kde.plasma.private.mobileshell 1.0 as MobileShell MobileShell.QuickSetting { + property var batteryInfo: MobileShell.BatteryInfo {} + text: i18n("Battery") - status: i18n("%1%", MobileShell.BatteryProvider.percent) - icon: "battery-full" + (MobileShell.BatteryProvider.pluggedIn ? "-charging" : "") + status: i18n("%1%", batteryInfo.percent) + icon: "battery-full" + (batteryInfo.pluggedIn ? "-charging" : "") enabled: false settingsCommand: "plasma-open-settings kcm_mobile_power" } diff --git a/quicksettings/donotdisturb/contents/ui/main.qml b/quicksettings/donotdisturb/contents/ui/main.qml index b8d7e1c5..cf3ca567 100644 --- a/quicksettings/donotdisturb/contents/ui/main.qml +++ b/quicksettings/donotdisturb/contents/ui/main.qml @@ -6,17 +6,18 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState MobileShell.QuickSetting { text: i18n("Do Not Disturb") icon: enabled ? "notifications-disabled" : "notifications" status: "" - enabled: MobileShell.TopPanelControls.notificationsWidget && MobileShell.TopPanelControls.notificationsWidget.doNotDisturbModeEnabled - available: MobileShell.TopPanelControls.notificationsWidget + enabled: MobileShellState.TopPanelControls.notificationsWidget && MobileShellState.TopPanelControls.notificationsWidget.doNotDisturbModeEnabled + available: MobileShellState.TopPanelControls.notificationsWidget function toggle() { - if (MobileShell.TopPanelControls.notificationsWidget) { - MobileShell.TopPanelControls.notificationsWidget.toggleDoNotDisturbMode(); + if (MobileShellState.TopPanelControls.notificationsWidget) { + MobileShellState.TopPanelControls.notificationsWidget.toggleDoNotDisturbMode(); } } } diff --git a/quicksettings/record/package/contents/ui/main.qml b/quicksettings/record/package/contents/ui/main.qml index 7ae65274..b59135ab 100644 --- a/quicksettings/record/package/contents/ui/main.qml +++ b/quicksettings/record/package/contents/ui/main.qml @@ -5,6 +5,7 @@ import QtQuick 2.15 import QtQuick.Window 2.15 import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.pipewire.record 0.1 as PWRec import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.quicksetting.record 1.0 @@ -38,7 +39,7 @@ MobileShell.QuickSetting { } enabled = !enabled - MobileShell.TopPanelControls.closeActionDrawer(); + MobileShellState.Shell.closeActionDrawer(); } PWRec.PipeWireRecord { diff --git a/quicksettings/screenshot/package/contents/ui/main.qml b/quicksettings/screenshot/package/contents/ui/main.qml index 3c097b0e..a1775f40 100644 --- a/quicksettings/screenshot/package/contents/ui/main.qml +++ b/quicksettings/screenshot/package/contents/ui/main.qml @@ -4,6 +4,7 @@ import QtQuick 2.15 import org.kde.plasma.private.mobileshell 1.0 as MobileShell +import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import org.kde.plasma.quicksetting.screenshot 1.0 MobileShell.QuickSetting { @@ -16,11 +17,11 @@ MobileShell.QuickSetting { function toggle() { screenshotRequested = true; - MobileShell.TopPanelControls.closeActionDrawer(); + MobileShellState.Shell.closeActionDrawer(); } Connections { - target: MobileShell.TopPanelControls + target: MobileShellState.Shell function onActionDrawerVisibleChanged(visible) { if (!visible && screenshotRequested) { screenshotRequested = false;