void init_keyboard_hardware() { KConfigGroup config(KSharedConfig::openConfig( "kcminputrc" ), "Keyboard"); QString keyRepeatStr = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON)); TriState keyRepeat = STATE_UNCHANGED; if( keyRepeatStr == "true" || keyRepeatStr == TriStateHelper::getString(STATE_ON) ) { keyRepeat = STATE_ON; } else if( keyRepeatStr == "false" || keyRepeatStr == TriStateHelper::getString(STATE_OFF) ) { keyRepeat = STATE_OFF; } int clickVolumePercent = config.readEntry("ClickVolume", -1); if( clickVolumePercent != -1 && keyRepeat != STATE_UNCHANGED ) { set_volume(clickVolumePercent, keyRepeat); } if( keyRepeat == STATE_ON ) { int delay_ = config.readEntry("RepeatDelay", 250); double rate_ = config.readEntry("RepeatRate", 30.); set_repeatrate(delay_, rate_); } TriState numlockState = TriStateHelper::getTriState( config.readEntry( "NumLock", TriStateHelper::getInt(STATE_UNCHANGED) ) ); if( numlockState != STATE_UNCHANGED ) { numlockx_change_numlock_state(QX11Info::display(), numlockState == STATE_ON ); } }
void KeyboardConfig::init_keyboard() { KConfig *config = new KConfig("kcminputrc", true); // Read-only, no globals config->setGroup("Keyboard"); XKeyboardState kbd; XKeyboardControl kbdc; XGetKeyboardControl(kapp->getDisplay(), &kbd); bool key = config->readBoolEntry("KeyboardRepeating", true); kbdc.key_click_percent = config->readNumEntry("ClickVolume", kbd.key_click_percent); kbdc.auto_repeat_mode = (key ? AutoRepeatModeOn : AutoRepeatModeOff); XChangeKeyboardControl(kapp->getDisplay(), KBKeyClickPercent | KBAutoRepeatMode, &kbdc); if( key ) { int delay_ = config->readNumEntry("RepeatDelay", 250); double rate_ = config->readDoubleNumEntry("RepeatRate", 30); set_repeatrate(delay_, rate_); } int numlockState = config->readNumEntry( "NumLock", 2 ); if( numlockState != 2 ) numlockx_change_numlock_state( numlockState == 0 ); delete config; }
void init_keyboard_hardware() { KConfigGroup config(KSharedConfig::openConfig( "kcminputrc" ), "Keyboard"); QString keyRepeatStr = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON)); TriState keyRepeat = STATE_UNCHANGED; if( keyRepeatStr == "true" || keyRepeatStr == TriStateHelper::getString(STATE_ON) ) { keyRepeat = STATE_ON; } else if( keyRepeatStr == "false" || keyRepeatStr == TriStateHelper::getString(STATE_OFF) ) { keyRepeat = STATE_OFF; } if( keyRepeat == STATE_ON ) { int delay_ = config.readEntry("RepeatDelay", 250); double rate_ = config.readEntry("RepeatRate", 30.); set_repeatrate(delay_, rate_); } TriState numlockState = TriStateHelper::getTriState( config.readEntry( "NumLock", TriStateHelper::getInt(STATE_UNCHANGED) ) ); if( numlockState != STATE_UNCHANGED ) { KModifierKeyInfo keyInfo; keyInfo.setKeyLocked(Qt::Key_NumLock, numlockState == STATE_ON); } }
void KeyboardConfig::save() { KConfig config("kcminputrc"); XKeyboardControl kbd; clickVolume = getClick(); keyboardRepeat = ui->repeatBox->isChecked() ? AutoRepeatModeOn : AutoRepeatModeOff; numlockState = getNumLockState(); kbd.key_click_percent = clickVolume; kbd.auto_repeat_mode = keyboardRepeat; XChangeKeyboardControl(kapp->getDisplay(), KBKeyClickPercent | KBAutoRepeatMode, &kbd); if( keyboardRepeat ) { set_repeatrate(ui->delay->value(), ui->rate->value()); } config.setGroup("Keyboard"); config.writeEntry("ClickVolume",clickVolume); config.writeEntry("KeyboardRepeating", (keyboardRepeat == AutoRepeatModeOn)); config.writeEntry("RepeatRate", ui->rate->value() ); config.writeEntry("RepeatDelay", ui->delay->value() ); config.writeEntry("NumLock", numlockState ); config.sync(); }