Merge pull request #915 from dustinlieu/master

Fixed gui writing invalid config for hotkeys with multiple actions
This commit is contained in:
Povilas Kanapickas 2021-01-10 16:57:53 +02:00 committed by GitHub
commit 7ee94cca94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -68,8 +68,20 @@ void Hotkey::saveSettings(QSettings& settings) const
QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey) QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey)
{ {
for (int i = 0; i < hotkey.actions().size(); i++) // Don't write config if there are no actions
outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl; if (hotkey.actions().size() == 0) {
return outStream;
}
outStream << "\t" << hotkey.text() << " = ";
for (int i = 0; i < hotkey.actions().size(); i++) {
outStream << hotkey.actions()[i];
if (i != hotkey.actions().size() - 1) {
outStream << ", ";
}
}
outStream << "\n";
return outStream; return outStream;
} }

View File

@ -316,5 +316,5 @@ TEST(HotkeyToTexStreamTests, KeysMultipleAction)
} }
}; };
ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)), ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)),
"\tkeystroke(a+b) = keyDown(z,*)\n\tkeystroke(a+b) = switchToScreen(test_screen)\n"); "\tkeystroke(a+b) = keyDown(z,*), switchToScreen(test_screen)\n");
} }