mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-01-09 00:20:39 +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);
|
||||
hk.context = static_cast<Qt::ShortcutContext>(shortcut.shortcut.context);
|
||||
}
|
||||
if (hk.shortcut) {
|
||||
hk.shortcut->disconnect();
|
||||
hk.shortcut->setKey(hk.keyseq);
|
||||
for(auto const& [_, hotkey_shortcut] : hk.shortcuts) {
|
||||
if (hotkey_shortcut) {
|
||||
hotkey_shortcut->disconnect();
|
||||
hotkey_shortcut->setKey(hk.keyseq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QShortcut* HotkeyRegistry::GetHotkey(const QString& group, const QString& action, QObject* widget) {
|
||||
Hotkey& hk = hotkey_groups[group][action];
|
||||
QShortcut* shortcut = hk.shortcuts[widget->objectName()];
|
||||
|
||||
if (!hk.shortcut) {
|
||||
hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
|
||||
if (!shortcut) {
|
||||
shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
|
||||
}
|
||||
|
||||
return hk.shortcut;
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
QKeySequence HotkeyRegistry::GetKeySequence(const QString& group, const QString& action) {
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
struct Hotkey {
|
||||
QKeySequence keyseq;
|
||||
QString controller_keyseq;
|
||||
QShortcut* shortcut = nullptr;
|
||||
std::map<QString, QShortcut*> shortcuts;
|
||||
Qt::ShortcutContext context = Qt::WindowShortcut;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user