citra_qt: Improvements to hotkeys and ui state management (#6224)

This commit is contained in:
Tobias 2023-02-04 19:06:20 +01:00 committed by GitHub
parent 9b49d94644
commit f66d03dd48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 383 additions and 292 deletions

View file

@ -17,8 +17,8 @@ void HotkeyRegistry::SaveHotkeys() {
for (const auto& hotkey : group.second) {
UISettings::values.shortcuts.push_back(
{hotkey.first, group.first,
UISettings::ContextualShortcut(hotkey.second.keyseq.toString(),
hotkey.second.context)});
UISettings::ContextualShortcut(
{hotkey.second.keyseq.toString(), hotkey.second.context})});
}
}
}
@ -28,9 +28,10 @@ void HotkeyRegistry::LoadHotkeys() {
// beginGroup()
for (auto shortcut : UISettings::values.shortcuts) {
Hotkey& hk = hotkey_groups[shortcut.group][shortcut.name];
if (!shortcut.shortcut.first.isEmpty()) {
hk.keyseq = QKeySequence::fromString(shortcut.shortcut.first, QKeySequence::NativeText);
hk.context = static_cast<Qt::ShortcutContext>(shortcut.shortcut.second);
if (!shortcut.shortcut.keyseq.isEmpty()) {
hk.keyseq =
QKeySequence::fromString(shortcut.shortcut.keyseq, QKeySequence::NativeText);
hk.context = static_cast<Qt::ShortcutContext>(shortcut.shortcut.context);
}
if (hk.shortcut) {
hk.shortcut->disconnect();
@ -42,8 +43,9 @@ void HotkeyRegistry::LoadHotkeys() {
QShortcut* HotkeyRegistry::GetHotkey(const QString& group, const QString& action, QWidget* widget) {
Hotkey& hk = hotkey_groups[group][action];
if (!hk.shortcut)
if (!hk.shortcut) {
hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context);
}
return hk.shortcut;
}