Skip to content
This repository has been archived by the owner on Dec 17, 2017. It is now read-only.

Commit

Permalink
The DesktopSwitch plugin was ported
Browse files Browse the repository at this point in the history
  • Loading branch information
SokoloffA committed Feb 8, 2013
1 parent 37617fe commit 5bbf8e0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion razorqt-panel/CMakeLists.txt
Expand Up @@ -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)
Expand Down
22 changes: 10 additions & 12 deletions razorqt-panel/plugin-desktopswitch/desktopswitch.cpp
Expand Up @@ -34,26 +34,24 @@
#include <razorqt/xfitman.h>
#include <razorqxt/qxtglobalshortcut.h>

#include <QHBoxLayout>
#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();
}

Expand All @@ -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);
}

Expand Down
24 changes: 18 additions & 6 deletions razorqt-panel/plugin-desktopswitch/desktopswitch.h
Expand Up @@ -29,7 +29,8 @@
#ifndef DESKTOPSWITCH_H
#define DESKTOPSWITCH_H

#include "../panel/razorpanelplugin.h"
#include "../panel/irazorpanelplugin.h"
#include <QFrame>

class QSignalMapper;
class QButtonGroup;
Expand All @@ -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();
Expand All @@ -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

0 comments on commit 5bbf8e0

Please sign in to comment.