Skip to content

Commit

Permalink
ui: expose keystroke delay option
Browse files Browse the repository at this point in the history
  • Loading branch information
mkiol committed Jan 5, 2025
1 parent d592109 commit bc603e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
21 changes: 18 additions & 3 deletions desktop/qml/SettingsAdvancedPage.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Michal Kosciesza <[email protected]>
/* Copyright (C) 2024-2025 Michal Kosciesza <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -302,7 +302,7 @@ ColumnLayout {
ComboBoxForm {
visible: _settings.is_xcb()
label.text: qsTranslate("SettingsPage", "Keystroke sending method")
toolTip: qsTranslate("SettingsPage", "Keystroke sending method used in %1.").arg("<i>" + qsTranslate("SettingsPage", "Insert into active window") + "</i>")
toolTip: qsTranslate("SettingsPage", "Simulated keystroke sending method used in %1.").arg("<i>" + qsTranslate("SettingsPage", "Insert into active window") + "</i>")
comboBox {
currentIndex: {
if (_settings.fake_keyboard_type === Settings.FakeKeyboardTypeLegacy) return 0
Expand All @@ -323,8 +323,23 @@ ColumnLayout {
}
}

SpinBoxForm {
visible: _settings.is_xcb() && _settings.fake_keyboard_type === Settings.FakeKeyboardTypeLegacy
label.text: qsTranslate("SettingsPage", "Keystroke delay")
toolTip: qsTranslate("SettingsPage", "The delay between simulated keystrokes used in %1.").arg("<i>" + qsTranslate("SettingsPage", "Insert into active window") + "</i>")
spinBox {
from: 1
to: 1000
stepSize: 1
value: _settings.fake_keyboard_delay
onValueChanged: {
_settings.fake_keyboard_delay = spinBox.value;
}
}
}

TextFieldForm {
visible: _settings.is_xcb() && _settings.fake_keyboard_type === Settings.FakeKeyboardTypeNative
visible: _settings.is_xcb() && _settings.fake_keyboard_type === Settings.FakeKeyboardTypeLegacy
label.text: qsTranslate("SettingsPage", "Compose file")
toolTip: qsTranslate("SettingsPage", "X11 compose file used in %1.").arg("<i>" + qsTranslate("SettingsPage", "Insert into active window") + "</i>") + " " +
qsTranslate("SettingsPage", "Leave blank to use the default value.")
Expand Down
5 changes: 3 additions & 2 deletions src/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2021-2024 Michal Kosciesza <[email protected]>
/* Copyright (C) 2021-2025 Michal Kosciesza <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -2677,7 +2677,8 @@ void settings::set_fake_keyboard_type(fake_keyboard_type_t value) {
}

int settings::fake_keyboard_delay() const {
return value(QStringLiteral("fake_keyboard_delay"), 10).toInt();
auto v = value(QStringLiteral("fake_keyboard_delay"), 10).toInt();
return std::clamp(v, 1, 1000);
}

void settings::set_fake_keyboard_delay(int value) {
Expand Down

0 comments on commit bc603e1

Please sign in to comment.