Skip to content

Commit

Permalink
DesktopSwitchConfiguration: port to ILXQtTaskBarAbstractBackend TODO
Browse files Browse the repository at this point in the history
TODO: this will disable changing desktop names
  • Loading branch information
gfgit committed Mar 26, 2024
1 parent 0ec3d51 commit 0afcc3f
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions plugin-desktopswitch/desktopswitchconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

#include "desktopswitchconfiguration.h"
#include "ui_desktopswitchconfiguration.h"
#include <KX11Extras>
#include <QTimer>

#include "../panel/lxqtpanelapplication.h"
#include "../panel/backends/ilxqttaskbarabstractbackend.h"

DesktopSwitchConfiguration::DesktopSwitchConfiguration(PluginSettings *settings, QWidget *parent) :
LXQtPanelPluginConfigDialog(settings, parent),
Expand Down Expand Up @@ -64,18 +65,25 @@ void DesktopSwitchConfiguration::loadSettings()

void DesktopSwitchConfiguration::loadDesktopsNames()
{
int n = KX11Extras::numberOfDesktops();
LXQtPanelApplication *a = reinterpret_cast<LXQtPanelApplication*>(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(); });
}
}

Expand Down

0 comments on commit 0afcc3f

Please sign in to comment.