Move global shortcut handling into OSUtils (#5566)

Move global shortcut handling into OSUtils
This commit is contained in:
Jonathan White 2020-12-13 23:23:25 -05:00 committed by GitHub
parent a6f01349e8
commit 404fd941e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1124 additions and 1136 deletions

View file

@ -19,9 +19,10 @@
#define KEEPASSXC_NIXUTILS_H
#include "gui/osutils/OSUtilsBase.h"
#include <QAbstractNativeEventFilter>
#include <QPointer>
class NixUtils : public OSUtilsBase
class NixUtils : public OSUtilsBase, QAbstractNativeEventFilter
{
Q_OBJECT
@ -33,15 +34,35 @@ public:
void setLaunchAtStartup(bool enable) override;
bool isCapslockEnabled() override;
void registerNativeEventFilter() override;
bool registerGlobalShortcut(const QString& name,
Qt::Key key,
Qt::KeyboardModifiers modifiers,
QString* error = nullptr) override;
bool unregisterGlobalShortcut(const QString& name) override;
signals:
void keymapChanged();
private:
explicit NixUtils(QObject* parent = nullptr);
~NixUtils() override;
private:
bool nativeEventFilter(const QByteArray& eventType, void* message, long*) override;
QString getAutostartDesktopFilename(bool createDirs = false) const;
bool triggerGlobalShortcut(uint keycode, uint modifiers);
static QPointer<NixUtils> m_instance;
struct globalShortcut
{
uint nativeKeyCode;
uint nativeModifiers;
};
QHash<QString, QSharedPointer<globalShortcut>> m_globalShortcuts;
Q_DISABLE_COPY(NixUtils)
};