From 2d87bb3e651e6648db8a925185a7fc0b3a99c45a Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 24 Dec 2021 19:18:38 -0500 Subject: [PATCH] taskpanel: Extract navbar and task switcher to components/mobileshell --- components/mobileshell/CMakeLists.txt | 9 +- components/mobileshell/displaysmodel.cpp | 99 +++++++++++++++ components/mobileshell/displaysmodel.h | 44 +++++++ components/mobileshell/mobileshellplugin.cpp | 11 +- .../qml/navigationpanel}/NavigationPanel.qml | 3 - .../NavigationPanelAction.qml | 0 .../NavigationPanelButton.qml | 2 +- components/mobileshell/qml/qmldir | 7 ++ .../mobileshell/qml/taskswitcher}/Task.qml | 7 +- .../qml/taskswitcher}/TaskIcon.qml | 2 +- .../qml/taskswitcher}/TaskSwitcher.qml | 15 ++- .../qml/taskswitcher}/Thumbnail.qml | 1 + components/mobileshell/vkbdinterface.cpp | 12 ++ components/mobileshell/vkbdinterface.h | 23 ++++ .../package/contents/config/main.xml | 21 ---- .../taskpanel/package/contents/ui/main.qml | 22 ++-- containments/taskpanel/taskpanel.cpp | 114 ------------------ containments/taskpanel/taskpanel.h | 4 - 18 files changed, 228 insertions(+), 168 deletions(-) create mode 100644 components/mobileshell/displaysmodel.cpp create mode 100644 components/mobileshell/displaysmodel.h rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/navigationpanel}/NavigationPanel.qml (98%) rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/navigationpanel}/NavigationPanelAction.qml (100%) rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/navigationpanel}/NavigationPanelButton.qml (98%) rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/taskswitcher}/Task.qml (96%) rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/taskswitcher}/TaskIcon.qml (100%) rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/taskswitcher}/TaskSwitcher.qml (97%) rename {containments/taskpanel/package/contents/ui => components/mobileshell/qml/taskswitcher}/Thumbnail.qml (99%) create mode 100644 components/mobileshell/vkbdinterface.cpp create mode 100644 components/mobileshell/vkbdinterface.h delete mode 100644 containments/taskpanel/package/contents/config/main.xml diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index e6bb9bd0..c41aa147 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -2,14 +2,19 @@ # SPDX-License-Identifier: GPL-2.0-or-later qt_add_dbus_interfaces(DBUS_SRCS dbus/org.kde.KWin.ScreenShot2.xml - dbus/org.kde.KScreen.xml) - + dbus/org.kde.KScreen.xml + ${KWIN_VIRTUALKEYBOARD_INTERFACE}) + set(mobileshellplugin_SRCS mobileshellplugin.cpp shellutil.cpp quicksettingsmodel.cpp + vkbdinterface.cpp + displaysmodel.cpp + notifications/notificationthumbnailer.cpp notifications/notificationfilemenu.cpp + ${DBUS_SRCS} ) diff --git a/components/mobileshell/displaysmodel.cpp b/components/mobileshell/displaysmodel.cpp new file mode 100644 index 00000000..223f089a --- /dev/null +++ b/components/mobileshell/displaysmodel.cpp @@ -0,0 +1,99 @@ +/* + * SPDX-FileCopyrightText: 2021 Aleix Pol + * SPDX-FileCopyrightText: 2021 Devin Lin + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "displaysmodel.h" + +#include + +DisplaysModel::DisplaysModel(QObject *parent) + : QAbstractListModel(parent) +{ + if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + return; + } + + using namespace KWayland::Client; + ConnectionThread *connection = ConnectionThread::fromApplication(this); + + if (!connection) { + return; + } + + auto *registry = new Registry(this); + registry->create(connection); + + connect(registry, &Registry::outputAnnounced, this, [this, registry](quint32 name, quint32 version) { + createOutput(registry->bindOutput(name, version)); + }); + connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) { + m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); + }); + + registry->setup(); + connection->roundtrip(); +} + +QHash DisplaysModel::roleNames() const +{ + return { + {Model, "modelName"}, + {Geometry, "geometry"}, + {Position, "position"}, + {Output, "output"}, + }; +} + +void DisplaysModel::createOutput(wl_output *output) +{ + auto newOutput = new KWayland::Client::Output(this); + connect(newOutput, &KWayland::Client::Output::removed, this, [this, newOutput] { + auto i = m_outputs.indexOf(newOutput); + Q_ASSERT(i >= 0); + beginRemoveRows({}, i, i); + m_outputs.removeAt(i); + endRemoveRows(); + }); + newOutput->setup(output); + beginInsertRows({}, m_outputs.count(), m_outputs.count()); + m_outputs.append(newOutput); + endInsertRows(); +} + +void DisplaysModel::sendWindowToOutput(const QString &uuid, KWayland::Client::Output *output) +{ + const auto windows = m_windowManagement->windows(); + for (auto w : windows) { + if (w->uuid() == uuid) { + w->sendToOutput(output); + } + } +} + +int DisplaysModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : m_outputs.count(); +} + +QVariant DisplaysModel::data(const QModelIndex &index, int role) const +{ + if (index.row() >= m_outputs.count()) { + return {}; + } + + auto o = m_outputs[index.row()]; + switch (role) { + case Model: + return o->model(); + case Geometry: + return o->geometry(); + case Position: + return o->globalPosition(); + case Output: + return QVariant::fromValue(o); + } + return {}; +} diff --git a/components/mobileshell/displaysmodel.h b/components/mobileshell/displaysmodel.h new file mode 100644 index 00000000..ea8f1bad --- /dev/null +++ b/components/mobileshell/displaysmodel.h @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2021 Aleix Pol + * SPDX-FileCopyrightText: 2021 Devin Lin + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include +#include +#include + +class DisplaysModel : public QAbstractListModel +{ +public: + enum Roles { + Model = Qt::DisplayRole, + Geometry = Qt::UserRole, + Position, + Output, + }; + + DisplaysModel(QObject *parent = nullptr); + + void createOutput(wl_output *output); + + Q_INVOKABLE void sendWindowToOutput(const QString &uuid, KWayland::Client::Output *output); + + QHash roleNames() const override; + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +private: + KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr; + + QVector m_outputs; +}; diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index 4a1d3100..63627fe0 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -4,14 +4,18 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "mobileshellplugin.h" + #include #include -#include "mobileshellplugin.h" +#include "displaysmodel.h" #include "notifications/notificationfilemenu.h" #include "notifications/notificationthumbnailer.h" #include "quicksettingsmodel.h" #include "shellutil.h" +#include "virtualkeyboardinterface.h" +#include "vkbdinterface.h" void MobileShellPlugin::registerTypes(const char *uri) { @@ -24,6 +28,11 @@ void MobileShellPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "QuickSetting"); qmlRegisterType(uri, 1, 0, "QuickSettingsModel"); + qmlRegisterType(uri, 1, 0, "DisplaysModel"); + qmlRegisterSingletonType(uri, 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * { + return new KwinVirtualKeyboardInterface; + }); + // notifications qmlRegisterType(uri, 1, 0, "NotificationThumbnailer"); qmlRegisterType(uri, 1, 0, "NotificationFileMenu"); diff --git a/containments/taskpanel/package/contents/ui/NavigationPanel.qml b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml similarity index 98% rename from containments/taskpanel/package/contents/ui/NavigationPanel.qml rename to components/mobileshell/qml/navigationpanel/NavigationPanel.qml index 10dee9d8..7f9f9ed8 100644 --- a/containments/taskpanel/package/contents/ui/NavigationPanel.qml +++ b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml @@ -11,13 +11,11 @@ import QtQuick.Window 2.2 import QtGraphicalEffects 1.12 import org.kde.taskmanager 0.1 as TaskManager -import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore 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 Item { id: root @@ -112,7 +110,6 @@ Item { id: icons anchors.fill: parent - visible: plasmoid.configuration.PanelButtonsVisible property real buttonLength: 0 // background colour diff --git a/containments/taskpanel/package/contents/ui/NavigationPanelAction.qml b/components/mobileshell/qml/navigationpanel/NavigationPanelAction.qml similarity index 100% rename from containments/taskpanel/package/contents/ui/NavigationPanelAction.qml rename to components/mobileshell/qml/navigationpanel/NavigationPanelAction.qml diff --git a/containments/taskpanel/package/contents/ui/NavigationPanelButton.qml b/components/mobileshell/qml/navigationpanel/NavigationPanelButton.qml similarity index 98% rename from containments/taskpanel/package/contents/ui/NavigationPanelButton.qml rename to components/mobileshell/qml/navigationpanel/NavigationPanelButton.qml index 7de08bcb..5f122864 100644 --- a/containments/taskpanel/package/contents/ui/NavigationPanelButton.qml +++ b/components/mobileshell/qml/navigationpanel/NavigationPanelButton.qml @@ -8,7 +8,6 @@ import QtQuick 2.12 import QtQuick.Layouts 1.1 -import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kquickcontrolsaddons 2.0 @@ -22,6 +21,7 @@ Item { property double iconSizeFactor: 1 property alias iconSource: icon.source property alias colorGroup: icon.colorGroup + signal clicked() Rectangle { diff --git a/components/mobileshell/qml/qmldir b/components/mobileshell/qml/qmldir index c2279a19..e27c8ef7 100644 --- a/components/mobileshell/qml/qmldir +++ b/components/mobileshell/qml/qmldir @@ -21,9 +21,16 @@ singleton SignalStrengthProvider 1.0 dataproviders/SignalStrengthProvider.qml singleton VolumeProvider 1.0 dataproviders/VolumeProvider.qml singleton WifiProvider 1.0 dataproviders/WifiProvider.qml +# /navigationpanel +NavigationPanel 1.0 navigationpanel/NavigationPanel.qml +NavigationPanelAction 1.0 navigationpanel/NavigationPanelAction.qml + # /statusbar StatusBar 1.0 statusbar/StatusBar.qml +# /taskswitcher +TaskSwitcher 1.0 taskswitcher/TaskSwitcher.qml + # /widgets MediaControlsWidget 1.0 widgets/MediaControlsWidget.qml NotificationsWidget 1.0 widgets/NotificationsWidget.qml diff --git a/containments/taskpanel/package/contents/ui/Task.qml b/components/mobileshell/qml/taskswitcher/Task.qml similarity index 96% rename from containments/taskpanel/package/contents/ui/Task.qml rename to components/mobileshell/qml/taskswitcher/Task.qml index f51e12ad..e09b6b28 100644 --- a/containments/taskpanel/package/contents/ui/Task.qml +++ b/components/mobileshell/qml/taskswitcher/Task.qml @@ -9,7 +9,7 @@ import QtQuick 2.15 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 as QQC2 -import org.kde.plasma.phone.taskpanel 1.0 + import org.kde.taskmanager 0.1 as TaskManager import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents @@ -18,6 +18,7 @@ Item { id: delegate required property var model + required property var displaysModel readonly property point taskScreenPoint: Qt.point(model.ScreenGeometry.x, model.ScreenGeometry.y) readonly property real dragOffset: -control.y @@ -129,7 +130,7 @@ Item { Repeater { id: rep - model: plasmoid.nativeInterface.outputs + model: displaysModel delegate: PlasmaComponents.ToolButton { Layout.alignment: Qt.AlignVCenter text: model.modelName @@ -138,7 +139,7 @@ Item { icon.name: "tv" //TODO provide a more adequate icon onClicked: { - plasmoid.nativeInterface.sendWindowToOutput(delegate.model.WinIdList[0], model.output) + displaysModel.sendWindowToOutput(delegate.model.WinIdList[0], model.output) } } } diff --git a/containments/taskpanel/package/contents/ui/TaskIcon.qml b/components/mobileshell/qml/taskswitcher/TaskIcon.qml similarity index 100% rename from containments/taskpanel/package/contents/ui/TaskIcon.qml rename to components/mobileshell/qml/taskswitcher/TaskIcon.qml index f3bf2f75..592d48b2 100644 --- a/containments/taskpanel/package/contents/ui/TaskIcon.qml +++ b/components/mobileshell/qml/taskswitcher/TaskIcon.qml @@ -6,8 +6,8 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 -import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.core 2.0 as PlasmaCore PlasmaCore.IconItem { implicitWidth: PlasmaCore.Units.iconSizes.medium diff --git a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml similarity index 97% rename from containments/taskpanel/package/contents/ui/TaskSwitcher.qml rename to components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index 122a93c3..f8f23fc4 100644 --- a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -8,6 +8,7 @@ import QtQuick 2.12 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 + 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 @@ -43,8 +44,8 @@ NanoShell.FullScreenOverlay { property bool wasInActiveTask: false // whether we were in an app before opening the task switcher property bool currentlyDragging: false // whether we are in a swipe up gesture - Component.onCompleted: plasmoid.nativeInterface.panel = window; - + property var displaysModel: MobileShell.DisplaysModel {} + enum MovementDirection { None = 0, Left, @@ -231,6 +232,8 @@ NanoShell.FullScreenOverlay { width: tasksView.width height: tasksView.height + displaysModel: window.displaysModel + // account for header offset (center the preview) y: -tasksView.taskHeaderHeight / 2 @@ -273,7 +276,7 @@ NanoShell.FullScreenOverlay { } // task panel - NavigationPanel { + MobileShell.NavigationPanel { id: navPanel property bool isPortrait: Screen.width <= Screen.height @@ -292,7 +295,7 @@ NanoShell.FullScreenOverlay { Behavior on backgroundColor { ColorAnimation {} } - leftAction: NavigationPanelAction { + leftAction: MobileShell.NavigationPanelAction { enabled: true iconSource: "mobile-task-switcher" iconSizeFactor: 0.75 @@ -305,7 +308,7 @@ NanoShell.FullScreenOverlay { } } - middleAction: NavigationPanelAction { + middleAction: MobileShell.NavigationPanelAction { enabled: true iconSource: "start-here-kde" iconSizeFactor: 1 @@ -315,7 +318,7 @@ NanoShell.FullScreenOverlay { } } - rightAction: NavigationPanelAction { + rightAction: MobileShell.NavigationPanelAction { enabled: true iconSource: "mobile-close-app" iconSizeFactor: 0.75 diff --git a/containments/taskpanel/package/contents/ui/Thumbnail.qml b/components/mobileshell/qml/taskswitcher/Thumbnail.qml similarity index 99% rename from containments/taskpanel/package/contents/ui/Thumbnail.qml rename to components/mobileshell/qml/taskswitcher/Thumbnail.qml index b2c0d958..2cbc1289 100644 --- a/containments/taskpanel/package/contents/ui/Thumbnail.qml +++ b/components/mobileshell/qml/taskswitcher/Thumbnail.qml @@ -7,6 +7,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 + import org.kde.taskmanager 0.1 as TaskManager TaskManager.PipeWireSourceItem { diff --git a/components/mobileshell/vkbdinterface.cpp b/components/mobileshell/vkbdinterface.cpp new file mode 100644 index 00000000..85d5d54d --- /dev/null +++ b/components/mobileshell/vkbdinterface.cpp @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2021 Aleix Pol + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "vkbdinterface.h" + +KwinVirtualKeyboardInterface::KwinVirtualKeyboardInterface() + : OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()) +{ +} diff --git a/components/mobileshell/vkbdinterface.h b/components/mobileshell/vkbdinterface.h new file mode 100644 index 00000000..dbb22b9d --- /dev/null +++ b/components/mobileshell/vkbdinterface.h @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2021 Aleix Pol + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#pragma once + +#include +#include +#include + +#include + +class 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(); +}; diff --git a/containments/taskpanel/package/contents/config/main.xml b/containments/taskpanel/package/contents/config/main.xml deleted file mode 100644 index b8219f6f..00000000 --- a/containments/taskpanel/package/contents/config/main.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - true - - - - - diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 0b7fd605..b2bb5068 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -21,8 +21,6 @@ import org.kde.plasma.phone.taskpanel 1.0 as TaskPanel PlasmaCore.ColorScope { id: root - width: 600 - height: 480 colorGroup: showingApp ? PlasmaCore.Theme.HeaderColorGroup : PlasmaCore.Theme.ComplementaryColorGroup Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground @@ -99,14 +97,14 @@ PlasmaCore.ColorScope { // task switcher Loader { id: taskSwitcherLoader - sourceComponent: TaskSwitcher { + sourceComponent: MobileShell.TaskSwitcher { model: tasksModel taskPanelHeight: root.state === "portrait" ? root.height : root.width } } // bottom navigation panel - NavigationPanel { + MobileShell.NavigationPanel { id: panel anchors.fill: parent opacity: (root.taskSwitcher && root.taskSwitcher.visible) ? 0 : 1 // hide bar when task switcher is open @@ -117,7 +115,7 @@ PlasmaCore.ColorScope { dragGestureEnabled: true taskSwitcher: root.taskSwitcher - leftAction: NavigationPanelAction { + leftAction: MobileShell.NavigationPanelAction { enabled: hasTasks iconSource: "mobile-task-switcher" iconSizeFactor: 0.75 @@ -128,22 +126,22 @@ PlasmaCore.ColorScope { } } - middleAction: NavigationPanelAction { + middleAction: MobileShell.NavigationPanelAction { enabled: true iconSource: "start-here-kde" iconSizeFactor: 1 onTriggered: root.triggerHomescreen() } - rightAction: NavigationPanelAction { - enabled: TaskPanel.KWinVirtualKeyboard.visible || (plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible) + rightAction: MobileShell.NavigationPanelAction { + enabled: MobileShell.KWinVirtualKeyboard.visible || (plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible) // mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons - iconSizeFactor: TaskPanel.KWinVirtualKeyboard.visible ? 1 : 0.75 - iconSource: TaskPanel.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app" + iconSizeFactor: MobileShell.KWinVirtualKeyboard.visible ? 1 : 0.75 + iconSource: MobileShell.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app" onTriggered: { - if (TaskPanel.KWinVirtualKeyboard.active) { - TaskPanel.KWinVirtualKeyboard.active = false; + if (MobileShell.KWinVirtualKeyboard.active) { + MobileShell.KWinVirtualKeyboard.active = false; } else if (plasmoid.nativeInterface.hasCloseableActiveWindow) { var index = taskSwitcher.model.activeTask; if (index) { diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp index fe09ae73..31a8f895 100644 --- a/containments/taskpanel/taskpanel.cpp +++ b/containments/taskpanel/taskpanel.cpp @@ -24,95 +24,10 @@ static const QString s_kwinService = QStringLiteral("org.kde.KWin"); constexpr int ACTIVE_WINDOW_UPDATE_INVERVAL = 250; -class OutputsModel : public QAbstractListModel -{ -public: - enum Roles { - Model = Qt::DisplayRole, - Geometry = Qt::UserRole, - Position, - Output, - }; - - OutputsModel(QObject *parent) - : QAbstractListModel(parent) - { - } - - QHash roleNames() const override - { - return { - {Model, "modelName"}, - {Geometry, "geometry"}, - {Position, "position"}, - {Output, "output"}, - }; - } - - void createOutput(wl_output *output) - { - auto newOutput = new KWayland::Client::Output(this); - connect(newOutput, &KWayland::Client::Output::removed, this, [this, newOutput] { - auto i = m_outputs.indexOf(newOutput); - Q_ASSERT(i >= 0); - beginRemoveRows({}, i, i); - m_outputs.removeAt(i); - endRemoveRows(); - }); - newOutput->setup(output); - beginInsertRows({}, m_outputs.count(), m_outputs.count()); - m_outputs.append(newOutput); - endInsertRows(); - } - - int rowCount(const QModelIndex &parent) const override - { - return parent.isValid() ? 0 : m_outputs.count(); - } - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override - { - if (index.row() >= m_outputs.count()) { - return {}; - } - - auto o = m_outputs[index.row()]; - switch (role) { - case Model: - return o->model(); - case Geometry: - return o->geometry(); - case Position: - return o->globalPosition(); - case Output: - return QVariant::fromValue(o); - } - return {}; - } - -private: - QVector m_outputs; -}; - -// helper class to expose the NOTIFY in the properties -class 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() - : OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()) - { - } -}; - TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) , m_showingDesktop(false) , m_windowManagement(nullptr) - , m_outputsModel(new OutputsModel(this)) { setHasConfigurationInterface(true); m_activeTimer = new QTimer(this); @@ -122,14 +37,6 @@ TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) initWayland(); qmlRegisterUncreatableType("org.kde.plasma.phone.taskpanel", 1, 0, "Output", "nope"); - qmlRegisterUncreatableType("org.kde.plasma.phone.taskpanel", 1, 0, "OutputsModel", "nope"); - qmlRegisterSingletonType("org.kde.plasma.phone.taskpanel", - 1, - 0, - "KWinVirtualKeyboard", - [](QQmlEngine *, QJSEngine *) -> QObject * { - return new KwinVirtualKeyboardInterface; - }); connect(this, &Plasma::Containment::locationChanged, this, &TaskPanel::locationChanged); connect(this, &Plasma::Containment::locationChanged, this, [this] { @@ -161,9 +68,6 @@ void TaskPanel::initWayland() } auto *registry = new Registry(this); registry->create(connection); - connect(registry, &Registry::outputAnnounced, m_outputsModel, [this, registry](quint32 name, quint32 version) { - m_outputsModel->createOutput(registry->bindOutput(name, version)); - }); connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) { m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); qRegisterMetaType>("QVector"); @@ -174,9 +78,6 @@ void TaskPanel::initWayland() m_showingDesktop = showing; emit showingDesktopChanged(m_showingDesktop); }); - // FIXME - // connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, &TaskPanel::updateActiveWindow, Qt::QueuedConnection); - connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged, m_activeTimer, qOverload<>(&QTimer::start)); m_activeTimer->start(); @@ -290,21 +191,6 @@ void TaskPanel::closeActiveWindow() } } -void TaskPanel::sendWindowToOutput(const QString &uuid, KWayland::Client::Output *output) -{ - const auto windows = m_windowManagement->windows(); - for (auto w : windows) { - if (w->uuid() == uuid) { - w->sendToOutput(output); - } - } -} - -QAbstractItemModel *TaskPanel::outputs() const -{ - return m_outputsModel; -} - K_PLUGIN_CLASS_WITH_JSON(TaskPanel, "metadata.json") #include "taskpanel.moc" diff --git a/containments/taskpanel/taskpanel.h b/containments/taskpanel/taskpanel.h index 2657f0df..e94c9151 100644 --- a/containments/taskpanel/taskpanel.h +++ b/containments/taskpanel/taskpanel.h @@ -33,7 +33,6 @@ class TaskPanel : public Plasma::Containment Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged) Q_PROPERTY(QWindow *panel READ panel WRITE setPanel NOTIFY panelChanged) Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) - Q_PROPERTY(QAbstractItemModel *outputs READ outputs CONSTANT) public: TaskPanel(QObject *parent, const QVariantList &args); @@ -58,8 +57,6 @@ public: QAbstractItemModel *outputs() const; - Q_INVOKABLE void sendWindowToOutput(const QString &uuid, KWayland::Client::Output *output); - public Q_SLOTS: void forgetActiveWindow(); @@ -83,7 +80,6 @@ private: KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr; QPointer m_activeWindow; QTimer *m_activeTimer; - OutputsModel *m_outputsModel; }; #endif