mirror of
https://github.com/Skycoder42/QHotkey.git
synced 2026-11-19 12:49:58 +03:00
doc ready and add QPrivateSignal to activated
This commit is contained in:
+7
-10
@@ -34,11 +34,6 @@ QHotkey::~QHotkey()
|
||||
QHotkeyPrivate::instance()->removeShortcut(this);
|
||||
}
|
||||
|
||||
bool QHotkey::isKeyCaptured(Qt::Key key, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
return QHotkeyPrivate::instance()->hasShortcut(key, modifiers);
|
||||
}
|
||||
|
||||
QKeySequence QHotkey::shortcut() const
|
||||
{
|
||||
if(this->key == Qt::Key_unknown)
|
||||
@@ -86,6 +81,13 @@ bool QHotkey::setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers, bool aut
|
||||
return false;
|
||||
}
|
||||
|
||||
if(key == Qt::Key_unknown) {
|
||||
this->key = Qt::Key_unknown;
|
||||
this->mods = Qt::NoModifier;
|
||||
this->nativeShortcut = NativeShortcut();
|
||||
return true;
|
||||
}
|
||||
|
||||
this->key = key;
|
||||
this->mods = modifiers;
|
||||
this->nativeShortcut = QHotkeyPrivate::instance()->nativeShortcut(key, modifiers);
|
||||
@@ -163,11 +165,6 @@ QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::Keyb
|
||||
return res;
|
||||
}
|
||||
|
||||
bool QHotkeyPrivate::hasShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
return this->shortcuts.contains(this->nativeShortcut(keycode, modifiers));
|
||||
}
|
||||
|
||||
bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
|
||||
{
|
||||
if(hotkey->registered)
|
||||
|
||||
+8
-11
@@ -24,22 +24,19 @@ public:
|
||||
//! Constructor
|
||||
explicit QHotkey(QObject *parent = 0);
|
||||
//! Constructs a hotkey with a shortcut and optionally registers it
|
||||
explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = true, QObject *parent = 0);
|
||||
explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = 0);
|
||||
//! Constructs a hotkey with a key and modifiers and optionally registers it
|
||||
explicit QHotkey(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister = true, QObject *parent = 0);
|
||||
explicit QHotkey(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister = false, QObject *parent = 0);
|
||||
//! Destructor
|
||||
~QHotkey();
|
||||
|
||||
//! Test if a certain key with modifiers is currently registered somewhere or not
|
||||
static bool isKeyCaptured(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
//! READ-Accessor for QHotkey::registered
|
||||
bool isRegistered() const;
|
||||
//! READ-Accessor for QHotkey::shortcut
|
||||
//! READ-Accessor for QHotkey::shortcut - the key and modifiers as a QKeySequence
|
||||
QKeySequence shortcut() const;
|
||||
//! The key-code of the current shortcut
|
||||
//! READ-Accessor for QHotkey::shortcut - the key only
|
||||
Qt::Key keyCode() const;
|
||||
//! The modifiers of the current shortcut
|
||||
//! READ-Accessor for QHotkey::shortcut - the modifiers only
|
||||
Qt::KeyboardModifiers modifiers() const;
|
||||
|
||||
public slots:
|
||||
@@ -47,15 +44,15 @@ public slots:
|
||||
bool setRegistered(bool registered);
|
||||
|
||||
//! WRITE-Accessor for QHotkey::shortcut
|
||||
bool setShortcut(const QKeySequence& shortcut, bool autoRegister = true);
|
||||
bool setShortcut(const QKeySequence &shortcut, bool autoRegister = false);
|
||||
//! WRITE-Accessor for QHotkey::shortcut
|
||||
bool setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister = true);
|
||||
bool setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers, bool autoRegister = false);
|
||||
//! RESET-Accessor for QHotkey::shortcut
|
||||
bool resetShortcut();
|
||||
|
||||
signals:
|
||||
//! Will be emitted if the shortcut is pressed
|
||||
void activated();
|
||||
void activated(QPrivateSignal);
|
||||
|
||||
//! NOTIFY-Accessor for QHotkey::registered
|
||||
void registeredChanged(bool registered);
|
||||
|
||||
@@ -20,8 +20,6 @@ public:
|
||||
|
||||
QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
bool hasShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
||||
|
||||
bool addShortcut(QHotkey *hotkey);
|
||||
bool removeShortcut(QHotkey *hotkey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user