diff options
-rw-r--r-- | kxkb/kcmlayout.cpp | 15 | ||||
-rw-r--r-- | kxkb/kcmlayoutwidget.ui | 73 | ||||
-rw-r--r-- | kxkb/kxkbconfig.cpp | 12 | ||||
-rw-r--r-- | kxkb/kxkbconfig.h | 3 | ||||
-rw-r--r-- | kxkb/pixmap.cpp | 83 | ||||
-rw-r--r-- | kxkb/pixmap.h | 2 |
6 files changed, 155 insertions, 33 deletions
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp index 236acb3d9..4ee6c172a 100644 --- a/kxkb/kcmlayout.cpp +++ b/kxkb/kcmlayout.cpp @@ -146,6 +146,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())); @@ -153,6 +156,8 @@ 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())); @@ -264,6 +269,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); @@ -275,11 +282,14 @@ 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); switch( m_kxkbConfig.m_switchingPolicy ) { default: @@ -357,6 +367,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(); @@ -365,6 +378,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) { diff --git a/kxkb/kcmlayoutwidget.ui b/kxkb/kcmlayoutwidget.ui index 814fdde39..8a16ebf0a 100644 --- a/kxkb/kcmlayoutwidget.ui +++ b/kxkb/kcmlayoutwidget.ui @@ -8,8 +8,8 @@ <rect> <x>0</x> <y>0</y> - <width>709</width> - <height>563</height> + <width>700</width> + <height>600</height> </rect> </property> <property name="sizePolicy"> @@ -22,8 +22,8 @@ </property> <property name="minimumSize"> <size> - <width>600</width> - <height>510</height> + <width>700</width> + <height>600</height> </size> </property> <grid> @@ -975,7 +975,8 @@ <verstretch>0</verstretch> </sizepolicy> </property> - </widget> <spacer row="7" column="2"> + </widget> + <spacer row="7" column="2"> <property name="name"> <cstring>spacer23</cstring> </property> @@ -994,6 +995,35 @@ </spacer> </grid> </widget> + <widget class="TQButtonGroup" row="2" column="0" column="0" colspan="2"> + <property name="name"> + <cstring>grpFlag</cstring> + </property> + <property name="title"> + <string>Flag Style</string> + </property> + <vbox> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>chkFitToBox</cstring> + </property> + <property name="text"> + <string>Stretc&h flag</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If this option is enabled, the flag will be stretched to fit the tray indicator size.</string> + </property> + </widget> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>chkDimFlag</cstring> + </property> + <property name="text"> + <string>Dim flag to make the label more visible</string> + </property> + </widget> + </vbox> + </widget> <widget class="TQButtonGroup" row="0" column="1"> <property name="name"> <cstring>grpMisc</cstring> @@ -1010,6 +1040,17 @@ <string>Show indicator for single layout</string> </property> </widget> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>chkBevel</cstring> + </property> + <property name="text"> + <string>Show indicator bevel</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If this option is enabled, the layout indicator will be drawn with a thin 3D bevel around it.</string> + </property> + </widget> </vbox> </widget> </grid> @@ -1192,8 +1233,8 @@ <signal>toggled(bool)</signal> <receiver>bgColor</receiver> <slot>setEnabled(bool)</slot> - </connection> - <connection> + </connection> + <connection> <sender>radLabelOnly</sender> <signal>toggled(bool)</signal> <receiver>labelBgColor</receiver> @@ -1217,6 +1258,24 @@ <receiver>chkNotifyUseKMilo</receiver> <slot>setEnabled(bool)</slot> </connection> + <connection> + <sender>radFlagOnly</sender> + <signal>toggled(bool)</signal> + <receiver>grpFlag</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>radFlagLabel</sender> + <signal>toggled(bool)</signal> + <receiver>grpFlag</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>radLabelOnly</sender> + <signal>toggled(bool)</signal> + <receiver>grpFlag</receiver> + <slot>setDisabled(bool)</slot> + </connection> </connections> <includes> <include location="local" impldecl="in implementation">kiconloader.h</include> diff --git a/kxkb/kxkbconfig.cpp b/kxkb/kxkbconfig.cpp index a10ad7177..89e96a0aa 100644 --- a/kxkb/kxkbconfig.cpp +++ b/kxkb/kxkbconfig.cpp @@ -84,6 +84,8 @@ bool KxkbConfig::load(int loadMode) m_showSingle = config->readBoolEntry("ShowSingle", false); m_showFlag = config->readBoolEntry("ShowFlag", true); m_showLabel = config->readBoolEntry("ShowLabel", true); + m_fitToBox = config->readBoolEntry("FitFlagToBox", true); + m_dimFlag = config->readBoolEntry("DimFlag", true); m_useThemeColors = config->readBoolEntry("UseThemeColors", false); m_colorBackground = config->readColorEntry("ColorBackground", new TQColor(TQt::gray)); @@ -93,6 +95,8 @@ bool KxkbConfig::load(int loadMode) m_labelShadow = config->readBoolEntry("LabelShadow", true); m_colorShadow = config->readColorEntry("ColorShadow", new TQColor(TQt::black)); + m_bevel = config->readBoolEntry("IndicatorBevel", false); + TQString layoutOwner = config->readEntry("SwitchMode", "Global"); if( layoutOwner == "WinClass" ) { @@ -178,6 +182,8 @@ void KxkbConfig::save() config->writeEntry("ShowFlag", m_showFlag); config->writeEntry("ShowLabel", m_showLabel); + config->writeEntry("FitFlagToBox", m_fitToBox); + config->writeEntry("DimFlag", m_dimFlag); config->writeEntry("UseThemeColors", m_useThemeColors); config->writeEntry("ColorBackground", m_colorBackground); @@ -187,6 +193,8 @@ void KxkbConfig::save() config->writeEntry("LabelShadow", m_labelShadow); config->writeEntry("ColorShadow", m_colorShadow); + config->writeEntry("IndicatorBevel", m_bevel); + config->writeEntry("SwitchMode", switchModes[m_switchingPolicy]); config->writeEntry("StickySwitching", m_stickySwitching); @@ -222,6 +230,10 @@ void KxkbConfig::setDefaults() m_useKxkb = false; m_showSingle = false; m_showFlag = true; + m_fitToBox = true; + m_dimFlag = true; + + m_bevel = false; m_switchingPolicy = SWITCH_POLICY_GLOBAL; diff --git a/kxkb/kxkbconfig.h b/kxkb/kxkbconfig.h index 4e424102a..2eeb25c13 100644 --- a/kxkb/kxkbconfig.h +++ b/kxkb/kxkbconfig.h @@ -51,6 +51,9 @@ public: bool m_showSingle; bool m_showFlag; bool m_showLabel; + bool m_fitToBox; + bool m_dimFlag; + bool m_bevel; bool m_enableXkbOptions; bool m_resetOldOptions; SwitchingPolicy m_switchingPolicy; diff --git a/kxkb/pixmap.cpp b/kxkb/pixmap.cpp index 830625ca8..012350143 100644 --- a/kxkb/pixmap.cpp +++ b/kxkb/pixmap.cpp @@ -1,9 +1,11 @@ +#include <tqapplication.h> #include <tqimage.h> #include <tqbitmap.h> #include <tqfont.h> #include <tqpainter.h> #include <tqregexp.h> #include <tqdict.h> +#include <tqdrawutil.h> #include <kstandarddirs.h> #include <tdeglobalsettings.h> @@ -35,17 +37,18 @@ const TQPixmap& LayoutIconManager::find(const TQString& code_, int pixmapStyle, m_labelShadow = m_kxkbConfig->m_labelShadow; m_shColor = m_kxkbConfig->m_colorShadow; m_bgTransparent = m_kxkbConfig->m_bgTransparent; + m_fitToBox = m_kxkbConfig->m_fitToBox; + m_dimFlag = m_kxkbConfig->m_dimFlag && m_showFlag && m_showLabel; + m_bevel = m_kxkbConfig->m_bevel && !m_bgTransparent && pixmapStyle == PIXMAP_STYLE_INDICATOR; // 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; @@ -58,7 +61,7 @@ const TQPixmap& LayoutIconManager::find(const TQString& code_, int pixmapStyle, } // Label only mode is always 'fit to box' - if( m_showLabel && !m_showFlag ) + if (m_showLabel && !m_showFlag) m_fitToBox = true; TQPixmap* pm = NULL; @@ -74,57 +77,81 @@ const TQPixmap& LayoutIconManager::find(const TQString& code_, int pixmapStyle, TQString displayName(displayName_); - if( displayName.isEmpty() ) { + if (displayName.isEmpty()) { displayName = KxkbConfig::getDefaultDisplayName(code_); } - if( displayName.length() > 3 ) + if (displayName.length() > 3) displayName = displayName.left(3); const TQString pixmapKey( - TQString( m_showFlag ? "f" : "" ) + TQString( m_showLabel ? "l" : "" ) + TQString( m_labelShadow ? "s" : "" ) + "." + + TQString(m_showFlag ? "f" : "") + TQString(m_showLabel ? "l" : "") + TQString(m_labelShadow ? "s" : "") + "." + + TQString(m_fitToBox ? "F" : "") + TQString(m_dimFlag ? "D" : "") + TQString(m_bevel ? "B" : "") + "." + m_labelFont.key() + "." + ( m_bgTransparent ? "x" : m_bgColor.name() ) + "." + m_fgColor.name() + "." + m_shColor.name() + '.' + code_ + "." + displayName ); // Only use cache for indicator - if( pixmapStyle == PIXMAP_STYLE_INDICATOR ) { + if (pixmapStyle == PIXMAP_STYLE_INDICATOR) { pm = m_pixmapCache[pixmapKey]; - if( pm ) + if (pm) return *pm; } - // Need to create new pixmap - pm = new TQPixmap(); + pm = new TQPixmap(FLAG_MAX_DIM, FLAG_MAX_DIM); - if( m_fitToBox ) // Resize to box size - pm->resize(FLAG_MAX_DIM, FLAG_MAX_DIM); + TQRect r = pm->rect(); + TQPainter p_(pm); - if( m_showFlag ) { - TQString countryCode = getCountryFromLayoutName( code_ ); + if (m_showFlag) { + TQString countryCode = getCountryFromLayoutName(code_); TQString flag = locate("locale", flagTemplate.arg(countryCode)); - if( flag.isEmpty() ) { + 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); + TQPixmap fp(flag); + + if (m_dimFlag) // only dim for label + { + dimPixmap(fp); + } + + if (!m_fitToBox) { + r = TQRect((FLAG_MAX_DIM - fp.width()) / 2, (FLAG_MAX_DIM - fp.height()) / 2, fp.width(), fp.height()); + } + + TQRect fr(r); // flag rect might be smaller to accomodate the bevel + if (m_bevel) + { + fr.setX(fr.x() + 1); + fr.setY(fr.y() + 1); + fr.setWidth(fr.width() - 1); + fr.setHeight(fr.height() - 1); } - if( m_showLabel ) // only dim for label - dimPixmap( *pm ); + p_.drawPixmap(fr, fp); + + // If we don't stretch the flag, we need to apply a mask to it + if (!m_fitToBox) + { + TQPixmap fpmask(FLAG_MAX_DIM, FLAG_MAX_DIM); + TQPainter fpmaskp(&fpmask); + fpmask.fill(TQt::white); + fpmaskp.fillRect(r, TQt::black); + TQBitmap fpmask_; + fpmask_ = fpmask; + pm->setMask((TQBitmap)fpmask_); + } } } else { pm->fill(m_bgColor); } - if( m_showLabel ) { + if (m_showLabel) { TQPainter p(pm); p.setFont(m_labelFont); - if( m_labelShadow ) { + if (m_labelShadow) { p.setPen(m_shColor); p.drawText(1, 1, pm->width(), pm->height(), TQt::AlignCenter, displayName); } @@ -153,8 +180,14 @@ const TQPixmap& LayoutIconManager::find(const TQString& code_, int pixmapStyle, } } + if (m_bevel) + { + TQPainter p_(pm); + qDrawShadePanel(&p_, r.x(), r.y(), r.width(), r.height(), tqApp->palette().active(), false, 1, nullptr); + } + - if( pixmapStyle == PIXMAP_STYLE_INDICATOR ) + if (pixmapStyle == PIXMAP_STYLE_INDICATOR) m_pixmapCache.insert(pixmapKey, pm); return *pm; diff --git a/kxkb/pixmap.h b/kxkb/pixmap.h index bbf292689..bb747f8c8 100644 --- a/kxkb/pixmap.h +++ b/kxkb/pixmap.h @@ -32,7 +32,7 @@ class LayoutIconManager { private: KxkbConfig *m_kxkbConfig; static const TQString flagTemplate; - bool m_showFlag, m_showLabel, m_bgTransparent, m_labelShadow, m_fitToBox; + bool m_showFlag, m_showLabel, m_bgTransparent, m_labelShadow, m_fitToBox, m_dimFlag, m_bevel; TQColor m_bgColor, m_fgColor, m_shColor; TQFont m_labelFont; |