1 #include "gnomeglobalshortcutbackend.h"
2 #include "globalshortcuts.h"
11 const char* GnomeGlobalShortcutBackend::kGsdService = "org.gnome.SettingsDaemon";
12 const char* GnomeGlobalShortcutBackend::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
13 const char* GnomeGlobalShortcutBackend::kGsdInterface = "org.gnome.SettingsDaemon.MediaKeys";
15 GnomeGlobalShortcutBackend::GnomeGlobalShortcutBackend(GlobalShortcuts* parent)
16 : GlobalShortcutBackend(parent),
19 bool GnomeGlobalShortcutBackend::IsGsdAvailable() {
21 return QDBusConnection::sessionBus().interface()->isServiceRegistered(
22 GnomeGlobalShortcutBackend::kGsdService);
28 bool GnomeGlobalShortcutBackend::DoRegister() {
29 // qDebug() << __PRETTY_FUNCTION__;
31 // Check if the GSD service is available
32 if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService))
36 interface_ = new QDBusInterface(
37 kGsdService, kGsdPath, kGsdInterface, QDBusConnection::sessionBus(), this);
40 connect(interface_, SIGNAL(MediaPlayerKeyPressed(QString,QString)),
41 this, SLOT(GnomeMediaKeyPressed(QString,QString)));
49 void GnomeGlobalShortcutBackend::DoUnregister() {
52 // Check if the GSD service is available
53 if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService))
58 disconnect(interface_, SIGNAL(MediaPlayerKeyPressed(QString,QString)),
59 this, SLOT(GnomeMediaKeyPressed(QString,QString)));
63 void GnomeGlobalShortcutBackend::GnomeMediaKeyPressed(const QString&, const QString& key) {
64 if (key == "Play") manager_->shortcuts()["play_pause"].action->trigger();
65 if (key == "Stop") manager_->shortcuts()["stop"].action->trigger();
66 if (key == "Next") manager_->shortcuts()["next_track"].action->trigger();
67 if (key == "Previous") manager_->shortcuts()["prev_track"].action->trigger();