add run command to the desktop context menu

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=689104
This commit is contained in:
Aaron J. Seigo 2007-07-17 16:55:27 +00:00
parent 50ee468b54
commit 5151879373
3 changed files with 27 additions and 4 deletions

View File

@ -42,6 +42,8 @@ set(plasmagik_HEADERS
package.h 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}) kde4_add_library(plasma SHARED ${plasma_LIB_SRCS})

View File

@ -42,6 +42,8 @@
#include "widgets/vboxlayout.h" #include "widgets/vboxlayout.h"
#include "widgets/icon.h" #include "widgets/icon.h"
#include "krunner_interface.h"
using namespace Plasma; using namespace Plasma;
namespace Plasma namespace Plasma
@ -70,6 +72,7 @@ public:
Location location; Location location;
Layout* layout; Layout* layout;
QAction *engineExplorerAction; QAction *engineExplorerAction;
QAction *runCommandAction;
}; };
Corona::Corona(QObject * parent) Corona::Corona(QObject * parent)
@ -95,8 +98,6 @@ Corona::Corona(qreal x, qreal y, qreal width, qreal height, QObject * parent)
void Corona::init() void Corona::init()
{ {
/* setBackgroundMode(Qt::NoBackground);*/
/* QPalette pal = palette(); /* QPalette pal = palette();
pal.setBrush(QPalette::Base, Qt::transparent); pal.setBrush(QPalette::Base, Qt::transparent);
setPalette(pal);*/ setPalette(pal);*/
@ -111,11 +112,12 @@ void Corona::init()
kDebug() << "=========================" << endl; 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); d->engineExplorerAction = new QAction(i18n("Engine Explorer"), this);
connect(d->engineExplorerAction, SIGNAL(triggered(bool)), this, SLOT(launchExplorer())); 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; d->immutable = false;
// setContextMenuPolicy(Qt::CustomContextMenu);
} }
Corona::~Corona() Corona::~Corona()
@ -311,7 +313,13 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
return; return;
} }
//FIXME: change this to show this only in debug mode (or not at all?)
// before final release
desktopMenu.addAction(d->engineExplorerAction); desktopMenu.addAction(d->engineExplorerAction);
if (KAuthorized::authorizeKAction("run_command")) {
desktopMenu.addAction(d->runCommandAction);
}
} else if (applet->immutable()) { } else if (applet->immutable()) {
return; return;
} else { } else {
@ -345,6 +353,18 @@ void Corona::launchExplorer()
KRun::run("plasmaengineexplorer", KUrl::List(), 0); 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) void Corona::appletDestroyed(QObject* object)
{ {
// we do a static_cast here since it really isn't an Applet by this // we do a static_cast here since it really isn't an Applet by this

View File

@ -112,6 +112,7 @@ protected:
protected Q_SLOTS: protected Q_SLOTS:
void launchExplorer(); void launchExplorer();
void runCommand();
void appletDestroyed(QObject*); void appletDestroyed(QObject*);
private: private: