From 72f36f1bf6708bdc29d2e9cf1b457496592cf3ea Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 18 Mar 2022 22:58:19 -0400 Subject: [PATCH] libmobileshell: Move non-API components to declarative and use PW API for keyboard t --- .../contents/ui/NavigationPanelComponent.qml | 13 ++++---- libmobileshell/CMakeLists.txt | 10 ------- libmobileshell/declarative/CMakeLists.txt | 2 ++ .../declarative/mobileshellplugin.cpp | 6 +--- .../{ => declarative}/shellutil.cpp | 0 libmobileshell/{ => declarative}/shellutil.h | 0 .../taskswitcher}/displaysmodel.cpp | 0 .../taskswitcher}/displaysmodel.h | 0 .../kwinvirtualkeyboardinterface.cpp | 14 --------- libmobileshell/kwinvirtualkeyboardinterface.h | 30 ------------------- libmobileshell/savedquicksettings.h | 7 ++++- libmobileshell/savedquicksettingsmodel.h | 12 +++++--- 12 files changed, 24 insertions(+), 70 deletions(-) rename libmobileshell/{ => declarative}/shellutil.cpp (100%) rename libmobileshell/{ => declarative}/shellutil.h (100%) rename libmobileshell/{ => declarative/taskswitcher}/displaysmodel.cpp (100%) rename libmobileshell/{ => declarative/taskswitcher}/displaysmodel.h (100%) delete mode 100644 libmobileshell/kwinvirtualkeyboardinterface.cpp delete mode 100644 libmobileshell/kwinvirtualkeyboardinterface.h diff --git a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml index 1db7be73..e7df3714 100644 --- a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml +++ b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml @@ -10,6 +10,7 @@ import QtQuick.Window 2.15 import org.kde.plasma.plasmoid 2.0 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 @@ -25,7 +26,7 @@ MobileShell.NavigationPanel { if (root.taskSwitcher.visible) { return Qt.rgba(0, 0, 0, 0.1); } else { - return (MobileShell.KWinVirtualKeyboard.visible || appIsShown) ? PlasmaCore.ColorScope.backgroundColor : "transparent"; + return (Keyboards.KWinVirtualKeyboard.visible || appIsShown) ? PlasmaCore.ColorScope.backgroundColor : "transparent"; } } foregroundColorGroup: (!root.taskSwitcher.visible && appIsShown) ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup @@ -81,15 +82,15 @@ MobileShell.NavigationPanel { rightAction: MobileShell.NavigationPanelAction { id: closeAppAction - enabled: MobileShell.KWinVirtualKeyboard.visible || root.taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow - iconSource: MobileShell.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app" + enabled: Keyboards.KWinVirtualKeyboard.visible || root.taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow + iconSource: Keyboards.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app" // mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons - iconSizeFactor: MobileShell.KWinVirtualKeyboard.visible ? 1 : 0.75 + iconSizeFactor: Keyboards.KWinVirtualKeyboard.visible ? 1 : 0.75 onTriggered: { - if (MobileShell.KWinVirtualKeyboard.active) { + if (Keyboards.KWinVirtualKeyboard.active) { // close keyboard if it is open - MobileShell.KWinVirtualKeyboard.active = false; + Keyboards.KWinVirtualKeyboard.active = false; } else if (taskSwitcher.visible) { // if task switcher is open, close the current window shown let indexToClose = root.taskSwitcher.tasksModel.index(root.taskSwitcher.currentTaskIndex, 0); diff --git a/libmobileshell/CMakeLists.txt b/libmobileshell/CMakeLists.txt index ea6f8272..81b7c97d 100644 --- a/libmobileshell/CMakeLists.txt +++ b/libmobileshell/CMakeLists.txt @@ -7,20 +7,13 @@ if (BUILD_TESTING) add_subdirectory(autotests) endif() -qt_add_dbus_interfaces(DBUS_SRCS ${KWIN_VIRTUALKEYBOARD_INTERFACE}) - set(mobileshell_LIB_SRCS - displaysmodel.cpp mobileshellsettings.cpp - shellutil.cpp - kwinvirtualkeyboardinterface.cpp quicksetting.cpp quicksettingsmodel.cpp savedquicksettingsmodel.cpp savedquicksettings.cpp - - ${DBUS_SRCS} ) add_library(mobileshell ${mobileshell_LIB_SRCS}) @@ -57,10 +50,7 @@ set_target_properties(mobileshell PROPERTIES install(TARGETS mobileshell EXPORT mobileshellLibraryTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES - displaysmodel.h - kwinvirtualkeyboardinterface.h mobileshellsettings.h - shellutil.h quicksetting.h quicksettingsmodel.h diff --git a/libmobileshell/declarative/CMakeLists.txt b/libmobileshell/declarative/CMakeLists.txt index a690c4b3..376c255f 100644 --- a/libmobileshell/declarative/CMakeLists.txt +++ b/libmobileshell/declarative/CMakeLists.txt @@ -6,8 +6,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) set(mobileshellplugin_SRCS mobileshellplugin.cpp + shellutil.cpp notifications/notificationthumbnailer.cpp notifications/notificationfilemenu.cpp + taskswitcher/displaysmodel.cpp ) if(QUICK_COMPILER) diff --git a/libmobileshell/declarative/mobileshellplugin.cpp b/libmobileshell/declarative/mobileshellplugin.cpp index d5bbed09..58ee69ea 100644 --- a/libmobileshell/declarative/mobileshellplugin.cpp +++ b/libmobileshell/declarative/mobileshellplugin.cpp @@ -12,12 +12,11 @@ #include "notifications/notificationfilemenu.h" #include "notifications/notificationthumbnailer.h" -#include "displaysmodel.h" -#include "kwinvirtualkeyboardinterface.h" #include "mobileshellsettings.h" #include "quicksetting.h" #include "quicksettingsmodel.h" #include "shellutil.h" +#include "taskswitcher/displaysmodel.h" using namespace MobileShell; @@ -44,9 +43,6 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "SavedQuickSettingsModel"); qmlRegisterType(uri, 1, 0, "DisplaysModel"); - qmlRegisterSingletonType(uri, 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * { - return new KwinVirtualKeyboardInterface; - }); // notifications qmlRegisterType(uri, 1, 0, "NotificationThumbnailer"); diff --git a/libmobileshell/shellutil.cpp b/libmobileshell/declarative/shellutil.cpp similarity index 100% rename from libmobileshell/shellutil.cpp rename to libmobileshell/declarative/shellutil.cpp diff --git a/libmobileshell/shellutil.h b/libmobileshell/declarative/shellutil.h similarity index 100% rename from libmobileshell/shellutil.h rename to libmobileshell/declarative/shellutil.h diff --git a/libmobileshell/displaysmodel.cpp b/libmobileshell/declarative/taskswitcher/displaysmodel.cpp similarity index 100% rename from libmobileshell/displaysmodel.cpp rename to libmobileshell/declarative/taskswitcher/displaysmodel.cpp diff --git a/libmobileshell/displaysmodel.h b/libmobileshell/declarative/taskswitcher/displaysmodel.h similarity index 100% rename from libmobileshell/displaysmodel.h rename to libmobileshell/declarative/taskswitcher/displaysmodel.h diff --git a/libmobileshell/kwinvirtualkeyboardinterface.cpp b/libmobileshell/kwinvirtualkeyboardinterface.cpp deleted file mode 100644 index 0ca18b5b..00000000 --- a/libmobileshell/kwinvirtualkeyboardinterface.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Aleix Pol - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "kwinvirtualkeyboardinterface.h" - -using namespace MobileShell; - -KwinVirtualKeyboardInterface::KwinVirtualKeyboardInterface() - : OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()) -{ -} diff --git a/libmobileshell/kwinvirtualkeyboardinterface.h b/libmobileshell/kwinvirtualkeyboardinterface.h deleted file mode 100644 index f79d00e3..00000000 --- a/libmobileshell/kwinvirtualkeyboardinterface.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Aleix Pol - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#pragma once - -#include -#include -#include - -#include - -#include "mobileshell_export.h" - -namespace MobileShell -{ - -class MOBILESHELL_EXPORT KwinVirtualKeyboardInterface : public OrgKdeKwinVirtualKeyboardInterface -{ - Q_OBJECT - Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) -public: - KwinVirtualKeyboardInterface(); -}; - -} // namespace MobileShell diff --git a/libmobileshell/savedquicksettings.h b/libmobileshell/savedquicksettings.h index 3a2a1c86..80afc1e9 100644 --- a/libmobileshell/savedquicksettings.h +++ b/libmobileshell/savedquicksettings.h @@ -19,7 +19,12 @@ namespace MobileShell { - +/** + * @short A model that reads quick settings configurations + * from the config and presents models to display them. + * + * @author Devin Lin + **/ class MOBILESHELL_EXPORT SavedQuickSettings : public QObject { Q_OBJECT diff --git a/libmobileshell/savedquicksettingsmodel.h b/libmobileshell/savedquicksettingsmodel.h index e0110adc..f8a433ec 100644 --- a/libmobileshell/savedquicksettingsmodel.h +++ b/libmobileshell/savedquicksettingsmodel.h @@ -16,7 +16,11 @@ namespace MobileShell { - +/** + * @short A list model for serving quick settings metadata. + * + * @author Devin Lin + **/ class MOBILESHELL_EXPORT SavedQuickSettingsModel : public QAbstractListModel { Q_OBJECT @@ -25,9 +29,9 @@ public: SavedQuickSettingsModel(QObject *parent = nullptr); enum { - NameRole, - IdRole, - IconRole, + NameRole, /**< The name of the quick setting. */ + IdRole, /**< The plugin id of the quick setting package. */ + IconRole, /**< The icon of the quick setting. */ }; QVariant data(const QModelIndex &index, int role) const override;