kxkb: re-add custom TDE switching shortcut

This commit fixes issue #342.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
(cherry picked from commit 22bb398b3b)
pull/478/head
Mavridis Philippe 1 year ago
parent e4e948060d
commit 4e428e11c5
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 "../../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";

@ -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

@ -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 );

@ -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

@ -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();
}

@ -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,

@ -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>
@ -423,6 +396,59 @@
</widget>
</grid>
</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>

@ -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[])
{

@ -67,6 +67,7 @@ k_dcop:
public slots:
void nextLayout();
void prevLayout();
protected slots:
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");
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();

@ -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()

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

Loading…
Cancel
Save