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).
This commit is contained in:
Devin Lin 2022-11-11 11:21:12 -05:00
parent 8dd2ac8dd6
commit 7d3bf39750
62 changed files with 438 additions and 302 deletions

View file

@ -46,6 +46,7 @@ find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED
Core Core
Qml Qml
Quick Quick
Feedback
) )
if (QT_MAJOR_VERSION STREQUAL "5") if (QT_MAJOR_VERSION STREQUAL "5")
if (QUICK_COMPILER) if (QUICK_COMPILER)

View file

@ -40,6 +40,7 @@ Dependencies:
* Plasma Nano * Plasma Nano
* Kirigami * Kirigami
* Kirigami Addons * Kirigami Addons
* Qt Feedback
To start the phone homescreen in a window, run: To start the phone homescreen in a window, run:
``` ```

View file

@ -4,3 +4,4 @@
add_subdirectory(mmplugin) add_subdirectory(mmplugin)
add_subdirectory(mobileshell) add_subdirectory(mobileshell)
add_subdirectory(mobileshellstate)

View file

@ -38,6 +38,7 @@ target_link_libraries(mobileshellplugin
Qt::Qml Qt::Qml
Qt::Gui Qt::Gui
Qt::Quick Qt::Quick
Qt::Feedback
KF5::ConfigWidgets # for KStandardAction KF5::ConfigWidgets # for KStandardAction
KF5::KIOGui KF5::KIOGui
KF5::Plasma KF5::Plasma

View file

@ -73,15 +73,14 @@ void MobileShellPlugin::registerTypes(const char *uri)
qmlRegisterType(resolvePath("components/Flickable.qml"), uri, 1, 0, "Flickable"); qmlRegisterType(resolvePath("components/Flickable.qml"), uri, 1, 0, "Flickable");
qmlRegisterType(resolvePath("components/GridView.qml"), uri, 1, 0, "GridView"); qmlRegisterType(resolvePath("components/GridView.qml"), uri, 1, 0, "GridView");
qmlRegisterType(resolvePath("components/ListView.qml"), uri, 1, 0, "ListView"); 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/StartupFeedback.qml"), uri, 1, 0, "StartupFeedback");
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator"); qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
// /dataproviders // /dataproviders
qmlRegisterSingletonType(resolvePath("dataproviders/BatteryProvider.qml"), uri, 1, 0, "BatteryProvider"); qmlRegisterType(resolvePath("dataproviders/BatteryInfo.qml"), uri, 1, 0, "BatteryInfo");
qmlRegisterSingletonType(resolvePath("dataproviders/BluetoothProvider.qml"), uri, 1, 0, "BluetoothProvider"); qmlRegisterType(resolvePath("dataproviders/BluetoothInfo.qml"), uri, 1, 0, "BluetoothInfo");
qmlRegisterSingletonType(resolvePath("dataproviders/SignalStrengthProvider.qml"), uri, 1, 0, "SignalStrengthProvider"); qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo");
qmlRegisterSingletonType(resolvePath("dataproviders/VolumeProvider.qml"), uri, 1, 0, "VolumeProvider"); qmlRegisterSingletonType(resolvePath("dataproviders/AudioProvider.qml"), uri, 1, 0, "AudioProvider");
// /homescreen // /homescreen
qmlRegisterType(resolvePath("homescreen/HomeScreen.qml"), uri, 1, 0, "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/mediacontrols/MediaControlsWidget.qml"), uri, 1, 0, "MediaControlsWidget");
qmlRegisterType(resolvePath("widgets/notifications/NotificationsWidget.qml"), uri, 1, 0, "NotificationsWidget"); qmlRegisterType(resolvePath("widgets/notifications/NotificationsWidget.qml"), uri, 1, 0, "NotificationsWidget");
qmlRegisterType(resolvePath("widgets/notifications/NotificationsModelType.qml"), uri, 1, 0, "NotificationsModelType"); 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");
} }

View file

@ -1,47 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
*
* 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
}
}

View file

@ -13,6 +13,7 @@ import QtQuick.Window 2.2
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents 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 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
import "../../components" as Components import "../../components" as Components
import "../../components/util.js" as Util import "../../components/util.js" as Util
@ -46,7 +47,7 @@ Item {
readonly property int columnCount: Math.floor(width/columnWidth) readonly property int columnCount: Math.floor(width/columnWidth)
readonly property int rowCount: { readonly property int rowCount: {
let totalRows = Math.ceil(quickSettingsCount / columnCount); 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 maxRows = 5; // more than 5 is just disorienting
let targetRows = Math.floor(Window.height * (isPortrait ? 0.65 : 0.8) / rowHeight); let targetRows = Math.floor(Window.height * (isPortrait ? 0.65 : 0.8) / rowHeight);
return Math.min(maxRows, Math.min(totalRows, targetRows)); return Math.min(maxRows, Math.min(totalRows, targetRows));
@ -56,7 +57,7 @@ Item {
readonly property int quickSettingsCount: quickSettingsModel.count readonly property int quickSettingsCount: quickSettingsModel.count
function resetSwipeView() { function resetSwipeView() {
if (MobileShell.Shell.orientation === MobileShell.Shell.Portrait) { if (MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait) {
pageLoader.item.view.currentIndex = 0; pageLoader.item.view.currentIndex = 0;
} }
} }
@ -91,7 +92,7 @@ Item {
Layout.minimumHeight: rowCount * rowHeight Layout.minimumHeight: rowCount * rowHeight
asynchronous: true asynchronous: true
sourceComponent: MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? swipeViewComponent : scrollViewComponent sourceComponent: MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait ? swipeViewComponent : scrollViewComponent
} }
BrightnessItem { BrightnessItem {

View file

@ -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.core 2.0 as PlasmaCore
import org.kde.plasma.private.nanoshell 2.0 as NanoShell 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 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 org.kde.plasma.components 3.0 as PlasmaComponents
import "../../components" as Components import "../../components" as Components
@ -65,7 +66,7 @@ Components.BaseItem {
root.toggleFunction(); root.toggleFunction();
} else if (root.settingsCommand && !root.restrictedPermissions) { } else if (root.settingsCommand && !root.restrictedPermissions) {
closeRequested(); closeRequested();
MobileShell.HomeScreenControls.openAppLaunchAnimation( MobileShellState.Shell.openAppLaunchAnimation(
root.icon, root.icon,
root.text, root.text,
iconItem.Kirigami.ScenePosition.x + iconItem.width/2, iconItem.Kirigami.ScenePosition.x + iconItem.width/2,
@ -78,7 +79,7 @@ Components.BaseItem {
function delegatePressAndHold() { function delegatePressAndHold() {
if (root.settingsCommand && !root.restrictedPermissions) { if (root.settingsCommand && !root.restrictedPermissions) {
closeRequested(); closeRequested();
MobileShell.HomeScreenControls.openAppLaunchAnimation( MobileShellState.Shell.openAppLaunchAnimation(
root.icon, root.icon,
root.text, root.text,
iconItem.Kirigami.ScenePosition.x + iconItem.width/2, iconItem.Kirigami.ScenePosition.x + iconItem.width/2,

View file

@ -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.core 2.0 as PlasmaCore
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 "../../statusbar" as StatusBar
import "../../components" as Components import "../../components" as Components
@ -79,7 +80,7 @@ Components.BaseItem {
StatusBar.StatusBar { StatusBar.StatusBar {
id: statusBar id: statusBar
Layout.fillWidth: true 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 colorGroup: PlasmaCore.Theme.NormalColorGroup
backgroundColor: "transparent" backgroundColor: "transparent"

View file

@ -58,10 +58,10 @@ QuickSettingsDelegate {
contentItem: MouseArea { contentItem: MouseArea {
id: mouseArea id: mouseArea
onPressed: MobileShell.Haptics.buttonVibrate() onPressed: MobileShell.ShellUtil.buttonVibrate()
onClicked: root.delegateClick() onClicked: root.delegateClick()
onPressAndHold: { onPressAndHold: {
MobileShell.Haptics.buttonVibrate(); MobileShell.ShellUtil.buttonVibrate();
root.delegatePressAndHold(); root.delegatePressAndHold();
} }

View file

@ -55,10 +55,10 @@ QuickSettingsDelegate {
contentItem: MouseArea { contentItem: MouseArea {
id: mouseArea id: mouseArea
onPressed: MobileShell.Haptics.buttonVibrate(); onPressed: MobileShell.ShellUtil.buttonVibrate();
onClicked: root.delegateClick() onClicked: root.delegateClick()
onPressAndHold: { onPressAndHold: {
MobileShell.Haptics.buttonVibrate(); MobileShell.ShellUtil.buttonVibrate();
root.delegatePressAndHold(); root.delegatePressAndHold();
} }

View file

@ -1,32 +0,0 @@
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// 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 {}
}

View file

@ -1,12 +0,0 @@
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// 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 {}

View file

@ -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.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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. * 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"; background.state = "open";
MobileShell.HomeScreenControls.taskSwitcher.minimizeAll(); MobileShellState.HomeScreenControls.taskSwitcher.minimizeAll();
} }
function close() { function close() {
@ -55,7 +56,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind
// close when homescreen requested // close when homescreen requested
Connections { Connections {
target: MobileShell.HomeScreenControls target: MobileShellState.HomeScreenControls
function onOpenHomeScreen() { function onOpenHomeScreen() {
background.state = "closed"; background.state = "closed";
} }
@ -168,7 +169,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind
ScriptAction { ScriptAction {
script: { script: {
// close the app drawer after it isn't visible // 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 { ScriptAction {
script: { script: {
// close the app drawer after it isn't visible // close the app drawer after it isn't visible
MobileShell.HomeScreenControls.resetHomeScreenPosition(); MobileShellState.HomeScreenControls.resetHomeScreenPosition();
} }
} }
} }

View file

@ -24,15 +24,15 @@ QtObject {
*/ */
property bool bindShortcuts: false 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) readonly property string icon: paSinkModel.preferredSink && !isDummyOutput(paSinkModel.preferredSink)
? iconName(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted) ? iconName(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted)
: iconName(0, true) : 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 property int volumeValue
readonly property string dummyOutputName: "auto_null" readonly property string dummyOutputName: "auto_null"
@ -75,9 +75,6 @@ QtObject {
} }
function playFeedback(sinkIndex) { function playFeedback(sinkIndex) {
if (!volumeFeedback){
return;
}
if (sinkIndex == undefined) { if (sinkIndex == undefined) {
sinkIndex = paSinkModel.preferredSink.index; sinkIndex = paSinkModel.preferredSink.index;
} }
@ -113,8 +110,6 @@ QtObject {
playFeedback(); playFeedback();
} }
function muteVolume() { function muteVolume() {
if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) {
return; return;

View file

@ -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.components 3.0 as PlasmaComponents
import org.kde.plasma.workspace.components 2.0 as PW import org.kde.plasma.workspace.components 2.0 as PW
pragma Singleton
Item { Item {
property bool isVisible: pmSource.data["Battery"]["Has Cumulative"] property bool isVisible: pmSource.data["Battery"]["Has Cumulative"]
property int percent: pmSource.data["Battery"]["Percent"] property int percent: pmSource.data["Battery"]["Percent"]
@ -24,4 +22,3 @@ Item {
connectedSources: ["Battery", "AC Adapter"] connectedSources: ["Battery", "AC Adapter"]
} }
} }

View file

@ -0,0 +1,58 @@
/*
SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
SPDX-FileCopyrightText: 2013-2017 Jan Grulich <jgrulich@redhat.com>
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();
}
}

View file

@ -1,44 +0,0 @@
/*
SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
SPDX-FileCopyrightText: 2013-2017 Jan Grulich <jgrulich@redhat.com>
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();
}
}

View file

@ -9,14 +9,11 @@
import QtQuick 2.1 import QtQuick 2.1
import org.kde.plasma.mm 1.0 import org.kde.plasma.mm 1.0
pragma Singleton
QtObject { QtObject {
readonly property string icon: "network-mobile-" + Math.floor(SignalIndicator.strength / 20) * 20
property string icon: "network-mobile-" + Math.floor(SignalIndicator.strength / 20) * 20 readonly property string label: SignalIndicator.simLocked ? i18n("SIM Locked") : SignalIndicator.name
property string label: SignalIndicator.simLocked ? i18n("SIM Locked") : SignalIndicator.name readonly property bool showIndicator: SignalIndicator.modemAvailable
property bool showIndicator: SignalIndicator.modemAvailable
} }

View file

@ -11,6 +11,7 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.taskmanager 0.1 as TaskManager import org.kde.taskmanager 0.1 as TaskManager
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 * The base homescreen component, implementing features that simplify
@ -47,14 +48,14 @@ Item {
//BEGIN API implementation //BEGIN API implementation
Connections { Connections {
target: MobileShell.HomeScreenControls target: MobileShellState.HomeScreenControls
function onOpenHomeScreen() { function onOpenHomeScreen() {
if (!MobileShell.WindowUtil.allWindowsMinimized) { if (!MobileShell.WindowUtil.allWindowsMinimized) {
itemContainer.zoomIn(); itemContainer.zoomIn();
} }
MobileShell.HomeScreenControls.resetHomeScreenPosition(); MobileShellState.HomeScreenControls.resetHomeScreenPosition();
taskSwitcher.visible = false; // will trigger homescreen open taskSwitcher.visible = false; // will trigger homescreen open
taskSwitcher.minimizeAll(); taskSwitcher.minimizeAll();
@ -82,13 +83,13 @@ Item {
Plasmoid.onScreenChanged: { Plasmoid.onScreenChanged: {
if (plasmoid.screen == 0) { if (plasmoid.screen == 0) {
MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; MobileShellState.HomeScreenControls.taskSwitcher = taskSwitcher;
MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; MobileShellState.HomeScreenControls.homeScreenWindow = root.Window.window;
} }
} }
Window.onWindowChanged: { Window.onWindowChanged: {
if (plasmoid.screen == 0) { if (plasmoid.screen == 0) {
MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; MobileShellState.HomeScreenControls.homeScreenWindow = root.Window.window;
} }
} }
@ -97,8 +98,8 @@ Item {
Component.onCompleted: { Component.onCompleted: {
// set API variables // set API variables
if (plasmoid.screen == 0) { if (plasmoid.screen == 0) {
MobileShell.HomeScreenControls.taskSwitcher = taskSwitcher; MobileShellState.HomeScreenControls.taskSwitcher = taskSwitcher;
MobileShell.HomeScreenControls.homeScreenWindow = root.Window.window; MobileShellState.HomeScreenControls.homeScreenWindow = root.Window.window;
} }
} }

View file

@ -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.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
Item { Item {
id: root id: root
@ -65,7 +66,7 @@ Item {
startMouseY = oldMouseY = mouse.y; startMouseY = oldMouseY = mouse.y;
activeButton = icons.childAt(mouse.x, mouse.y); activeButton = icons.childAt(mouse.x, mouse.y);
if (activeButton && activeButton.enabled) { if (activeButton && activeButton.enabled) {
MobileShell.Haptics.buttonVibrate(); MobileShell.ShellUtil.buttonVibrate();
} }
} }
@ -96,7 +97,7 @@ Item {
activeButton = null; activeButton = null;
root.taskSwitcher.show(false); root.taskSwitcher.show(false);
} else if (taskSwitcher.tasksCount === 0) { // no tasks, let's scroll up the homescreen instead } 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; oldMouseY = mouse.y;

View file

@ -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.extras 2.0 as PlasmaExtra
import org.kde.plasma.private.nanoshell 2.0 as NanoShell 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 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.12 as Kirigami
@ -171,7 +172,7 @@ NanoShell.FullScreenOverlay {
onClicked: { onClicked: {
let coords = mapToItem(flickable, 0, 0); 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"); MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_pulseaudio");
} }
} }

View file

@ -15,6 +15,7 @@ import QtGraphicalEffects 1.12
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents 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 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
import "indicators" as Indicators import "indicators" as Indicators
@ -121,7 +122,7 @@ Item {
RowLayout { RowLayout {
id: row id: row
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumHeight: MobileShell.TopPanelControls.panelHeight - control.topPadding - control.bottomPadding Layout.maximumHeight: MobileShellState.TopPanelControls.panelHeight - control.topPadding - control.bottomPadding
spacing: 0 spacing: 0
// clock // clock
@ -211,10 +212,14 @@ Item {
color: PlasmaCore.ColorScope.disabledTextColor color: PlasmaCore.ColorScope.disabledTextColor
font.pixelSize: root.smallerTextPixelSize font.pixelSize: root.smallerTextPixelSize
} }
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
PlasmaComponents.Label { PlasmaComponents.Label {
property var signalStrengthInfo: MobileShell.SignalStrengthInfo {}
visible: root.showTime visible: root.showTime
text: MobileShell.SignalStrengthProvider.label text: signalStrengthInfo.label
color: PlasmaCore.ColorScope.disabledTextColor color: PlasmaCore.ColorScope.disabledTextColor
font.pixelSize: root.smallerTextPixelSize font.pixelSize: root.smallerTextPixelSize
horizontalAlignment: Qt.AlignRight horizontalAlignment: Qt.AlignRight

View file

@ -14,8 +14,9 @@ import org.kde.plasma.workspace.components 2.0 as PW
import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell
RowLayout { RowLayout {
property MobileShell.BatteryProvider provider: MobileShell.BatteryProvider readonly property var provider: MobileShell.BatteryInfo {}
property real textPixelSize: PlasmaCore.Units.gridUnit * 0.6 property real textPixelSize: PlasmaCore.Units.gridUnit * 0.6
visible: provider.isVisible visible: provider.isVisible
PW.BatteryIcon { PW.BatteryIcon {

View file

@ -16,7 +16,8 @@ import org.kde.bluezqt 1.0 as BluezQt
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: connectionIcon id: connectionIcon
property MobileShell.BluetoothProvider provider: MobileShell.BluetoothProvider
readonly property var provider: MobileShell.BluetoothInfo {}
source: provider.icon source: provider.icon
colorGroup: PlasmaCore.ColorScope.colorGroup colorGroup: PlasmaCore.ColorScope.colorGroup

View file

@ -13,10 +13,10 @@ 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 1.0 as MobileShell
Item { Item {
property MobileShell.SignalStrengthProvider provider: MobileShell.SignalStrengthProvider
required property InternetIndicator internetIndicator required property InternetIndicator internetIndicator
readonly property var provider: MobileShell.SignalStrengthInfo {}
// check if the internet indicator icon is a mobile data related one // check if the internet indicator icon is a mobile data related one
readonly property bool isInternetIndicatorMobileData: internetIndicator && internetIndicator.icon && internetIndicator.icon.startsWith('network-mobile-') readonly property bool isInternetIndicatorMobileData: internetIndicator && internetIndicator.icon && internetIndicator.icon.startsWith('network-mobile-')

View file

@ -14,7 +14,7 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: paIcon id: paIcon
property MobileShell.VolumeProvider provider: MobileShell.VolumeProvider readonly property var provider: MobileShell.AudioProvider
Layout.fillHeight: true Layout.fillHeight: true
Layout.preferredWidth: height Layout.preferredWidth: height

View file

@ -10,8 +10,7 @@ import QtQuick.Layouts 1.1
import org.kde.taskmanager 0.1 as TaskManager import org.kde.taskmanager 0.1 as TaskManager
import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.plasma.core 2.1 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents 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.state 1.0 as MobileShellState
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
Item { Item {
id: root id: root
@ -21,13 +20,13 @@ Item {
// account for system header and footer offset (center the preview image) // account for system header and footer offset (center the preview image)
readonly property real taskY: { readonly property real taskY: {
let headerHeight = MobileShell.Shell.topMargin; let headerHeight = MobileShellState.Shell.topMargin;
let footerHeight = MobileShell.Shell.bottomMargin; let footerHeight = MobileShellState.Shell.bottomMargin;
let diff = headerHeight - footerHeight; let diff = headerHeight - footerHeight;
let baseY = (taskSwitcher.height / 2) - (taskSwitcherState.taskHeight / 2) - (taskSwitcherState.taskHeaderHeight / 2) 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 { transform: Scale {

View file

@ -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.components 3.0 as PlasmaComponents
import org.kde.plasma.private.nanoshell 2.0 as NanoShell 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 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
import "../components" as Components import "../components" as Components
@ -58,7 +59,7 @@ Item {
} }
// update API property // update API property
onVisibleChanged: MobileShell.HomeScreenControls.taskSwitcherVisible = visible; onVisibleChanged: MobileShellState.HomeScreenControls.taskSwitcherVisible = visible;
// keep track of task list events // keep track of task list events
property int oldTasksCount: tasksCount property int oldTasksCount: tasksCount
@ -200,10 +201,10 @@ Item {
// provide shell margins // provide shell margins
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: MobileShell.Shell.leftMargin anchors.leftMargin: MobileShellState.Shell.leftMargin
anchors.rightMargin: MobileShell.Shell.rightMargin anchors.rightMargin: MobileShellState.Shell.rightMargin
anchors.bottomMargin: MobileShell.Shell.bottomMargin anchors.bottomMargin: MobileShellState.Shell.bottomMargin
anchors.topMargin: MobileShell.Shell.topMargin anchors.topMargin: MobileShellState.Shell.topMargin
FlickContainer { FlickContainer {
id: flickable id: flickable

View file

@ -9,6 +9,7 @@ import QtQuick 2.15
import org.kde.plasma.core 2.1 as PlasmaCore 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 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
/** /**
* State object for the task switcher. * State object for the task switcher.
@ -76,8 +77,8 @@ QtObject {
// ~~ measurement constants ~~ // ~~ measurement constants ~~
// dimensions of a real window on the screen // dimensions of a real window on the screen
readonly property real windowHeight: taskSwitcher.height - MobileShell.Shell.topMargin - MobileShell.Shell.bottomMargin readonly property real windowHeight: taskSwitcher.height - MobileShellState.Shell.topMargin - MobileShellState.Shell.bottomMargin
readonly property real windowWidth: taskSwitcher.width - MobileShell.Shell.leftMargin - MobileShell.Shell.rightMargin readonly property real windowWidth: taskSwitcher.width - MobileShellState.Shell.leftMargin - MobileShellState.Shell.rightMargin
// dimensions of the task previews // dimensions of the task previews
readonly property real previewHeight: windowHeight * scalingFactor readonly property real previewHeight: windowHeight * scalingFactor

View file

@ -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.components 3.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras 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 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.milou 0.1 as Milou
import org.kde.kirigami 2.19 as Kirigami import org.kde.kirigami 2.19 as Kirigami
@ -75,10 +76,10 @@ Item {
id: flickable id: flickable
anchors.fill: parent anchors.fill: parent
anchors.topMargin: MobileShell.Shell.topMargin anchors.topMargin: MobileShellState.Shell.topMargin
anchors.bottomMargin: MobileShell.Shell.bottomMargin anchors.bottomMargin: MobileShellState.Shell.bottomMargin
anchors.leftMargin: MobileShell.Shell.leftMargin anchors.leftMargin: MobileShellState.Shell.leftMargin
anchors.rightMargin: MobileShell.Shell.rightMargin anchors.rightMargin: MobileShellState.Shell.rightMargin
contentHeight: flickable.height + root.closedContentY + 999999 contentHeight: flickable.height + root.closedContentY + 999999
contentY: root.closedContentY contentY: root.closedContentY

View file

@ -12,6 +12,7 @@ import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.extras 2.0 as PlasmaExtras
@ -75,7 +76,7 @@ Item {
onClicked: { onClicked: {
MobileShell.ShellUtil.launchApp(modelData.desktopEntry + ".desktop"); MobileShell.ShellUtil.launchApp(modelData.desktopEntry + ".desktop");
MobileShell.TopPanelControls.closeActionDrawer(); MobileShellState.Shell.closeActionDrawer();
} }
Components.BaseItem { Components.BaseItem {

View file

@ -24,18 +24,16 @@
<file>qml/components/ExtendedAbstractButton.qml</file> <file>qml/components/ExtendedAbstractButton.qml</file>
<file>qml/components/Flickable.qml</file> <file>qml/components/Flickable.qml</file>
<file>qml/components/GridView.qml</file> <file>qml/components/GridView.qml</file>
<file>qml/components/Haptics.qml</file>
<file>qml/components/HapticsEffectWrapper.qml</file>
<file>qml/components/ListView.qml</file> <file>qml/components/ListView.qml</file>
<file>qml/components/MarqueeLabel.qml</file> <file>qml/components/MarqueeLabel.qml</file>
<file>qml/components/StartupFeedback.qml</file> <file>qml/components/StartupFeedback.qml</file>
<file>qml/components/util.js</file> <file>qml/components/util.js</file>
<file>qml/components/VelocityCalculator.qml</file> <file>qml/components/VelocityCalculator.qml</file>
<file>qml/dataproviders/BatteryProvider.qml</file> <file>qml/dataproviders/BatteryInfo.qml</file>
<file>qml/dataproviders/BluetoothProvider.qml</file> <file>qml/dataproviders/BluetoothInfo.qml</file>
<file>qml/dataproviders/SignalStrengthProvider.qml</file> <file>qml/dataproviders/SignalStrengthInfo.qml</file>
<file>qml/dataproviders/VolumeProvider.qml</file> <file>qml/dataproviders/AudioProvider.qml</file>
<file>qml/homescreen/HomeScreen.qml</file> <file>qml/homescreen/HomeScreen.qml</file>
@ -89,10 +87,5 @@
<file>qml/widgets/notifications/ThumbnailStrip.qml</file> <file>qml/widgets/notifications/ThumbnailStrip.qml</file>
<file>qml/widgets/notifications/util.js</file> <file>qml/widgets/notifications/util.js</file>
<file>qml/HomeScreenControls.qml</file>
<file>qml/Shell.qml</file>
<file>qml/TaskPanelControls.qml</file>
<file>qml/TopPanelControls.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -7,6 +7,7 @@
*/ */
#include "shellutil.h" #include "shellutil.h"
#include "mobileshellsettings.h"
#include "windowutil.h" #include "windowutil.h"
#include <KConfigGroup> #include <KConfigGroup>
@ -18,6 +19,7 @@
#include <QDBusPendingReply> #include <QDBusPendingReply>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QFeedbackHapticsEffect>
#include <QFile> #include <QFile>
#include <QProcess> #include <QProcess>
@ -25,8 +27,8 @@
ShellUtil::ShellUtil(QObject *parent) ShellUtil::ShellUtil(QObject *parent)
: QObject{parent} : QObject{parent}
, m_launchingApp{nullptr}
, m_localeConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)} , m_localeConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)}
, m_launchingApp{nullptr}
{ {
m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig); m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig);
@ -131,3 +133,13 @@ void ShellUtil::clearLaunchingApp()
m_launchingApp = nullptr; m_launchingApp = nullptr;
Q_EMIT isLaunchingAppChanged(); Q_EMIT isLaunchingAppChanged();
} }
void ShellUtil::buttonVibrate()
{
if (MobileShellSettings::self()->vibrationsEnabled()) {
QFeedbackHapticsEffect rumble;
rumble.setDuration(MobileShellSettings::self()->vibrationDuration());
rumble.setIntensity(MobileShellSettings::self()->vibrationIntensity());
rumble.start();
}
}

View file

@ -81,6 +81,11 @@ public:
*/ */
Q_INVOKABLE void clearLaunchingApp(); Q_INVOKABLE void clearLaunchingApp();
/**
* Initiates a vibration event, meant for a button.
*/
Q_INVOKABLE void buttonVibrate();
Q_SIGNALS: Q_SIGNALS:
void isSystem24HourFormatChanged(); void isSystem24HourFormatChanged();
void isLaunchingAppChanged(); void isLaunchingAppChanged();

View file

@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
# 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)

View file

@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "mobileshellstateplugin.h"
#include <QQmlContext>
#include <QQuickItem>
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");
}

View file

@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QUrl>
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
class MobileShellStatePlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri) override;
};

View file

@ -1,9 +1,6 @@
/* // SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
* SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> // SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org> // SPDX-License-Identifier: GPL-2.0-or-later
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Window 2.2 import QtQuick.Window 2.2

View file

@ -0,0 +1,87 @@
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// 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();
}
}

View file

@ -21,7 +21,7 @@ QtObject {
signal closeActionDrawer() signal closeActionDrawer()
signal openActionDrawer() signal openActionDrawer()
property bool inSwipe: false 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 bool actionDrawerVisible: false
property var notificationsWidget // updated in panel containment property var notificationsWidget // updated in panel containment
} }

View file

@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
# SPDX-License-Identifier: GPL-2.0-or-later
module org.kde.plasma.private.mobileshell.state
plugin mobileshellstateplugin

View file

@ -0,0 +1,14 @@
<!--
- Copyright 2022 Devin Lin <devin@kde.org>
- SPDX-License-Identifier: GPL-2.0-or-later
-->
<RCC>
<qresource prefix="/org/kde/plasma/private/mobileshell/state/">
<file>qml/HomeScreenControls.qml</file>
<file>qml/Shell.qml</file>
<file>qml/TaskPanelControls.qml</file>
<file>qml/TopPanelControls.qml</file>
</qresource>
</RCC>

View file

@ -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.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 org.kde.phone.homescreen.default 1.0 as HomeScreenLib
import "private" as Private import "private" as Private
@ -50,7 +51,7 @@ ContainmentLayoutManager.ItemContainer {
return; return;
} }
if (!MobileShell.HomeScreenControls.taskSwitcherVisible) { if (!MobileShellState.Shell.taskSwitcherVisible) {
HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate); HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate);
} else { } else {
HomeScreenLib.DesktopModel.unsetMinimizedDelegate(index, delegate); HomeScreenLib.DesktopModel.unsetMinimizedDelegate(index, delegate);
@ -88,7 +89,7 @@ ContainmentLayoutManager.ItemContainer {
} }
} }
Connections { Connections {
target: MobileShell.HomeScreenControls target: MobileShellState.Shell
function onTaskSwitcherVisibleChanged() { function onTaskSwitcherVisibleChanged() {
syncDelegateGeometry(); syncDelegateGeometry();
} }

View file

@ -20,6 +20,7 @@ import "appdrawer"
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager 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 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 org.kde.phone.homescreen.default 1.0 as HomeScreenLib
Item { Item {
@ -34,8 +35,8 @@ Item {
appDrawerFlickable: appDrawer.flickable appDrawerFlickable: appDrawer.flickable
availableScreenHeight: height - MobileShell.Shell.bottomMargin availableScreenHeight: height - MobileShellState.Shell.bottomMargin
availableScreenWidth: width - MobileShell.Shell.leftMargin - MobileShell.Shell.rightMargin availableScreenWidth: width - MobileShellState.Shell.leftMargin - MobileShellState.Shell.rightMargin
appDrawerBottomOffset: favoriteStrip.height appDrawerBottomOffset: favoriteStrip.height
} }
@ -74,10 +75,10 @@ Item {
// account for panels // account for panels
anchors.fill: parent anchors.fill: parent
anchors.topMargin: MobileShell.Shell.topMargin anchors.topMargin: MobileShellState.Shell.topMargin
anchors.bottomMargin: MobileShell.Shell.bottomMargin anchors.bottomMargin: MobileShellState.Shell.bottomMargin
anchors.leftMargin: MobileShell.Shell.leftMargin anchors.leftMargin: MobileShellState.Shell.leftMargin
anchors.rightMargin: MobileShell.Shell.rightMargin anchors.rightMargin: MobileShellState.Shell.rightMargin
// animation when app drawer is being shown // animation when app drawer is being shown
opacity: root.appDrawer ? 1 - root.appDrawer.openFactor : 1 opacity: root.appDrawer ? 1 - root.appDrawer.openFactor : 1
@ -132,10 +133,10 @@ Item {
homeScreenState: root.homeScreenState homeScreenState: root.homeScreenState
// account for panels // account for panels
topPadding: MobileShell.Shell.topMargin topPadding: MobileShellState.Shell.topMargin
bottomPadding: MobileShell.Shell.bottomMargin bottomPadding: MobileShellState.Shell.bottomMargin
leftPadding: MobileShell.Shell.leftMargin leftPadding: MobileShellState.Shell.leftMargin
rightPadding: MobileShell.Shell.rightMargin rightPadding: MobileShellState.Shell.rightMargin
} }
} }
} }

View file

@ -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.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.phone.homescreen.default 1.0 as HomeScreenLib import org.kde.phone.homescreen.default 1.0 as HomeScreenLib
import org.kde.kirigami 2.14 as Kirigami import org.kde.kirigami 2.14 as Kirigami
@ -105,7 +106,7 @@ Repeater {
onLaunch: (x, y, icon, title) => { onLaunch: (x, y, icon, title) => {
if (icon !== "") { if (icon !== "") {
MobileShell.HomeScreenControls.openAppLaunchAnimation( MobileShellState.Shell.openAppLaunchAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -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.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 org.kde.phone.homescreen.default 1.0 as HomeScreenLib
import "../private" import "../private"
@ -69,7 +70,7 @@ AbstractAppDrawer {
} }
onLaunch: (x, y, icon, title, storageId) => { onLaunch: (x, y, icon, title, storageId) => {
if (icon !== "") { if (icon !== "") {
MobileShell.HomeScreenControls.openAppLaunchAnimation( MobileShellState.Shell.openAppLaunchAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -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.components 3.0 as PlasmaComponents
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 org.kde.phone.homescreen.default 1.0 as HomeScreenLib
MobileShell.HomeScreen { MobileShell.HomeScreen {
@ -45,13 +46,13 @@ MobileShell.HomeScreen {
// - minimize windows (only if we are in an app) // - minimize windows (only if we are in an app)
// - open app drawer // - open app drawer
// - close app drawer and, if necessary, restore windows // - close app drawer and, if necessary, restore windows
if (!plasmoid.nativeInterface.showingDesktop && !MobileShell.HomeScreenControls.homeScreenVisible if (!plasmoid.nativeInterface.showingDesktop && !MobileShellState.Shell.homeScreenVisible
|| MobileShell.TopPanelControls.actionDrawerVisible || MobileShellState.Shell.actionDrawerVisible
|| searchWidget.isOpen || searchWidget.isOpen
) { ) {
// Always close action drawer // Always close action drawer
if (MobileShell.TopPanelControls.actionDrawerVisible) { if (MobileShellState.Shell.actionDrawerVisible) {
MobileShell.TopPanelControls.closeActionDrawer(); MobileShellState.Shell.closeActionDrawer();
} }
// Always close the search widget as well // Always close the search widget as well
@ -88,7 +89,7 @@ MobileShell.HomeScreen {
// close search component when task switcher is shown or hidden // close search component when task switcher is shown or hidden
Connections { Connections {
target: MobileShell.HomeScreenControls.taskSwitcher target: MobileShellState.HomeScreenControls.taskSwitcher
function onVisibleChanged() { function onVisibleChanged() {
searchWidget.close(); searchWidget.close();
} }
@ -114,7 +115,7 @@ MobileShell.HomeScreen {
Connections { Connections {
target: HomeScreenLib.ApplicationListModel target: HomeScreenLib.ApplicationListModel
function onLaunchError(msg) { function onLaunchError(msg) {
MobileShell.HomeScreenControls.closeAppLaunchAnimation() MobileShellState.Shell.closeAppLaunchAnimation()
} }
} }
} }

View file

@ -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.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.phone.homescreen.halcyon 1.0 as Halcyon
import org.kde.kirigami 2.19 as Kirigami import org.kde.kirigami 2.19 as Kirigami
@ -79,7 +80,7 @@ Item {
function launchAppWithAnim(x: int, y: int, source, title: string, storageId: string) { function launchAppWithAnim(x: int, y: int, source, title: string, storageId: string) {
if (source !== "") { if (source !== "") {
MobileShell.HomeScreenControls.openAppLaunchAnimation( MobileShellState.Shell.openAppLaunchAnimation(
source, source,
title, title,
iconLoader.Kirigami.ScenePosition.x + iconLoader.width/2, iconLoader.Kirigami.ScenePosition.x + iconLoader.width/2,

View file

@ -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.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.phone.homescreen.halcyon 1.0 as Halcyon
MobileShell.GridView { MobileShell.GridView {
@ -76,7 +77,7 @@ MobileShell.GridView {
onLaunch: (x, y, icon, title, storageId) => { onLaunch: (x, y, icon, title, storageId) => {
if (icon !== "") { if (icon !== "") {
MobileShell.HomeScreenControls.openAppLaunchAnimation( MobileShellState.Shell.openAppLaunchAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -13,7 +13,7 @@ import org.kde.plasma.components 3.0 as PC3
import org.kde.draganddrop 2.0 as DragDrop import org.kde.draganddrop 2.0 as DragDrop
import org.kde.kirigami 2.19 as Kirigami 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 import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
Item { Item {
@ -42,10 +42,10 @@ Item {
interactive: root.interactive interactive: root.interactive
anchors.fill: parent anchors.fill: parent
anchors.topMargin: MobileShell.Shell.topMargin anchors.topMargin: MobileShellState.Shell.topMargin
anchors.bottomMargin: MobileShell.Shell.bottomMargin anchors.bottomMargin: MobileShellState.Shell.bottomMargin
anchors.leftMargin: MobileShell.Shell.leftMargin anchors.leftMargin: MobileShellState.Shell.leftMargin
anchors.rightMargin: MobileShell.Shell.rightMargin anchors.rightMargin: MobileShellState.Shell.rightMargin
Item { Item {
height: swipeView.height height: swipeView.height

View file

@ -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.components 3.0 as PlasmaComponents
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.phone.homescreen.halcyon 1.0 as Halcyon
MobileShell.HomeScreen { MobileShell.HomeScreen {
@ -44,13 +45,13 @@ MobileShell.HomeScreen {
// - minimize windows (only if we are in an app) // - minimize windows (only if we are in an app)
// - open app drawer // - open app drawer
// - close app drawer and, if necessary, restore windows // - close app drawer and, if necessary, restore windows
if (!plasmoid.nativeInterface.showingDesktop && !MobileShell.HomeScreenControls.homeScreenVisible if (!plasmoid.nativeInterface.showingDesktop && !MobileShellState.Shell.homeScreenVisible
|| MobileShell.TopPanelControls.actionDrawerVisible || MobileShellState.Shell.actionDrawerVisible
|| search.isOpen || search.isOpen
) { ) {
// Always close action drawer // Always close action drawer
if (MobileShell.TopPanelControls.actionDrawerVisible) { if (MobileShellState.Shell.actionDrawerVisible) {
MobileShell.TopPanelControls.closeActionDrawer(); MobileShellState.Shell.closeActionDrawer();
} }
// Always close the search widget as well // Always close the search widget as well
@ -86,7 +87,7 @@ MobileShell.HomeScreen {
// close search component when task switcher is shown or hidden // close search component when task switcher is shown or hidden
Connections { Connections {
target: MobileShell.HomeScreenControls.taskSwitcher target: MobileShellState.HomeScreenControls.taskSwitcher
function onVisibleChanged() { function onVisibleChanged() {
search.close(); search.close();
} }

View file

@ -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.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.taskmanager 0.1 as TaskManager
import org.kde.notificationmanager 1.0 as NotificationManager import org.kde.notificationmanager 1.0 as NotificationManager
@ -44,29 +45,29 @@ Item {
//BEGIN API implementation //BEGIN API implementation
Binding { Binding {
target: MobileShell.TopPanelControls target: MobileShellState.TopPanelControls
property: "panelHeight" property: "panelHeight"
value: root.height value: root.height
} }
Binding { Binding {
target: MobileShell.TopPanelControls target: MobileShellState.TopPanelControls
property: "inSwipe" property: "inSwipe"
value: drawer.actionDrawer.dragging value: drawer.actionDrawer.dragging
} }
Binding { Binding {
target: MobileShell.TopPanelControls target: MobileShellState.TopPanelControls
property: "actionDrawerVisible" property: "actionDrawerVisible"
value: drawer.visible value: drawer.visible
} }
Binding { Binding {
target: MobileShell.TopPanelControls target: MobileShellState.TopPanelControls
property: "notificationsWidget" property: "notificationsWidget"
value: drawer.actionDrawer.notificationsWidget value: drawer.actionDrawer.notificationsWidget
} }
Connections { Connections {
target: MobileShell.TopPanelControls target: MobileShellState.TopPanelControls
function onStartSwipe() { function onStartSwipe() {
swipeArea.startSwipe(); swipeArea.startSwipe();
@ -89,7 +90,7 @@ Item {
Component.onCompleted: { Component.onCompleted: {
// we want to bind global volume shortcuts here // we want to bind global volume shortcuts here
MobileShell.VolumeProvider.bindShortcuts = true; MobileShell.AudioProvider.bindShortcuts = true;
} }
TaskManager.VirtualDesktopInfo { TaskManager.VirtualDesktopInfo {

View file

@ -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.workspace.keyboardlayout 1.0 as Keyboards
import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
MobileShell.NavigationPanel { MobileShell.NavigationPanel {
id: root id: root
@ -73,7 +74,7 @@ MobileShell.NavigationPanel {
iconSizeFactor: 1 iconSizeFactor: 1
onTriggered: { onTriggered: {
MobileShell.HomeScreenControls.openHomeScreen(); MobileShellState.HomeScreenControls.openHomeScreen();
MobileShell.WindowUtil.allWindowsMinimizedChanged(); MobileShell.WindowUtil.allWindowsMinimizedChanged();
} }
} }
@ -101,11 +102,11 @@ MobileShell.NavigationPanel {
if (root.taskSwitcher.tasksModel.activeTask !== 0) { if (root.taskSwitcher.tasksModel.activeTask !== 0) {
root.taskSwitcher.tasksModel.requestClose(root.taskSwitcher.tasksModel.activeTask); root.taskSwitcher.tasksModel.requestClose(root.taskSwitcher.tasksModel.activeTask);
} }
MobileShell.HomeScreenControls.closeAppLaunchAnimation(); MobileShellState.Shell.closeAppLaunchAnimation();
} else if (MobileShell.ShellUtil.isLaunchingApp) { } else if (MobileShell.ShellUtil.isLaunchingApp) {
// cancel the launching of the app // cancel the launching of the app
MobileShell.HomeScreenControls.closeAppLaunchAnimation(); MobileShellState.Shell.closeAppLaunchAnimation();
MobileShell.ShellUtil.cancelLaunchingApp(); MobileShell.ShellUtil.cancelLaunchingApp();
} }
} }

View file

@ -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.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 { PlasmaCore.ColorScope {
id: root id: root
@ -40,7 +40,7 @@ PlasmaCore.ColorScope {
// plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component // plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component
plasmoid.Window.window.offset = Qt.binding(() => { 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(() => { plasmoid.Window.window.thickness = Qt.binding(() => {
// height of panel: // height of panel:
@ -49,18 +49,18 @@ PlasmaCore.ColorScope {
return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Units.gridUnit * 2 : 8 return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Units.gridUnit * 2 : 8
}); });
plasmoid.Window.window.length = Qt.binding(() => { 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(() => { 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(() => { 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(() => { plasmoid.Window.window.location = Qt.binding(() => {
if (MobileShell.Shell.orientation === MobileShell.Shell.Portrait) { if (MobileShellState.Shell.orientation === MobileShellState.Shell.Portrait) {
return PlasmaCore.Types.BottomEdge; 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 return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
} }
}); });
@ -81,17 +81,17 @@ PlasmaCore.ColorScope {
//BEGIN API implementation //BEGIN API implementation
Binding { Binding {
target: MobileShell.TaskPanelControls target: MobileShellState.TaskPanelControls
property: "isPortrait" property: "isPortrait"
value: Screen.width <= Screen.height value: Screen.width <= Screen.height
} }
Binding { Binding {
target: MobileShell.TaskPanelControls target: MobileShellState.TaskPanelControls
property: "panelHeight" property: "panelHeight"
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? root.height : 0 value: MobileShell.MobileShellSettings.navigationPanelEnabled ? root.height : 0
} }
Binding { Binding {
target: MobileShell.TaskPanelControls target: MobileShellState.TaskPanelControls
property: "panelWidth" property: "panelWidth"
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? root.width : 0 value: MobileShell.MobileShellSettings.navigationPanelEnabled ? root.width : 0
} }
@ -99,7 +99,7 @@ PlasmaCore.ColorScope {
Connections { Connections {
target: MobileShell.WindowUtil target: MobileShell.WindowUtil
function onAllWindowsMinimizedChanged() { function onAllWindowsMinimizedChanged() {
MobileShell.HomeScreenControls.homeScreenVisible = MobileShell.WindowUtil.allWindowsMinimized MobileShellState.HomeScreenControls.homeScreenVisible = MobileShell.WindowUtil.allWindowsMinimized
} }
} }
@ -142,7 +142,7 @@ PlasmaCore.ColorScope {
Component { Component {
id: navigationPanel id: navigationPanel
NavigationPanelComponent { NavigationPanelComponent {
taskSwitcher: MobileShell.HomeScreenControls.taskSwitcher taskSwitcher: MobileShellState.HomeScreenControls.taskSwitcher
opaqueBar: root.opaqueBar opaqueBar: root.opaqueBar
} }
} }
@ -151,7 +151,7 @@ PlasmaCore.ColorScope {
Component { Component {
id: navigationGesture id: navigationGesture
MobileShell.NavigationGestureArea { MobileShell.NavigationGestureArea {
taskSwitcher: MobileShell.HomeScreenControls.taskSwitcher taskSwitcher: MobileShellState.HomeScreenControls.taskSwitcher
} }
} }

View file

@ -147,7 +147,7 @@ Rectangle {
onPressedChanged: { onPressedChanged: {
if (pressed) { if (pressed) {
MobileShell.Haptics.buttonVibrate(); MobileShell.ShellUtil.buttonVibrate();
} }
} }
@ -162,7 +162,7 @@ Rectangle {
} }
onPressAndHold: { onPressAndHold: {
if (modelData === "R") { if (modelData === "R") {
MobileShell.Haptics.buttonVibrate(); MobileShell.ShellUtil.buttonVibrate();
passwordBar.clear(); passwordBar.clear();
} }
} }

View file

@ -8,10 +8,10 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell
MobileShell.QuickSetting { MobileShell.QuickSetting {
text: i18n("Sound") text: i18n("Sound")
icon: "audio-speakers-symbolic" icon: "audio-speakers-symbolic"
status: i18n("%1%", MobileShell.VolumeProvider.volumeValue) status: i18n("%1%", MobileShell.AudioProvider.volumeValue)
enabled: false enabled: false
settingsCommand: "plasma-open-settings kcm_pulseaudio" settingsCommand: "plasma-open-settings kcm_pulseaudio"
function toggle() { function toggle() {
MobileShell.VolumeProvider.showVolumeOverlay() MobileShell.AudioProvider.showVolumeOverlay()
} }
} }

View file

@ -6,9 +6,11 @@ import QtQuick 2.15
import org.kde.plasma.private.mobileshell 1.0 as MobileShell import org.kde.plasma.private.mobileshell 1.0 as MobileShell
MobileShell.QuickSetting { MobileShell.QuickSetting {
property var batteryInfo: MobileShell.BatteryInfo {}
text: i18n("Battery") text: i18n("Battery")
status: i18n("%1%", MobileShell.BatteryProvider.percent) status: i18n("%1%", batteryInfo.percent)
icon: "battery-full" + (MobileShell.BatteryProvider.pluggedIn ? "-charging" : "") icon: "battery-full" + (batteryInfo.pluggedIn ? "-charging" : "")
enabled: false enabled: false
settingsCommand: "plasma-open-settings kcm_mobile_power" settingsCommand: "plasma-open-settings kcm_mobile_power"
} }

View file

@ -6,17 +6,18 @@
import org.kde.plasma.core 2.0 as PlasmaCore 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 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
MobileShell.QuickSetting { MobileShell.QuickSetting {
text: i18n("Do Not Disturb") text: i18n("Do Not Disturb")
icon: enabled ? "notifications-disabled" : "notifications" icon: enabled ? "notifications-disabled" : "notifications"
status: "" status: ""
enabled: MobileShell.TopPanelControls.notificationsWidget && MobileShell.TopPanelControls.notificationsWidget.doNotDisturbModeEnabled enabled: MobileShellState.TopPanelControls.notificationsWidget && MobileShellState.TopPanelControls.notificationsWidget.doNotDisturbModeEnabled
available: MobileShell.TopPanelControls.notificationsWidget available: MobileShellState.TopPanelControls.notificationsWidget
function toggle() { function toggle() {
if (MobileShell.TopPanelControls.notificationsWidget) { if (MobileShellState.TopPanelControls.notificationsWidget) {
MobileShell.TopPanelControls.notificationsWidget.toggleDoNotDisturbMode(); MobileShellState.TopPanelControls.notificationsWidget.toggleDoNotDisturbMode();
} }
} }
} }

View file

@ -5,6 +5,7 @@ import QtQuick 2.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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.pipewire.record 0.1 as PWRec
import org.kde.taskmanager 0.1 as TaskManager import org.kde.taskmanager 0.1 as TaskManager
import org.kde.plasma.quicksetting.record 1.0 import org.kde.plasma.quicksetting.record 1.0
@ -38,7 +39,7 @@ MobileShell.QuickSetting {
} }
enabled = !enabled enabled = !enabled
MobileShell.TopPanelControls.closeActionDrawer(); MobileShellState.Shell.closeActionDrawer();
} }
PWRec.PipeWireRecord { PWRec.PipeWireRecord {

View file

@ -4,6 +4,7 @@
import QtQuick 2.15 import QtQuick 2.15
import org.kde.plasma.private.mobileshell 1.0 as MobileShell 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 import org.kde.plasma.quicksetting.screenshot 1.0
MobileShell.QuickSetting { MobileShell.QuickSetting {
@ -16,11 +17,11 @@ MobileShell.QuickSetting {
function toggle() { function toggle() {
screenshotRequested = true; screenshotRequested = true;
MobileShell.TopPanelControls.closeActionDrawer(); MobileShellState.Shell.closeActionDrawer();
} }
Connections { Connections {
target: MobileShell.TopPanelControls target: MobileShellState.Shell
function onActionDrawerVisibleChanged(visible) { function onActionDrawerVisibleChanged(visible) {
if (!visible && screenshotRequested) { if (!visible && screenshotRequested) {
screenshotRequested = false; screenshotRequested = false;