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
)
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})

View File

@ -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

View File

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