Clementine-audio-player-Mac.../src/core/kglobalaccelglobalshortcutb...

68 lines
1.6 KiB
C
Raw Normal View History

2019-12-06 05:25:28 +01:00
#ifndef CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
#define CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
2019-12-07 00:53:40 +01:00
#include "config.h"
2019-12-06 05:25:28 +01:00
#include "globalshortcutbackend.h"
2019-12-07 00:53:40 +01:00
#include "globalshortcuts.h"
2019-12-06 05:25:28 +01:00
#include <QSet>
#include <QStringList>
class QAction;
class OrgKdeKGlobalAccelInterface;
class OrgKdeKglobalaccelComponentInterface;
class KGlobalAccelShortcutBackend : public GlobalShortcutBackend {
Q_OBJECT
2019-12-07 20:30:10 +01:00
public:
explicit KGlobalAccelShortcutBackend(GlobalShortcuts* parent);
2019-12-06 05:25:28 +01:00
2019-12-07 00:53:40 +01:00
static bool isKGlobalAccelAvailable();
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
protected:
2019-12-07 00:53:40 +01:00
bool DoRegister() override;
2019-12-06 05:25:28 +01:00
2019-12-07 00:53:40 +01:00
void DoUnregister() override;
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
private:
2019-12-06 05:25:28 +01:00
#ifdef HAVE_DBUS
2019-12-07 00:53:40 +01:00
enum SetShortcutFlag { SetPresent = 2, NoAutoloading = 4, IsDefault = 8 };
2019-12-06 05:25:28 +01:00
2019-12-07 00:53:40 +01:00
bool acquireComponent();
2019-12-06 05:25:28 +01:00
2019-12-07 00:53:40 +01:00
bool acquireInterface();
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
static QStringList id(const QString& name, const QAction* action);
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
static QList<int> intList(const QList<QKeySequence>& seq);
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
bool registerAction(const QString& name, QAction* action,
QStringList& actionId);
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
bool registerShortcut(const GlobalShortcuts::Shortcut& shortcut);
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
static QList<QKeySequence> shortcutList(const QList<int>& seq);
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
void unregisterAction(const QString& name, QAction* action);
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
private slots:
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
void onShortcutPressed(const QString& componentUnique,
const QString& actionUnique,
2019-12-07 00:53:40 +01:00
qlonglong timestamp) const;
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
private:
static const char* Service;
static const char* Path;
2019-12-06 05:25:28 +01:00
2019-12-07 20:30:10 +01:00
OrgKdeKGlobalAccelInterface* iface_;
OrgKdeKglobalaccelComponentInterface* component_;
QMultiHash<QString, QAction*> nameToAction_;
#endif // HAVE_DBUS
2019-12-06 05:25:28 +01:00
};
2019-12-07 20:30:10 +01:00
#endif // CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_