diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2018-10-25 03:11:42 +0200 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-10-25 03:11:42 +0200 | 
| commit | 0a1a0e9df00f37a210b67a11cf8f99550cafeeaf (patch) | |
| tree | 35da3c9a2d6464025dc324647253966d4a63a351 /logic/shortcuts.cpp | |
| parent | a4c9807acacc87f323f31d252a37c0ed2029ee5b (diff) | |
cleanups only
Diffstat (limited to 'logic/shortcuts.cpp')
| -rw-r--r-- | logic/shortcuts.cpp | 41 | 
1 files changed, 21 insertions, 20 deletions
diff --git a/logic/shortcuts.cpp b/logic/shortcuts.cpp index f03c8973..a0027fea 100644 --- a/logic/shortcuts.cpp +++ b/logic/shortcuts.cpp @@ -29,9 +29,9 @@ void Shortcuts::free_binding(K& key)  #endif  } -void Shortcuts::bind_shortcut(K &key, const key_opts& k, bool held) +void Shortcuts::bind_shortcut(K& key, const key_opts& k, bool held)  { -#if !defined(_WIN32) +#if !defined _WIN32      (void)held;      using sh = QxtGlobalShortcut;      if (key) @@ -46,13 +46,12 @@ void Shortcuts::bind_shortcut(K &key, const key_opts& k, bool held)          key->setShortcut(QKeySequence::fromString(k.keycode, QKeySequence::PortableText));          key->setEnabled();      } -}  #else -    key = K(); +    key = {};      int idx = 0; -    QKeySequence code; +    QKeySequence code(QKeySequence::UnknownKey); -    if (k.guid != "") +    if (!k.guid->isEmpty())      {          key.guid = k.guid;          key.keycode = k.button & ~Qt::KeyboardModifierMask; @@ -63,26 +62,27 @@ void Shortcuts::bind_shortcut(K &key, const key_opts& k, bool held)      }      else      { -        if (k.keycode == "") -            code = QKeySequence(Qt::Key_unknown); -        else +        if (!k.keycode->isEmpty())              code = QKeySequence::fromString(k.keycode, QKeySequence::PortableText);          Qt::KeyboardModifiers mods = Qt::NoModifier; -        if (code != Qt::Key_unknown) -            win_key::from_qt(code, idx, mods); - -        key.guid = ""; -        key.keycode = idx; -        key.held = held; -        key.ctrl = !!(mods & Qt::ControlModifier); -        key.alt = !!(mods & Qt::AltModifier); -        key.shift = !!(mods & Qt::ShiftModifier); +        if (!code.isEmpty() && +            code != QKeySequence{ QKeySequence::UnknownKey } && +            win_key::from_qt(code, idx, mods)) +        { +            key.guid = ""; +            key.keycode = idx; +            key.held = held; +            key.ctrl = !!(mods & Qt::ControlModifier); +            key.alt = !!(mods & Qt::AltModifier); +            key.shift = !!(mods & Qt::ShiftModifier); +        }      } -}  #endif +}  #ifdef _WIN32 +  void Shortcuts::receiver(const Key& k)  {      const unsigned sz = keys.size(); @@ -105,6 +105,7 @@ void Shortcuts::receiver(const Key& k)          f(k.held);      }  } +  #endif  Shortcuts::~Shortcuts() @@ -127,7 +128,7 @@ void Shortcuts::reload(const t_keys& keys_)      for (unsigned i = 0; i < sz; i++)      { -        auto const& [opts, fun, held] = keys_[i]; +        auto const&[opts, fun, held] = keys_[i];  #ifdef _WIN32          K k;  #else  | 
