2019-12-06 05:25:28 +01:00
|
|
|
#ifndef CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
|
|
|
|
#define CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
|
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
#include <QSet>
|
|
|
|
#include <QStringList>
|
|
|
|
|
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
|
|
|
|
|
|
|
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-09 17:25:29 +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-09 17:25:29 +01:00
|
|
|
bool AcquireComponent();
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +01:00
|
|
|
bool AcquireInterface();
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +01:00
|
|
|
static QStringList GetId(const QString& name, const QAction* action);
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +01:00
|
|
|
static QList<int> ToIntList(const QList<QKeySequence>& seq);
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +01:00
|
|
|
bool RegisterAction(const QString& name, QAction* action);
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +01:00
|
|
|
bool RegisterShortcut(const GlobalShortcuts::Shortcut& shortcut);
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +01:00
|
|
|
static QList<QKeySequence> ToKeySequenceList(const QList<int>& seq);
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-09 17:25:29 +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-09 17:25:29 +01:00
|
|
|
void OnShortcutPressed(const QString& component_unique,
|
|
|
|
const QString& action_unique,
|
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:
|
2019-12-09 17:25:29 +01:00
|
|
|
static const char* kService;
|
|
|
|
static const char* kPath;
|
2019-12-06 05:25:28 +01:00
|
|
|
|
2019-12-07 20:30:10 +01:00
|
|
|
OrgKdeKGlobalAccelInterface* iface_;
|
|
|
|
OrgKdeKglobalaccelComponentInterface* component_;
|
2019-12-09 17:25:29 +01:00
|
|
|
QMultiHash<QString, QAction*> name_to_action_;
|
2019-12-07 20:30:10 +01:00
|
|
|
#endif // HAVE_DBUS
|
2019-12-06 05:25:28 +01:00
|
|
|
};
|
|
|
|
|
2019-12-07 20:30:10 +01:00
|
|
|
#endif // CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
|