Commit 13e576ed authored by Jan Blackquill's avatar Jan Blackquill 🌈 Committed by Nate Graham

[kcms/keyboard]: Adjust settings to reflect existence of key-held behaviour

parent d1462745
......@@ -94,6 +94,11 @@ set(kcm_keyboard_PART_SRCS
bindings.cpp
tastenbrett.cpp)
install(FILES kcminputrc_repeat.upd
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kcminputrc_migrate_repeat_value.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
ecm_qt_declare_logging_category(kcm_keyboard_PART_SRCS
HEADER debug.h
IDENTIFIER KCM_KEYBOARD
......
#!/usr/bin/env python
import sys
for line in sys.stdin:
line = line.rstrip()
print(line, file=sys.stderr)
if line.startswith("KeyboardRepeating=0"):
print("KeyRepeat=nothing")
elif line.startswith("KeyboardRepeating="):
print("KeyRepeat=accent")
print("# DELETE KeyboardRepeating")
Version=5
Id=kcminputrc_migrate_repeat_value
File=kcminputrc
Group=Keyboard
Script=kcminputrc_migrate_repeat_value.py
......@@ -77,10 +77,10 @@ KCMiscKeyboardWidget::KCMiscKeyboardWidget(QWidget *parent)
connect(_numlockButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(changed()));
_keyboardRepeatButtonGroup = new QButtonGroup(ui.keyboardRepeatButtonGroup);
_keyboardRepeatButtonGroup->addButton(ui.keyboardRepeatOnRadioButton, 0);
_keyboardRepeatButtonGroup->addButton(ui.keyboardRepeatOffRadioButton, 1);
_keyboardRepeatButtonGroup->addButton(ui.keyboardRepeatUnchangedRadioButton, 2);
_keyboardRepeatButtonGroup = new QButtonGroup(ui.repeatFormLayout);
_keyboardRepeatButtonGroup->addButton(ui.accentMenuRadioButton, 0);
_keyboardRepeatButtonGroup->addButton(ui.repeatRadioButton, 1);
_keyboardRepeatButtonGroup->addButton(ui.nothingRadioButton, 2);
connect(_keyboardRepeatButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(changed()));
connect(_keyboardRepeatButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(keyboardRepeatStateChanged(int)));
......@@ -101,10 +101,9 @@ KCMiscKeyboardWidget::~KCMiscKeyboardWidget()
}
// set the slider and LCD values
void KCMiscKeyboardWidget::setRepeat(TriState keyboardRepeat, int delay_, double rate_)
void KCMiscKeyboardWidget::setRepeat(KeyBehaviour keyboardRepeat, int delay_, double rate_)
{
TriStateHelper::setTriState( _keyboardRepeatButtonGroup, keyboardRepeat );
// ui.repeatBox->setChecked(r == AutoRepeatModeOn);
_keyboardRepeatButtonGroup->button(keyboardRepeat)->click();
ui.delay->setValue(delay_);
ui.rate->setValue(rate_);
delaySpinboxChanged(delay_);
......@@ -130,15 +129,14 @@ void KCMiscKeyboardWidget::load()
ui.rate->blockSignals(true);
// need to read as string to support old "true/false" parameter
QString key = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON));
if( key == QLatin1String("true") || key == TriStateHelper::getString(STATE_ON)) {
keyboardRepeat = STATE_ON;
QString key = config.readEntry("KeyRepeat", TriStateHelper::getString(STATE_ON));
if( key == QLatin1String("true") || key == TriStateHelper::getString(STATE_ON) || key == QLatin1String("accent")) {
keyboardRepeat = KeyBehaviour::AccentMenu;
}
else if( key == QLatin1String("false") || key == TriStateHelper::getString(STATE_OFF)) {
keyboardRepeat = STATE_OFF;
}
else {
keyboardRepeat = STATE_UNCHANGED;
else if( key == QLatin1String("false") || key == TriStateHelper::getString(STATE_OFF) || key == QLatin1String("nothing")) {
keyboardRepeat = KeyBehaviour::DoNothing;
} else if (key == QLatin1String("repeat")) {
keyboardRepeat = KeyBehaviour::RepeatKey;
}
// keyboardRepeat = (key ? AutoRepeatModeOn : AutoRepeatModeOff);
......@@ -159,19 +157,19 @@ void KCMiscKeyboardWidget::save()
{
KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kcminputrc"), KConfig::NoGlobals), "Keyboard");
keyboardRepeat = TriStateHelper::getTriState(_keyboardRepeatButtonGroup);
keyboardRepeat = KeyBehaviour(_keyboardRepeatButtonGroup->checkedId());
numlockState = TriStateHelper::getTriState(_numlockButtonGroup);
config.writeEntry("KeyboardRepeating", TriStateHelper::getInt(keyboardRepeat));
config.writeEntry("RepeatRate", ui.rate->value() );
config.writeEntry("RepeatDelay", ui.delay->value() );
config.writeEntry("KeyRepeat", keybehaviourNames[KeyBehaviour(_keyboardRepeatButtonGroup->checkedId())], KConfig::Notify);
config.writeEntry("RepeatRate", ui.rate->value(), KConfig::Notify );
config.writeEntry("RepeatDelay", ui.delay->value(), KConfig::Notify );
config.writeEntry("NumLock", TriStateHelper::getInt(numlockState) );
config.sync();
}
void KCMiscKeyboardWidget::defaults()
{
setRepeat(STATE_ON, DEFAULT_REPEAT_DELAY, DEFAULT_REPEAT_RATE);
setRepeat(KeyBehaviour::AccentMenu, DEFAULT_REPEAT_DELAY, DEFAULT_REPEAT_RATE);
TriStateHelper::setTriState( _numlockButtonGroup, STATE_UNCHANGED );
emit changed(true);
}
......@@ -225,7 +223,6 @@ void KCMiscKeyboardWidget::changed()
void KCMiscKeyboardWidget::keyboardRepeatStateChanged(int selection)
{
bool enabled = selection == TriStateHelper::getInt(STATE_ON);
ui.keyboardRepeatParamsGroupBox->setEnabled(enabled);
ui.keyboardRepeatParamsGroupBox->setVisible(selection == KeyBehaviour::RepeatKey);
changed();
}
......@@ -24,6 +24,7 @@
#ifndef __KCMMISC_H__
#define __KCMMISC_H__
#include <QMap>
#include <QString>
#include <QWidget>
......@@ -33,6 +34,18 @@ class Ui_KeyboardConfigWidget;
const int DEFAULT_REPEAT_DELAY = 600;
const double DEFAULT_REPEAT_RATE = 25.0;
enum KeyBehaviour {
AccentMenu = 0,
RepeatKey = 1,
DoNothing = 2
};
const QMap<KeyBehaviour,QString> keybehaviourNames = {
{ AccentMenu, QStringLiteral("accent") },
{ RepeatKey, QStringLiteral("repeat") },
{ DoNothing, QStringLiteral("nothing") },
};
enum TriState {
STATE_ON = 0, STATE_OFF = 1, STATE_UNCHANGED = 2
};
......@@ -75,13 +88,13 @@ Q_SIGNALS:
void changed(bool state);
private:
void setRepeat( TriState flag, int delay, double rate);
void setRepeat( KeyBehaviour flag, int delay, double rate);
void setRepeatRate( int );
int sliderMax;
int clickVolume;
enum TriState keyboardRepeat;
KeyBehaviour keyboardRepeat;
enum TriState numlockState;
QButtonGroup* _numlockButtonGroup;
......
......@@ -6,11 +6,55 @@
<rect>
<x>0</x>
<y>0</y>
<width>577</width>
<height>411</height>
<width>824</width>
<height>550</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QFormLayout" name="repeatFormLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>When a key is held:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="accentMenuRadioButton">
<property name="text">
<string>&amp;Show accented and similar characters </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="nothingRadioButton">
<property name="text">
<string>&amp;Do nothing</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="repeatRadioButton">
<property name="text">
<string>&amp;Repeat the key being held</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="numlockGroupBox">
<property name="whatsThis">
......@@ -53,179 +97,142 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="keyboardRepeatGroupBox">
<item row="2" column="0">
<widget class="QGroupBox" name="keyboardRepeatParamsGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Keyboard Repeat</string>
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="keyboardRepeatButtonGroup">
<property name="flat">
<bool>true</bool>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="2" column="0">
<widget class="QLabel" name="lblRate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Rate:</string>
</property>
<property name="buddy">
<cstring>rate</cstring>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QRadioButton" name="keyboardRepeatOnRadioButton">
<property name="text">
<string>T&amp;urn on</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="keyboardRepeatOffRadioButton">
<property name="text">
<string>Turn o&amp;ff</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="keyboardRepeatUnchangedRadioButton">
<property name="text">
<string>&amp;Leave unchanged</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<item row="1" column="1">
<widget class="QSlider" name="delaySlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>If supported, this option allows you to set the delay after which a pressed key will start generating keycodes. The 'Repeat rate' option controls the frequency of these keycodes.</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>1000</number>
</property>
<property name="pageStep">
<number>1000</number>
</property>
<property name="value">
<number>5000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>159</width>
<height>20</height>
</size>
<property name="tickInterval">
<number>1000</number>
</property>
</spacer>
</widget>
</item>
<item row="0" column="2">
<widget class="QGroupBox" name="keyboardRepeatParamsGroupBox">
<property name="title">
<string/>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="rate">
<property name="whatsThis">
<string>If supported, this option allows you to set the rate at which keycodes are generated while a key is pressed.</string>
</property>
<property name="flat">
<bool>false</bool>
<property name="suffix">
<string> repeats/s</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="delay">
<property name="whatsThis">
<string>If supported, this option allows you to set the delay after which a pressed key will start generating keycodes. The 'Repeat rate' option controls the frequency of these keycodes.</string>
</property>
<property name="suffix">
<string> ms</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="rateSlider">
<property name="whatsThis">
<string>If supported, this option allows you to set the rate at which keycodes are generated while a key is pressed.</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>1000</number>
</property>
<property name="pageStep">
<number>1000</number>
</property>
<property name="value">
<number>5000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblDelay">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Delay:</string>
</property>
<property name="buddy">
<cstring>delay</cstring>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lblDelay">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Delay:</string>
</property>
<property name="buddy">
<cstring>delay</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="delaySlider">
<property name="whatsThis">
<string>If supported, this option allows you to set the delay after which a pressed key will start generating keycodes. The 'Repeat rate' option controls the frequency of these keycodes.</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>1000</number>
</property>
<property name="pageStep">
<number>1000</number>
</property>
<property name="value">
<number>5000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="delay">
<property name="whatsThis">
<string>If supported, this option allows you to set the delay after which a pressed key will start generating keycodes. The 'Repeat rate' option controls the frequency of these keycodes.</string>
</property>
<property name="suffix">
<string> ms</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblRate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Rate:</string>
</property>
<property name="buddy">
<cstring>rate</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="rateSlider">
<property name="whatsThis">
<string>If supported, this option allows you to set the rate at which keycodes are generated while a key is pressed.</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>1000</number>
</property>
<property name="pageStep">
<number>1000</number>
</property>
<property name="value">
<number>5000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="rate">
<property name="whatsThis">
<string>If supported, this option allows you to set the rate at which keycodes are generated while a key is pressed.</string>
</property>
<property name="suffix">
<string> repeats/s</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<item row="7" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
......@@ -246,26 +253,6 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment