kxkb: re-add custom TDE switching shortcut

This commit fixes issue #342.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/352/head
Mavridis Philippe 12 months ago
parent bcd2bfcdc4
commit 22bb398b3b
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -66,6 +66,7 @@ void KKeyModule::init( bool isGlobal, bool _bSeriesOnly, bool bSeriesNone )
#include "../../kicker/taskbar/taskbarbindings.cpp" #include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp" #include "../../kdesktop/kdesktopbindings.cpp"
#include "../../klipper/klipperbindings.cpp" #include "../../klipper/klipperbindings.cpp"
#include "../../kxkb/kxkbbindings.cpp"
#undef TDEShortcuts #undef TDEShortcuts
KeyScheme = "Global Key Scheme"; KeyScheme = "Global Key Scheme";
KeySet = "Global Keys"; KeySet = "Global Keys";
@ -488,6 +489,7 @@ void KKeyModule::init()
#include "../../kicker/kicker/core/kickerbindings.cpp" #include "../../kicker/kicker/core/kickerbindings.cpp"
#include "../../kicker/taskbar/taskbarbindings.cpp" #include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp" #include "../../kdesktop/kdesktopbindings.cpp"
#include "../../kxkb/kxkbbindings.cpp"
#undef TDEShortcuts #undef TDEShortcuts
kdDebug(125) << "KKeyModule::init() - Read Config Bindings\n"; kdDebug(125) << "KKeyModule::init() - Read Config Bindings\n";

@ -190,6 +190,7 @@ extern "C"
#include "../../kicker/kicker/core/kickerbindings.cpp" #include "../../kicker/kicker/core/kickerbindings.cpp"
#include "../../kicker/taskbar/taskbarbindings.cpp" #include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp" #include "../../kdesktop/kdesktopbindings.cpp"
#include "../../kxkb/kxkbbindings.cpp"
// Write all the global keys to kdeglobals. // Write all the global keys to kdeglobals.
// This is needed to be able to check for conflicts with global keys in app's keyconfig // This is needed to be able to check for conflicts with global keys in app's keyconfig

@ -116,6 +116,7 @@ void ShortcutsModule::initGUI()
#include "../../kicker/taskbar/taskbarbindings.cpp" #include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp" #include "../../kdesktop/kdesktopbindings.cpp"
#include "../../klipper/klipperbindings.cpp" #include "../../klipper/klipperbindings.cpp"
#include "../../kxkb/kxkbbindings.cpp"
kdDebug(125) << "B-----------" << endl; kdDebug(125) << "B-----------" << endl;
m_actionsSequence.init( m_actionsGeneral ); m_actionsSequence.init( m_actionsGeneral );

@ -5,6 +5,7 @@ tde_l10n_create_template(
SOURCES SOURCES
kcmlayout.cpp kcmlayout.cpp
kcmmisc.cpp kcmmisc.cpp
kxkbbindings.cpp
pixmap.cpp pixmap.cpp
rules.cpp rules.cpp
*.ui *.ui
@ -15,6 +16,7 @@ tde_l10n_create_template(
SOURCES SOURCES
extension.cpp extension.cpp
kxkb.cpp kxkb.cpp
kxkbbindings.cpp
kxkbtraywindow.cpp kxkbtraywindow.cpp
pixmap.cpp pixmap.cpp
rules.cpp rules.cpp

@ -13,6 +13,7 @@
#include <tqlistview.h> #include <tqlistview.h>
#include <tqbuttongroup.h> #include <tqbuttongroup.h>
#include <tqspinbox.h> #include <tqspinbox.h>
#include <tqvbox.h>
#include <tdefontrequester.h> #include <tdefontrequester.h>
#include <kcolorbutton.h> #include <kcolorbutton.h>
@ -25,6 +26,7 @@
#include <tdeapplication.h> #include <tdeapplication.h>
#include <kiconloader.h> #include <kiconloader.h>
#include <tdemessagebox.h> #include <tdemessagebox.h>
#include <kglobalaccel.h>
#include <dcopref.h> #include <dcopref.h>
#include <dcopclient.h> #include <dcopclient.h>
@ -168,9 +170,14 @@ LayoutConfig::LayoutConfig(TQWidget *parent, const char *name)
//Read rules - we _must_ read _before_ creating xkb-options comboboxes //Read rules - we _must_ read _before_ creating xkb-options comboboxes
loadRules(); loadRules();
makeOptionsTab(); // Load global shortcuts
#define NOSLOTS
keys = new TDEGlobalAccel(TQT_TQOBJECT(this));
#include "kxkbbindings.cpp"
makeOptionsTab();
load(); load();
makeShortcutsTab();
} }
@ -184,6 +191,8 @@ void LayoutConfig::load()
{ {
m_kxkbConfig.load(KxkbConfig::LOAD_ALL); m_kxkbConfig.load(KxkbConfig::LOAD_ALL);
keys->readSettings();
initUI(); initUI();
} }
@ -419,6 +428,10 @@ void LayoutConfig::save()
m_forceGrpOverwrite = false; m_forceGrpOverwrite = false;
} }
// Save and apply global shortcuts
m_keyChooser->commitChanges();
keys->writeSettings(0, true);
// Get current layout from Kxkb // Get current layout from Kxkb
if (!kapp->dcopClient()->isAttached()) if (!kapp->dcopClient()->isAttached())
kapp->dcopClient()->attach(); kapp->dcopClient()->attach();
@ -715,6 +728,13 @@ TQWidget* LayoutConfig::makeOptionsTab()
return listView; return listView;
} }
TQWidget* LayoutConfig::makeShortcutsTab() {
m_keyChooser = new KKeyChooser(keys, widget->tabShortcuts, false, false);
connect(m_keyChooser, SIGNAL(keyChange()), this, SLOT(changed()));
widget->tabShortcuts->layout()->add(m_keyChooser);
return m_keyChooser;
}
void LayoutConfig::updateOptionsCommand() void LayoutConfig::updateOptionsCommand()
{ {
TQString setxkbmap; TQString setxkbmap;
@ -1064,7 +1084,7 @@ void LayoutConfig::hotkeyComboChanged() {
} }
if (widget->comboHotkey->currentItem() == other) { if (widget->comboHotkey->currentItem() == other) {
widget->tabWidget->setCurrentPage(3); widget->tabWidget->setCurrentPage(4);
widget->listOptions->ensureItemVisible(grpItem); widget->listOptions->ensureItemVisible(grpItem);
widget->listOptions->setFocus(); widget->listOptions->setFocus();
} }

@ -58,8 +58,11 @@ private:
KxkbConfig m_kxkbConfig; KxkbConfig m_kxkbConfig;
TQDict<OptionListItem> m_optionGroups; TQDict<OptionListItem> m_optionGroups;
bool m_forceGrpOverwrite; bool m_forceGrpOverwrite;
KKeyChooser *m_keyChooser;
TDEGlobalAccel *keys;
TQWidget* makeOptionsTab(); TQWidget* makeOptionsTab();
TQWidget* makeShortcutsTab();
void updateStickyLimit(); void updateStickyLimit();
static LayoutUnit getLayoutUnitKey(TQListViewItem *sel); static LayoutUnit getLayoutUnitKey(TQListViewItem *sel);
void checkConflicts(OptionListItem *current, TQStringList conflicting, void checkConflicts(OptionListItem *current, TQStringList conflicting,

@ -76,7 +76,7 @@
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="TQLabel" row="2" column="0" rowspan="1" colspan="2"> <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="2">
<property name="name"> <property name="name">
<cstring>textLabel1_4</cstring> <cstring>textLabel1_4</cstring>
</property> </property>
@ -92,33 +92,6 @@
<string>Active layouts:</string> <string>Active layouts:</string>
</property> </property>
</widget> </widget>
<widget class="TQLabel" row="0" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>labelHotkey</cstring>
</property>
<property name="text">
<string>Key combination to &amp;switch layout:</string>
</property>
<property name="buddy" stdset="0">
<cstring>comboHotkey</cstring>
</property>
</widget>
<widget class="TQComboBox" row="1" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>comboHotkey</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" stdset="0">
<string>Here you can choose the key combination you want to use to switch to the next layout. This list includes only the most common variants. If you choose "Other...", then you will be redirected to the "Options" tab where you can pick from all the available variants. Note that if you have selected Append Mode in the Xkb Options tab this option is not available; you have to use the Xkb Options tab instead.</string>
</property>
</widget>
<widget class="TQLabel" row="0" column="2" rowspan="1" colspan="3"> <widget class="TQLabel" row="0" column="2" rowspan="1" colspan="3">
<property name="name"> <property name="name">
<cstring>labelModel</cstring> <cstring>labelModel</cstring>
@ -282,7 +255,7 @@
<cstring>editCmdLine</cstring> <cstring>editCmdLine</cstring>
</property> </property>
</widget> </widget>
<widget class="TQListView" row="3" column="0" rowspan="5" colspan="2"> <widget class="TQListView" row="1" column="0" rowspan="6" colspan="2">
<column> <column>
<property name="text"> <property name="text">
<string></string> <string></string>
@ -423,6 +396,59 @@
</widget> </widget>
</grid> </grid>
</widget> </widget>
<widget class="TQWidget">
<property name="name">
<cstring>tabShortcuts</cstring>
</property>
<attribute name="title">
<string>Keyboard Shortcuts</string>
</attribute>
<vbox>
<widget class="TQLabel">
<property name="name">
<cstring>labelHotkey</cstring>
</property>
<property name="text">
<string>&lt;qt&gt;&lt;b&gt;Key combination to switch layout (X11):&lt;/b&gt;&lt;/qt&gt;</string>
</property>
<property name="buddy" stdset="0">
<cstring>comboHotkey</cstring>
</property>
</widget>
<widget class="TQComboBox">
<property name="name">
<cstring>comboHotkey</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" stdset="0">
<string>Here you can choose the key combination you want to use to switch to the next layout. This list includes only the most common variants. If you choose "Other...", then you will be redirected to the "Options" tab where you can pick from all the available variants. Note that if you have selected Append Mode in the Xkb Options tab this option is not available; you have to use the Xkb Options tab instead.</string>
</property>
</widget>
<widget class="KSeparator">
<property name="name">
<cstring>switchingGrpSeparator</cstring>
</property>
</widget>
<widget class="TQLabel">
<property name="name">
<cstring>labelHotkey</cstring>
</property>
<property name="text">
<string>&lt;qt&gt;&lt;b&gt;TDE shortcuts to switch layout:&lt;/b&gt;&lt;/qt&gt;</string>
</property>
<property name="buddy" stdset="0">
<cstring>comboHotkey</cstring>
</property>
</widget>
</vbox>
</widget>
<widget class="TQWidget"> <widget class="TQWidget">
<property name="name"> <property name="name">
<cstring>tab</cstring> <cstring>tab</cstring>

@ -74,6 +74,10 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled)
m_layoutOwnerMap = new LayoutMap(kxkbConfig); m_layoutOwnerMap = new LayoutMap(kxkbConfig);
// keep in sync with kcmlayout.cpp
keys = new TDEGlobalAccel(TQT_TQOBJECT(this));
#include "kxkbbindings.cpp"
connect( this, TQT_SIGNAL(settingsChanged(int)), TQT_SLOT(slotSettingsChanged(int)) ); connect( this, TQT_SIGNAL(settingsChanged(int)), TQT_SLOT(slotSettingsChanged(int)) );
addKipcEventMask( KIPC::SettingsChanged ); addKipcEventMask( KIPC::SettingsChanged );
} }
@ -81,11 +85,12 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled)
KXKBApp::~KXKBApp() KXKBApp::~KXKBApp()
{ {
delete m_tray; delete m_tray;
delete m_rules; delete m_rules;
delete m_extension; delete m_extension;
delete m_layoutOwnerMap; delete m_layoutOwnerMap;
delete kWinModule; delete kWinModule;
delete keys;
} }
int KXKBApp::newInstance() int KXKBApp::newInstance()
@ -151,6 +156,8 @@ bool KXKBApp::settingsRead()
initTray(); initTray();
TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals
keys->readSettings();
keys->updateConnections();
return true; return true;
} }
@ -235,6 +242,13 @@ void KXKBApp::nextLayout()
setLayout(layout); setLayout(layout);
} }
void KXKBApp::prevLayout()
{
const LayoutUnit& layout = m_layoutOwnerMap->getPrevLayout().layoutUnit;
setLayout(layout);
}
void KXKBApp::menuActivated(int id) void KXKBApp::menuActivated(int id)
{ {
if( KxkbLabelController::START_MENU_ID <= id if( KxkbLabelController::START_MENU_ID <= id
@ -297,10 +311,11 @@ void KXKBApp::windowChanged(WId winId)
void KXKBApp::slotSettingsChanged(int category) void KXKBApp::slotSettingsChanged(int category)
{ {
if ( category != TDEApplication::SETTINGS_SHORTCUTS) if (category == TDEApplication::SETTINGS_SHORTCUTS) {
return; TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals
keys->readSettings();
TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals keys->updateConnections();
}
} }
bool KXKBApp::x11EventFilter(XEvent *e) { bool KXKBApp::x11EventFilter(XEvent *e) {
@ -309,8 +324,7 @@ bool KXKBApp::x11EventFilter(XEvent *e) {
return TDEApplication::x11EventFilter(e); return TDEApplication::x11EventFilter(e);
} }
const char * DESCRIPTION = const char *DESCRIPTION = I18N_NOOP("A utility to switch keyboard maps");
I18N_NOOP("A utility to switch keyboard maps");
extern "C" KDE_EXPORT int kdemain(int argc, char *argv[]) extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
{ {

@ -67,6 +67,7 @@ k_dcop:
public slots: public slots:
void nextLayout(); void nextLayout();
void prevLayout();
protected slots: protected slots:
void menuActivated(int id); void menuActivated(int id);

@ -0,0 +1,13 @@
#ifndef NOSLOTS
# define DEF( name, key3, key4, fnSlot ) \
keys->insert( name, i18n(name), TQString(), key3, key4, TQT_TQOBJECT(this), TQT_SLOT(fnSlot) )
#else
# define DEF( name, key3, key4, fnSlot ) \
keys->insert( name, i18n(name), TQString(), key3, key4, 0, 0 )
#endif
keys->insert( "Program:kxkb", i18n("Keyboard") );
DEF( I18N_NOOP("Switch to Next Keyboard Layout"), TDEShortcut(), TDEShortcut(), nextLayout() );
DEF( I18N_NOOP("Switch to Previous Keyboard Layout"), TDEShortcut(), TDEShortcut(), prevLayout() );
#undef DEF

@ -36,7 +36,7 @@ bool KxkbConfig::load(int loadMode)
config->setGroup("Layout"); config->setGroup("Layout");
if( loadMode == LOAD_ALL ) { if( loadMode == LOAD_ALL ) {
m_resetOldOptions = config->readBoolEntry("ResetOldOptions", false); m_resetOldOptions = config->readBoolEntry("ResetOldOptions", true);
m_options = config->readEntry("Options", ""); m_options = config->readEntry("Options", "");
} }
@ -205,7 +205,7 @@ void KxkbConfig::setDefaults()
{ {
m_model = DEFAULT_MODEL; m_model = DEFAULT_MODEL;
m_resetOldOptions = false; m_resetOldOptions = true;
m_options = ""; m_options = "";
m_layouts.clear(); m_layouts.clear();

@ -93,6 +93,19 @@ LayoutState& LayoutMap::getNextLayout() {
return *layoutQueue.head(); return *layoutQueue.head();
} }
LayoutState& LayoutMap::getPrevLayout() {
LayoutQueue& layoutQueue = getCurrentLayoutQueue(m_currentWinId);
for (int i = 1; i < layoutQueue.count(); ++i) {
LayoutState* layoutState = layoutQueue.dequeue();
layoutQueue.enqueue(layoutState);
}
kdDebug() << "map: Next layout: " << layoutQueue.head()->layoutUnit.toPair()
<< " for " << m_currentWinId << endl;
return *layoutQueue.head();
}
void LayoutMap::setCurrentLayout(const LayoutUnit& layoutUnit) { void LayoutMap::setCurrentLayout(const LayoutUnit& layoutUnit) {
LayoutQueue& layoutQueue = getCurrentLayoutQueue(m_currentWinId); LayoutQueue& layoutQueue = getCurrentLayoutQueue(m_currentWinId);
kdDebug() << "map: Storing layout: " << layoutUnit.toPair() kdDebug() << "map: Storing layout: " << layoutUnit.toPair()

@ -48,6 +48,7 @@ public:
void setCurrentLayout(const LayoutUnit& layoutUnit); void setCurrentLayout(const LayoutUnit& layoutUnit);
LayoutState& getNextLayout(); LayoutState& getNextLayout();
LayoutState& getPrevLayout();
LayoutState& getCurrentLayout(); LayoutState& getCurrentLayout();
void setCurrentWindow(WId winId); void setCurrentWindow(WId winId);

Loading…
Cancel
Save