gui/test: Extract createHotkey()

This commit is contained in:
Povilas Kanapickas 2021-01-10 15:28:07 +02:00
parent a004cd8eba
commit 141f6de2c4
1 changed files with 16 additions and 10 deletions

View File

@ -131,6 +131,21 @@ namespace {
} }
return action; return action;
} }
Hotkey createHotkey(const TestHotKey& test_hotkey)
{
Hotkey hotkey;
KeySequence sequence;
for (auto key : test_hotkey.keys) {
sequence.appendKey(key.key, key.modifier);
}
hotkey.setKeySequence(sequence);
for (auto action : test_hotkey.actions) {
hotkey.appendAction(createAction(action));
}
return hotkey;
}
} // namespace } // namespace
void doHotkeyLoadSaveTest(const TestHotKey& test_hotkey, QSettings::Format format) void doHotkeyLoadSaveTest(const TestHotKey& test_hotkey, QSettings::Format format)
@ -141,16 +156,7 @@ void doHotkeyLoadSaveTest(const TestHotKey& test_hotkey, QSettings::Format forma
{ {
QSettings settings(filename, format); QSettings settings(filename, format);
hotkey_before = createHotkey(test_hotkey);
KeySequence sequence;
for (auto key : test_hotkey.keys) {
sequence.appendKey(key.key, key.modifier);
}
hotkey_before.setKeySequence(sequence);
for (auto action : test_hotkey.actions) {
hotkey_before.appendAction(createAction(action));
}
settings.beginGroup("test"); settings.beginGroup("test");
hotkey_before.saveSettings(settings); hotkey_before.saveSettings(settings);