diff options
Diffstat (limited to 'kcontrol/keys')
-rw-r--r-- | kcontrol/keys/shortcuts.cpp | 57 | ||||
-rw-r--r-- | kcontrol/keys/shortcuts.h | 4 |
2 files changed, 61 insertions, 0 deletions
diff --git a/kcontrol/keys/shortcuts.cpp b/kcontrol/keys/shortcuts.cpp index e65364f4c..2ceceb46a 100644 --- a/kcontrol/keys/shortcuts.cpp +++ b/kcontrol/keys/shortcuts.cpp @@ -24,9 +24,12 @@ #include "shortcuts.h" +#include <stdlib.h> + #include <qdir.h> #include <qlayout.h> #include <qwhatsthis.h> +#include <qcheckbox.h> #include <kapplication.h> #include <kdebug.h> @@ -101,6 +104,8 @@ QString ShortcutsModule::quickHelp() const void ShortcutsModule::initGUI() { + QString kde_winkeys_env_dir = KGlobal::dirs()->localkdedir() + "/env/"; + kdDebug(125) << "A-----------" << endl; KAccelActions* keys = &m_actionsGeneral; // see also KShortcutsModule::init() below !!! @@ -172,8 +177,27 @@ void ShortcutsModule::initGUI() m_pTab->setMargin( KDialog::marginHint() ); pVLayout->addWidget( m_pTab ); + // See if ~/.kde3/env/win-key.sh exists + QFile f( kde_winkeys_env_dir + "win-key.sh" ); + if ( f.exists() == false ) { + // No, it does not, so Win is a modifier + m_bUseRmWinKeys = true; + } + else { + // Yes, it does, so Win is a key + m_bUseRmWinKeys = false; + } m_pListGeneral = new KAccelShortcutList( m_actionsGeneral, true ); + m_pkcGeneral = new KKeyChooser( m_pListGeneral, this, KKeyChooser::Global, false ); + m_pkcGeneral->resize (m_pkcGeneral->sizeHint() ); + if (system("xmodmap 1> /dev/null 2> /dev/null") == 0) { + m_useRmWinKeys = new QCheckBox( i18n("Use Win key as modifier (uncheck to bind Win key to Menu)"), this ); + m_useRmWinKeys->resize( m_useRmWinKeys->sizeHint() ); + m_useRmWinKeys->setChecked( m_bUseRmWinKeys ); + pVLayout->addWidget( m_useRmWinKeys, 1, 0 ); + connect( m_useRmWinKeys, SIGNAL(clicked()), SLOT(slotUseRmWinKeysClicked()) ); + } m_pTab->addTab( m_pkcGeneral, i18n("&Global Shortcuts") ); connect( m_pkcGeneral, SIGNAL(keyChange()), SLOT(slotKeyChange()) ); @@ -432,4 +456,37 @@ void ShortcutsModule::slotRemoveScheme() { } +void ShortcutsModule::slotUseRmWinKeysClicked() +{ + QString kde_winkeys_env_dir = KGlobal::dirs()->localkdedir() + "/env/"; + + // See if ~/.kde3/env/win-key.sh exists + QFile f( kde_winkeys_env_dir + "win-key.sh" ); + if ( f.exists() == false ) { + // No, it does not, so Win is currently a modifier + if (m_useRmWinKeys->isChecked() == false) { + // Create the file + if ( f.open( IO_WriteOnly ) ) { + QTextStream stream( &f ); + stream << "xmodmap -e 'keycode 133=Menu'" << "\n"; + stream << "xmodmap -e 'keycode 134=Menu'" << "\n"; + f.close(); + system("xmodmap -e 'keycode 133=Menu'"); + system("xmodmap -e 'keycode 134=Menu'"); + } + } + } + else { + // Yes, it does, so Win is currently a key + m_bUseRmWinKeys = false; + if (m_useRmWinKeys->isChecked() == true) { + // Remove the file + f.remove(); + // Update key mappings + system("xmodmap -e 'keycode 133=Super_L'"); + system("xmodmap -e 'keycode 134=Super_R'"); + } + } +} + #include "shortcuts.moc" diff --git a/kcontrol/keys/shortcuts.h b/kcontrol/keys/shortcuts.h index a16a619e3..e51d8cb7a 100644 --- a/kcontrol/keys/shortcuts.h +++ b/kcontrol/keys/shortcuts.h @@ -25,6 +25,7 @@ #define __SHORTCUTS_MODULE_H #include <qbuttongroup.h> +#include <qcheckbox.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qtabwidget.h> @@ -61,6 +62,7 @@ class ShortcutsModule : public QWidget void slotSelectScheme( int = 0 ); void slotSaveSchemeAs(); void slotRemoveScheme(); + void slotUseRmWinKeysClicked(); private: QTabWidget* m_pTab; @@ -72,6 +74,8 @@ class ShortcutsModule : public QWidget KAccelActions m_actionsGeneral, m_actionsSequence;//, m_actionsApplication; KShortcutList* m_pListGeneral, * m_pListSequence, * m_pListApplication; KKeyChooser* m_pkcGeneral, * m_pkcSequence, * m_pkcApplication; + QCheckBox* m_useRmWinKeys; + bool m_bUseRmWinKeys; }; #endif // __SHORTCUTS_MODULE_H |