From a9e5a2f1e46dbd14683154242ab22eab883dd275 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sat, 9 May 2026 10:48:52 +0200 Subject: [PATCH] Add virtual desktop actions to the dock pager Open desktop management from the convergence pager and let the pager add or remove the last virtual desktop without leaving the dock. --- containments/homescreens/folio/homescreen.cpp | 16 +++++ containments/homescreens/folio/homescreen.h | 2 + .../homescreens/folio/qml/FavouritesBar.qml | 70 +++++++++++++++++-- 3 files changed, 84 insertions(+), 4 deletions(-) diff --git a/containments/homescreens/folio/homescreen.cpp b/containments/homescreens/folio/homescreen.cpp index ca81b8e7..3c6dafbb 100644 --- a/containments/homescreens/folio/homescreen.cpp +++ b/containments/homescreens/folio/homescreen.cpp @@ -115,6 +115,22 @@ void HomeScreen::activateVirtualDesktop(const QVariant &desktop) const virtualDesktopInfo.requestActivate(desktop); } +void HomeScreen::createVirtualDesktop() const +{ + TaskManager::VirtualDesktopInfo virtualDesktopInfo; + virtualDesktopInfo.requestCreateDesktop(virtualDesktopInfo.numberOfDesktops()); +} + +void HomeScreen::removeLastVirtualDesktop() const +{ + TaskManager::VirtualDesktopInfo virtualDesktopInfo; + if (virtualDesktopInfo.numberOfDesktops() <= 1) { + return; + } + + virtualDesktopInfo.requestRemoveDesktop(virtualDesktopInfo.numberOfDesktops() - 1); +} + void HomeScreen::emptyTrash() const { QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kio.trash"), diff --git a/containments/homescreens/folio/homescreen.h b/containments/homescreens/folio/homescreen.h index b0ae853a..0161b62e 100644 --- a/containments/homescreens/folio/homescreen.h +++ b/containments/homescreens/folio/homescreen.h @@ -53,6 +53,8 @@ public: Q_INVOKABLE void triggerOverview() const; Q_INVOKABLE void triggerMinimizeAll() const; Q_INVOKABLE void activateVirtualDesktop(const QVariant &desktop) const; + Q_INVOKABLE void createVirtualDesktop() const; + Q_INVOKABLE void removeLastVirtualDesktop() const; Q_INVOKABLE void emptyTrash() const; FolioSettings *folioSettings(); diff --git a/containments/homescreens/folio/qml/FavouritesBar.qml b/containments/homescreens/folio/qml/FavouritesBar.qml index 3329a1a7..be33359c 100644 --- a/containments/homescreens/folio/qml/FavouritesBar.qml +++ b/containments/homescreens/folio/qml/FavouritesBar.qml @@ -562,10 +562,41 @@ MouseArea { id: leftPagerHover anchors.fill: parent hoverEnabled: true + acceptedButtons: Qt.LeftButton | Qt.RightButton cursorShape: Qt.PointingHandCursor - onClicked: { - if (leftDesktopBtn.desktopId) + onClicked: (mouse) => { + if (mouse.button === Qt.RightButton) { + leftPagerContextMenu.open() + } else if (leftDesktopBtn.desktopId) { root.folio.activateVirtualDesktop(leftDesktopBtn.desktopId) + } + } + onPressAndHold: { + leftPagerContextMenu.open() + haptics.buttonVibrate() + } + } + + PC3.Menu { + id: leftPagerContextMenu + popupType: T.Popup.Window + + PC3.MenuItem { + icon.name: "list-add" + text: i18n("Add Virtual Desktop") + onTriggered: root.folio.createVirtualDesktop() + } + PC3.MenuItem { + icon.name: "list-remove" + text: i18n("Remove Virtual Desktop") + enabled: virtualDesktopInfo.numberOfDesktops > 1 + onTriggered: root.folio.removeLastVirtualDesktop() + } + Controls.MenuSeparator {} + PC3.MenuItem { + icon.name: "preferences-desktop-virtual" + text: i18n("Configure Virtual Desktops…") + onTriggered: MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_kwin_virtualdesktops") } } } @@ -625,10 +656,41 @@ MouseArea { id: rightPagerHover anchors.fill: parent hoverEnabled: true + acceptedButtons: Qt.LeftButton | Qt.RightButton cursorShape: Qt.PointingHandCursor - onClicked: { - if (rightDesktopBtn.desktopId) + onClicked: (mouse) => { + if (mouse.button === Qt.RightButton) { + rightPagerContextMenu.open() + } else if (rightDesktopBtn.desktopId) { root.folio.activateVirtualDesktop(rightDesktopBtn.desktopId) + } + } + onPressAndHold: { + rightPagerContextMenu.open() + haptics.buttonVibrate() + } + } + + PC3.Menu { + id: rightPagerContextMenu + popupType: T.Popup.Window + + PC3.MenuItem { + icon.name: "list-add" + text: i18n("Add Virtual Desktop") + onTriggered: root.folio.createVirtualDesktop() + } + PC3.MenuItem { + icon.name: "list-remove" + text: i18n("Remove Virtual Desktop") + enabled: virtualDesktopInfo.numberOfDesktops > 1 + onTriggered: root.folio.removeLastVirtualDesktop() + } + Controls.MenuSeparator {} + PC3.MenuItem { + icon.name: "preferences-desktop-virtual" + text: i18n("Configure Virtual Desktops…") + onTriggered: MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_kwin_virtualdesktops") } } }