From 5bbf8e08179a5bc304ed68e2fc37bc5059c8e647 Mon Sep 17 00:00:00 2001 From: Alexander Sokolov Date: Fri, 8 Feb 2013 20:52:56 +0400 Subject: [PATCH] The DesktopSwitch plugin was ported --- razorqt-panel/CMakeLists.txt | 2 +- .../plugin-desktopswitch/desktopswitch.cpp | 22 ++++++++--------- .../plugin-desktopswitch/desktopswitch.h | 24 ++++++++++++++----- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/razorqt-panel/CMakeLists.txt b/razorqt-panel/CMakeLists.txt index 8743dd23..9f432c1f 100644 --- a/razorqt-panel/CMakeLists.txt +++ b/razorqt-panel/CMakeLists.txt @@ -20,7 +20,7 @@ endmacro() # cmake -DCLOCK_PLUGIN=No .. # Disable clock plugin setByDefault(CLOCK_PLUGIN Yes) -setByDefault(DESKTOPSWITCH_PLUGIN No) +setByDefault(DESKTOPSWITCH_PLUGIN Yes) setByDefault(QUICKLAUNCH_PLUGIN No) setByDefault(TRAY_PLUGIN Yes) setByDefault(MAINMENU_PLUGIN Yes) diff --git a/razorqt-panel/plugin-desktopswitch/desktopswitch.cpp b/razorqt-panel/plugin-desktopswitch/desktopswitch.cpp index 655db049..16d995d0 100644 --- a/razorqt-panel/plugin-desktopswitch/desktopswitch.cpp +++ b/razorqt-panel/plugin-desktopswitch/desktopswitch.cpp @@ -34,26 +34,24 @@ #include #include +#include #include "desktopswitch.h" #include "desktopswitchbutton.h" -EXPORT_RAZOR_PANEL_PLUGIN_CPP(DesktopSwitch) +Q_EXPORT_PLUGIN2(DesktopSwitch, DesktopSwitchPluginLibrary) -DesktopSwitch::DesktopSwitch(const RazorPanelPluginStartInfo* startInfo, QWidget* parent) - : RazorPanelPlugin(startInfo, parent), - m_pSignalMapper(new QSignalMapper(this)), - m_desktopCount(1) +DesktopSwitch::DesktopSwitch(const IRazorPanelPluginStartupInfo &startupInfo) : + QObject(), + IRazorPanelPlugin(startupInfo), + m_pSignalMapper(new QSignalMapper(this)), + m_desktopCount(1) { - setObjectName("DesktopSwitch"); - connect(panel(), SIGNAL(panelRealigned()), this, SLOT(realign())); - m_buttons = new QButtonGroup(this); - connect ( m_pSignalMapper, SIGNAL(mapped(int)), this, SLOT(setDesktop(int))); - layout()->setAlignment(Qt::AlignCenter); + mWidget.setLayout(new QHBoxLayout(&mWidget)); setup(); } @@ -80,10 +78,10 @@ void DesktopSwitch::setup() sequence = QKeySequence(Qt::CTRL + firstKey++); } - DesktopSwitchButton * m = new DesktopSwitchButton(this, i, sequence, xfitMan().getDesktopName(i, tr("Desktop %1").arg(i+1))); + DesktopSwitchButton * m = new DesktopSwitchButton(&mWidget, i, sequence, xfitMan().getDesktopName(i, tr("Desktop %1").arg(i+1))); m_pSignalMapper->setMapping(m, i); connect(m, SIGNAL(activated()), m_pSignalMapper, SLOT(map())) ; - addWidget(m); + mWidget.layout()->addWidget(m); m_buttons->addButton(m, i); } diff --git a/razorqt-panel/plugin-desktopswitch/desktopswitch.h b/razorqt-panel/plugin-desktopswitch/desktopswitch.h index 01d76692..58434fa3 100644 --- a/razorqt-panel/plugin-desktopswitch/desktopswitch.h +++ b/razorqt-panel/plugin-desktopswitch/desktopswitch.h @@ -29,7 +29,8 @@ #ifndef DESKTOPSWITCH_H #define DESKTOPSWITCH_H -#include "../panel/razorpanelplugin.h" +#include "../panel/irazorpanelplugin.h" +#include class QSignalMapper; class QButtonGroup; @@ -38,20 +39,25 @@ class QButtonGroup; /** * @brief Desktop switcher. A very simple one... */ -class DesktopSwitch : public RazorPanelPlugin +class DesktopSwitch : public QObject, public IRazorPanelPlugin { Q_OBJECT public: - DesktopSwitch(const RazorPanelPluginStartInfo* startInfo, QWidget* parent = 0); + DesktopSwitch(const IRazorPanelPluginStartupInfo &startupInfo); ~DesktopSwitch(); + QString themeId() const { return "DesktopSwitch"; } + QWidget *widget() { return &mWidget; } + bool isSeparate() const { return true; } virtual void x11EventFilter(XEvent* event); - + void realign(); + private: QButtonGroup * m_buttons; QSignalMapper* m_pSignalMapper; int m_desktopCount; QStringList m_desktopNames; + QFrame mWidget; void wheelEvent(QWheelEvent* e); void setup(); @@ -60,10 +66,16 @@ private slots: void setDesktop(int desktop); protected slots: - virtual void realign(); + }; -EXPORT_RAZOR_PANEL_PLUGIN_H +class DesktopSwitchPluginLibrary: public QObject, public IRazorPanelPluginLibrary +{ + Q_OBJECT + Q_INTERFACES(IRazorPanelPluginLibrary) +public: + IRazorPanelPlugin *instance(const IRazorPanelPluginStartupInfo &startupInfo) { return new DesktopSwitch(startupInfo);} +}; #endif