lock screen and log out ... this makes things slightly more bearable for
me on a day to day basis ;) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=714841
This commit is contained in:
parent
eb19605f15
commit
607d79dda6
@ -56,6 +56,11 @@ set(plasma_LIB_SRCS
|
|||||||
set(krunner_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/krunner/org.kde.krunner.Interface.xml)
|
set(krunner_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/krunner/org.kde.krunner.Interface.xml)
|
||||||
QT4_ADD_DBUS_INTERFACE(plasma_LIB_SRCS ${krunner_xml} krunner_interface)
|
QT4_ADD_DBUS_INTERFACE(plasma_LIB_SRCS ${krunner_xml} krunner_interface)
|
||||||
|
|
||||||
|
set(screensaver_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/krunner/org.freedesktop.ScreenSaver.xml)
|
||||||
|
QT4_ADD_DBUS_INTERFACE(plasma_LIB_SRCS ${screensaver_xml} screensaver_interface)
|
||||||
|
|
||||||
|
set(ksmserver_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/ksmserver/org.kde.KSMServerInterface.xml)
|
||||||
|
QT4_ADD_DBUS_INTERFACE(plasma_LIB_SRCS ${ksmserver_xml} ksmserver_interface)
|
||||||
|
|
||||||
if(QT_QTOPENGL_FOUND AND OPENGL_FOUND)
|
if(QT_QTOPENGL_FOUND AND OPENGL_FOUND)
|
||||||
MESSAGE(STATUS "Adding support for OpenGL applets to libplasma")
|
MESSAGE(STATUS "Adding support for OpenGL applets to libplasma")
|
||||||
|
@ -26,10 +26,14 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
#include <KApplication>
|
||||||
#include <KAuthorized>
|
#include <KAuthorized>
|
||||||
|
#include <KIcon>
|
||||||
#include <KMenu>
|
#include <KMenu>
|
||||||
#include <KRun>
|
#include <KRun>
|
||||||
|
|
||||||
|
#include "workspace/kworkspace.h"
|
||||||
|
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
#include "karambamanager.h"
|
#include "karambamanager.h"
|
||||||
#include "phase.h"
|
#include "phase.h"
|
||||||
@ -39,6 +43,8 @@
|
|||||||
#include "widgets/boxlayout.h"
|
#include "widgets/boxlayout.h"
|
||||||
|
|
||||||
#include "krunner_interface.h"
|
#include "krunner_interface.h"
|
||||||
|
#include "ksmserver_interface.h"
|
||||||
|
#include "screensaver_interface.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -76,6 +82,8 @@ public:
|
|||||||
QString wallpaperPath;
|
QString wallpaperPath;
|
||||||
QAction *engineExplorerAction;
|
QAction *engineExplorerAction;
|
||||||
QAction *runCommandAction;
|
QAction *runCommandAction;
|
||||||
|
QAction *lockAction;
|
||||||
|
QAction *logoutAction;
|
||||||
QSize size;
|
QSize size;
|
||||||
int screen;
|
int screen;
|
||||||
bool immutable;
|
bool immutable;
|
||||||
@ -113,11 +121,6 @@ void Containment::init()
|
|||||||
//kDebug() << "SVG wallpaper!";
|
//kDebug() << "SVG wallpaper!";
|
||||||
d->background = new Plasma::Svg("widgets/wallpaper", this);
|
d->background = new Plasma::Svg("widgets/wallpaper", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::initConstraints(KConfigGroup* group)
|
void Containment::initConstraints(KConfigGroup* group)
|
||||||
@ -194,6 +197,36 @@ void Containment::runCommand()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Containment::lockScreen()
|
||||||
|
{
|
||||||
|
if (!KAuthorized::authorizeKAction("lock_screen")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString interface("org.freedesktop.ScreenSaver");
|
||||||
|
org::freedesktop::ScreenSaver screensaver(interface, "/ScreenSaver",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if (screensaver.isValid()) {
|
||||||
|
screensaver.Lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Containment::logout()
|
||||||
|
{
|
||||||
|
if (!KAuthorized::authorizeKAction("logout")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString interface("org.kde.ksmserver");
|
||||||
|
org::kde::KSMServerInterface smserver(interface, "/KSMServer",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if (smserver.isValid()) {
|
||||||
|
smserver.logout(KWorkSpace::ShutdownConfirmDefault,
|
||||||
|
KWorkSpace::ShutdownTypeDefault,
|
||||||
|
KWorkSpace::ShutdownModeDefault);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSizeF Containment::contentSizeHint() const
|
QSizeF Containment::contentSizeHint() const
|
||||||
{
|
{
|
||||||
return d->size;
|
return d->size;
|
||||||
@ -201,6 +234,28 @@ QSizeF Containment::contentSizeHint() const
|
|||||||
|
|
||||||
QList<QAction*> Containment::contextActions()
|
QList<QAction*> Containment::contextActions()
|
||||||
{
|
{
|
||||||
|
//FIXME: several items here ... probably all junior jobs =)
|
||||||
|
// - engineExplorerAction is going to go away, so the !d->engineExplorerAction below needs to
|
||||||
|
// go
|
||||||
|
// - pretty up the menu with separators
|
||||||
|
// - should we offer "Switch User" here?
|
||||||
|
|
||||||
|
if (!d->engineExplorerAction) {
|
||||||
|
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->lockAction = new QAction(i18n("Lock Screen"), this);
|
||||||
|
d->lockAction->setIcon(KIcon("system-lock-screen"));
|
||||||
|
connect(d->lockAction, SIGNAL(triggered(bool)), this, SLOT(lockScreen()));
|
||||||
|
|
||||||
|
d->logoutAction = new QAction(i18n("Logout"), this);
|
||||||
|
d->logoutAction->setIcon(KIcon("system-log-out"));
|
||||||
|
connect(d->logoutAction, SIGNAL(triggered(bool)), this, SLOT(logout()));
|
||||||
|
}
|
||||||
|
|
||||||
QList<QAction*> actions;
|
QList<QAction*> actions;
|
||||||
|
|
||||||
actions.append(d->engineExplorerAction);
|
actions.append(d->engineExplorerAction);
|
||||||
@ -209,6 +264,14 @@ QList<QAction*> Containment::contextActions()
|
|||||||
actions.append(d->runCommandAction);
|
actions.append(d->runCommandAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (KAuthorized::authorizeKAction("lock_screen")) {
|
||||||
|
actions.append(d->lockAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (KAuthorized::authorizeKAction("logout")) {
|
||||||
|
actions.append(d->logoutAction);
|
||||||
|
}
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +230,8 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
void appletDestroyed(QObject*);
|
void appletDestroyed(QObject*);
|
||||||
void launchExplorer();
|
void launchExplorer();
|
||||||
void runCommand();
|
void runCommand();
|
||||||
|
void lockScreen();
|
||||||
|
void logout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(Containment)
|
Q_DISABLE_COPY(Containment)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user