You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
#pragma once |
|
|
|
#include "ptt_key_chord.h" |
|
#include <QObject> |
|
#include <QTimer> |
|
|
|
class DbManager; |
|
class PttPortal; |
|
class QWidget; |
|
|
|
// Глобальный PTT: Windows/X11 — состояние физических клавиш; Wayland — системный портал. |
|
// Физические комбинации хранит ui_state radio_ptt_hotkeys, Wayland-комбинации — портал. |
|
class PttHotkeyManager : public QObject { |
|
Q_OBJECT |
|
public: |
|
static PttHotkeyManager* instance(); |
|
void init(DbManager* db); |
|
QStringList hotkeys() const; |
|
void setHotkeys(const QStringList& chords); |
|
void reload(); |
|
static bool isSupported(); |
|
static bool usesPortal(); |
|
void configurePortal(QWidget* parentWindow); |
|
QStringList portalDescriptions() const; |
|
QString portalStatus() const; |
|
bool portalBusy() const; |
|
void inhibitPortal(bool inhibited); |
|
QString describe(const PttKeyChord& chord) const; |
|
bool beginCapture(); |
|
void endCapture(); |
|
|
|
signals: |
|
void portalChanged(); |
|
void keysChanged(const PttKeyChord& held); |
|
|
|
private: |
|
PttHotkeyManager(); |
|
~PttHotkeyManager() override; |
|
void pollKeys(); |
|
bool readKeys(PttKeyChord& held) const; |
|
QString keyName(int key) const; |
|
|
|
#ifdef UTUN_PTT_PORTAL |
|
PttPortal* m_portal = nullptr; |
|
#endif |
|
DbManager* m_db = nullptr; |
|
QTimer m_timer; |
|
void* m_display = nullptr; // собственное X11-соединение, только GUI-поток |
|
QList<PttKeyChord> m_chords; |
|
PttKeyChord m_held; |
|
bool m_capturing = false; |
|
bool m_captureArmed = false; |
|
bool m_talking = false; |
|
};
|
|
|