[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/containmentactions/switchdesktop
From: Chani Armitage <chanika () gmail ! com>
Date: 2009-08-28 22:23:16
Message-ID: 1251498196.066655.28125.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1016792 by chani:
contextualActions for switchdesktop
M +25 -6 desktop.cpp
M +2 -0 desktop.h
--- trunk/KDE/kdebase/workspace/plasma/containmentactions/switchdesktop/desktop.cpp #1016791:1016792
@@ -45,27 +45,46 @@
}
}
-void SwitchDesktop::contextEvent(QGraphicsSceneMouseEvent *event)
+void SwitchDesktop::makeMenu(QMenu *menu)
{
int numDesktops = KWindowSystem::numberOfDesktops();
int currentDesktop = KWindowSystem::currentDesktop();
- KMenu desktopMenu;
- desktopMenu.addTitle(i18n("Virtual Desktops"));
-
for (int i=1; i<=numDesktops; ++i) {
QString name = KWindowSystem::desktopName(i);
- QAction *action = desktopMenu.addAction(QString("%1: %2").arg(i).arg(name));
+ QAction *action = menu->addAction(QString("%1: %2").arg(i).arg(name));
action->setData(i);
if (i==currentDesktop) {
action->setEnabled(false);
}
}
+ connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(switchTo(QAction*)));
+}
- connect(&desktopMenu, SIGNAL(triggered(QAction*)), this, SLOT(switchTo(QAction*)));
+void SwitchDesktop::contextEvent(QGraphicsSceneMouseEvent *event)
+{
+ KMenu desktopMenu;
+
+ desktopMenu.addTitle(i18n("Virtual Desktops"));
+ makeMenu(&desktopMenu);
+
desktopMenu.exec(event->screenPos());
}
+QList<QAction*> SwitchDesktop::contextualActions()
+{
+ QList<QAction*> list;
+ QMenu *menu = new QMenu();
+
+ makeMenu(menu);
+ QAction *action = new QAction(this); //FIXME I hope this doesn't leak
+ action->setMenu(menu);
+ menu->setTitle(i18n("Virtual Desktops"));
+
+ list << action;
+ return list;
+}
+
void SwitchDesktop::switchTo(QAction *action)
{
int desktop = action->data().toInt();
--- trunk/KDE/kdebase/workspace/plasma/containmentactions/switchdesktop/desktop.h #1016791:1016792
@@ -33,6 +33,8 @@
void contextEvent(QEvent *event);
void contextEvent(QGraphicsSceneMouseEvent *event);
void wheelEvent(QGraphicsSceneWheelEvent *event);
+ QList<QAction*> contextualActions();
+ void makeMenu(QMenu *menu);
public slots:
void switchTo(QAction *action);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic