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
Qml
Quick
Feedback
)
if (QT_MAJOR_VERSION STREQUAL "5")
if (QUICK_COMPILER)

View file

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

View file

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

View file

@ -38,6 +38,7 @@ target_link_libraries(mobileshellplugin
Qt::Qml
Qt::Gui
Qt::Quick
Qt::Feedback
KF5::ConfigWidgets # for KStandardAction
KF5::KIOGui
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/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");
}

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.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 {

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.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,

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.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"

View file

@ -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();
}

View file

@ -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();
}

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.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();
}
}
}

View file

@ -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;

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.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"]
}
}

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 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
}

View file

@ -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;
}
}

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.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;

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.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");
}
}

View file

@ -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

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
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 {

View file

@ -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

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
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-')

View file

@ -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

View file

@ -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 {

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.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

View file

@ -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

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.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

View file

@ -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 {

View file

@ -24,18 +24,16 @@
<file>qml/components/ExtendedAbstractButton.qml</file>
<file>qml/components/Flickable.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/MarqueeLabel.qml</file>
<file>qml/components/StartupFeedback.qml</file>
<file>qml/components/util.js</file>
<file>qml/components/VelocityCalculator.qml</file>
<file>qml/dataproviders/BatteryProvider.qml</file>
<file>qml/dataproviders/BluetoothProvider.qml</file>
<file>qml/dataproviders/SignalStrengthProvider.qml</file>
<file>qml/dataproviders/VolumeProvider.qml</file>
<file>qml/dataproviders/BatteryInfo.qml</file>
<file>qml/dataproviders/BluetoothInfo.qml</file>
<file>qml/dataproviders/SignalStrengthInfo.qml</file>
<file>qml/dataproviders/AudioProvider.qml</file>
<file>qml/homescreen/HomeScreen.qml</file>
@ -89,10 +87,5 @@
<file>qml/widgets/notifications/ThumbnailStrip.qml</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>
</RCC>

View file

@ -7,6 +7,7 @@
*/
#include "shellutil.h"
#include "mobileshellsettings.h"
#include "windowutil.h"
#include <KConfigGroup>
@ -18,6 +19,7 @@
#include <QDBusPendingReply>
#include <QDateTime>
#include <QDebug>
#include <QFeedbackHapticsEffect>
#include <QFile>
#include <QProcess>
@ -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();
}
}

View file

@ -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();

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: 2021 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
// SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
// SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.12
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 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
}

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.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();
}

View file

@ -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
}
}
}

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.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,

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.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,

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.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()
}
}
}

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.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,

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.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,

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.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

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.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();
}

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.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 {

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.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();
}
}

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.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
}
}

View file

@ -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();
}
}

View file

@ -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()
}
}

View file

@ -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"
}

View file

@ -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();
}
}
}

View file

@ -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 {

View file

@ -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;