diff options
Diffstat (limited to 'kxkb')
-rw-r--r-- | kxkb/kxkb.cpp | 1 | ||||
-rw-r--r-- | kxkb/kxkbconfig.h | 55 | ||||
-rw-r--r-- | kxkb/kxkbtraywindow.cpp | 14 | ||||
-rw-r--r-- | kxkb/layoutunit.h | 64 | ||||
-rw-r--r-- | kxkb/rules.cpp | 7 | ||||
-rw-r--r-- | kxkb/rules.h | 3 |
6 files changed, 84 insertions, 60 deletions
diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp index 8d725e3e5..1ecbd2470 100644 --- a/kxkb/kxkb.cpp +++ b/kxkb/kxkb.cpp @@ -248,7 +248,6 @@ void KXKBApp::prevLayout() setLayout(layout); } - void KXKBApp::menuActivated(int id) { if( KxkbLabelController::START_MENU_ID <= id diff --git a/kxkb/kxkbconfig.h b/kxkb/kxkbconfig.h index 140a2b763..4ec3634be 100644 --- a/kxkb/kxkbconfig.h +++ b/kxkb/kxkbconfig.h @@ -19,6 +19,8 @@ #include <tqptrqueue.h> #include <tqmap.h> +#include "layoutunit.h" + struct XkbOptions { TQString layouts; TQString variants; @@ -36,59 +38,6 @@ enum SwitchingPolicy { SWITCH_POLICY_COUNT = 3 }; - - -inline TQString createPair(TQString key, TQString value) -{ - if( value.isEmpty() ) - return key; - return TQString("%1(%2)").arg(key, value); -} - -struct LayoutUnit { - TQString layout; - TQString variant; - TQString displayName; - - LayoutUnit() {} - - LayoutUnit(TQString layout_, TQString variant_): - layout(layout_), - variant(variant_) - {} - - LayoutUnit(TQString pair) { - setFromPair( pair ); - } - - void setFromPair(const TQString& pair) { - layout = parseLayout(pair); - variant = parseVariant(pair); - } - - TQString toPair() const { - return createPair(layout, variant); - } - - bool operator<(const LayoutUnit& lu) const { - return layout<lu.layout || - (layout==lu.layout && variant<lu.variant); - } - - bool operator!=(const LayoutUnit& lu) const { - return layout!=lu.layout || variant!=lu.variant; - } - - bool operator==(const LayoutUnit& lu) const { -// kdDebug() << layout << "==" << lu.layout << "&&" << variant << "==" << lu.variant << endl; - return layout==lu.layout && variant==lu.variant; - } - -//private: - static const TQString parseLayout(const TQString &layvar); - static const TQString parseVariant(const TQString &layvar); -}; - extern const LayoutUnit DEFAULT_LAYOUT_UNIT; extern const char* DEFAULT_MODEL; diff --git a/kxkb/kxkbtraywindow.cpp b/kxkb/kxkbtraywindow.cpp index 46b03da15..d84c529c6 100644 --- a/kxkb/kxkbtraywindow.cpp +++ b/kxkb/kxkbtraywindow.cpp @@ -90,13 +90,15 @@ void KxkbLabelController::initLayoutList(const TQValueList<LayoutUnit>& layouts, const TQString layoutName = (*it).layout; const TQString variantName = (*it).variant; - const TQPixmap& layoutPixmap = LayoutIcon::getInstance().findPixmap(layoutName, PIXMAP_STYLE_CONTEXTMENU, (*it).displayName); - const TQPixmap pix = iconeffect.apply(layoutPixmap, TDEIcon::Small, TDEIcon::DefaultState); + const TQPixmap& layoutPixmap = LayoutIcon::getInstance().findPixmap( + (*it).layout, PIXMAP_STYLE_CONTEXTMENU, (*it).displayName); + const TQPixmap pix = iconeffect.apply(layoutPixmap, TDEIcon::Small, + TDEIcon::DefaultState); + + TQString fullName = rules.getLayoutName((*it)); + contextMenu->insertItem(pix, fullName, START_MENU_ID + cnt, + m_menuStartIndex + cnt); - TQString fullName = i18n((rules.layouts()[layoutName])); - if( variantName.isEmpty() == false ) - fullName += " (" + variantName + ")"; - contextMenu->insertItem(pix, fullName, START_MENU_ID + cnt, m_menuStartIndex + cnt); m_descriptionMap.insert((*it).toPair(), fullName); cnt++; diff --git a/kxkb/layoutunit.h b/kxkb/layoutunit.h new file mode 100644 index 000000000..f4d82f73f --- /dev/null +++ b/kxkb/layoutunit.h @@ -0,0 +1,64 @@ +// +// +// Author: Andriy Rysin <rysin@kde.org>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef _LAYOUTUNIT_H +#define _LAYOUTUNIT_H + +#include <tqstring.h> + +inline TQString createPair(TQString key, TQString value) +{ + if (value.isEmpty()) return key; + return TQString("%1(%2)").arg(key, value); +} + +struct LayoutUnit { + TQString layout; + TQString variant; + TQString displayName; + + LayoutUnit() {} + + LayoutUnit(TQString layout_, TQString variant_): + layout(layout_), + variant(variant_) + {} + + LayoutUnit(TQString pair) { + setFromPair( pair ); + } + + void setFromPair(const TQString& pair) { + layout = parseLayout(pair); + variant = parseVariant(pair); + } + + TQString toPair() const { + return createPair(layout, variant); + } + + bool operator<(const LayoutUnit& lu) const { + return layout<lu.layout || + (layout==lu.layout && variant<lu.variant); + } + + bool operator!=(const LayoutUnit& lu) const { + return layout!=lu.layout || variant!=lu.variant; + } + + bool operator==(const LayoutUnit& lu) const { +// kdDebug() << layout << "==" << lu.layout << "&&" << variant << "==" << lu.variant << endl; + return layout==lu.layout && variant==lu.variant; + } + +//private: + static const TQString parseLayout(const TQString &layvar); + static const TQString parseVariant(const TQString &layvar); +}; + +#endif // _LAYOUTUNIT_H
\ No newline at end of file diff --git a/kxkb/rules.cpp b/kxkb/rules.cpp index 37cdc9bc4..442a78c00 100644 --- a/kxkb/rules.cpp +++ b/kxkb/rules.cpp @@ -73,3 +73,10 @@ XkbRules::getAvailableVariants(const TQString& layout) return *result; } +TQString XkbRules::getLayoutName(LayoutUnit layout) const { + TQString fullName = i18n(m_layouts[layout.layout]); + if (!layout.variant.isEmpty()) { + fullName += " (" + layout.variant + ")"; + } + return fullName; +}
\ No newline at end of file diff --git a/kxkb/rules.h b/kxkb/rules.h index 38dd40fb6..e7a6e8840 100644 --- a/kxkb/rules.h +++ b/kxkb/rules.h @@ -5,6 +5,7 @@ #include <tqdict.h> #include <tqmap.h> +#include "layoutunit.h" class XkbRules { @@ -18,6 +19,8 @@ public: TQStringList getAvailableVariants(const TQString& layout); + TQString getLayoutName(LayoutUnit layout) const; + protected: void loadRules(TQString filename, bool layoutsOnly=false); |