summaryrefslogtreecommitdiffstats
path: root/kxkb
diff options
context:
space:
mode:
authorMavridis Philippe <[email protected]>2021-05-12 14:42:00 +0300
committerMavridis Philippe <[email protected]>2021-05-16 16:02:45 +0300
commit1684db01bd44d0dedfc0ef6c447016bd7c4ea656 (patch)
treef46a4da786523d7b10e0407a623b0299523c4817 /kxkb
parent63b5e825b82b0f6936a97865d1907c5998f302af (diff)
downloadtdebase-1684db01bd44d0dedfc0ef6c447016bd7c4ea656.tar.gz
tdebase-1684db01bd44d0dedfc0ef6c447016bd7c4ea656.zip
Re-set previous layout after changing layout settings.
Signed-off-by: Mavridis Philippe <[email protected]>
Diffstat (limited to 'kxkb')
-rw-r--r--kxkb/kcmlayout.cpp89
-rw-r--r--kxkb/pixmap.cpp184
2 files changed, 153 insertions, 120 deletions
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp
index def7e1048..682ea10da 100644
--- a/kxkb/kcmlayout.cpp
+++ b/kxkb/kcmlayout.cpp
@@ -24,6 +24,8 @@
#include <kdebug.h>
#include <tdeapplication.h>
#include <kiconloader.h>
+#include <dcopref.h>
+#include <dcopclient.h>
#include "extension.h"
#include "kxkbconfig.h"
@@ -197,7 +199,7 @@ void LayoutConfig::initUI() {
TQValueList<LayoutUnit> otherLayouts = m_kxkbConfig.m_layouts;
widget->listLayoutsDst->clear();
-// to optimize we should have gone from it.end to it.begin
+ // to optimize we should have gone from it.end to it.begin
TQValueList<LayoutUnit>::ConstIterator it;
for (it = otherLayouts.begin(); it != otherLayouts.end(); ++it ) {
TQListViewItemIterator src_it( widget->listLayoutsSrc );
@@ -223,21 +225,21 @@ void LayoutConfig::initUI() {
// display KXKB switching options
widget->chkShowSingle->setChecked(m_kxkbConfig.m_showSingle);
- bool showFlag = m_kxkbConfig.m_showFlag;
- bool showLabel = m_kxkbConfig.m_showLabel;
- widget->radFlagLabel->setChecked( showFlag && showLabel );
- widget->radFlagOnly->setChecked( showFlag && !showLabel );
- widget->radLabelOnly->setChecked( !showFlag && showLabel );
+ bool showFlag = m_kxkbConfig.m_showFlag;
+ bool showLabel = m_kxkbConfig.m_showLabel;
+ widget->radFlagLabel->setChecked( showFlag && showLabel );
+ widget->radFlagOnly->setChecked( showFlag && !showLabel );
+ widget->radLabelOnly->setChecked( !showFlag && showLabel );
widget->chkEnableOptions->setChecked( m_kxkbConfig.m_enableXkbOptions );
widget->checkResetOld->setChecked(m_kxkbConfig.m_resetOldOptions);
- widget->grpLabel->setButton( ( m_kxkbConfig.m_useThemeColors ? 0 : 1 ) );
- widget->bgColor->setColor( m_kxkbConfig.m_colorBackground );
- widget->fgColor->setColor( m_kxkbConfig.m_colorLabel );
- widget->labelFont->setFont( m_kxkbConfig.m_labelFont );
- widget->chkLabelShadow->setChecked( m_kxkbConfig.m_labelShadow );
- widget->shColor->setColor( m_kxkbConfig.m_colorShadow );
+ widget->grpLabel->setButton( ( m_kxkbConfig.m_useThemeColors ? 0 : 1 ) );
+ widget->bgColor->setColor( m_kxkbConfig.m_colorBackground );
+ widget->fgColor->setColor( m_kxkbConfig.m_colorLabel );
+ widget->labelFont->setFont( m_kxkbConfig.m_labelFont );
+ widget->chkLabelShadow->setChecked( m_kxkbConfig.m_labelShadow );
+ widget->shColor->setColor( m_kxkbConfig.m_colorShadow );
switch( m_kxkbConfig.m_switchingPolicy ) {
default:
@@ -296,14 +298,14 @@ void LayoutConfig::save()
m_kxkbConfig.m_enableXkbOptions = widget->chkEnableOptions->isChecked();
m_kxkbConfig.m_resetOldOptions = widget->checkResetOld->isChecked();
- m_kxkbConfig.m_options = createOptionString();
+ m_kxkbConfig.m_options = createOptionString();
- m_kxkbConfig.m_useThemeColors = widget->radLabelUseTheme->isChecked();
- m_kxkbConfig.m_colorBackground = widget->bgColor->color();
- m_kxkbConfig.m_colorLabel = widget->fgColor->color();
- m_kxkbConfig.m_labelFont = widget->labelFont->font();
- m_kxkbConfig.m_labelShadow = widget->chkLabelShadow->isChecked();
- m_kxkbConfig.m_colorShadow = widget->shColor->color();
+ m_kxkbConfig.m_useThemeColors = widget->radLabelUseTheme->isChecked();
+ m_kxkbConfig.m_colorBackground = widget->bgColor->color();
+ m_kxkbConfig.m_colorLabel = widget->fgColor->color();
+ m_kxkbConfig.m_labelFont = widget->labelFont->font();
+ m_kxkbConfig.m_labelShadow = widget->chkLabelShadow->isChecked();
+ m_kxkbConfig.m_colorShadow = widget->shColor->color();
TQListViewItem *item = widget->listLayoutsDst->firstChild();
TQValueList<LayoutUnit> layouts;
@@ -333,8 +335,8 @@ void LayoutConfig::save()
m_kxkbConfig.m_useKxkb = widget->chkEnable->isChecked();
m_kxkbConfig.m_showSingle = widget->chkShowSingle->isChecked();
- m_kxkbConfig.m_showFlag = ( widget->radFlagLabel->isChecked() || widget->radFlagOnly->isChecked() );
- m_kxkbConfig.m_showLabel = ( widget->radFlagLabel->isChecked() || widget->radLabelOnly->isChecked() );
+ m_kxkbConfig.m_showFlag = ( widget->radFlagLabel->isChecked() || widget->radFlagOnly->isChecked() );
+ m_kxkbConfig.m_showLabel = ( widget->radFlagLabel->isChecked() || widget->radLabelOnly->isChecked() );
int modeId = widget->grpSwitching->id(widget->grpSwitching->selected());
switch( modeId ) {
@@ -355,7 +357,38 @@ void LayoutConfig::save()
m_kxkbConfig.save();
- kapp->tdeinitExec("kxkb");
+ // Get current layout from Kxkb
+ if (!kapp->dcopClient()->isAttached())
+ kapp->dcopClient()->attach();
+
+ DCOPRef kxkbref("kxkb", "kxkb");
+ DCOPReply reply = kxkbref.call( "getCurrentLayout" );
+
+ TQString currentLayout;
+ if ( reply.isValid() ) {
+ reply.get(currentLayout);
+ } else {
+ kdDebug() << "Warning: cannot get current layout! (invalid DCOP reply from Kxkb)" << endl;
+ }
+
+ // Cause Kxkb to reread configuration
+ kapp->tdeinitExecWait("kxkb");
+
+ // If previous call was valid, try to change layout
+ if ( reply.isValid() ) {
+ DCOPReply successReply = kxkbref.call( "setLayout", currentLayout );
+
+ if ( successReply.isValid() ) {
+ bool success;
+ successReply.get(success);
+
+ if ( ! success )
+ kdDebug() << "Warning: restoring previous layout failed!" << endl;
+ } else {
+ kdDebug() << "Warning: cannot restore previous layout! (invalid DCOP reply from Kxkb)" << endl;
+ }
+ }
+
emit TDECModule::changed( false );
}
@@ -461,12 +494,12 @@ void LayoutConfig::moveDown()
void LayoutConfig::variantChanged()
{
- TQListViewItem* selLayout = widget->listLayoutsDst->selectedItem();
- if( selLayout == NULL ) {
- widget->comboVariant->clear();
- widget->comboVariant->setEnabled(false);
- return;
- }
+ TQListViewItem* selLayout = widget->listLayoutsDst->selectedItem();
+ if( selLayout == NULL ) {
+ widget->comboVariant->clear();
+ widget->comboVariant->setEnabled(false);
+ return;
+ }
TQString selectedVariant = widget->comboVariant->currentText();
if( selectedVariant == DEFAULT_VARIANT_NAME )
diff --git a/kxkb/pixmap.cpp b/kxkb/pixmap.cpp
index 084a6980c..4a3e6aff2 100644
--- a/kxkb/pixmap.cpp
+++ b/kxkb/pixmap.cpp
@@ -36,44 +36,44 @@ LayoutIcon::LayoutIcon():
const TQPixmap&
LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& displayName_)
{
- m_kxkbConfig.load(KxkbConfig::LOAD_ALL); // (re)load settings
-
- if (m_kxkbConfig.m_useThemeColors) { // use colors from color scheme
- m_bgColor = TDEGlobalSettings::highlightColor();
- m_fgColor = TDEGlobalSettings::highlightedTextColor();
- } else {
- m_bgColor = m_kxkbConfig.m_colorBackground;
- m_fgColor = m_kxkbConfig.m_colorLabel;
- }
-
- m_labelFont = m_kxkbConfig.m_labelFont;
- m_labelShadow = m_kxkbConfig.m_labelShadow;
- m_shColor = m_kxkbConfig.m_colorShadow;
-
- // Decide on how to style the pixmap
- switch(pixmapStyle) {
- case PIXMAP_STYLE_NORMAL:
- m_fitToBox = true;
- m_showFlag = true;
- m_showLabel = false;
- break;
-
- case PIXMAP_STYLE_INDICATOR:
- m_fitToBox = true;
- m_showFlag = m_kxkbConfig.m_showFlag;
- m_showLabel = m_kxkbConfig.m_showLabel;
- break;
-
- case PIXMAP_STYLE_CONTEXTMENU:
- m_fitToBox = false; // causes white color loss
- m_showFlag = true;
- m_showLabel = false;
- break;
- }
-
- // Label only mode is always 'fit to box'
- if( m_showLabel && !m_showFlag )
- m_fitToBox = true;
+ m_kxkbConfig.load(KxkbConfig::LOAD_ALL); // (re)load settings
+
+ if (m_kxkbConfig.m_useThemeColors) { // use colors from color scheme
+ m_bgColor = TDEGlobalSettings::highlightColor();
+ m_fgColor = TDEGlobalSettings::highlightedTextColor();
+ } else {
+ m_bgColor = m_kxkbConfig.m_colorBackground;
+ m_fgColor = m_kxkbConfig.m_colorLabel;
+ }
+
+ m_labelFont = m_kxkbConfig.m_labelFont;
+ m_labelShadow = m_kxkbConfig.m_labelShadow;
+ m_shColor = m_kxkbConfig.m_colorShadow;
+
+ // Decide on how to style the pixmap
+ switch(pixmapStyle) {
+ case PIXMAP_STYLE_NORMAL:
+ m_fitToBox = true;
+ m_showFlag = true;
+ m_showLabel = false;
+ break;
+
+ case PIXMAP_STYLE_INDICATOR:
+ m_fitToBox = true;
+ m_showFlag = m_kxkbConfig.m_showFlag;
+ m_showLabel = m_kxkbConfig.m_showLabel;
+ break;
+
+ case PIXMAP_STYLE_CONTEXTMENU:
+ m_fitToBox = false; // causes white color loss
+ m_showFlag = true;
+ m_showLabel = false;
+ break;
+ }
+
+ // Label only mode is always 'fit to box'
+ if( m_showLabel && !m_showFlag )
+ m_fitToBox = true;
TQPixmap* pm = NULL;
@@ -95,60 +95,60 @@ LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& d
displayName = displayName.left(3);
const TQString pixmapKey(
- TQString( m_showFlag ? "f" : "" ) + TQString( m_showLabel ? "l" : "" ) + TQString( m_labelShadow ? "s" : "" ) + "." +
- m_labelFont.key() + "." + m_bgColor.name() + "." + m_fgColor.name() + "." + m_shColor.name() + '.' + code_ + "." + displayName
- );
-
- // Only use cache for indicator
- if( pixmapStyle == PIXMAP_STYLE_INDICATOR ) {
- pm = m_pixmapCache[pixmapKey];
- if( pm )
- return *pm;
- }
-
- // Need to create new pixmap
- pm = new TQPixmap();
-
- if( m_fitToBox ) // Resize to box size
- pm->resize(FLAG_MAX_DIM, FLAG_MAX_DIM);
-
- if( m_showFlag ) {
- TQString countryCode = getCountryFromLayoutName( code_ );
- TQString flag = locate("locale", flagTemplate.arg(countryCode));
-
- if( flag.isEmpty() ) {
- pm->fill(m_bgColor);
- m_showLabel = true;
- } else {
- if( m_fitToBox ) { // Resize flag
- TQPainter p_(pm);
- p_.drawPixmap(TQRect(0, 0, FLAG_MAX_DIM, FLAG_MAX_DIM), flag);
- } else { // Show the flag as is
- pm->load(flag);
- }
-
- if( m_showLabel ) // only dim for label
- dimPixmap( *pm );
- }
- } else {
- pm->fill(m_bgColor);
- }
-
- if( m_showLabel ) {
- TQPainter p(pm);
- p.setFont(m_labelFont);
-
- if( m_labelShadow ) {
- p.setPen(m_shColor);
- p.drawText(1, 1, pm->width(), pm->height(), Qt::AlignCenter, displayName);
- }
-
- p.setPen(m_fgColor);
- p.drawText(0, 0, pm->width(), pm->height(), Qt::AlignCenter, displayName);
- }
-
- if( pixmapStyle == PIXMAP_STYLE_INDICATOR )
- m_pixmapCache.insert(pixmapKey, pm);
+ TQString( m_showFlag ? "f" : "" ) + TQString( m_showLabel ? "l" : "" ) + TQString( m_labelShadow ? "s" : "" ) + "." +
+ m_labelFont.key() + "." + m_bgColor.name() + "." + m_fgColor.name() + "." + m_shColor.name() + '.' + code_ + "." + displayName
+ );
+
+ // Only use cache for indicator
+ if( pixmapStyle == PIXMAP_STYLE_INDICATOR ) {
+ pm = m_pixmapCache[pixmapKey];
+ if( pm )
+ return *pm;
+ }
+
+ // Need to create new pixmap
+ pm = new TQPixmap();
+
+ if( m_fitToBox ) // Resize to box size
+ pm->resize(FLAG_MAX_DIM, FLAG_MAX_DIM);
+
+ if( m_showFlag ) {
+ TQString countryCode = getCountryFromLayoutName( code_ );
+ TQString flag = locate("locale", flagTemplate.arg(countryCode));
+
+ if( flag.isEmpty() ) {
+ pm->fill(m_bgColor);
+ m_showLabel = true;
+ } else {
+ if( m_fitToBox ) { // Resize flag
+ TQPainter p_(pm);
+ p_.drawPixmap(TQRect(0, 0, FLAG_MAX_DIM, FLAG_MAX_DIM), flag);
+ } else { // Show the flag as is
+ pm->load(flag);
+ }
+
+ if( m_showLabel ) // only dim for label
+ dimPixmap( *pm );
+ }
+ } else {
+ pm->fill(m_bgColor);
+ }
+
+ if( m_showLabel ) {
+ TQPainter p(pm);
+ p.setFont(m_labelFont);
+
+ if( m_labelShadow ) {
+ p.setPen(m_shColor);
+ p.drawText(1, 1, pm->width(), pm->height(), Qt::AlignCenter, displayName);
+ }
+
+ p.setPen(m_fgColor);
+ p.drawText(0, 0, pm->width(), pm->height(), Qt::AlignCenter, displayName);
+ }
+
+ if( pixmapStyle == PIXMAP_STYLE_INDICATOR )
+ m_pixmapCache.insert(pixmapKey, pm);
return *pm;
}