summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <[email protected]>2022-03-10 19:51:52 +0200
committerMavridis Philippe <[email protected]>2022-03-19 13:25:55 +0200
commit515465039af34e4bf87a3d4ae4585e9b37315310 (patch)
tree66e799511fc7067c7f4007e1bf862e22de06d89b
parent4cd8cd29f5edac59e5c1ab7fb5e82db8c6c5c364 (diff)
downloadtdebase-515465039af34e4bf87a3d4ae4585e9b37315310.tar.gz
tdebase-515465039af34e4bf87a3d4ae4585e9b37315310.zip
kxkb: transparent indicator background feature
Signed-off-by: Mavridis Philippe <[email protected]> (cherry picked from commit d048506bb65a3f77102f07f54c7bfc16c80e003e)
-rw-r--r--kxkb/kcmlayout.cpp8
-rw-r--r--kxkb/kcmlayoutwidget.ui222
-rw-r--r--kxkb/kxkbconfig.cpp2
-rw-r--r--kxkb/kxkbconfig.h1
-rw-r--r--kxkb/pixmap.cpp26
-rw-r--r--kxkb/pixmap.h1
6 files changed, 162 insertions, 98 deletions
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp
index 682ea10da..a022b6389 100644
--- a/kxkb/kcmlayout.cpp
+++ b/kxkb/kcmlayout.cpp
@@ -237,10 +237,17 @@ void LayoutConfig::initUI() {
widget->grpLabel->setButton( ( m_kxkbConfig.m_useThemeColors ? 0 : 1 ) );
widget->bgColor->setColor( m_kxkbConfig.m_colorBackground );
widget->fgColor->setColor( m_kxkbConfig.m_colorLabel );
+ widget->chkBgTransparent->setChecked( m_kxkbConfig.m_bgTransparent );
widget->labelFont->setFont( m_kxkbConfig.m_labelFont );
widget->chkLabelShadow->setChecked( m_kxkbConfig.m_labelShadow );
widget->shColor->setColor( m_kxkbConfig.m_colorShadow );
+ widget->grpLabel->setDisabled(showFlag && !showLabel);
+ widget->grpLabelColors->setDisabled(m_kxkbConfig.m_useThemeColors);
+ widget->labelBgColor->setDisabled(showFlag);
+ widget->bgColor->setDisabled(showFlag);
+ widget->chkBgTransparent->setDisabled(showFlag);
+
switch( m_kxkbConfig.m_switchingPolicy ) {
default:
case SWITCH_POLICY_GLOBAL:
@@ -303,6 +310,7 @@ void LayoutConfig::save()
m_kxkbConfig.m_useThemeColors = widget->radLabelUseTheme->isChecked();
m_kxkbConfig.m_colorBackground = widget->bgColor->color();
m_kxkbConfig.m_colorLabel = widget->fgColor->color();
+ m_kxkbConfig.m_bgTransparent = widget->chkBgTransparent->isChecked();
m_kxkbConfig.m_labelFont = widget->labelFont->font();
m_kxkbConfig.m_labelShadow = widget->chkLabelShadow->isChecked();
m_kxkbConfig.m_colorShadow = widget->shColor->color();
diff --git a/kxkb/kcmlayoutwidget.ui b/kxkb/kcmlayoutwidget.ui
index dc3350a87..e8dcc3a9e 100644
--- a/kxkb/kcmlayoutwidget.ui
+++ b/kxkb/kcmlayoutwidget.ui
@@ -545,96 +545,108 @@
<bool>false</bool>
</property>
</widget>
- <spacer row="2" column="0">
+ <widget class="TQFrame" row="2" column="0" colspan="3">
<property name="name">
- <cstring>spacer2</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Fixed</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget class="TQLabel" row="2" column="1">
- <property name="name">
- <cstring>labelBgColor</cstring>
- </property>
- <property name="text">
- <string>Background color:</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>This color will be used as the indicator's background unless the indicator was set to display a flag.</string>
- </property>
- <property name="enabled">
- <bool>false</bool>
- </property>
+ <cstring>grpLabelColors</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <grid>
+ <spacer row="0" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>labelBgColor</cstring>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This color will be used as the indicator's background unless the indicator was set to display a flag.</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="2">
+ <property name="name">
+ <cstring>bgColor</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This color will be used as the indicator's background unless the indicator was set to display a flag.</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>labelFgColor</cstring>
+ </property>
+ <property name="text">
+ <string>Text color:</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This color will be used to draw the language label on the indicator.</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="2">
+ <property name="name">
+ <cstring>fgColor</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This color will be used to draw the language label on the indicator.</string>
+ </property>
+ </widget>
+ </grid>
</widget>
- <widget class="KColorButton" row="2" column="2">
+ <widget class="TQCheckBox" row="4" column="0" rowspan="1" colspan="3">
<property name="name">
- <cstring>bgColor</cstring>
- </property>
- <property name="whatsThis" stdset="0">
- <string>This color will be used as the indicator's background unless the indicator was set to display a flag.</string>
- </property>
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- <spacer row="3" column="0">
- <property name="name">
- <cstring>spacer2</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Fixed</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget class="TQLabel" row="3" column="1">
- <property name="name">
- <cstring>labelFgColor</cstring>
+ <cstring>chkBgTransparent</cstring>
</property>
<property name="text">
- <string>Text color:</string>
+ <string>Transparent background</string>
</property>
<property name="whatsThis" stdset="0">
- <string>This color will be used to draw the language label on the indicator.</string>
- </property>
- <property name="enabled">
- <bool>false</bool>
+ <string>Check this to remove the indicator's background. Only applicable in "Label only" mode.</string>
</property>
</widget>
- <widget class="KColorButton" row="3" column="2">
- <property name="name">
- <cstring>fgColor</cstring>
- </property>
- <property name="whatsThis" stdset="0">
- <string>This color will be used to draw the language label on the indicator.</string>
- </property>
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- <widget class="KSeparator" row="4" column="0" rowspan="1" colspan="3">
+ <widget class="KSeparator" row="5" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>separator1</cstring>
</property>
</widget>
- <widget class="TQLabel" row="5" column="0" rowspan="1" colspan="2">
+ <widget class="TQLabel" row="6" column="0" rowspan="1">
<property name="name">
<cstring>labelFontRequester</cstring>
</property>
@@ -645,12 +657,12 @@
<string>This is the font which will be used by the layout indicator to draw the label.</string>
</property>
</widget>
- <widget class="TDEFontRequester" row="5" column="2">
+ <widget class="TDEFontRequester" row="6" column="2">
<property name="name">
<cstring>labelFont</cstring>
</property>
</widget>
- <widget class="TQCheckBox" row="6" column="0" rowspan="1" colspan="2">
+ <widget class="TQCheckBox" row="7" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>chkLabelShadow</cstring>
</property>
@@ -661,7 +673,7 @@
<string>Draw a drop shadow behind the language label. In some cases this option can improve readability.</string>
</property>
</widget>
- <widget class="KColorButton" row="6" column="2">
+ <widget class="KColorButton" row="7" column="2">
<property name="name">
<cstring>shColor</cstring>
</property>
@@ -920,38 +932,56 @@
<connection>
<sender>radLabelUseCustom</sender>
<signal>toggled(bool)</signal>
- <receiver>bgColor</receiver>
+ <receiver>grpLabelColors</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
- <sender>radLabelUseCustom</sender>
+ <sender>chkLabelShadow</sender>
<signal>toggled(bool)</signal>
- <receiver>fgColor</receiver>
+ <receiver>shColor</receiver>
<slot>setEnabled(bool)</slot>
- </connection>
- <connection>
- <sender>radLabelUseCustom</sender>
+ </connection>
+ <connection>
+ <sender>chkEnable</sender>
<signal>toggled(bool)</signal>
- <receiver>labelBgColor</receiver>
+ <receiver>optionsFrame</receiver>
<slot>setEnabled(bool)</slot>
- </connection>
- <connection>
- <sender>radLabelUseCustom</sender>
+ </connection>
+ <connection>
+ <sender>radFlagOnly</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>grpLabel</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>radLabelOnly</sender>
<signal>toggled(bool)</signal>
- <receiver>labelFgColor</receiver>
+ <receiver>chkBgTransparent</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>radLabelOnly</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>bgColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
- <sender>chkLabelShadow</sender>
+ <sender>radLabelOnly</sender>
<signal>toggled(bool)</signal>
- <receiver>shColor</receiver>
+ <receiver>labelBgColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
- <sender>chkEnable</sender>
+ <sender>radFlagLabel</sender>
<signal>toggled(bool)</signal>
- <receiver>optionsFrame</receiver>
- <slot>setEnabled(bool)</slot>
+ <receiver>bgColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>radFlagLabel</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>labelBgColor</receiver>
+ <slot>setDisabled(bool)</slot>
</connection>
</connections>
<includes>
diff --git a/kxkb/kxkbconfig.cpp b/kxkb/kxkbconfig.cpp
index a01fd6a0e..8e6890161 100644
--- a/kxkb/kxkbconfig.cpp
+++ b/kxkb/kxkbconfig.cpp
@@ -131,6 +131,7 @@ bool KxkbConfig::load(int loadMode)
m_useThemeColors = config->readBoolEntry("UseThemeColors", false);
m_colorBackground = config->readColorEntry("ColorBackground", new TQColor(TQt::gray));
+ m_bgTransparent = config->readBoolEntry("BgTransparent", false);
m_colorLabel = config->readColorEntry("ColorLabel", new TQColor(TQt::white));
m_labelFont = config->readFontEntry("LabelFont", new TQFont("sans", 10, TQFont::Bold));
m_labelShadow = config->readBoolEntry("LabelShadow", true);
@@ -230,6 +231,7 @@ void KxkbConfig::save()
config->writeEntry("UseThemeColors", m_useThemeColors);
config->writeEntry("ColorBackground", m_colorBackground);
+ config->writeEntry("BgTransparent", m_bgTransparent);
config->writeEntry("ColorLabel", m_colorLabel);
config->writeEntry("LabelFont", m_labelFont);
config->writeEntry("LabelShadow", m_labelShadow);
diff --git a/kxkb/kxkbconfig.h b/kxkb/kxkbconfig.h
index 0f8c981ea..a4dc83e5a 100644
--- a/kxkb/kxkbconfig.h
+++ b/kxkb/kxkbconfig.h
@@ -105,6 +105,7 @@ public:
bool m_useThemeColors;
TQColor m_colorBackground;
+ bool m_bgTransparent;
TQColor m_colorLabel;
TQFont m_labelFont;
bool m_labelShadow;
diff --git a/kxkb/pixmap.cpp b/kxkb/pixmap.cpp
index 238023d9b..c7e08a741 100644
--- a/kxkb/pixmap.cpp
+++ b/kxkb/pixmap.cpp
@@ -1,5 +1,5 @@
#include <tqimage.h>
-//#include <tqbitmap.h>
+#include <tqbitmap.h>
#include <tqfont.h>
#include <tqpainter.h>
#include <tqregexp.h>
@@ -49,6 +49,7 @@ LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& d
m_labelFont = m_kxkbConfig.m_labelFont;
m_labelShadow = m_kxkbConfig.m_labelShadow;
m_shColor = m_kxkbConfig.m_colorShadow;
+ m_bgTransparent = m_kxkbConfig.m_bgTransparent;
// Decide on how to style the pixmap
switch(pixmapStyle) {
@@ -96,7 +97,7 @@ LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& d
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
+ m_labelFont.key() + "." + ( m_bgTransparent ? "x" : m_bgColor.name() ) + "." + m_fgColor.name() + "." + m_shColor.name() + '.' + code_ + "." + displayName
);
// Only use cache for indicator
@@ -145,8 +146,29 @@ LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& d
p.setPen(m_fgColor);
p.drawText(0, 0, pm->width(), pm->height(), Qt::AlignCenter, displayName);
+
+ if( m_bgTransparent && !m_showFlag )
+ {
+ TQPixmap maskpix(pm->width(), pm->height());
+ TQPainter maskp(&maskpix);
+
+ maskpix.fill(TQt::white);
+ maskp.setPen(TQt::black);
+ maskp.setFont(m_labelFont);
+
+ maskp.drawText(0, 0, maskpix.width(), maskpix.height(), Qt::AlignCenter, displayName);
+ if( m_labelShadow )
+ {
+ maskp.drawText(1, 1, maskpix.width(), maskpix.height(), Qt::AlignCenter, displayName);
+ }
+
+ TQBitmap mask;
+ mask = maskpix;
+ pm->setMask(mask);
+ }
}
+
if( pixmapStyle == PIXMAP_STYLE_INDICATOR )
m_pixmapCache.insert(pixmapKey, pm);
diff --git a/kxkb/pixmap.h b/kxkb/pixmap.h
index 2fd6c2a3c..a17f48d89 100644
--- a/kxkb/pixmap.h
+++ b/kxkb/pixmap.h
@@ -24,6 +24,7 @@ private:
bool m_showFlag;
bool m_showLabel;
TQColor m_bgColor;
+ bool m_bgTransparent;
TQColor m_fgColor;
TQFont m_labelFont;
bool m_labelShadow;