From ac9634e9094f97325979ce07ece560ddbe941a9d Mon Sep 17 00:00:00 2001 From: Filippo Gentile Date: Fri, 23 Feb 2024 14:07:05 +0100 Subject: [PATCH] DesktopSwitchConfiguration: port to ILXQtTaskBarAbstractBackend TODO TODO: this will disable changing desktop names --- .../desktopswitchconfiguration.cpp | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugin-desktopswitch/desktopswitchconfiguration.cpp b/plugin-desktopswitch/desktopswitchconfiguration.cpp index 943dbdd6b..a6edb41a6 100644 --- a/plugin-desktopswitch/desktopswitchconfiguration.cpp +++ b/plugin-desktopswitch/desktopswitchconfiguration.cpp @@ -26,8 +26,9 @@ #include "desktopswitchconfiguration.h" #include "ui_desktopswitchconfiguration.h" -#include -#include + +#include "../panel/lxqtpanelapplication.h" +#include "../panel/backends/ilxqttaskbarabstractbackend.h" DesktopSwitchConfiguration::DesktopSwitchConfiguration(PluginSettings *settings, QWidget *parent) : LXQtPanelPluginConfigDialog(settings, parent), @@ -64,18 +65,25 @@ void DesktopSwitchConfiguration::loadSettings() void DesktopSwitchConfiguration::loadDesktopsNames() { - int n = KX11Extras::numberOfDesktops(); + LXQtPanelApplication *a = reinterpret_cast(qApp); + auto wmBackend = a->getWMBackend(); + + int n = wmBackend->getWorkspacesCount(); for (int i = 1; i <= n; i++) { - QLineEdit *edit = new QLineEdit(KX11Extras::desktopName(i), this); + QLineEdit *edit = new QLineEdit(wmBackend->getWorkspaceName(i), this); ((QFormLayout *) ui->namesGroupBox->layout())->addRow(tr("Desktop %1:").arg(i), edit); + //TODO: on Wayland we cannot set desktop names in a standart way + // On KWin we could use DBus org.kde.KWin as done by kcm_kwin_virtualdesktops + edit->setReadOnly(true); + // C++11 rocks! - QTimer *timer = new QTimer(this); - timer->setInterval(400); - timer->setSingleShot(true); - connect(timer, &QTimer::timeout, this, [=] { KX11Extras::setDesktopName(i, edit->text()); }); - connect(edit, &QLineEdit::textEdited, this, [=] { timer->start(); }); + //QTimer *timer = new QTimer(this); + //timer->setInterval(400); + //timer->setSingleShot(true); + //connect(timer, &QTimer::timeout, this, [=] { KX11Extras::setDesktopName(i, edit->text()); }); + //connect(edit, &QLineEdit::textEdited, this, [=] { timer->start(); }); } }