diff options
Diffstat (limited to 'kxkb')
-rw-r--r-- | kxkb/kcmlayout.cpp | 8 | ||||
-rw-r--r-- | kxkb/kcmlayout.h | 2 | ||||
-rw-r--r-- | kxkb/kcmlayoutwidget.ui | 39 | ||||
-rw-r--r-- | kxkb/kxkb.cpp | 11 | ||||
-rw-r--r-- | kxkb/kxkbconfig.cpp | 2 | ||||
-rw-r--r-- | kxkb/kxkbtraywindow.cpp | 15 | ||||
-rw-r--r-- | kxkb/kxkbtraywindow.h | 8 | ||||
-rw-r--r-- | kxkb/pixmap.cpp | 51 | ||||
-rw-r--r-- | kxkb/pixmap.h | 52 |
9 files changed, 81 insertions, 107 deletions
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp index fac058a6f..236acb3d9 100644 --- a/kxkb/kcmlayout.cpp +++ b/kxkb/kcmlayout.cpp @@ -107,6 +107,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"); @@ -189,7 +192,8 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) LayoutConfig::~LayoutConfig() { - delete m_rules; + delete m_rules; + delete m_icoMgr; } @@ -1141,7 +1145,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; diff --git a/kxkb/kcmlayout.h b/kxkb/kcmlayout.h index db0f89690..256946ad1 100644 --- a/kxkb/kcmlayout.h +++ b/kxkb/kcmlayout.h @@ -11,6 +11,7 @@ class OptionListItem; +class LayoutIconManager; class LayoutConfigWidget; class XkbRules; @@ -52,6 +53,7 @@ protected slots: void changed(); private: + LayoutIconManager *m_icoMgr; LayoutConfigWidget* widget; XkbRules *m_rules; diff --git a/kxkb/kcmlayoutwidget.ui b/kxkb/kcmlayoutwidget.ui index 11d147211..814fdde39 100644 --- a/kxkb/kcmlayoutwidget.ui +++ b/kxkb/kcmlayoutwidget.ui @@ -904,36 +904,19 @@ </size> </property> </spacer> - <spacer row="4" column="0"> - <property name="name"> - <cstring>spacer22</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="TQCheckBox" row="4" column="1" rowspan="1" colspan="3"> - <property name="name"> - <cstring>chkBgTransparent</cstring> - </property> - <property name="text"> - <string>Transparent background</string> - </property> - <property name="whatsThis" stdset="0"> - <string>Check this to remove the indicator's background. Only applicable in "Label only" mode.</string> - </property> - </widget> </grid> </widget> + <widget class="TQCheckBox" row="4" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>chkBgTransparent</cstring> + </property> + <property name="text"> + <string>Transparent background</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this to remove the indicator's background. Only applicable in "Label only" mode.</string> + </property> + </widget> <widget class="KSeparator" row="5" column="0" rowspan="1" colspan="3"> <property name="name"> <cstring>separator1</cstring> diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp index bbfa4d87e..3d04824ad 100644 --- a/kxkb/kxkb.cpp +++ b/kxkb/kxkb.cpp @@ -106,10 +106,11 @@ int KXKBApp::newInstance() bool KXKBApp::settingsRead() { - XkbOptions options = kxkbConfig.getKXkbOptions(); - if( !m_extension->setXkbOptions(options) ) { - kdDebug() << "Setting XKB options failed!" << endl; - } + kxkbConfig.load(KxkbConfig::LOAD_ALL); + XkbOptions options = kxkbConfig.getKXkbOptions(); + if (!m_extension->setXkbOptions(options)) { + kdWarning() << "Setting XKB options failed!" << endl; + } if ( kxkbConfig.m_useKxkb == false ) { kapp->quit(); @@ -168,7 +169,7 @@ void KXKBApp::initTray() { if (!m_tray) { - m_tray = new KxkbSystemTray(); + m_tray = new KxkbSystemTray(&kxkbConfig); connect(m_tray, TQ_SIGNAL(menuActivated(int)), this, TQ_SLOT(menuActivated(int))); connect(m_tray, TQ_SIGNAL(toggled()), this, TQ_SLOT(nextLayout())); } diff --git a/kxkb/kxkbconfig.cpp b/kxkb/kxkbconfig.cpp index 0c3dc9e0a..a10ad7177 100644 --- a/kxkb/kxkbconfig.cpp +++ b/kxkb/kxkbconfig.cpp @@ -275,8 +275,6 @@ TQString KxkbConfig::getDefaultDisplayName(const LayoutUnit& layoutUnit, bool si } const XkbOptions KxkbConfig::getKXkbOptions() { - load(LOAD_ALL); - XkbOptions options; TQStringList layouts; TQStringList variants; diff --git a/kxkb/kxkbtraywindow.cpp b/kxkb/kxkbtraywindow.cpp index da0c7c0b4..4f0359d79 100644 --- a/kxkb/kxkbtraywindow.cpp +++ b/kxkb/kxkbtraywindow.cpp @@ -22,12 +22,17 @@ #include "kxkbtraywindow.h" #include "pixmap.h" #include "rules.h" -#include "kxkbconfig.h" -KxkbSystemTray::KxkbSystemTray() +KxkbSystemTray::KxkbSystemTray(KxkbConfig *kxkbConfig) : KSystemTray(nullptr), m_prevLayoutCount(0) { + m_icoMgr = new LayoutIconManager(kxkbConfig); +} + +KxkbSystemTray::~KxkbSystemTray() +{ + delete m_icoMgr; } void KxkbSystemTray::setToolTip(const TQString& tip) @@ -45,7 +50,7 @@ void KxkbSystemTray::setPixmap(const TQPixmap& pix) void KxkbSystemTray::setCurrentLayout(const LayoutUnit& layoutUnit) { setToolTip(m_descriptionMap[layoutUnit.toPair()]); - setPixmap(LayoutIcon::getInstance().findPixmap(layoutUnit.layout, PIXMAP_STYLE_INDICATOR, layoutUnit.displayName)); + setPixmap(m_icoMgr->find(layoutUnit.layout, PIXMAP_STYLE_INDICATOR, layoutUnit.displayName)); } void KxkbSystemTray::setError(const TQString& layoutInfo) @@ -57,7 +62,7 @@ void KxkbSystemTray::setError(const TQString& layoutInfo) TQString msg = i18n("Error changing keyboard layout to '%1'").arg(layoutInfo); setToolTip(msg); - setPixmap(LayoutIcon::getInstance().findPixmap("error", PIXMAP_STYLE_NORMAL)); + setPixmap(m_icoMgr->find(ERROR_CODE, PIXMAP_STYLE_NORMAL)); } void KxkbSystemTray::initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rules) @@ -78,7 +83,7 @@ void KxkbSystemTray::initLayoutList(const TQValueList<LayoutUnit>& layouts, cons const TQString layoutName = (*it).layout; const TQString variantName = (*it).variant; - const TQPixmap& layoutPixmap = LayoutIcon::getInstance().findPixmap((*it).layout, PIXMAP_STYLE_CONTEXTMENU, (*it).displayName); + const TQPixmap& layoutPixmap = m_icoMgr->find((*it).layout, PIXMAP_STYLE_CONTEXTMENU, (*it).displayName); const TQPixmap pix = iconeffect.apply(layoutPixmap, TDEIcon::Small, TDEIcon::DefaultState); TQString fullName = rules.getLayoutName((*it)); diff --git a/kxkb/kxkbtraywindow.h b/kxkb/kxkbtraywindow.h index 484bae632..3e1ae2c05 100644 --- a/kxkb/kxkbtraywindow.h +++ b/kxkb/kxkbtraywindow.h @@ -17,16 +17,19 @@ #include <tqstring.h> #include <tqvaluelist.h> -#include "kxkbconfig.h" +#include "layoutunit.h" class XkbRules; +class KxkbConfig; +class LayoutIconManager; class KxkbSystemTray : public KSystemTray { TQ_OBJECT public: - KxkbSystemTray(); + KxkbSystemTray(KxkbConfig *kxkbConfig); + ~KxkbSystemTray(); void initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rule); void setCurrentLayout(const LayoutUnit& layout); void setError(const TQString& layoutInfo = TQString::null); @@ -45,6 +48,7 @@ class KxkbSystemTray : public KSystemTray void toggled(); private: + LayoutIconManager *m_icoMgr; int m_prevLayoutCount; TQMap<TQString, TQString> m_descriptionMap; }; diff --git a/kxkb/pixmap.cpp b/kxkb/pixmap.cpp index 63fc4f1db..830625ca8 100644 --- a/kxkb/pixmap.cpp +++ b/kxkb/pixmap.cpp @@ -13,43 +13,28 @@ #include "pixmap.h" #include "x11helper.h" +const TQString LayoutIconManager::flagTemplate("l10n/%1/flag.png"); -static const int FLAG_MAX_DIM = 24; - -const TQString LayoutIcon::flagTemplate("l10n/%1/flag.png"); -const TQString& LayoutIcon::ERROR_CODE("error"); -LayoutIcon* LayoutIcon::instance; - - -LayoutIcon& LayoutIcon::getInstance() { - if( instance == NULL ) { - instance = new LayoutIcon(); - } - return *instance; -} - -LayoutIcon::LayoutIcon(): - m_pixmapCache(80) +LayoutIconManager::LayoutIconManager(KxkbConfig *kxkbConfig) + : m_pixmapCache(80), + m_kxkbConfig(kxkbConfig) { } -const TQPixmap& -LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& displayName_) +const TQPixmap& LayoutIconManager::find(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 + 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_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; - m_bgTransparent = m_kxkbConfig.m_bgTransparent; + 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) { @@ -61,8 +46,8 @@ LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& d case PIXMAP_STYLE_INDICATOR: m_fitToBox = true; - m_showFlag = m_kxkbConfig.m_showFlag; - m_showLabel = m_kxkbConfig.m_showLabel; + m_showFlag = m_kxkbConfig->m_showFlag; + m_showLabel = m_kxkbConfig->m_showLabel; break; case PIXMAP_STYLE_CONTEXTMENU: @@ -178,7 +163,7 @@ LayoutIcon::findPixmap(const TQString& code_, int pixmapStyle, const TQString& d /** @brief Try to get country code from layout name in xkb before xorg 6.9.0 */ -TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName) +TQString LayoutIconManager::getCountryFromLayoutName(const TQString& layoutName) { TQString flag; @@ -286,7 +271,7 @@ TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName) } -void LayoutIcon::dimPixmap(TQPixmap& pm) +void LayoutIconManager::dimPixmap(TQPixmap& pm) { TQImage image = pm.convertToImage(); for (int y=0; y<image.height(); y++) @@ -299,10 +284,8 @@ void LayoutIcon::dimPixmap(TQPixmap& pm) pm.convertFromImage(image); } -static const char* ERROR_LABEL = "err"; - //private -TQPixmap* LayoutIcon::createErrorPixmap() +TQPixmap* LayoutIconManager::createErrorPixmap() { TQPixmap* pm = new TQPixmap(21, 14); pm->fill(TQt::white); diff --git a/kxkb/pixmap.h b/kxkb/pixmap.h index a17f48d89..bbf292689 100644 --- a/kxkb/pixmap.h +++ b/kxkb/pixmap.h @@ -8,41 +8,35 @@ #include "kxkbconfig.h" -enum PixmapStyle { - PIXMAP_STYLE_NORMAL = 0, - PIXMAP_STYLE_INDICATOR = 1, - PIXMAP_STYLE_CONTEXTMENU = 2 -}; - -class LayoutIcon { +#define ERROR_CODE "error" +#define ERROR_LABEL "!" -private: - static LayoutIcon* instance; - static const TQString flagTemplate; +#define FLAG_MAX_DIM 24 - KxkbConfig m_kxkbConfig; - bool m_showFlag; - bool m_showLabel; - TQColor m_bgColor; - bool m_bgTransparent; - TQColor m_fgColor; - TQFont m_labelFont; - bool m_labelShadow; - TQColor m_shColor; - bool m_fitToBox; +enum PixmapStyle { + PIXMAP_STYLE_NORMAL = 0, + PIXMAP_STYLE_INDICATOR = 1, + PIXMAP_STYLE_CONTEXTMENU = 2 +}; - TQDict<TQPixmap> m_pixmapCache; +class LayoutIconManager { + public: + LayoutIconManager(KxkbConfig *kxkbConfig); + const TQPixmap& find(const TQString& code, int pixmapStyle, const TQString& displayName = TQString::null); - LayoutIcon(); - TQPixmap* createErrorPixmap(); - void dimPixmap(TQPixmap& pixmap); - TQString getCountryFromLayoutName(const TQString& layoutName); + private: + TQPixmap* createErrorPixmap(); + void dimPixmap(TQPixmap& pixmap); + TQString getCountryFromLayoutName(const TQString& layoutName); -public: - static const TQString& ERROR_CODE; + private: + KxkbConfig *m_kxkbConfig; + static const TQString flagTemplate; + bool m_showFlag, m_showLabel, m_bgTransparent, m_labelShadow, m_fitToBox; + TQColor m_bgColor, m_fgColor, m_shColor; + TQFont m_labelFont; - static LayoutIcon& getInstance(); - const TQPixmap& findPixmap(const TQString& code, int pixmapStyle, const TQString& displayName=""); + TQDict<TQPixmap> m_pixmapCache; }; #endif |