Added customization options for Kxkb

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/202/head
Mavridis Philippe 3 years ago
parent bbdeb170a4
commit eff93621da
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -14,6 +14,8 @@
#include <tqbuttongroup.h> #include <tqbuttongroup.h>
#include <tqspinbox.h> #include <tqspinbox.h>
#include <tdefontrequester.h>
#include <kcolorbutton.h>
#include <kkeydialog.h> #include <kkeydialog.h>
#include <tdeglobal.h> #include <tdeglobal.h>
#include <tdeconfig.h> #include <tdeconfig.h>
@ -95,7 +97,7 @@ static TQListViewItem* copyLVI(const TQListViewItem* src, TQListView* parent)
LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) LayoutConfig::LayoutConfig(TQWidget *parent, const char *name)
: TDECModule(parent, name), : TDECModule(parent, name),
m_rules(NULL) m_rules(NULL)
{ {
TQVBoxLayout *main = new TQVBoxLayout(this, 0, KDialog::spacingHint()); TQVBoxLayout *main = new TQVBoxLayout(this, 0, KDialog::spacingHint());
@ -105,7 +107,7 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name)
connect( TQT_TQOBJECT(widget->chkEnable), TQT_SIGNAL( toggled( bool )), TQT_TQOBJECT(this), TQT_SLOT(changed())); connect( TQT_TQOBJECT(widget->chkEnable), TQT_SIGNAL( toggled( bool )), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( TQT_TQOBJECT(widget->chkShowSingle), TQT_SIGNAL( toggled( bool )), TQT_TQOBJECT(this), TQT_SLOT(changed())); connect( TQT_TQOBJECT(widget->chkShowSingle), TQT_SIGNAL( toggled( bool )), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( TQT_TQOBJECT(widget->chkShowFlag), TQT_SIGNAL( toggled( bool )), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( TQT_TQOBJECT(widget->comboModel), TQT_SIGNAL(activated(int)), TQT_TQOBJECT(this), TQT_SLOT(changed())); connect( TQT_TQOBJECT(widget->comboModel), TQT_SIGNAL(activated(int)), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( TQT_TQOBJECT(widget->listLayoutsSrc), TQT_SIGNAL(doubleClicked(TQListViewItem*,const TQPoint&, int)), connect( TQT_TQOBJECT(widget->listLayoutsSrc), TQT_SIGNAL(doubleClicked(TQListViewItem*,const TQPoint&, int)),
@ -130,7 +132,15 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name)
connect( widget->btnDown, TQT_SIGNAL(clicked()), TQT_TQOBJECT(this), TQT_SLOT(changed())); connect( widget->btnDown, TQT_SIGNAL(clicked()), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->btnDown, TQT_SIGNAL(clicked()), TQT_TQOBJECT(this), TQT_SLOT(moveDown())); connect( widget->btnDown, TQT_SIGNAL(clicked()), TQT_TQOBJECT(this), TQT_SLOT(moveDown()));
connect( widget->grpStyle, TQT_SIGNAL( clicked( int ) ), TQT_SLOT(changed()));
connect( widget->grpSwitching, TQT_SIGNAL( clicked( int ) ), TQT_SLOT(changed())); connect( widget->grpSwitching, TQT_SIGNAL( clicked( int ) ), TQT_SLOT(changed()));
connect( widget->grpLabel, TQT_SIGNAL( clicked( int ) ), TQT_SLOT(changed()));
connect( widget->bgColor, TQT_SIGNAL( changed(const TQColor&) ), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->fgColor, TQT_SIGNAL( changed(const TQColor&) ), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->labelFont, TQT_SIGNAL( fontSelected(const TQFont&) ), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->chkLabelShadow, TQT_SIGNAL( toggled( bool ) ), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->shColor, TQT_SIGNAL( changed(const TQColor&) ), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->chkEnableSticky, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(changed())); connect( widget->chkEnableSticky, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(changed()));
connect( widget->spinStickyDepth, TQT_SIGNAL(valueChanged(int)), TQT_TQOBJECT(this), TQT_SLOT(changed())); connect( widget->spinStickyDepth, TQT_SIGNAL(valueChanged(int)), TQT_TQOBJECT(this), TQT_SLOT(changed()));
@ -148,7 +158,7 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name)
widget->listLayoutsDst->setColumnWidthMode(LAYOUT_COLUMN_INCLUDE, TQListView::Manual); widget->listLayoutsDst->setColumnWidthMode(LAYOUT_COLUMN_INCLUDE, TQListView::Manual);
widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_INCLUDE, 0); widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_INCLUDE, 0);
// widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_DISPLAY_NAME, 0); // widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_DISPLAY_NAME, 0);
widget->listLayoutsDst->setSorting(-1); widget->listLayoutsDst->setSorting(-1);
#if 0 #if 0
widget->listLayoutsDst->setResizeMode(TQListView::LastColumn); widget->listLayoutsDst->setResizeMode(TQListView::LastColumn);
@ -177,12 +187,12 @@ void LayoutConfig::load()
initUI(); initUI();
} }
void LayoutConfig::initUI() { void LayoutConfig::initUI() {
const char* modelName = m_rules->models()[m_kxkbConfig.m_model]; const char* modelName = m_rules->models()[m_kxkbConfig.m_model];
if( modelName == NULL ) if( modelName == NULL )
modelName = DEFAULT_MODEL; modelName = DEFAULT_MODEL;
widget->comboModel->setCurrentText(i18n(modelName)); widget->comboModel->setCurrentText(i18n(modelName));
TQValueList<LayoutUnit> otherLayouts = m_kxkbConfig.m_layouts; TQValueList<LayoutUnit> otherLayouts = m_kxkbConfig.m_layouts;
@ -192,13 +202,13 @@ void LayoutConfig::initUI() {
for (it = otherLayouts.begin(); it != otherLayouts.end(); ++it ) { for (it = otherLayouts.begin(); it != otherLayouts.end(); ++it ) {
TQListViewItemIterator src_it( widget->listLayoutsSrc ); TQListViewItemIterator src_it( widget->listLayoutsSrc );
LayoutUnit layoutUnit = *it; LayoutUnit layoutUnit = *it;
for ( ; src_it.current(); ++src_it ) { for ( ; src_it.current(); ++src_it ) {
TQListViewItem* srcItem = src_it.current(); TQListViewItem* srcItem = src_it.current();
if ( layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP) ) { // check if current config knows about this layout if ( layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP) ) { // check if current config knows about this layout
TQListViewItem* newItem = copyLVI(srcItem, widget->listLayoutsDst); TQListViewItem* newItem = copyLVI(srcItem, widget->listLayoutsDst);
newItem->setText(LAYOUT_COLUMN_VARIANT, layoutUnit.variant); newItem->setText(LAYOUT_COLUMN_VARIANT, layoutUnit.variant);
newItem->setText(LAYOUT_COLUMN_INCLUDE, layoutUnit.includeGroup); newItem->setText(LAYOUT_COLUMN_INCLUDE, layoutUnit.includeGroup);
newItem->setText(LAYOUT_COLUMN_DISPLAY_NAME, layoutUnit.displayName); newItem->setText(LAYOUT_COLUMN_DISPLAY_NAME, layoutUnit.displayName);
@ -212,11 +222,23 @@ void LayoutConfig::initUI() {
// display KXKB switching options // display KXKB switching options
widget->chkShowSingle->setChecked(m_kxkbConfig.m_showSingle); widget->chkShowSingle->setChecked(m_kxkbConfig.m_showSingle);
widget->chkShowFlag->setChecked(m_kxkbConfig.m_showFlag);
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->chkEnableOptions->setChecked( m_kxkbConfig.m_enableXkbOptions );
widget->checkResetOld->setChecked(m_kxkbConfig.m_resetOldOptions); 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 );
switch( m_kxkbConfig.m_switchingPolicy ) { switch( m_kxkbConfig.m_switchingPolicy ) {
default: default:
case SWITCH_POLICY_GLOBAL: case SWITCH_POLICY_GLOBAL:
@ -248,7 +270,7 @@ void LayoutConfig::initUI() {
TQString optionKey = option.mid(0, option.find(':')); TQString optionKey = option.mid(0, option.find(':'));
TQString optionName = m_rules->options()[option]; TQString optionName = m_rules->options()[option];
OptionListItem *item = m_optionGroups[i18n(optionKey.latin1())]; OptionListItem *item = m_optionGroups[i18n(optionKey.latin1())];
if (item != NULL) { if (item != NULL) {
OptionListItem *child = item->findChildItem( option ); OptionListItem *child = item->findChildItem( option );
@ -274,7 +296,14 @@ void LayoutConfig::save()
m_kxkbConfig.m_enableXkbOptions = widget->chkEnableOptions->isChecked(); m_kxkbConfig.m_enableXkbOptions = widget->chkEnableOptions->isChecked();
m_kxkbConfig.m_resetOldOptions = widget->checkResetOld->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();
TQListViewItem *item = widget->listLayoutsDst->firstChild(); TQListViewItem *item = widget->listLayoutsDst->firstChild();
TQValueList<LayoutUnit> layouts; TQValueList<LayoutUnit> layouts;
@ -283,15 +312,15 @@ void LayoutConfig::save()
TQString variant = item->text(LAYOUT_COLUMN_VARIANT); TQString variant = item->text(LAYOUT_COLUMN_VARIANT);
TQString includes = item->text(LAYOUT_COLUMN_INCLUDE); TQString includes = item->text(LAYOUT_COLUMN_INCLUDE);
TQString displayName = item->text(LAYOUT_COLUMN_DISPLAY_NAME); TQString displayName = item->text(LAYOUT_COLUMN_DISPLAY_NAME);
LayoutUnit layoutUnit(layout, variant); LayoutUnit layoutUnit(layout, variant);
layoutUnit.includeGroup = includes; layoutUnit.includeGroup = includes;
layoutUnit.displayName = displayName; layoutUnit.displayName = displayName;
layouts.append( layoutUnit ); layouts.append( layoutUnit );
item = item->nextSibling(); item = item->nextSibling();
kdDebug() << "To save: layout " << layoutUnit.toPair() kdDebug() << "To save: layout " << layoutUnit.toPair()
<< ", inc: " << layoutUnit.includeGroup << ", inc: " << layoutUnit.includeGroup
<< ", disp: " << layoutUnit.displayName << endl; << ", disp: " << layoutUnit.displayName << endl;
} }
m_kxkbConfig.m_layouts = layouts; m_kxkbConfig.m_layouts = layouts;
@ -303,7 +332,9 @@ void LayoutConfig::save()
m_kxkbConfig.m_useKxkb = widget->chkEnable->isChecked(); m_kxkbConfig.m_useKxkb = widget->chkEnable->isChecked();
m_kxkbConfig.m_showSingle = widget->chkShowSingle->isChecked(); m_kxkbConfig.m_showSingle = widget->chkShowSingle->isChecked();
m_kxkbConfig.m_showFlag = widget->chkShowFlag->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()); int modeId = widget->grpSwitching->id(widget->grpSwitching->selected());
switch( modeId ) { switch( modeId ) {
@ -323,7 +354,7 @@ void LayoutConfig::save()
m_kxkbConfig.m_stickySwitchingDepth = widget->spinStickyDepth->value(); m_kxkbConfig.m_stickySwitchingDepth = widget->spinStickyDepth->value();
m_kxkbConfig.save(); m_kxkbConfig.save();
kapp->tdeinitExec("kxkb"); kapp->tdeinitExec("kxkb");
emit TDECModule::changed( false ); emit TDECModule::changed( false );
} }
@ -347,11 +378,11 @@ void LayoutConfig::updateStickyLimit()
{ {
int layoutsCnt = widget->listLayoutsDst->childCount(); int layoutsCnt = widget->listLayoutsDst->childCount();
int maxDepth = layoutsCnt - 1; int maxDepth = layoutsCnt - 1;
if( maxDepth < 2 ) { if( maxDepth < 2 ) {
maxDepth = 2; maxDepth = 2;
} }
widget->spinStickyDepth->setMaxValue(maxDepth); widget->spinStickyDepth->setMaxValue(maxDepth);
/* if( value > maxDepth ) /* if( value > maxDepth )
setValue(maxDepth);*/ setValue(maxDepth);*/
@ -366,7 +397,7 @@ void LayoutConfig::add()
// Create a copy of the sel widget, as one might add the same layout more // Create a copy of the sel widget, as one might add the same layout more
// than one time, with different variants. // than one time, with different variants.
TQListViewItem* toadd = copyLVI(sel, widget->listLayoutsDst); TQListViewItem* toadd = copyLVI(sel, widget->listLayoutsDst);
// Turn on "Include Latin layout" for new language by default (bnc:204402) // Turn on "Include Latin layout" for new language by default (bnc:204402)
toadd->setText(LAYOUT_COLUMN_INCLUDE, "us"); toadd->setText(LAYOUT_COLUMN_INCLUDE, "us");
@ -376,12 +407,12 @@ void LayoutConfig::add()
// disabling temporary: does not work reliable in Qt :( // disabling temporary: does not work reliable in Qt :(
// widget->listLayoutsDst->setSelected(sel, true); // widget->listLayoutsDst->setSelected(sel, true);
// layoutSelChanged(sel); // layoutSelChanged(sel);
updateStickyLimit(); updateStickyLimit();
changed(); changed();
} }
void LayoutConfig::remove() void LayoutConfig::remove()
{ {
TQListViewItem* sel = widget->listLayoutsDst->selectedItem(); TQListViewItem* sel = widget->listLayoutsDst->selectedItem();
TQListViewItem* newSel = 0; TQListViewItem* newSel = 0;
@ -456,15 +487,15 @@ void LayoutConfig::displayNameChanged(const TQString& newDisplayName)
TQListViewItem* selLayout = widget->listLayoutsDst->selectedItem(); TQListViewItem* selLayout = widget->listLayoutsDst->selectedItem();
if( selLayout == NULL ) if( selLayout == NULL )
return; return;
const LayoutUnit layoutUnitKey = getLayoutUnitKey( selLayout ); const LayoutUnit layoutUnitKey = getLayoutUnitKey( selLayout );
LayoutUnit& layoutUnit = *m_kxkbConfig.m_layouts.find(layoutUnitKey); LayoutUnit& layoutUnit = *m_kxkbConfig.m_layouts.find(layoutUnitKey);
TQString oldName = selLayout->text(LAYOUT_COLUMN_DISPLAY_NAME); TQString oldName = selLayout->text(LAYOUT_COLUMN_DISPLAY_NAME);
if( oldName.isEmpty() ) if( oldName.isEmpty() )
oldName = KxkbConfig::getDefaultDisplayName( layoutUnit ); oldName = KxkbConfig::getDefaultDisplayName( layoutUnit );
if( oldName != newDisplayName ) { if( oldName != newDisplayName ) {
kdDebug() << "setting label for " << layoutUnit.toPair() << " : " << newDisplayName << endl; kdDebug() << "setting label for " << layoutUnit.toPair() << " : " << newDisplayName << endl;
selLayout->setText(LAYOUT_COLUMN_DISPLAY_NAME, newDisplayName); selLayout->setText(LAYOUT_COLUMN_DISPLAY_NAME, newDisplayName);
@ -517,7 +548,7 @@ void LayoutConfig::layoutSelChanged(TQListViewItem *sel)
TQString kbdLayout = layoutUnitKey.layout; TQString kbdLayout = layoutUnitKey.layout;
// TODO: need better algorithm here for determining if needs us group // TODO: need better algorithm here for determining if needs us group
if ( ! m_rules->isSingleGroup(kbdLayout) if ( ! m_rules->isSingleGroup(kbdLayout)
|| kbdLayout.startsWith("us") || kbdLayout.startsWith("en") ) { || kbdLayout.startsWith("us") || kbdLayout.startsWith("en") ) {
widget->chkLatin->setEnabled( false ); widget->chkLatin->setEnabled( false );
} }
@ -533,11 +564,11 @@ void LayoutConfig::layoutSelChanged(TQListViewItem *sel)
TQStringList vars = m_rules->getAvailableVariants(kbdLayout); TQStringList vars = m_rules->getAvailableVariants(kbdLayout);
kdDebug() << "layout " << kbdLayout << " has " << vars.count() << " variants" << endl; kdDebug() << "layout " << kbdLayout << " has " << vars.count() << " variants" << endl;
if( vars.count() > 0 ) { if( vars.count() > 0 ) {
vars.prepend(DEFAULT_VARIANT_NAME); vars.prepend(DEFAULT_VARIANT_NAME);
widget->comboVariant->insertStringList(vars); widget->comboVariant->insertStringList(vars);
TQString variant = sel->text(LAYOUT_COLUMN_VARIANT); TQString variant = sel->text(LAYOUT_COLUMN_VARIANT);
if( variant != NULL && variant.isEmpty() == false ) { if( variant != NULL && variant.isEmpty() == false ) {
widget->comboVariant->setCurrentText(variant); widget->comboVariant->setCurrentText(variant);
@ -668,7 +699,7 @@ void LayoutConfig::updateLayoutCommand()
layoutDisplayName = m_kxkbConfig.getDefaultDisplayName(LayoutUnit(kbdLayout, variant), single); layoutDisplayName = m_kxkbConfig.getDefaultDisplayName(LayoutUnit(kbdLayout, variant), single);
} }
kdDebug() << "disp: '" << layoutDisplayName << "'" << endl; kdDebug() << "disp: '" << layoutDisplayName << "'" << endl;
if( !variant.isEmpty() ) { if( !variant.isEmpty() ) {
setxkbmap += " -variant "; setxkbmap += " -variant ";
if( widget->chkLatin->isChecked() ) if( widget->chkLatin->isChecked() )
@ -676,9 +707,9 @@ void LayoutConfig::updateLayoutCommand()
setxkbmap += variant; setxkbmap += variant;
} }
} }
widget->editCmdLine->setText(setxkbmap); widget->editCmdLine->setText(setxkbmap);
widget->editDisplayName->setEnabled( sel != NULL ); widget->editDisplayName->setEnabled( sel != NULL );
widget->editDisplayName->setText(layoutDisplayName); widget->editDisplayName->setText(layoutDisplayName);
} }
@ -704,7 +735,7 @@ void LayoutConfig::loadRules()
++it; ++it;
} }
modelsList.sort(); modelsList.sort();
widget->comboModel->clear(); widget->comboModel->clear();
widget->comboModel->insertStringList(modelsList); widget->comboModel->insertStringList(modelsList);
widget->comboModel->setCurrentItem(0); widget->comboModel->setCurrentItem(0);
@ -713,20 +744,20 @@ void LayoutConfig::loadRules()
widget->listLayoutsSrc->clear(); widget->listLayoutsSrc->clear();
widget->listLayoutsDst->clear(); widget->listLayoutsDst->clear();
TQDictIterator<char> it2(m_rules->layouts()); TQDictIterator<char> it2(m_rules->layouts());
while (it2.current()) while (it2.current())
{ {
TQString layout = it2.currentKey(); TQString layout = it2.currentKey();
TQString layoutName = it2.current(); TQString layoutName = it2.current();
TQListViewItem *item = new TQListViewItem(widget->listLayoutsSrc); TQListViewItem *item = new TQListViewItem(widget->listLayoutsSrc);
item->setPixmap(LAYOUT_COLUMN_FLAG, LayoutIcon::getInstance().findPixmap(layout, true)); item->setPixmap(LAYOUT_COLUMN_FLAG, LayoutIcon::getInstance().findPixmap(layout, false));
item->setText(LAYOUT_COLUMN_NAME, i18n(layoutName.latin1())); item->setText(LAYOUT_COLUMN_NAME, i18n(layoutName.latin1()));
item->setText(LAYOUT_COLUMN_MAP, layout); item->setText(LAYOUT_COLUMN_MAP, layout);
++it2; ++it2;
} }
widget->listLayoutsSrc->setSorting(LAYOUT_COLUMN_NAME); // from Qt3 TQListView sorts by language widget->listLayoutsSrc->setSorting(LAYOUT_COLUMN_NAME); // from Qt3 TQListView sorts by language
//TODO: reset options and xkb options //TODO: reset options and xkb options
} }
@ -813,19 +844,19 @@ extern "C"
{ {
return new LayoutConfig(parent, "kcmlayout"); return new LayoutConfig(parent, "kcmlayout");
} }
KDE_EXPORT TDECModule *create_keyboard(TQWidget *parent, const char *) KDE_EXPORT TDECModule *create_keyboard(TQWidget *parent, const char *)
{ {
return new KeyboardConfig(parent, "kcmlayout"); return new KeyboardConfig(parent, "kcmlayout");
} }
KDE_EXPORT void init_keyboard() KDE_EXPORT void init_keyboard()
{ {
KeyboardConfig::init_keyboard(); KeyboardConfig::init_keyboard();
KxkbConfig m_kxkbConfig; KxkbConfig m_kxkbConfig;
m_kxkbConfig.load(KxkbConfig::LOAD_INIT_OPTIONS); m_kxkbConfig.load(KxkbConfig::LOAD_INIT_OPTIONS);
if( m_kxkbConfig.m_useKxkb == true ) { if( m_kxkbConfig.m_useKxkb == true ) {
kapp->startServiceByDesktopName("kxkb"); kapp->startServiceByDesktopName("kxkb");
} }
@ -916,7 +947,7 @@ extern "C"
I18N_NOOP( "Left Alt key changes group" ); I18N_NOOP( "Left Alt key changes group" );
I18N_NOOP( "Left Ctrl key changes group" ); I18N_NOOP( "Left Ctrl key changes group" );
I18N_NOOP( "Compose Key" ); I18N_NOOP( "Compose Key" );
//these seem to be new in XFree86 4.4.0 //these seem to be new in XFree86 4.4.0
I18N_NOOP("Shift with numpad keys works as in MS Windows."); I18N_NOOP("Shift with numpad keys works as in MS Windows.");
I18N_NOOP("Special keys (Ctrl+Alt+<key>) handled in a server."); I18N_NOOP("Special keys (Ctrl+Alt+<key>) handled in a server.");

@ -466,6 +466,214 @@
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="TQButtonGroup" row="1" column="0">
<property name="name">
<cstring>grpStyle</cstring>
</property>
<property name="title">
<string>Indicator Style</string>
</property>
<property name="exclusive">
<bool>true</bool>
</property>
<property name="whatsThis" stdset="0">
<string>Here you can choose the way your keyboard layout indicator will look.</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQRadioButton">
<property name="name">
<cstring>radFlagLabel</cstring>
</property>
<property name="text">
<string>&amp;Both Flag and Label</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="TQRadioButton">
<property name="name">
<cstring>radFlagOnly</cstring>
</property>
<property name="text">
<string>&amp;Flag Only</string>
</property>
</widget>
<widget class="TQRadioButton">
<property name="name">
<cstring>radLabelOnly</cstring>
</property>
<property name="text">
<string>&amp;Label Only</string>
</property>
</widget>
</vbox>
</widget>
<widget class="TQButtonGroup" row="1" column="1">
<property name="name">
<cstring>grpLabel</cstring>
</property>
<property name="title">
<string>Label Style</string>
</property>
<property name="whatsThis" stdset="0">
<string>Here you can choose the way the label of your keyboard layout indicator will be displayed. These options are relevant even when labels are disabled, for locales where the flag is missing.</string>
</property>
<grid>
<widget class="TQRadioButton" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>radLabelUseTheme</cstring>
</property>
<property name="text">
<string>Use &amp;theme colors</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="TQRadioButton" row="1" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>radLabelUseCustom</cstring>
</property>
<property name="text">
<string>Use c&amp;ustom colors</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<spacer row="2" 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="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>
</widget>
<widget class="KColorButton" row="2" 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>
<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>
</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>
<property name="enabled">
<bool>false</bool>
</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">
<property name="name">
<cstring>separator1</cstring>
</property>
</widget>
<widget class="TQLabel" row="5" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>labelFontRequester</cstring>
</property>
<property name="text">
<string>Label font:</string>
</property>
<property name="whatsThis" stdset="0">
<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">
<property name="name">
<cstring>labelFont</cstring>
</property>
</widget>
<widget class="TQCheckBox" row="6" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>chkLabelShadow</cstring>
</property>
<property name="text">
<string>Enable shadow</string>
</property>
<property name="whatsThis" stdset="0">
<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">
<property name="name">
<cstring>shColor</cstring>
</property>
<property name="whatsThis" stdset="0">
<string>The drop shadow behind the language label will be of this color.</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</grid>
</widget>
<widget class="TQButtonGroup" row="2" column="0"> <widget class="TQButtonGroup" row="2" column="0">
<property name="name"> <property name="name">
<cstring>grpSwitching</cstring> <cstring>grpSwitching</cstring>
@ -512,20 +720,6 @@
</widget> </widget>
</vbox> </vbox>
</widget> </widget>
<widget class="TQCheckBox" row="1" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>chkShowFlag</cstring>
</property>
<property name="text">
<string>Show country flag</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="whatsThis" stdset="0">
<string>Shows country flag on background of layout name in tray icon</string>
</property>
</widget>
<widget class="TQGroupBox" row="2" column="1"> <widget class="TQGroupBox" row="2" column="1">
<property name="name"> <property name="name">
<cstring>grpBoxStickySwitching</cstring> <cstring>grpBoxStickySwitching</cstring>
@ -537,7 +731,7 @@
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="TQCheckBox" row="0" column="0" rowspan="1" colspan="2"> <widget class="TQCheckBox" row="0" column="0" rowspan="1" colspan="3">
<property name="name"> <property name="name">
<cstring>chkEnableSticky</cstring> <cstring>chkEnableSticky</cstring>
</property> </property>
@ -548,7 +742,24 @@
<string>If you have more than two layouts and turn this option on, switching with the keyboard shortcut or clicking on the kxkb indicator will only cycle through the last few layouts. You can specify the number of layouts to rotate below. You can still access all layouts by right-clicking on the kxkb indicator.</string> <string>If you have more than two layouts and turn this option on, switching with the keyboard shortcut or clicking on the kxkb indicator will only cycle through the last few layouts. You can specify the number of layouts to rotate below. You can still access all layouts by right-clicking on the kxkb indicator.</string>
</property> </property>
</widget> </widget>
<widget class="TQLabel" row="1" column="0"> <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"> <property name="name">
<cstring>textLabel1_5</cstring> <cstring>textLabel1_5</cstring>
</property> </property>
@ -562,7 +773,7 @@
<cstring>spinBox1</cstring> <cstring>spinBox1</cstring>
</property> </property>
</widget> </widget>
<widget class="TQSpinBox" row="1" column="1"> <widget class="TQSpinBox" row="1" column="2">
<property name="name"> <property name="name">
<cstring>spinStickyDepth</cstring> <cstring>spinStickyDepth</cstring>
</property> </property>
@ -575,6 +786,14 @@
<property name="minValue"> <property name="minValue">
<number>2</number> <number>2</number>
</property> </property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget> </widget>
</grid> </grid>
</widget> </widget>
@ -698,6 +917,36 @@
<receiver>textLabel1_5</receiver> <receiver>textLabel1_5</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
</connection> </connection>
<connection>
<sender>radLabelUseCustom</sender>
<signal>toggled(bool)</signal>
<receiver>bgColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>radLabelUseCustom</sender>
<signal>toggled(bool)</signal>
<receiver>fgColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>radLabelUseCustom</sender>
<signal>toggled(bool)</signal>
<receiver>labelBgColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>radLabelUseCustom</sender>
<signal>toggled(bool)</signal>
<receiver>labelFgColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>chkLabelShadow</sender>
<signal>toggled(bool)</signal>
<receiver>shColor</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection> <connection>
<sender>chkEnable</sender> <sender>chkEnable</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
@ -708,6 +957,9 @@
<includes> <includes>
<include location="local" impldecl="in implementation">kiconloader.h</include> <include location="local" impldecl="in implementation">kiconloader.h</include>
<include location="local" impldecl="in implementation">kdialogbase.h</include> <include location="local" impldecl="in implementation">kdialogbase.h</include>
<include location="local" impldecl="in implementation">kcolorbutton.h</include>
<include location="local" impldecl="in implementation">kseparator.h</include>
<include location="local" impldecl="in implementation">tdefontrequester.h</include>
</includes> </includes>
<pixmapfunction>SmallIcon</pixmapfunction> <pixmapfunction>SmallIcon</pixmapfunction>
<layoutdefaults spacing="6" margin="11"/> <layoutdefaults spacing="6" margin="11"/>

@ -1,7 +1,7 @@
// //
// C++ Implementation: kxkbconfig // C++ Implementation: kxkbconfig
// //
// Description: // Description:
// //
// //
// Author: Andriy Rysin <rysin@kde.org>, (C) 2006 // Author: Andriy Rysin <rysin@kde.org>, (C) 2006
@ -34,11 +34,11 @@ LayoutUnit KxkbConfig::getDefaultLayout()
{ {
if( m_layouts.size() == 0 ) if( m_layouts.size() == 0 )
return DEFAULT_LAYOUT_UNIT; return DEFAULT_LAYOUT_UNIT;
return m_layouts[0]; return m_layouts[0];
} }
bool KxkbConfig::load(int loadMode) bool KxkbConfig::load(int loadMode)
{ {
TDEConfig *config = new TDEConfig("kxkbrc", true, false); TDEConfig *config = new TDEConfig("kxkbrc", true, false);
config->setGroup("Layout"); config->setGroup("Layout");
@ -46,13 +46,13 @@ bool KxkbConfig::load(int loadMode)
// Even if the layouts have been disabled we still want to set Xkb options // Even if the layouts have been disabled we still want to set Xkb options
// user can always switch them off now in the "Options" tab // user can always switch them off now in the "Options" tab
m_enableXkbOptions = config->readBoolEntry("EnableXkbOptions", false); m_enableXkbOptions = config->readBoolEntry("EnableXkbOptions", false);
if( m_enableXkbOptions == true || loadMode == LOAD_ALL ) { if( m_enableXkbOptions == true || loadMode == LOAD_ALL ) {
m_resetOldOptions = config->readBoolEntry("ResetOldOptions", false); m_resetOldOptions = config->readBoolEntry("ResetOldOptions", false);
m_options = config->readEntry("Options", ""); m_options = config->readEntry("Options", "");
kdDebug() << "Xkb options (enabled=" << m_enableXkbOptions << "): " << m_options << endl; kdDebug() << "Xkb options (enabled=" << m_enableXkbOptions << "): " << m_options << endl;
} }
m_useKxkb = config->readBoolEntry("Use", false); m_useKxkb = config->readBoolEntry("Use", false);
kdDebug() << "Use kxkb " << m_useKxkb << endl; kdDebug() << "Use kxkb " << m_useKxkb << endl;
@ -62,7 +62,7 @@ bool KxkbConfig::load(int loadMode)
m_model = config->readEntry("Model", DEFAULT_MODEL); m_model = config->readEntry("Model", DEFAULT_MODEL);
kdDebug() << "Model: " << m_model << endl; kdDebug() << "Model: " << m_model << endl;
TQStringList layoutList; TQStringList layoutList;
if( config->hasKey("LayoutList") ) { if( config->hasKey("LayoutList") ) {
layoutList = config->readListEntry("LayoutList"); layoutList = config->readListEntry("LayoutList");
@ -74,7 +74,7 @@ bool KxkbConfig::load(int loadMode)
} }
if( layoutList.count() == 0 ) if( layoutList.count() == 0 )
layoutList.append("us"); layoutList.append("us");
m_layouts.clear(); m_layouts.clear();
for(TQStringList::ConstIterator it = layoutList.begin(); it != layoutList.end() ; ++it) { for(TQStringList::ConstIterator it = layoutList.begin(); it != layoutList.end() ; ++it) {
m_layouts.append( LayoutUnit(*it) ); m_layouts.append( LayoutUnit(*it) );
@ -82,7 +82,7 @@ bool KxkbConfig::load(int loadMode)
} }
kdDebug() << "Found " << m_layouts.count() << " layouts, default is " << getDefaultLayout().toPair() << endl; kdDebug() << "Found " << m_layouts.count() << " layouts, default is " << getDefaultLayout().toPair() << endl;
TQStringList displayNamesList = config->readListEntry("DisplayNames", ','); TQStringList displayNamesList = config->readListEntry("DisplayNames", ',');
for(TQStringList::ConstIterator it = displayNamesList.begin(); it != displayNamesList.end() ; ++it) { for(TQStringList::ConstIterator it = displayNamesList.begin(); it != displayNamesList.end() ; ++it) {
TQStringList displayNamePair = TQStringList::split(':', *it ); TQStringList displayNamePair = TQStringList::split(':', *it );
@ -127,7 +127,15 @@ bool KxkbConfig::load(int loadMode)
m_showSingle = config->readBoolEntry("ShowSingle", false); m_showSingle = config->readBoolEntry("ShowSingle", false);
m_showFlag = config->readBoolEntry("ShowFlag", true); m_showFlag = config->readBoolEntry("ShowFlag", true);
m_showLabel = config->readBoolEntry("ShowLabel", true);
m_useThemeColors = config->readBoolEntry("UseThemeColors", false);
m_colorBackground = config->readColorEntry("ColorBackground", new TQColor(TQt::gray));
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);
m_colorShadow = config->readColorEntry("ColorShadow", new TQColor(TQt::black));
TQString layoutOwner = config->readEntry("SwitchMode", "Global"); TQString layoutOwner = config->readEntry("SwitchMode", "Global");
if( layoutOwner == "WinClass" ) { if( layoutOwner == "WinClass" ) {
@ -139,14 +147,14 @@ bool KxkbConfig::load(int loadMode)
else /*if( layoutOwner == "Global" )*/ { else /*if( layoutOwner == "Global" )*/ {
m_switchingPolicy = SWITCH_POLICY_GLOBAL; m_switchingPolicy = SWITCH_POLICY_GLOBAL;
} }
if( m_layouts.count() < 2 && m_switchingPolicy != SWITCH_POLICY_GLOBAL ) { if( m_layouts.count() < 2 && m_switchingPolicy != SWITCH_POLICY_GLOBAL ) {
kdWarning() << "Layout count is less than 2, using Global switching policy" << endl; kdWarning() << "Layout count is less than 2, using Global switching policy" << endl;
m_switchingPolicy = SWITCH_POLICY_GLOBAL; m_switchingPolicy = SWITCH_POLICY_GLOBAL;
} }
kdDebug() << "Layout owner mode " << layoutOwner << endl; kdDebug() << "Layout owner mode " << layoutOwner << endl;
m_stickySwitching = config->readBoolEntry("StickySwitching", false); m_stickySwitching = config->readBoolEntry("StickySwitching", false);
m_stickySwitchingDepth = config->readEntry("StickySwitchingDepth", "2").toInt(); m_stickySwitchingDepth = config->readEntry("StickySwitchingDepth", "2").toInt();
if( m_stickySwitchingDepth < 2 ) if( m_stickySwitchingDepth < 2 )
@ -157,7 +165,7 @@ bool KxkbConfig::load(int loadMode)
kdWarning() << "Layout count is less than 3, sticky switching will be off" << endl; kdWarning() << "Layout count is less than 3, sticky switching will be off" << endl;
m_stickySwitching = false; m_stickySwitching = false;
} }
else else
if( (int)m_layouts.count() - 1 < m_stickySwitchingDepth ) { if( (int)m_layouts.count() - 1 < m_stickySwitchingDepth ) {
kdWarning() << "Sticky switching depth is more than layout count -1, adjusting..." << endl; kdWarning() << "Sticky switching depth is more than layout count -1, adjusting..." << endl;
m_stickySwitchingDepth = m_layouts.count() - 1; m_stickySwitchingDepth = m_layouts.count() - 1;
@ -169,7 +177,7 @@ bool KxkbConfig::load(int loadMode)
return true; return true;
} }
void KxkbConfig::save() void KxkbConfig::save()
{ {
TDEConfig *config = new TDEConfig("kxkbrc", false, false); TDEConfig *config = new TDEConfig("kxkbrc", false, false);
config->setGroup("Layout"); config->setGroup("Layout");
@ -183,18 +191,18 @@ void KxkbConfig::save()
TQStringList layoutList; TQStringList layoutList;
TQStringList includeList; TQStringList includeList;
TQStringList displayNamesList; TQStringList displayNamesList;
TQValueList<LayoutUnit>::ConstIterator it; TQValueList<LayoutUnit>::ConstIterator it;
for(it = m_layouts.begin(); it != m_layouts.end(); ++it) { for(it = m_layouts.begin(); it != m_layouts.end(); ++it) {
const LayoutUnit& layoutUnit = *it; const LayoutUnit& layoutUnit = *it;
layoutList.append( layoutUnit.toPair() ); layoutList.append( layoutUnit.toPair() );
if( layoutUnit.includeGroup.isEmpty() == false ) { if( layoutUnit.includeGroup.isEmpty() == false ) {
TQString incGroupUnit = TQString("%1:%2").arg(layoutUnit.toPair(), layoutUnit.includeGroup); TQString incGroupUnit = TQString("%1:%2").arg(layoutUnit.toPair(), layoutUnit.includeGroup);
includeList.append( incGroupUnit ); includeList.append( incGroupUnit );
} }
TQString displayName( layoutUnit.displayName ); TQString displayName( layoutUnit.displayName );
kdDebug() << " displayName " << layoutUnit.toPair() << " : " << displayName << endl; kdDebug() << " displayName " << layoutUnit.toPair() << " : " << displayName << endl;
if( displayName.isEmpty() == false && displayName != layoutUnit.layout ) { if( displayName.isEmpty() == false && displayName != layoutUnit.layout ) {
@ -202,13 +210,13 @@ void KxkbConfig::save()
displayNamesList.append( displayName ); displayNamesList.append( displayName );
} }
} }
config->writeEntry("LayoutList", layoutList); config->writeEntry("LayoutList", layoutList);
kdDebug() << "Saving Layouts: " << layoutList << endl; kdDebug() << "Saving Layouts: " << layoutList << endl;
config->writeEntry("IncludeGroups", includeList); config->writeEntry("IncludeGroups", includeList);
kdDebug() << "Saving includeGroups: " << includeList << endl; kdDebug() << "Saving includeGroups: " << includeList << endl;
// if( displayNamesList.empty() == false ) // if( displayNamesList.empty() == false )
config->writeEntry("DisplayNames", displayNamesList); config->writeEntry("DisplayNames", displayNamesList);
// else // else
@ -216,21 +224,30 @@ void KxkbConfig::save()
config->writeEntry("Use", m_useKxkb); config->writeEntry("Use", m_useKxkb);
config->writeEntry("ShowSingle", m_showSingle); config->writeEntry("ShowSingle", m_showSingle);
config->writeEntry("ShowFlag", m_showFlag); config->writeEntry("ShowFlag", m_showFlag);
config->writeEntry("ShowLabel", m_showLabel);
config->writeEntry("UseThemeColors", m_useThemeColors);
config->writeEntry("ColorBackground", m_colorBackground);
config->writeEntry("ColorLabel", m_colorLabel);
config->writeEntry("LabelFont", m_labelFont);
config->writeEntry("LabelShadow", m_labelShadow);
config->writeEntry("ColorShadow", m_colorShadow);
config->writeEntry("SwitchMode", switchModes[m_switchingPolicy]); config->writeEntry("SwitchMode", switchModes[m_switchingPolicy]);
config->writeEntry("StickySwitching", m_stickySwitching); config->writeEntry("StickySwitching", m_stickySwitching);
config->writeEntry("StickySwitchingDepth", m_stickySwitchingDepth); config->writeEntry("StickySwitchingDepth", m_stickySwitchingDepth);
// remove old options // remove old options
config->deleteEntry("Variants"); config->deleteEntry("Variants");
config->deleteEntry("Includes"); config->deleteEntry("Includes");
config->deleteEntry("Encoding"); config->deleteEntry("Encoding");
config->deleteEntry("AdditionalEncodings"); config->deleteEntry("AdditionalEncodings");
config->deleteEntry("Additional"); config->deleteEntry("Additional");
config->deleteEntry("Layout"); config->deleteEntry("Layout");
config->sync(); config->sync();
delete config; delete config;
@ -252,7 +269,7 @@ void KxkbConfig::setDefaults()
m_showFlag = true; m_showFlag = true;
m_switchingPolicy = SWITCH_POLICY_GLOBAL; m_switchingPolicy = SWITCH_POLICY_GLOBAL;
m_stickySwitching = false; m_stickySwitching = false;
m_stickySwitchingDepth = 2; m_stickySwitchingDepth = 2;
} }
@ -271,7 +288,7 @@ TQStringList KxkbConfig::getLayoutStringList(/*bool compact*/)
TQString KxkbConfig::getDefaultDisplayName(const TQString& code_) TQString KxkbConfig::getDefaultDisplayName(const TQString& code_)
{ {
TQString displayName; TQString displayName;
if( code_.length() <= 2 ) { if( code_.length() <= 2 ) {
displayName = code_; displayName = code_;
} }
@ -281,13 +298,13 @@ TQString KxkbConfig::getDefaultDisplayName(const TQString& code_)
TQString rightCode; TQString rightCode;
if( sepPos != -1 ) if( sepPos != -1 )
rightCode = code_.mid(sepPos+1); rightCode = code_.mid(sepPos+1);
if( rightCode.length() > 0 ) if( rightCode.length() > 0 )
displayName = leftCode.left(2) + rightCode.left(1).lower(); displayName = leftCode.left(2) + rightCode.left(1).lower();
else else
displayName = leftCode.left(3); displayName = leftCode.left(3);
} }
return displayName; return displayName;
} }
@ -295,7 +312,7 @@ TQString KxkbConfig::getDefaultDisplayName(const LayoutUnit& layoutUnit, bool si
{ {
if( layoutUnit.variant == "" ) if( layoutUnit.variant == "" )
return getDefaultDisplayName( layoutUnit.layout ); return getDefaultDisplayName( layoutUnit.layout );
TQString displayName = layoutUnit.layout.left(2); TQString displayName = layoutUnit.layout.left(2);
if( single == false ) if( single == false )
displayName += layoutUnit.variant.left(1); displayName += layoutUnit.variant.left(1);

@ -1,7 +1,7 @@
// //
// C++ Interface: kxkbconfig // C++ Interface: kxkbconfig
// //
// Description: // Description:
// //
// //
// Author: Andriy Rysin <rysin@kde.org>, (C) 2006 // Author: Andriy Rysin <rysin@kde.org>, (C) 2006
@ -14,13 +14,15 @@
#include <tqstring.h> #include <tqstring.h>
#include <tqstringlist.h> #include <tqstringlist.h>
#include <tqcolor.h>
#include <tqfont.h>
#include <tqptrqueue.h> #include <tqptrqueue.h>
#include <tqmap.h> #include <tqmap.h>
/* Utility classes for per-window/per-application layout implementation /* Utility classes for per-window/per-application layout implementation
*/ */
enum SwitchingPolicy { enum SwitchingPolicy {
SWITCH_POLICY_GLOBAL = 0, SWITCH_POLICY_GLOBAL = 0,
SWITCH_POLICY_WIN_CLASS = 1, SWITCH_POLICY_WIN_CLASS = 1,
SWITCH_POLICY_WINDOW = 2, SWITCH_POLICY_WINDOW = 2,
@ -29,12 +31,12 @@ enum SwitchingPolicy {
inline TQString createPair(TQString key, TQString value) inline TQString createPair(TQString key, TQString value)
{ {
if( value.isEmpty() ) if( value.isEmpty() )
return key; return key;
return TQString("%1(%2)").arg(key, value); return TQString("%1(%2)").arg(key, value);
} }
struct LayoutUnit { struct LayoutUnit {
TQString layout; TQString layout;
@ -42,41 +44,41 @@ struct LayoutUnit {
TQString includeGroup; TQString includeGroup;
TQString displayName; TQString displayName;
int defaultGroup; int defaultGroup;
LayoutUnit() {} LayoutUnit() {}
LayoutUnit(TQString layout_, TQString variant_): LayoutUnit(TQString layout_, TQString variant_):
layout(layout_), layout(layout_),
variant(variant_) variant(variant_)
{} {}
LayoutUnit(TQString pair) { LayoutUnit(TQString pair) {
setFromPair( pair ); setFromPair( pair );
} }
void setFromPair(const TQString& pair) { void setFromPair(const TQString& pair) {
layout = parseLayout(pair); layout = parseLayout(pair);
variant = parseVariant(pair); variant = parseVariant(pair);
} }
TQString toPair() const { TQString toPair() const {
return createPair(layout, variant); return createPair(layout, variant);
} }
bool operator<(const LayoutUnit& lu) const { bool operator<(const LayoutUnit& lu) const {
return layout<lu.layout || return layout<lu.layout ||
(layout==lu.layout && variant<lu.variant); (layout==lu.layout && variant<lu.variant);
} }
bool operator!=(const LayoutUnit& lu) const { bool operator!=(const LayoutUnit& lu) const {
return layout!=lu.layout || variant!=lu.variant; return layout!=lu.layout || variant!=lu.variant;
} }
bool operator==(const LayoutUnit& lu) const { bool operator==(const LayoutUnit& lu) const {
// kdDebug() << layout << "==" << lu.layout << "&&" << variant << "==" << lu.variant << endl; // kdDebug() << layout << "==" << lu.layout << "&&" << variant << "==" << lu.variant << endl;
return layout==lu.layout && variant==lu.variant; return layout==lu.layout && variant==lu.variant;
} }
//private: //private:
static const TQString parseLayout(const TQString &layvar); static const TQString parseLayout(const TQString &layvar);
static const TQString parseVariant(const TQString &layvar); static const TQString parseVariant(const TQString &layvar);
@ -90,31 +92,39 @@ class KxkbConfig
{ {
public: public:
enum { LOAD_INIT_OPTIONS, LOAD_ACTIVE_OPTIONS, LOAD_ALL }; enum { LOAD_INIT_OPTIONS, LOAD_ACTIVE_OPTIONS, LOAD_ALL };
bool m_useKxkb; bool m_useKxkb;
bool m_showSingle; bool m_showSingle;
bool m_showFlag; bool m_showFlag;
bool m_showLabel;
bool m_enableXkbOptions; bool m_enableXkbOptions;
bool m_resetOldOptions; bool m_resetOldOptions;
SwitchingPolicy m_switchingPolicy; SwitchingPolicy m_switchingPolicy;
bool m_stickySwitching; bool m_stickySwitching;
int m_stickySwitchingDepth; int m_stickySwitchingDepth;
bool m_useThemeColors;
TQColor m_colorBackground;
TQColor m_colorLabel;
TQFont m_labelFont;
bool m_labelShadow;
TQColor m_colorShadow;
TQString m_model; TQString m_model;
TQString m_options; TQString m_options;
TQValueList<LayoutUnit> m_layouts; TQValueList<LayoutUnit> m_layouts;
LayoutUnit getDefaultLayout(); LayoutUnit getDefaultLayout();
bool load(int loadMode); bool load(int loadMode);
void save(); void save();
void setDefaults(); void setDefaults();
TQStringList getLayoutStringList(/*bool compact*/); TQStringList getLayoutStringList(/*bool compact*/);
static TQString getDefaultDisplayName(const TQString& code_); static TQString getDefaultDisplayName(const TQString& code_);
static TQString getDefaultDisplayName(const LayoutUnit& layoutUnit, bool single=false); static TQString getDefaultDisplayName(const LayoutUnit& layoutUnit, bool single=false);
private: private:
static const TQMap<TQString, TQString> parseIncludesMap(const TQStringList& pairList); static const TQMap<TQString, TQString> parseIncludesMap(const TQStringList& pairList);
}; };

@ -1,7 +1,7 @@
// //
// C++ Implementation: kxkbtraywindow // C++ Implementation: kxkbtraywindow
// //
// Description: // Description:
// //
// //
// Author: Andriy Rysin <rysin@kde.org>, (C) 2006 // Author: Andriy Rysin <rysin@kde.org>, (C) 2006
@ -25,7 +25,7 @@
#include "kxkbconfig.h" #include "kxkbconfig.h"
KxkbLabelController::KxkbLabelController(TQLabel* label_, TQPopupMenu* contextMenu_) : KxkbLabelController::KxkbLabelController(TQLabel* label_, TDEPopupMenu* contextMenu_) :
label(label_), label(label_),
contextMenu(contextMenu_), contextMenu(contextMenu_),
m_menuStartIndex(contextMenu_->count()), m_menuStartIndex(contextMenu_->count()),
@ -51,7 +51,7 @@ void KxkbLabelController::setPixmap(const TQPixmap& pixmap)
void KxkbLabelController::setCurrentLayout(const LayoutUnit& layoutUnit) void KxkbLabelController::setCurrentLayout(const LayoutUnit& layoutUnit)
{ {
setToolTip(m_descriptionMap[layoutUnit.toPair()]); setToolTip(m_descriptionMap[layoutUnit.toPair()]);
setPixmap( LayoutIcon::getInstance().findPixmap(layoutUnit.layout, m_showFlag, layoutUnit.displayName) ); setPixmap( LayoutIcon::getInstance().findPixmap(layoutUnit.layout, PIXMAP_STYLE_INDICATOR, layoutUnit.displayName) );
} }
@ -60,14 +60,14 @@ void KxkbLabelController::setError(const TQString& layoutInfo)
TQString msg = i18n("Error changing keyboard layout to '%1'").arg(layoutInfo); TQString msg = i18n("Error changing keyboard layout to '%1'").arg(layoutInfo);
setToolTip(msg); setToolTip(msg);
label->setPixmap(LayoutIcon::getInstance().findPixmap("error", m_showFlag)); label->setPixmap(LayoutIcon::getInstance().findPixmap("error", PIXMAP_STYLE_NORMAL));
} }
void KxkbLabelController::initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rules) void KxkbLabelController::initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rules)
{ {
// TDEPopupMenu* menu = contextMenu(); TDEPopupMenu* menu = contextMenu;
TQPopupMenu* menu = contextMenu; // TQPopupMenu* menu = contextMenu;
// int index = menu->indexOf(0); // int index = menu->indexOf(0);
m_descriptionMap.clear(); m_descriptionMap.clear();
@ -80,30 +80,30 @@ void KxkbLabelController::initLayoutList(const TQValueList<LayoutUnit>& layouts,
} }
/* menu->removeItem(CONFIG_MENU_ID); /* menu->removeItem(CONFIG_MENU_ID);
menu->removeItem(HELP_MENU_ID);*/ menu->removeItem(HELP_MENU_ID);*/
TDEIconEffect iconeffect; TDEIconEffect iconeffect;
int cnt = 0; int cnt = 0;
TQValueList<LayoutUnit>::ConstIterator it; TQValueList<LayoutUnit>::ConstIterator it;
for (it=layouts.begin(); it != layouts.end(); ++it) for (it=layouts.begin(); it != layouts.end(); ++it)
{ {
const TQString layoutName = (*it).layout; const TQString layoutName = (*it).layout;
const TQString variantName = (*it).variant; const TQString variantName = (*it).variant;
const TQPixmap& layoutPixmap = LayoutIcon::getInstance().findPixmap(layoutName, m_showFlag, (*it).displayName); const TQPixmap& layoutPixmap = LayoutIcon::getInstance().findPixmap(layoutName, PIXMAP_STYLE_CONTEXTMENU, (*it).displayName);
const TQPixmap pix = iconeffect.apply(layoutPixmap, TDEIcon::Small, TDEIcon::DefaultState); const TQPixmap pix = iconeffect.apply(layoutPixmap, TDEIcon::Small, TDEIcon::DefaultState);
TQString fullName = i18n((rules.layouts()[layoutName])); TQString fullName = i18n((rules.layouts()[layoutName]));
if( variantName.isEmpty() == false ) if( variantName.isEmpty() == false )
fullName += " (" + variantName + ")"; fullName += " (" + variantName + ")";
contextMenu->insertItem(pix, fullName, START_MENU_ID + cnt, m_menuStartIndex + cnt); contextMenu->insertItem(pix, fullName, START_MENU_ID + cnt, m_menuStartIndex + cnt);
m_descriptionMap.insert((*it).toPair(), fullName); m_descriptionMap.insert((*it).toPair(), fullName);
cnt++; cnt++;
} }
m_prevLayoutCount = cnt; m_prevLayoutCount = cnt;
// if show config, if show help // if show config, if show help
if( menu->indexOf(CONFIG_MENU_ID) == -1 ) { if( menu->indexOf(CONFIG_MENU_ID) == -1 ) {
contextMenu->insertSeparator(); contextMenu->insertSeparator();

@ -21,7 +21,7 @@
class TQLabel; class TQLabel;
class TQPopupMenu; class TDEPopupMenu;
class XkbRules; class XkbRules;
/* This class is responsible for displaying flag/label for the layout, /* This class is responsible for displaying flag/label for the layout,
@ -35,7 +35,7 @@ class KxkbLabelController: public QObject
public: public:
enum { START_MENU_ID = 100, CONFIG_MENU_ID = 130, HELP_MENU_ID = 131 }; enum { START_MENU_ID = 100, CONFIG_MENU_ID = 130, HELP_MENU_ID = 131 };
KxkbLabelController(TQLabel *label, TQPopupMenu* contextMenu); KxkbLabelController(TQLabel *label, TDEPopupMenu* contextMenu);
void initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rule); void initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rule);
void setCurrentLayout(const LayoutUnit& layout); void setCurrentLayout(const LayoutUnit& layout);
@ -55,7 +55,7 @@ public:
private: private:
TQLabel* label; TQLabel* label;
TQPopupMenu* contextMenu; TDEPopupMenu* contextMenu;
const int m_menuStartIndex; const int m_menuStartIndex;
bool m_showFlag; bool m_showFlag;

@ -6,16 +6,15 @@
#include <tqdict.h> #include <tqdict.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <tdeglobalsettings.h>
#include <tdelocale.h> #include <tdelocale.h>
#include <kdebug.h> #include <kdebug.h>
#include "pixmap.h" #include "pixmap.h"
#include "x11helper.h" #include "x11helper.h"
#include "kxkbconfig.h"
static const int FLAG_MAX_WIDTH = 21; static const int FLAG_MAX_DIM = 24;
static const int FLAG_MAX_HEIGHT = 14;
const TQString LayoutIcon::flagTemplate("l10n/%1/flag.png"); const TQString LayoutIcon::flagTemplate("l10n/%1/flag.png");
const TQString& LayoutIcon::ERROR_CODE("error"); const TQString& LayoutIcon::ERROR_CODE("error");
@ -30,16 +29,52 @@ LayoutIcon& LayoutIcon::getInstance() {
} }
LayoutIcon::LayoutIcon(): LayoutIcon::LayoutIcon():
m_pixmapCache(80), m_pixmapCache(80)
m_labelFont("sans")
{ {
m_labelFont.setPixelSize(10);
m_labelFont.setWeight(TQFont::Bold);
} }
const TQPixmap& const TQPixmap&
LayoutIcon::findPixmap(const TQString& code_, bool showFlag, const TQString& displayName_) 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;
TQPixmap* pm = NULL; TQPixmap* pm = NULL;
if( code_ == ERROR_CODE ) { if( code_ == ERROR_CODE ) {
@ -52,61 +87,68 @@ LayoutIcon::findPixmap(const TQString& code_, bool showFlag, const TQString& dis
} }
TQString displayName(displayName_); TQString displayName(displayName_);
if( displayName.isEmpty() ) { if( displayName.isEmpty() ) {
displayName = KxkbConfig::getDefaultDisplayName(code_); displayName = KxkbConfig::getDefaultDisplayName(code_);
} }
if( displayName.length() > 3 ) if( displayName.length() > 3 )
displayName = displayName.left(3); displayName = displayName.left(3);
const TQString pixmapKey( showFlag ? code_ + "." + displayName : displayName ); const TQString pixmapKey(
TQString( m_showFlag ? "f" : "" ) + TQString( m_showLabel ? "l" : "" ) + TQString( m_labelShadow ? "s" : "" ) + "." +
pm = m_pixmapCache[pixmapKey]; m_labelFont.key() + "." + m_bgColor.name() + "." + m_fgColor.name() + "." + m_shColor.name() + '.' + code_ + "." + displayName
if( pm ) );
return *pm;
// Only use cache for indicator
TQString flag; if( pixmapStyle == PIXMAP_STYLE_INDICATOR ) {
if( showFlag ) { pm = m_pixmapCache[pixmapKey];
TQString countryCode = getCountryFromLayoutName( code_ ); if( pm )
flag = locate("locale", flagTemplate.arg(countryCode)); return *pm;
} }
if( flag.isEmpty() ) { // Need to create new pixmap
pm = new TQPixmap(FLAG_MAX_WIDTH, FLAG_MAX_HEIGHT); pm = new TQPixmap();
pm->fill(Qt::gray);
} if( m_fitToBox ) // Resize to box size
else { pm->resize(FLAG_MAX_DIM, FLAG_MAX_DIM);
pm = new TQPixmap(flag);
dimPixmap( *pm ); if( m_showFlag ) {
TQString countryCode = getCountryFromLayoutName( code_ );
#if 0 TQString flag = locate("locale", flagTemplate.arg(countryCode));
if( pm->height() < FLAG_MAX_HEIGHT ) {
TQPixmap* pix = new TQPixmap(FLAG_MAX_WIDTH, FLAG_MAX_HEIGHT); if( flag.isEmpty() ) {
pix->fill( Qt::lightGray ); pm->fill(m_bgColor);
// pix->fill( TQColor(tqRgba(127,127,127,255)) ); m_showLabel = true;
// TQBitmap mask; } else {
// mask.fill(1); if( m_fitToBox ) { // Resize flag
// pix->setMask(mask); TQPainter p_(pm);
p_.drawPixmap(TQRect(0, 0, FLAG_MAX_DIM, FLAG_MAX_DIM), flag);
int dy = (pix->height() - pm->height()) / 2; } else { // Show the flag as is
copyBlt( pix, 0, dy, pm, 0, 0, -1, -1 ); pm->load(flag);
// TQPixmap* px = new TQPixmap(21, 14); }
// px->convertFromImage(img);*/
delete pm; if( m_showLabel ) // only dim for label
pm = pix; dimPixmap( *pm );
} }
#endif } else {
} pm->fill(m_bgColor);
}
TQPainter p(pm);
p.setFont(m_labelFont); if( m_showLabel ) {
TQPainter p(pm);
p.setPen(Qt::black); p.setFont(m_labelFont);
p.drawText(1, 1, pm->width(), pm->height()-2, Qt::AlignCenter, displayName);
p.setPen(Qt::white); if( m_labelShadow ) {
p.drawText(0, 0, pm->width(), pm->height()-2, Qt::AlignCenter, displayName); p.setPen(m_shColor);
p.drawText(1, 1, pm->width(), pm->height(), Qt::AlignCenter, displayName);
m_pixmapCache.insert(pixmapKey, pm); }
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; return *pm;
} }
@ -117,7 +159,7 @@ LayoutIcon::findPixmap(const TQString& code_, bool showFlag, const TQString& dis
TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName) TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName)
{ {
TQString flag; TQString flag;
if( X11Helper::areLayoutsClean() ) { // >= Xorg 6.9.0 if( X11Helper::areLayoutsClean() ) { // >= Xorg 6.9.0
if( layoutName == "mkd" ) if( layoutName == "mkd" )
flag = "mk"; flag = "mk";
@ -178,8 +220,8 @@ TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName)
if( layoutName.endsWith("/jp") ) if( layoutName.endsWith("/jp") )
flag = "jp"; flag = "jp";
else else
if( layoutName == "ml" || layoutName == "dev" || layoutName == "gur" if( layoutName == "ml" || layoutName == "dev" || layoutName == "gur"
|| layoutName == "guj" || layoutName == "kan" || layoutName == "ori" || layoutName == "guj" || layoutName == "kan" || layoutName == "ori"
|| layoutName == "tel" || layoutName == "tml" || layoutName == "ben" ) // some Indian languages || layoutName == "tel" || layoutName == "tml" || layoutName == "ben" ) // some Indian languages
flag = "in"; flag = "in";
else { else {
@ -189,8 +231,8 @@ TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName)
if( sepPos != -1 ) if( sepPos != -1 )
rightCode = layoutName.mid(sepPos+1); rightCode = layoutName.mid(sepPos+1);
// kdDebug() << "layout name breakup: " << leftCode << ":" << rightCode << endl; // kdDebug() << "layout name breakup: " << leftCode << ":" << rightCode << endl;
if( rightCode.length() == 2 if( rightCode.length() == 2
&& TQRegExp("[A-Z][A-Z]").exactMatch(rightCode) ) { && TQRegExp("[A-Z][A-Z]").exactMatch(rightCode) ) {
flag = rightCode.lower(); flag = rightCode.lower();
} }
@ -199,7 +241,7 @@ TQString LayoutIcon::getCountryFromLayoutName(const TQString& layoutName)
} }
} }
} }
return flag; return flag;
} }

@ -6,26 +6,42 @@
#include <tqdict.h> #include <tqdict.h>
#include <tqstring.h> #include <tqstring.h>
#include "kxkbconfig.h"
enum PixmapStyle {
PIXMAP_STYLE_NORMAL = 0,
PIXMAP_STYLE_INDICATOR = 1,
PIXMAP_STYLE_CONTEXTMENU = 2
};
class LayoutIcon { class LayoutIcon {
private: private:
static LayoutIcon* instance; static LayoutIcon* instance;
static const TQString flagTemplate; static const TQString flagTemplate;
TQDict<TQPixmap> m_pixmapCache; KxkbConfig m_kxkbConfig;
TQFont m_labelFont; bool m_showFlag;
bool m_showLabel;
LayoutIcon(); TQColor m_bgColor;
TQPixmap* createErrorPixmap(); TQColor m_fgColor;
void dimPixmap(TQPixmap& pixmap); TQFont m_labelFont;
TQString getCountryFromLayoutName(const TQString& layoutName); bool m_labelShadow;
TQColor m_shColor;
public: bool m_fitToBox;
static const TQString& ERROR_CODE;
TQDict<TQPixmap> m_pixmapCache;
static LayoutIcon& getInstance();
const TQPixmap& findPixmap(const TQString& code, bool showFlag, const TQString& displayName=""); LayoutIcon();
TQPixmap* createErrorPixmap();
void dimPixmap(TQPixmap& pixmap);
TQString getCountryFromLayoutName(const TQString& layoutName);
public:
static const TQString& ERROR_CODE;
static LayoutIcon& getInstance();
const TQPixmap& findPixmap(const TQString& code, int pixmapStyle, const TQString& displayName="");
}; };
#endif #endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 99 B

Loading…
Cancel
Save