summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2023-06-01 12:53:38 +0300
committerMavridis Philippe <mavridisf@gmail.com>2023-06-14 14:18:24 +0300
commit22bb398b3ba83142bf49f6abf47081e5e9e11bef (patch)
tree4783649fb76eb12aac34fb9342e8e8205de616d9
parentbcd2bfcdc49dcf97b730889d5554b15623072a40 (diff)
downloadtdebase-22bb398b3ba83142bf49f6abf47081e5e9e11bef.tar.gz
tdebase-22bb398b3ba83142bf49f6abf47081e5e9e11bef.zip
kxkb: re-add custom TDE switching shortcut
This commit fixes issue #342. Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r--kcontrol/keys/keyconfig.cpp2
-rw-r--r--kcontrol/keys/main.cpp1
-rw-r--r--kcontrol/keys/shortcuts.cpp1
-rw-r--r--kxkb/CMakeL10n.txt2
-rw-r--r--kxkb/kcmlayout.cpp24
-rw-r--r--kxkb/kcmlayout.h3
-rw-r--r--kxkb/kcmlayoutwidget.ui84
-rw-r--r--kxkb/kxkb.cpp32
-rw-r--r--kxkb/kxkb.h1
-rw-r--r--kxkb/kxkbbindings.cpp13
-rw-r--r--kxkb/kxkbconfig.cpp4
-rw-r--r--kxkb/layoutmap.cpp13
-rw-r--r--kxkb/layoutmap.h1
13 files changed, 139 insertions, 42 deletions
diff --git a/kcontrol/keys/keyconfig.cpp b/kcontrol/keys/keyconfig.cpp
index 4ba5951dd..ee39447a1 100644
--- a/kcontrol/keys/keyconfig.cpp
+++ b/kcontrol/keys/keyconfig.cpp
@@ -66,6 +66,7 @@ void KKeyModule::init( bool isGlobal, bool _bSeriesOnly, bool bSeriesNone )
#include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp"
#include "../../klipper/klipperbindings.cpp"
+#include "../../kxkb/kxkbbindings.cpp"
#undef TDEShortcuts
KeyScheme = "Global Key Scheme";
KeySet = "Global Keys";
@@ -488,6 +489,7 @@ void KKeyModule::init()
#include "../../kicker/kicker/core/kickerbindings.cpp"
#include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp"
+#include "../../kxkb/kxkbbindings.cpp"
#undef TDEShortcuts
kdDebug(125) << "KKeyModule::init() - Read Config Bindings\n";
diff --git a/kcontrol/keys/main.cpp b/kcontrol/keys/main.cpp
index 53daa462e..d002b667f 100644
--- a/kcontrol/keys/main.cpp
+++ b/kcontrol/keys/main.cpp
@@ -190,6 +190,7 @@ extern "C"
#include "../../kicker/kicker/core/kickerbindings.cpp"
#include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp"
+#include "../../kxkb/kxkbbindings.cpp"
// Write all the global keys to kdeglobals.
// This is needed to be able to check for conflicts with global keys in app's keyconfig
diff --git a/kcontrol/keys/shortcuts.cpp b/kcontrol/keys/shortcuts.cpp
index e350b1e22..e7f599dda 100644
--- a/kcontrol/keys/shortcuts.cpp
+++ b/kcontrol/keys/shortcuts.cpp
@@ -116,6 +116,7 @@ void ShortcutsModule::initGUI()
#include "../../kicker/taskbar/taskbarbindings.cpp"
#include "../../kdesktop/kdesktopbindings.cpp"
#include "../../klipper/klipperbindings.cpp"
+#include "../../kxkb/kxkbbindings.cpp"
kdDebug(125) << "B-----------" << endl;
m_actionsSequence.init( m_actionsGeneral );
diff --git a/kxkb/CMakeL10n.txt b/kxkb/CMakeL10n.txt
index 908f4d080..0238bd7e3 100644
--- a/kxkb/CMakeL10n.txt
+++ b/kxkb/CMakeL10n.txt
@@ -5,6 +5,7 @@ tde_l10n_create_template(
SOURCES
kcmlayout.cpp
kcmmisc.cpp
+ kxkbbindings.cpp
pixmap.cpp
rules.cpp
*.ui
@@ -15,6 +16,7 @@ tde_l10n_create_template(
SOURCES
extension.cpp
kxkb.cpp
+ kxkbbindings.cpp
kxkbtraywindow.cpp
pixmap.cpp
rules.cpp
diff --git a/kxkb/kcmlayout.cpp b/kxkb/kcmlayout.cpp
index a2b5d8e12..9499d8efc 100644
--- a/kxkb/kcmlayout.cpp
+++ b/kxkb/kcmlayout.cpp
@@ -13,6 +13,7 @@
#include <tqlistview.h>
#include <tqbuttongroup.h>
#include <tqspinbox.h>
+#include <tqvbox.h>
#include <tdefontrequester.h>
#include <kcolorbutton.h>
@@ -25,6 +26,7 @@
#include <tdeapplication.h>
#include <kiconloader.h>
#include <tdemessagebox.h>
+#include <kglobalaccel.h>
#include <dcopref.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
loadRules();
- makeOptionsTab();
+ // Load global shortcuts
+#define NOSLOTS
+ keys = new TDEGlobalAccel(TQT_TQOBJECT(this));
+#include "kxkbbindings.cpp"
+ makeOptionsTab();
load();
+ makeShortcutsTab();
}
@@ -184,6 +191,8 @@ void LayoutConfig::load()
{
m_kxkbConfig.load(KxkbConfig::LOAD_ALL);
+ keys->readSettings();
+
initUI();
}
@@ -419,6 +428,10 @@ void LayoutConfig::save()
m_forceGrpOverwrite = false;
}
+ // Save and apply global shortcuts
+ m_keyChooser->commitChanges();
+ keys->writeSettings(0, true);
+
// Get current layout from Kxkb
if (!kapp->dcopClient()->isAttached())
kapp->dcopClient()->attach();
@@ -715,6 +728,13 @@ TQWidget* LayoutConfig::makeOptionsTab()
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()
{
TQString setxkbmap;
@@ -1064,7 +1084,7 @@ void LayoutConfig::hotkeyComboChanged() {
}
if (widget->comboHotkey->currentItem() == other) {
- widget->tabWidget->setCurrentPage(3);
+ widget->tabWidget->setCurrentPage(4);
widget->listOptions->ensureItemVisible(grpItem);
widget->listOptions->setFocus();
}
diff --git a/kxkb/kcmlayout.h b/kxkb/kcmlayout.h
index cfb748c10..23a1e0791 100644
--- a/kxkb/kcmlayout.h
+++ b/kxkb/kcmlayout.h
@@ -58,8 +58,11 @@ private:
KxkbConfig m_kxkbConfig;
TQDict<OptionListItem> m_optionGroups;
bool m_forceGrpOverwrite;
+ KKeyChooser *m_keyChooser;
+ TDEGlobalAccel *keys;
TQWidget* makeOptionsTab();
+ TQWidget* makeShortcutsTab();
void updateStickyLimit();
static LayoutUnit getLayoutUnitKey(TQListViewItem *sel);
void checkConflicts(OptionListItem *current, TQStringList conflicting,
diff --git a/kxkb/kcmlayoutwidget.ui b/kxkb/kcmlayoutwidget.ui
index aab21c2cf..c35df0921 100644
--- a/kxkb/kcmlayoutwidget.ui
+++ b/kxkb/kcmlayoutwidget.ui
@@ -76,7 +76,7 @@
<property name="name">
<cstring>unnamed</cstring>
</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">
<cstring>textLabel1_4</cstring>
</property>
@@ -92,33 +92,6 @@
<string>Active layouts:</string>
</property>
</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">
<property name="name">
<cstring>labelModel</cstring>
@@ -282,7 +255,7 @@
<cstring>editCmdLine</cstring>
</property>
</widget>
- <widget class="TQListView" row="3" column="0" rowspan="5" colspan="2">
+ <widget class="TQListView" row="1" column="0" rowspan="6" colspan="2">
<column>
<property name="text">
<string></string>
@@ -425,6 +398,59 @@
</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">
+ <property name="name">
<cstring>tab</cstring>
</property>
<attribute name="title">
diff --git a/kxkb/kxkb.cpp b/kxkb/kxkb.cpp
index 0764aff41..4bc5bdbd7 100644
--- a/kxkb/kxkb.cpp
+++ b/kxkb/kxkb.cpp
@@ -74,6 +74,10 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled)
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)) );
addKipcEventMask( KIPC::SettingsChanged );
}
@@ -81,11 +85,12 @@ KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled)
KXKBApp::~KXKBApp()
{
- delete m_tray;
- delete m_rules;
- delete m_extension;
+ delete m_tray;
+ delete m_rules;
+ delete m_extension;
delete m_layoutOwnerMap;
delete kWinModule;
+ delete keys;
}
int KXKBApp::newInstance()
@@ -151,6 +156,8 @@ bool KXKBApp::settingsRead()
initTray();
TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals
+ keys->readSettings();
+ keys->updateConnections();
return true;
}
@@ -235,6 +242,13 @@ void KXKBApp::nextLayout()
setLayout(layout);
}
+void KXKBApp::prevLayout()
+{
+ const LayoutUnit& layout = m_layoutOwnerMap->getPrevLayout().layoutUnit;
+ setLayout(layout);
+}
+
+
void KXKBApp::menuActivated(int id)
{
if( KxkbLabelController::START_MENU_ID <= id
@@ -297,10 +311,11 @@ void KXKBApp::windowChanged(WId winId)
void KXKBApp::slotSettingsChanged(int category)
{
- if ( category != TDEApplication::SETTINGS_SHORTCUTS)
- return;
-
- TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals
+ if (category == TDEApplication::SETTINGS_SHORTCUTS) {
+ TDEGlobal::config()->reparseConfiguration(); // kcontrol modified kdeglobals
+ keys->readSettings();
+ keys->updateConnections();
+ }
}
bool KXKBApp::x11EventFilter(XEvent *e) {
@@ -309,8 +324,7 @@ bool KXKBApp::x11EventFilter(XEvent *e) {
return TDEApplication::x11EventFilter(e);
}
-const char * DESCRIPTION =
- I18N_NOOP("A utility to switch keyboard maps");
+const char *DESCRIPTION = I18N_NOOP("A utility to switch keyboard maps");
extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
{
diff --git a/kxkb/kxkb.h b/kxkb/kxkb.h
index 06c45d834..5a54babdb 100644
--- a/kxkb/kxkb.h
+++ b/kxkb/kxkb.h
@@ -67,6 +67,7 @@ k_dcop:
public slots:
void nextLayout();
+ void prevLayout();
protected slots:
void menuActivated(int id);
diff --git a/kxkb/kxkbbindings.cpp b/kxkb/kxkbbindings.cpp
new file mode 100644
index 000000000..f4a0fb5c3
--- /dev/null
+++ b/kxkb/kxkbbindings.cpp
@@ -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 \ No newline at end of file
diff --git a/kxkb/kxkbconfig.cpp b/kxkb/kxkbconfig.cpp
index b1b428fa9..52ba6941b 100644
--- a/kxkb/kxkbconfig.cpp
+++ b/kxkb/kxkbconfig.cpp
@@ -36,7 +36,7 @@ bool KxkbConfig::load(int loadMode)
config->setGroup("Layout");
if( loadMode == LOAD_ALL ) {
- m_resetOldOptions = config->readBoolEntry("ResetOldOptions", false);
+ m_resetOldOptions = config->readBoolEntry("ResetOldOptions", true);
m_options = config->readEntry("Options", "");
}
@@ -205,7 +205,7 @@ void KxkbConfig::setDefaults()
{
m_model = DEFAULT_MODEL;
- m_resetOldOptions = false;
+ m_resetOldOptions = true;
m_options = "";
m_layouts.clear();
diff --git a/kxkb/layoutmap.cpp b/kxkb/layoutmap.cpp
index 636911199..62b44da10 100644
--- a/kxkb/layoutmap.cpp
+++ b/kxkb/layoutmap.cpp
@@ -93,6 +93,19 @@ LayoutState& LayoutMap::getNextLayout() {
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) {
LayoutQueue& layoutQueue = getCurrentLayoutQueue(m_currentWinId);
kdDebug() << "map: Storing layout: " << layoutUnit.toPair()
diff --git a/kxkb/layoutmap.h b/kxkb/layoutmap.h
index 38e6251ad..812814fff 100644
--- a/kxkb/layoutmap.h
+++ b/kxkb/layoutmap.h
@@ -48,6 +48,7 @@ public:
void setCurrentLayout(const LayoutUnit& layoutUnit);
LayoutState& getNextLayout();
+ LayoutState& getPrevLayout();
LayoutState& getCurrentLayout();
void setCurrentWindow(WId winId);