diff options
Diffstat (limited to 'kxkb/kcmlayout.cpp')
-rw-r--r-- | kxkb/kcmlayout.cpp | 176 |
1 files changed, 106 insertions, 70 deletions
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp index 303c88541..d9efb9e57 100644 --- a/kxkb/kcmlayout.cpp +++ b/kxkb/kcmlayout.cpp @@ -14,6 +14,7 @@ #include <tqbuttongroup.h> #include <tqspinbox.h> #include <tqvbox.h> +#include <tqtimer.h> #include <tdefontrequester.h> #include <kcolorbutton.h> @@ -21,12 +22,12 @@ #include <tdeglobal.h> #include <tdeconfig.h> #include <tdelocale.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <kdebug.h> #include <tdeapplication.h> #include <kiconloader.h> #include <tdemessagebox.h> -#include <kglobalaccel.h> +#include <tdeglobalaccel.h> #include <dcopref.h> #include <dcopclient.h> @@ -36,6 +37,7 @@ #include "pixmap.h" #include "kcmmisc.h" #include "kcmlayoutwidget.h" +#include "x11helper.h" #include "kcmlayout.h" #include "kcmlayout.moc" @@ -105,53 +107,64 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) m_rules(NULL), m_forceGrpOverwrite(false) { + X11Helper::initializeTranslations(); + + m_icoMgr = new LayoutIconManager(&m_kxkbConfig); + TQVBoxLayout *main = new TQVBoxLayout(this, 0, KDialog::spacingHint()); widget = new LayoutConfigWidget(this, "widget"); main->addWidget(widget); - connect( widget->chkEnable, TQT_SIGNAL( toggled( bool )), this, TQT_SLOT(changed())); - connect( widget->chkShowSingle, TQT_SIGNAL( toggled( bool )), this, TQT_SLOT(changed())); + connect( widget->chkEnable, TQ_SIGNAL( toggled( bool )), this, TQ_SLOT(changed())); + connect( widget->chkShowSingle, TQ_SIGNAL( toggled( bool )), this, TQ_SLOT(changed())); - connect( widget->comboHotkey, TQT_SIGNAL(activated(int)), this, TQT_SLOT(hotkeyComboChanged())); - connect( widget->comboHotkey, TQT_SIGNAL(activated(int)), this, TQT_SLOT(updateOptionsCommand())); - connect( widget->comboHotkey, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changed())); - connect( widget->comboModel, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changed())); + connect( widget->comboHotkey, TQ_SIGNAL(activated(int)), this, TQ_SLOT(hotkeyComboChanged())); + connect( widget->comboHotkey, TQ_SIGNAL(activated(int)), this, TQ_SLOT(updateOptionsCommand())); + connect( widget->comboHotkey, TQ_SIGNAL(activated(int)), this, TQ_SLOT(changed())); + connect( widget->comboModel, TQ_SIGNAL(activated(int)), this, TQ_SLOT(changed())); - connect( widget->listLayoutsSrc, TQT_SIGNAL(doubleClicked(TQListViewItem*,const TQPoint&, int)), - this, TQT_SLOT(add())); - connect( widget->btnAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(add())); - connect( widget->btnRemove, TQT_SIGNAL(clicked()), this, TQT_SLOT(remove())); + connect( widget->listLayoutsSrc, TQ_SIGNAL(doubleClicked(TQListViewItem*,const TQPoint&, int)), + this, TQ_SLOT(add())); + connect( widget->btnAdd, TQ_SIGNAL(clicked()), this, TQ_SLOT(add())); + connect( widget->btnRemove, TQ_SIGNAL(clicked()), this, TQ_SLOT(remove())); - connect( widget->comboVariant, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changed())); - connect( widget->comboVariant, TQT_SIGNAL(activated(int)), this, TQT_SLOT(variantChanged())); - connect( widget->listLayoutsDst, TQT_SIGNAL(selectionChanged(TQListViewItem *)), - this, TQT_SLOT(layoutSelChanged(TQListViewItem *))); + connect( widget->comboVariant, TQ_SIGNAL(activated(int)), this, TQ_SLOT(changed())); + connect( widget->comboVariant, TQ_SIGNAL(activated(int)), this, TQ_SLOT(variantChanged())); + connect( widget->listLayoutsDst, TQ_SIGNAL(selectionChanged(TQListViewItem *)), + this, TQ_SLOT(layoutSelChanged(TQListViewItem *))); - connect( widget->editDisplayName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(displayNameChanged(const TQString&))); + connect( widget->editDisplayName, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(displayNameChanged(const TQString&))); widget->btnUp->setIconSet(SmallIconSet("1uparrow")); - connect( widget->btnUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); - connect( widget->btnUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(moveUp())); + connect( widget->btnUp, TQ_SIGNAL(clicked()), this, TQ_SLOT(changed())); + connect( widget->btnUp, TQ_SIGNAL(clicked()), this, TQ_SLOT(moveUp())); widget->btnDown->setIconSet(SmallIconSet("1downarrow")); - connect( widget->btnDown, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); - connect( widget->btnDown, TQT_SIGNAL(clicked()), this, TQT_SLOT(moveDown())); + connect( widget->btnDown, TQ_SIGNAL(clicked()), this, TQ_SLOT(changed())); + connect( widget->btnDown, TQ_SIGNAL(clicked()), this, TQ_SLOT(moveDown())); + + connect( widget->grpStyle, TQ_SIGNAL( clicked( int ) ), TQ_SLOT(changed())); + connect( widget->grpSwitching, TQ_SIGNAL( clicked( int ) ), TQ_SLOT(changed())); + connect( widget->grpLabel, TQ_SIGNAL( clicked( int ) ), TQ_SLOT(changed())); + + connect( widget->chkFitToBox, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); + connect( widget->chkDimFlag, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); - connect( widget->grpStyle, 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, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT(changed())); + connect( widget->fgColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT(changed())); + connect( widget->chkBgTransparent, TQ_SIGNAL( toggled(bool) ), this, TQ_SLOT(changed())); + connect( widget->labelFont, TQ_SIGNAL( fontSelected(const TQFont&) ), this, TQ_SLOT(changed())); + connect( widget->chkLabelShadow, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT(changed())); + connect( widget->shColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT(changed())); - connect( widget->bgColor, TQT_SIGNAL( changed(const TQColor&) ), this, TQT_SLOT(changed())); - connect( widget->fgColor, TQT_SIGNAL( changed(const TQColor&) ), this, TQT_SLOT(changed())); - connect( widget->labelFont, TQT_SIGNAL( fontSelected(const TQFont&) ), this, TQT_SLOT(changed())); - connect( widget->chkLabelShadow, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT(changed())); - connect( widget->shColor, TQT_SIGNAL( changed(const TQColor&) ), this, TQT_SLOT(changed())); + connect( widget->chkBevel, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); - connect( widget->chkEnableSticky, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(changed())); - connect( widget->spinStickyDepth, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(changed())); + connect( widget->chkEnableSticky, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(changed())); + connect( widget->spinStickyDepth, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(changed())); - connect(widget->chkEnableNotify, SIGNAL(toggled(bool)), SLOT(changed())); - connect(widget->chkNotifyUseKMilo, SIGNAL(toggled(bool)), SLOT(changed())); + connect(widget->chkEnableNotify, TQ_SIGNAL(toggled(bool)), TQ_SLOT(changed())); + connect(widget->chkNotifyUseKMilo, TQ_SIGNAL(toggled(bool)), TQ_SLOT(changed())); + connect(widget->chkEnableNotify, TQ_SIGNAL(toggled(bool)), widget->chkNotifyUseKMilo, TQ_SLOT(setEnabled(bool))); widget->listLayoutsSrc->setColumnText(LAYOUT_COLUMN_FLAG, ""); widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_FLAG, ""); @@ -160,7 +173,7 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) widget->listLayoutsSrc->setColumnWidth(LAYOUT_COLUMN_FLAG, 28); widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_FLAG, 28); - widget->listLayoutsDst->header()->setResizeEnabled(FALSE, LAYOUT_COLUMN_DISPLAY_NAME); + widget->listLayoutsDst->header()->setResizeEnabled(false, LAYOUT_COLUMN_DISPLAY_NAME); // widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_DISPLAY_NAME, 0); widget->listLayoutsDst->setSorting(-1); @@ -177,29 +190,39 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name) #define NOSLOTS keys = new TDEGlobalAccel(this); #include "kxkbbindings.cpp" + keys->readSettings(); makeOptionsTab(); - load(); makeShortcutsTab(); + TQTimer::singleShot(0, this, TQ_SLOT(load())); } LayoutConfig::~LayoutConfig() { - delete m_rules; + delete m_rules; + delete m_icoMgr; } void LayoutConfig::load() { - m_kxkbConfig.load(KxkbConfig::LOAD_ALL); + bool modified = false; + m_kxkbConfig.load(KxkbConfig::LOAD_ALL_OPTIONS); - keys->readSettings(); + // Check if the active settings are different from the saved settings + if (m_kxkbConfig.m_useKxkb) + { + XkbOptions options = XKBExtension::the()->getServerOptions(); + modified = m_kxkbConfig.setFromXkbOptions(options); + } - initUI(); + m_kxkbConfig.load(KxkbConfig::LOAD_ALL_OPTIONS); + keys->readSettings(); + initUI(modified); } -void LayoutConfig::initUI() { +void LayoutConfig::initUI(bool modified) { const char* modelName = m_rules->models()[m_kxkbConfig.m_model]; if( modelName == NULL ) modelName = DEFAULT_MODEL; @@ -216,7 +239,6 @@ void LayoutConfig::initUI() { for ( ; src_it.current(); ++src_it ) { TQListViewItem* srcItem = src_it.current(); - if ( layoutUnit.layout == src_it.current()->text(LAYOUT_COLUMN_MAP) ) { // check if current config knows about this layout TQListViewItem* newItem = copyLVI(srcItem, widget->listLayoutsDst); @@ -243,7 +265,7 @@ void LayoutConfig::initUI() { const char *hkOpt = tqstrdup(TQString("grp:" + (*hk)).ascii()); const char *hkDesc = allOptions[hkOpt]; if (hkDesc != 0) { // the option exists - widget->comboHotkey->insertItem(i18n(hkDesc)); + widget->comboHotkey->insertItem(XkbRules::trOpt(hkDesc)); } } widget->comboHotkey->insertItem(i18n("None")); @@ -257,6 +279,8 @@ void LayoutConfig::initUI() { widget->radFlagLabel->setChecked( showFlag && showLabel ); widget->radFlagOnly->setChecked( showFlag && !showLabel ); widget->radLabelOnly->setChecked( !showFlag && showLabel ); + widget->chkFitToBox->setChecked(m_kxkbConfig.m_fitToBox); + widget->chkDimFlag->setChecked(m_kxkbConfig.m_dimFlag); widget->xkbOptsMode->setButton(m_kxkbConfig.m_resetOldOptions ? 0 : 1); @@ -268,11 +292,15 @@ void LayoutConfig::initUI() { widget->chkLabelShadow->setChecked( m_kxkbConfig.m_labelShadow ); widget->shColor->setColor( m_kxkbConfig.m_colorShadow ); + widget->chkBevel->setChecked(m_kxkbConfig.m_bevel); + widget->grpLabel->setDisabled(showFlag && !showLabel); widget->grpLabelColors->setDisabled(m_kxkbConfig.m_useThemeColors); widget->labelBgColor->setDisabled(showFlag); widget->bgColor->setDisabled(showFlag); widget->chkBgTransparent->setDisabled(showFlag); + widget->grpFlag->setEnabled(showFlag); + widget->chkDimFlag->setEnabled(showFlag && showLabel); switch( m_kxkbConfig.m_switchingPolicy ) { default: @@ -293,6 +321,7 @@ void LayoutConfig::initUI() { widget->chkEnableNotify->setChecked(m_kxkbConfig.m_enableNotify); widget->chkNotifyUseKMilo->setChecked(m_kxkbConfig.m_notifyUseKMilo); + widget->chkNotifyUseKMilo->setEnabled(m_kxkbConfig.m_enableNotify); updateStickyLimit(); @@ -314,7 +343,7 @@ void LayoutConfig::initUI() { foundGrp = true; } - OptionListItem *item = m_optionGroups[i18n(optionKey.latin1())]; + OptionListItem *item = m_optionGroups[optionKey]; if (item != NULL) { OptionListItem *child = item->findChildItem( option ); @@ -338,7 +367,7 @@ void LayoutConfig::initUI() { updateOptionsCommand(); updateHotkeyCombo(true); - emit TDECModule::changed( false ); + emit TDECModule::changed(modified); } @@ -350,6 +379,9 @@ void LayoutConfig::save() m_kxkbConfig.m_resetOldOptions = widget->radXkbOverwrite->isOn(); m_kxkbConfig.m_options = createOptionString(); + m_kxkbConfig.m_fitToBox = widget->chkFitToBox->isChecked(); + m_kxkbConfig.m_dimFlag = widget->chkDimFlag->isChecked(); + m_kxkbConfig.m_useThemeColors = widget->radLabelUseTheme->isChecked(); m_kxkbConfig.m_colorBackground = widget->bgColor->color(); m_kxkbConfig.m_colorLabel = widget->fgColor->color(); @@ -358,6 +390,8 @@ void LayoutConfig::save() m_kxkbConfig.m_labelShadow = widget->chkLabelShadow->isChecked(); m_kxkbConfig.m_colorShadow = widget->shColor->color(); + m_kxkbConfig.m_bevel = widget->chkBevel->isChecked(); + TQListViewItem *item = widget->listLayoutsDst->firstChild(); TQValueList<LayoutUnit> layouts; while (item) { @@ -412,7 +446,8 @@ void LayoutConfig::save() if (m_forceGrpOverwrite) { // First get all the server's options - TQStringList srvOptions = TQStringList::split(",", XKBExtension::getServerOptions()); + XkbOptions _opt = XKBExtension::the()->getServerOptions(); + TQStringList srvOptions = TQStringList::split(",", _opt.options); TQStringList newOptions; // Then remove all grp: options @@ -429,7 +464,7 @@ void LayoutConfig::save() xkbOptions.options = newOptions.join(","); xkbOptions.resetOld = true; - if (!XKBExtension::setXkbOptions(xkbOptions)) + if (!XKBExtension::the()->setXkbOptions(xkbOptions)) { kdWarning() << "[LayoutConfig::save] Could not overwrite previous grp: options!" << endl; } @@ -442,8 +477,8 @@ void LayoutConfig::save() keys->writeSettings(0, true); // Get current layout from Kxkb - if (!kapp->dcopClient()->isAttached()) - kapp->dcopClient()->attach(); + if (!tdeApp->dcopClient()->isAttached()) + tdeApp->dcopClient()->attach(); DCOPRef kxkbref("kxkb", "kxkb"); DCOPReply reply = kxkbref.call( "getCurrentLayout" ); @@ -456,7 +491,7 @@ void LayoutConfig::save() } // Cause Kxkb to reread configuration - kapp->tdeinitExecWait("kxkb"); + tdeApp->tdeinitExecWait("kxkb"); // If previous call was valid, try to change layout if ( reply.isValid() ) { @@ -668,13 +703,13 @@ TQWidget* LayoutConfig::makeOptionsTab() listView->setColumnText( 0, i18n( "Options" ) ); listView->clear(); - connect(listView, TQT_SIGNAL(clicked(TQListViewItem *)), TQT_SLOT(changed())); - connect(listView, TQT_SIGNAL(clicked(TQListViewItem *)), TQT_SLOT(resolveConflicts(TQListViewItem *))); - connect(listView, TQT_SIGNAL(clicked(TQListViewItem *)), TQT_SLOT(updateHotkeyCombo())); + connect(listView, TQ_SIGNAL(clicked(TQListViewItem *)), TQ_SLOT(changed())); + connect(listView, TQ_SIGNAL(clicked(TQListViewItem *)), TQ_SLOT(resolveConflicts(TQListViewItem *))); + connect(listView, TQ_SIGNAL(clicked(TQListViewItem *)), TQ_SLOT(updateHotkeyCombo())); - connect(widget->xkbOptsMode, TQT_SIGNAL(released(int)), TQT_SLOT(changed())); - connect(widget->xkbOptsMode, TQT_SIGNAL(released(int)), TQT_SLOT(updateOptionsCommand())); - connect(widget->xkbOptsMode, TQT_SIGNAL(released(int)), TQT_SLOT(updateHotkeyCombo())); + connect(widget->xkbOptsMode, TQ_SIGNAL(released(int)), TQ_SLOT(changed())); + connect(widget->xkbOptsMode, TQ_SIGNAL(released(int)), TQ_SLOT(updateOptionsCommand())); + connect(widget->xkbOptsMode, TQ_SIGNAL(released(int)), TQ_SLOT(updateHotkeyCombo())); //Create controllers for all options TQDictIterator<char> it(m_rules->options()); @@ -685,25 +720,25 @@ TQWidget* LayoutConfig::makeOptionsTab() { if( it.currentKey() == "ctrl" || it.currentKey() == "caps" || it.currentKey() == "altwin") { - parent = new OptionListItem(listView, i18n( it.current() ), + parent = new OptionListItem(listView, XkbRules::trOpt( it.current() ), TQCheckListItem::RadioButtonController, it.currentKey()); OptionListItem *item = new OptionListItem(parent, i18n( "None" ), TQCheckListItem::RadioButton, "none"); item->setState(TQCheckListItem::On); } else if (it.currentKey() == "grp") { - parent = new OptionListItem(listView, i18n(it.current()), + parent = new OptionListItem(listView, XkbRules::trOpt(it.current()), TQCheckListItem::RadioButtonController, it.currentKey()); parent->setSelectable(false); OptionListItem *item = new OptionListItem(parent, i18n("None"), TQCheckListItem::CheckBox, "grp:none"); } else { - parent = new OptionListItem(listView, i18n( it.current() ), + parent = new OptionListItem(listView, XkbRules::trOpt( it.current() ), TQCheckListItem::CheckBoxController, it.currentKey()); } parent->setOpen(true); - m_optionGroups.insert(i18n(it.currentKey().local8Bit()), parent); + m_optionGroups.insert(it.currentKey(), parent); } } @@ -723,10 +758,10 @@ TQWidget* LayoutConfig::makeOptionsTab() text = text.replace( "Cap$", "Caps." ); if ( parent->type() == TQCheckListItem::CheckBoxController || key.startsWith("grp:")) - new OptionListItem(parent, i18n(text.utf8()), + new OptionListItem(parent, XkbRules::trOpt(text), TQCheckListItem::CheckBox, key); else - new OptionListItem(parent, i18n(text.utf8()), + new OptionListItem(parent, XkbRules::trOpt(text), TQCheckListItem::RadioButton, key); } } @@ -739,7 +774,7 @@ TQWidget* LayoutConfig::makeOptionsTab() TQWidget* LayoutConfig::makeShortcutsTab() { m_keyChooser = new KKeyChooser(keys, widget->tabShortcuts, false, false); - connect(m_keyChooser, SIGNAL(keyChange()), this, SLOT(changed())); + connect(m_keyChooser, TQ_SIGNAL(keyChange()), this, TQ_SLOT(changed())); widget->tabShortcuts->layout()->add(m_keyChooser); return m_keyChooser; } @@ -987,7 +1022,8 @@ void LayoutConfig::updateHotkeyCombo(bool initial) { // Get server options first if (initial || widget->xkbOptsMode->selectedId() == 1) { - TQStringList opts = TQStringList::split(",", XKBExtension::getServerOptions()); + XkbOptions _opt = XKBExtension::the()->getServerOptions(); + TQStringList opts = TQStringList::split(",", _opt.options); for (TQStringList::Iterator it = opts.begin(); it != opts.end(); ++it) { TQString option(*it); @@ -1138,7 +1174,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; @@ -1226,17 +1262,17 @@ OptionListItem * OptionListItem::findChildItem( const TQString& optionName ) extern "C" { - KDE_EXPORT TDECModule *create_keyboard_layout(TQWidget *parent, const char *) + TDE_EXPORT TDECModule *create_keyboard_layout(TQWidget *parent, const char *) { return new LayoutConfig(parent, "kcmlayout"); } - KDE_EXPORT TDECModule *create_keyboard(TQWidget *parent, const char *) + TDE_EXPORT TDECModule *create_keyboard(TQWidget *parent, const char *) { return new KeyboardConfig(parent, "kcmlayout"); } - KDE_EXPORT void init_keyboard() + TDE_EXPORT void init_keyboard() { KeyboardConfig::init_keyboard(); @@ -1244,10 +1280,10 @@ extern "C" m_kxkbConfig.load(KxkbConfig::LOAD_INIT_OPTIONS); if( m_kxkbConfig.m_useKxkb == true ) { - kapp->startServiceByDesktopName("kxkb"); + tdeApp->startServiceByDesktopName("kxkb"); } else { - if (!XKBExtension::setXkbOptions(m_kxkbConfig.getKXkbOptions())) { + if (!XKBExtension::the()->setXkbOptions(m_kxkbConfig.getKXkbOptions())) { kdDebug() << "Setting XKB options failed!" << endl; } } @@ -1332,7 +1368,7 @@ extern "C" //these seem to be new in XFree86 4.4.0 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."); I18N_NOOP("Miscellaneous compatibility options"); I18N_NOOP("Right Control key works as Right Alt"); |