From 51518793734c3613fc337a6e56b7eb27dc6de8e5 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 17 Jul 2007 16:55:27 +0000 Subject: [PATCH] add run command to the desktop context menu svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=689104 --- CMakeLists.txt | 2 ++ corona.cpp | 28 ++++++++++++++++++++++++---- corona.h | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21ea84954..a0bbccf44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,8 @@ set(plasmagik_HEADERS package.h ) +set(krunner_xml ${CMAKE_SOURCE_DIR}/workspace/krunner/org.kde.krunner.Interface.xml) +QT4_ADD_DBUS_INTERFACE(plasma_LIB_SRCS ${krunner_xml} krunner_interface) kde4_add_library(plasma SHARED ${plasma_LIB_SRCS}) diff --git a/corona.cpp b/corona.cpp index 7bf6d1bc2..433753e9d 100644 --- a/corona.cpp +++ b/corona.cpp @@ -42,6 +42,8 @@ #include "widgets/vboxlayout.h" #include "widgets/icon.h" +#include "krunner_interface.h" + using namespace Plasma; namespace Plasma @@ -70,6 +72,7 @@ public: Location location; Layout* layout; QAction *engineExplorerAction; + QAction *runCommandAction; }; Corona::Corona(QObject * parent) @@ -95,8 +98,6 @@ Corona::Corona(qreal x, qreal y, qreal width, qreal height, QObject * parent) void Corona::init() { -/* setBackgroundMode(Qt::NoBackground);*/ - /* QPalette pal = palette(); pal.setBrush(QPalette::Base, Qt::transparent); setPalette(pal);*/ @@ -111,11 +112,12 @@ void Corona::init() kDebug() << "=========================" << endl; */ -// connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayContextMenu(QPoint))); + //TODO: should we delay the init of the actions until we actually need them? d->engineExplorerAction = new QAction(i18n("Engine Explorer"), this); connect(d->engineExplorerAction, SIGNAL(triggered(bool)), this, SLOT(launchExplorer())); + d->runCommandAction = new QAction(i18n("Run Command..."), this); + connect(d->runCommandAction, SIGNAL(triggered(bool)), this, SLOT(runCommand())); d->immutable = false; -// setContextMenuPolicy(Qt::CustomContextMenu); } Corona::~Corona() @@ -311,7 +313,13 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) return; } + //FIXME: change this to show this only in debug mode (or not at all?) + // before final release desktopMenu.addAction(d->engineExplorerAction); + + if (KAuthorized::authorizeKAction("run_command")) { + desktopMenu.addAction(d->runCommandAction); + } } else if (applet->immutable()) { return; } else { @@ -345,6 +353,18 @@ void Corona::launchExplorer() KRun::run("plasmaengineexplorer", KUrl::List(), 0); } +void Corona::runCommand() +{ + if (!KAuthorized::authorizeKAction("run_command")) { + return; + } + + QString interface("org.kde.krunner"); + org::kde::krunner::Interface krunner(interface, "/Interface", + QDBusConnection::sessionBus()); + krunner.display(); +} + void Corona::appletDestroyed(QObject* object) { // we do a static_cast here since it really isn't an Applet by this diff --git a/corona.h b/corona.h index 1d5db5f6d..348ee1855 100644 --- a/corona.h +++ b/corona.h @@ -112,6 +112,7 @@ protected: protected Q_SLOTS: void launchExplorer(); + void runCommand(); void appletDestroyed(QObject*); private: