diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2024-10-28 14:40:20 +0200 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2025-04-03 11:47:21 +0000 |
commit | aed24cdf3fd4615b0ac42fad074f20c0427cc3ac (patch) | |
tree | 21f348286454071ffbf35ae475b9b041695a19b5 /kxkb/kcmlayout.cpp | |
parent | 1686be58c6c34303f33803db2bc8688e634bf6cd (diff) | |
download | tdebase-aed24cdf3fd4615b0ac42fad074f20c0427cc3ac.tar.gz tdebase-aed24cdf3fd4615b0ac42fad074f20c0427cc3ac.zip |
Kxkb: layout switching and UI bugfixes and minor refactoring
* Layout switching
- Improved layout change logic (indicator is now always updated when the actual switch occurs). This fixes layout switching triggered by the X11 shortcut not being synchronized with layout switching from the tray icon click and the TDE shortcut.
- Kxkb will ignore XkbStateNotify events not related to XkbGroupState which caused strange behaviour with the system tray context menu.
- Reapply Xkb settings when a keyboard device changes state
- Do not run setxkbmap without arguments
- Catch and process changes to Xkb layouts and options
- Always check for Xkb opcode in X11 events, this fixes invalid group issue (Michele Calgaro)
* Tray indicator
- Do not reload all Kxkb settings every time we are requested to get a pixmap!
- Tray indicator pixmap manager improvements
- Fix Quit tray icon menu item
* Configuration
- Optimize settings reloading
- Do not reload settings every time getKxkbOptions() is called; if settings actually need to be re-read, it must be done maunally before calling this function
- Use pointer to global KxkbConfig instance instead of keeping own copy
- Fixed optimized loading of initial settings using KxkbConfig::LOAD_INIT_OPTIONS (I had sort of broken it in the past)
- Removed unused KxkbConfig::LOAD_ACTIVE_OPTIONS
- `newInstance()` now delegates calling setLayout() to readSettings()
- Merged `initTray()` into `readSettings()` - no reason to exist as separate function
* Refactoring
- Merged KxkbLabelController into KxkbSystemTray
- Rename LayoutIcon to LayoutIconManager for clarity
- Minor code cleanup in LayoutIconManager
- Remove use of singleton pattern for LayoutIconManager
- Make XKBExtension a singleton.
- Add mutex to XKBExtension to prevent it from processing configuration changes likely caused by KXkb
- `XKBExtension::getServerOptions()` now also returns layout and variant information in a XkbOptions struct
- New `KxkbConfig::setFromXkbOptions()` member can update current configuration from a XkbOptions struct
- No need to use `tdeApp` pointer in KXKBApp (KUniqueApplication) class
- Consistent code style and more appropriate function names and return types
- Commented option sections for clarity
- Removed superfluous debug messages
- Add proper copyright header to extension.*
* Settings GUI
- Make "Transparent background" checkbox available for theme colors in the GUI
- Add customization options "Stretch flag", "Dim flag", "Show indicator bevel"
- Disable KMilo checkbox when layout notifications disabled
- Fix reading settings for TDE layout hotkeys
This resolves #547.
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kxkb/kcmlayout.cpp')
-rw-r--r-- | kxkb/kcmlayout.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp index 70132cd1b..2424a3599 100644 --- a/kxkb/kcmlayout.cpp +++ b/kxkb/kcmlayout.cpp @@ -14,6 +14,7 @@ #include <tqbuttongroup.h> #include <tqspinbox.h> #include <tqvbox.h> +#include <tqtimer.h> #include <tdefontrequester.h> #include <kcolorbutton.h> @@ -107,6 +108,9 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) m_forceGrpOverwrite(false) { X11Helper::initializeTranslations(); + + m_icoMgr = new LayoutIconManager(&m_kxkbConfig); + TQVBoxLayout *main = new TQVBoxLayout(this, 0, KDialog::spacingHint()); widget = new LayoutConfigWidget(this, "widget"); @@ -143,6 +147,9 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) connect( widget->grpSwitching, TQ_SIGNAL( clicked( int ) ), TQ_SLOT(changed())); connect( widget->grpLabel, TQ_SIGNAL( clicked( int ) ), TQ_SLOT(changed())); + connect( widget->chkFitToBox, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); + connect( widget->chkDimFlag, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); + connect( widget->bgColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT(changed())); connect( widget->fgColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT(changed())); connect( widget->chkBgTransparent, TQ_SIGNAL( toggled(bool) ), this, TQ_SLOT(changed())); @@ -150,11 +157,14 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) connect( widget->chkLabelShadow, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT(changed())); connect( widget->shColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT(changed())); + connect( widget->chkBevel, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); + connect( widget->chkEnableSticky, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); connect( widget->spinStickyDepth, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(changed())); connect(widget->chkEnableNotify, TQ_SIGNAL(toggled(bool)), TQ_SLOT(changed())); connect(widget->chkNotifyUseKMilo, TQ_SIGNAL(toggled(bool)), TQ_SLOT(changed())); + connect(widget->chkEnableNotify, TQ_SIGNAL(toggled(bool)), widget->chkNotifyUseKMilo, TQ_SLOT(setEnabled(bool))); widget->listLayoutsSrc->setColumnText(LAYOUT_COLUMN_FLAG, ""); widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_FLAG, ""); @@ -180,29 +190,39 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) #define NOSLOTS keys = new TDEGlobalAccel(this); #include "kxkbbindings.cpp" + keys->readSettings(); makeOptionsTab(); - load(); makeShortcutsTab(); + TQTimer::singleShot(0, this, TQ_SLOT(load())); } LayoutConfig::~LayoutConfig() { - delete m_rules; + delete m_rules; + delete m_icoMgr; } void LayoutConfig::load() { - m_kxkbConfig.load(KxkbConfig::LOAD_ALL); + bool modified = false; + m_kxkbConfig.load(KxkbConfig::LOAD_ALL_OPTIONS); - keys->readSettings(); + // Check if the active settings are different from the saved settings + if (m_kxkbConfig.m_useKxkb) + { + XkbOptions options = XKBExtension::the()->getServerOptions(); + modified = m_kxkbConfig.setFromXkbOptions(options); + } - initUI(); + m_kxkbConfig.load(KxkbConfig::LOAD_ALL_OPTIONS); + keys->readSettings(); + initUI(modified); } -void LayoutConfig::initUI() { +void LayoutConfig::initUI(bool modified) { const char* modelName = m_rules->models()[m_kxkbConfig.m_model]; if( modelName == NULL ) modelName = DEFAULT_MODEL; @@ -219,7 +239,6 @@ void LayoutConfig::initUI() { for ( ; src_it.current(); ++src_it ) { TQListViewItem* srcItem = src_it.current(); - if ( layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP) ) { // check if current config knows about this layout TQListViewItem* newItem = copyLVI(srcItem, widget->listLayoutsDst); @@ -260,6 +279,8 @@ void LayoutConfig::initUI() { widget->radFlagLabel->setChecked( showFlag && showLabel ); widget->radFlagOnly->setChecked( showFlag && !showLabel ); widget->radLabelOnly->setChecked( !showFlag && showLabel ); + widget->chkFitToBox->setChecked(m_kxkbConfig.m_fitToBox); + widget->chkDimFlag->setChecked(m_kxkbConfig.m_dimFlag); widget->xkbOptsMode->setButton(m_kxkbConfig.m_resetOldOptions ? 0 : 1); @@ -271,11 +292,15 @@ void LayoutConfig::initUI() { widget->chkLabelShadow->setChecked( m_kxkbConfig.m_labelShadow ); widget->shColor->setColor( m_kxkbConfig.m_colorShadow ); + widget->chkBevel->setChecked(m_kxkbConfig.m_bevel); + widget->grpLabel->setDisabled(showFlag && !showLabel); widget->grpLabelColors->setDisabled(m_kxkbConfig.m_useThemeColors); widget->labelBgColor->setDisabled(showFlag); widget->bgColor->setDisabled(showFlag); widget->chkBgTransparent->setDisabled(showFlag); + widget->grpFlag->setEnabled(showFlag); + widget->chkDimFlag->setEnabled(showFlag && showLabel); switch( m_kxkbConfig.m_switchingPolicy ) { default: @@ -296,6 +321,7 @@ void LayoutConfig::initUI() { widget->chkEnableNotify->setChecked(m_kxkbConfig.m_enableNotify); widget->chkNotifyUseKMilo->setChecked(m_kxkbConfig.m_notifyUseKMilo); + widget->chkNotifyUseKMilo->setEnabled(m_kxkbConfig.m_enableNotify); updateStickyLimit(); @@ -341,7 +367,7 @@ void LayoutConfig::initUI() { updateOptionsCommand(); updateHotkeyCombo(true); - emit TDECModule::changed( false ); + emit TDECModule::changed(modified); } @@ -353,6 +379,9 @@ void LayoutConfig::save() m_kxkbConfig.m_resetOldOptions = widget->radXkbOverwrite->isOn(); m_kxkbConfig.m_options = createOptionString(); + m_kxkbConfig.m_fitToBox = widget->chkFitToBox->isChecked(); + m_kxkbConfig.m_dimFlag = widget->chkDimFlag->isChecked(); + m_kxkbConfig.m_useThemeColors = widget->radLabelUseTheme->isChecked(); m_kxkbConfig.m_colorBackground = widget->bgColor->color(); m_kxkbConfig.m_colorLabel = widget->fgColor->color(); @@ -361,6 +390,8 @@ void LayoutConfig::save() m_kxkbConfig.m_labelShadow = widget->chkLabelShadow->isChecked(); m_kxkbConfig.m_colorShadow = widget->shColor->color(); + m_kxkbConfig.m_bevel = widget->chkBevel->isChecked(); + TQListViewItem *item = widget->listLayoutsDst->firstChild(); TQValueList<LayoutUnit> layouts; while (item) { @@ -415,7 +446,8 @@ void LayoutConfig::save() if (m_forceGrpOverwrite) { // First get all the server's options - TQStringList srvOptions = TQStringList::split(",", XKBExtension::getServerOptions()); + XkbOptions _opt = XKBExtension::the()->getServerOptions(); + TQStringList srvOptions = TQStringList::split(",", _opt.options); TQStringList newOptions; // Then remove all grp: options @@ -432,7 +464,7 @@ void LayoutConfig::save() xkbOptions.options = newOptions.join(","); xkbOptions.resetOld = true; - if (!XKBExtension::setXkbOptions(xkbOptions)) + if (!XKBExtension::the()->setXkbOptions(xkbOptions)) { kdWarning() << "[LayoutConfig::save] Could not overwrite previous grp: options!" << endl; } @@ -990,7 +1022,8 @@ void LayoutConfig::updateHotkeyCombo(bool initial) { // Get server options first if (initial || widget->xkbOptsMode->selectedId() == 1) { - TQStringList opts = TQStringList::split(",", XKBExtension::getServerOptions()); + XkbOptions _opt = XKBExtension::the()->getServerOptions(); + TQStringList opts = TQStringList::split(",", _opt.options); for (TQStringList::Iterator it = opts.begin(); it != opts.end(); ++it) { TQString option(*it); @@ -1141,7 +1174,7 @@ void LayoutConfig::loadRules() TQString layoutName = it2.current(); TQListViewItem *item = new TQListViewItem(widget->listLayoutsSrc); - item->setPixmap(LAYOUT_COLUMN_FLAG, LayoutIcon::getInstance().findPixmap(layout, false)); + item->setPixmap(LAYOUT_COLUMN_FLAG, m_icoMgr->find(layout, PIXMAP_STYLE_CONTEXTMENU)); item->setText(LAYOUT_COLUMN_NAME, i18n(layoutName.latin1())); item->setText(LAYOUT_COLUMN_MAP, layout); ++it2; @@ -1250,7 +1283,7 @@ extern "C" tdeApp->startServiceByDesktopName("kxkb"); } else { - if (!XKBExtension::setXkbOptions(m_kxkbConfig.getKXkbOptions())) { + if (!XKBExtension::the()->setXkbOptions(m_kxkbConfig.getKXkbOptions())) { kdDebug() << "Setting XKB options failed!" << endl; } } |