mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-01-09 16:29:25 +01:00
Fixed HotkeyRegistry::GetHotkey
locking shortcuts to the first widget that calls it
This commit is contained in:
parent
bf0a1348c3
commit
303c67d3c8
@ -33,21 +33,24 @@ void HotkeyRegistry::LoadHotkeys() {
|
|||||||
QKeySequence::fromString(shortcut.shortcut.keyseq, QKeySequence::NativeText);
|
QKeySequence::fromString(shortcut.shortcut.keyseq, QKeySequence::NativeText);
|
||||||
hk.context = static_cast<Qt::ShortcutContext>(shortcut.shortcut.context);
|
hk.context = static_cast<Qt::ShortcutContext>(shortcut.shortcut.context);
|
||||||
}
|
}
|
||||||
if (hk.shortcut) {
|
for(auto const& [_, hotkey_shortcut] : hk.shortcuts) {
|
||||||
hk.shortcut->disconnect();
|
if (hotkey_shortcut) {
|
||||||
hk.shortcut->setKey(hk.keyseq);
|
hotkey_shortcut->disconnect();
|
||||||
|
hotkey_shortcut->setKey(hk.keyseq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QShortcut* HotkeyRegistry::GetHotkey(const QString& group, const QString& action, QObject* widget) {
|
QShortcut* HotkeyRegistry::GetHotkey(const QString& group, const QString& action, QObject* widget) {
|
||||||
Hotkey& hk = hotkey_groups[group][action];
|
Hotkey& hk = hotkey_groups[group][action];
|
||||||
|
QShortcut* shortcut = hk.shortcuts[widget->objectName()];
|
||||||
|
|
||||||
if (!hk.shortcut) {
|
if (!shortcut) {
|
||||||
hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
|
shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hk.shortcut;
|
return shortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
QKeySequence HotkeyRegistry::GetKeySequence(const QString& group, const QString& action) {
|
QKeySequence HotkeyRegistry::GetKeySequence(const QString& group, const QString& action) {
|
||||||
|
@ -71,7 +71,7 @@ private:
|
|||||||
struct Hotkey {
|
struct Hotkey {
|
||||||
QKeySequence keyseq;
|
QKeySequence keyseq;
|
||||||
QString controller_keyseq;
|
QString controller_keyseq;
|
||||||
QShortcut* shortcut = nullptr;
|
std::map<QString, QShortcut*> shortcuts;
|
||||||
Qt::ShortcutContext context = Qt::WindowShortcut;
|
Qt::ShortcutContext context = Qt::WindowShortcut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user