From 141f6de2c45015293938d0f0bdd04d9b987a2200 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 10 Jan 2021 15:28:07 +0200 Subject: [PATCH] gui/test: Extract createHotkey() --- src/gui/test/HotkeyTests.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gui/test/HotkeyTests.cpp b/src/gui/test/HotkeyTests.cpp index 0df017f5..918858d9 100644 --- a/src/gui/test/HotkeyTests.cpp +++ b/src/gui/test/HotkeyTests.cpp @@ -131,6 +131,21 @@ namespace { } 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 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); - - 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)); - } + hotkey_before = createHotkey(test_hotkey); settings.beginGroup("test"); hotkey_before.saveSettings(settings);