4
* Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
6
* Requires the Qt widget libraries, available at no cost at
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
#include <ksimpleconfig.h>
30
#include "commandShortcuts.h"
32
#include "modifiers.h"
33
#include "shortcuts.h"
37
| Shortcut Schemes | Modifier Keys |
39
o Current scheme o New scheme o Pre-set scheme
40
| KDE Traditional |v|| <Save Scheme...> <Remove Scheme>
41
[] Prefer 4-modifier defaults
44
o New scheme <Save Scheme>
45
o Pre-set scheme <Remove Scheme>
46
| KDE Traditional |v||
47
[] Prefer 4-modifier defaults
51
KeyModule::KeyModule( QWidget *parent, const char *name )
52
: KCModule( parent, name )
54
setQuickHelp( i18n("<h1>Keyboard Shortcuts</h1> Using shortcuts you can configure certain actions to be"
55
" triggered when you press a key or a combination of keys, e.g. Ctrl+C is normally bound to"
56
" 'Copy'. KDE allows you to store more than one 'scheme' of shortcuts, so you might want"
57
" to experiment a little setting up your own scheme, although you can still change back to the"
58
" KDE defaults.<p> In the 'Global Shortcuts' tab you can configure non-application-specific"
59
" bindings, like how to switch desktops or maximize a window; in the 'Application Shortcuts' tab"
60
" you will find bindings typically used in applications, such as copy and paste."));
65
KeyModule::~KeyModule()
70
void KeyModule::initGUI()
72
m_pTab = new QTabWidget( this );
73
QVBoxLayout *l = new QVBoxLayout(this);
76
m_pShortcuts = new ShortcutsModule( this );
77
m_pTab->addTab( m_pShortcuts, i18n("Shortcut Schemes") );
78
connect( m_pShortcuts, SIGNAL(changed(bool)), SIGNAL(changed(bool)) );
80
m_pCommandShortcuts = new CommandShortcutsModule ( this );
81
m_pTab->addTab( m_pCommandShortcuts, i18n("Command Shortcuts") );
82
connect( m_pCommandShortcuts, SIGNAL(changed(bool)), SIGNAL(changed(bool)) );
83
connect( m_pTab, SIGNAL(currentChanged(QWidget*)), m_pCommandShortcuts, SLOT(showing(QWidget*)) );
85
m_pModifiers = new ModifiersModule( this );
86
m_pTab->addTab( m_pModifiers, i18n("Modifier Keys") );
87
connect( m_pModifiers, SIGNAL(changed(bool)), SIGNAL(changed(bool)) );
90
void KeyModule::load()
95
// Called when [Reset] is pressed
96
void KeyModule::load( bool useDefaults )
98
kdDebug(125) << "KeyModule::load()" << endl;
100
m_pCommandShortcuts->load();
101
m_pModifiers->load( useDefaults );
103
emit changed( useDefaults );
106
// When [Apply] or [OK] are clicked.
107
void KeyModule::save()
109
kdDebug(125) << "KeyModule::save()" << endl;
110
m_pShortcuts->save();
111
m_pCommandShortcuts->save();
112
m_pModifiers->save();
115
void KeyModule::defaults()
117
kdDebug(125) << "KeyModule::defaults()" << endl;
118
m_pShortcuts->defaults();
119
m_pCommandShortcuts->defaults();
120
m_pModifiers->defaults();
123
void KeyModule::resizeEvent( QResizeEvent * )
125
m_pTab->setGeometry( 0, 0, width(), height() );
128
//----------------------------------------------------
132
KDE_EXPORT KCModule *create_keys(QWidget *parent, const char * /*name*/)
134
// What does this do? Why not insert klipper and kxkb, too? --ellis, 2002/01/15
135
KGlobal::locale()->insertCatalogue("kwin");
136
KGlobal::locale()->insertCatalogue("kdesktop");
137
KGlobal::locale()->insertCatalogue("kicker");
138
return new KeyModule(parent, "kcmkeys");
141
KDE_EXPORT void initModifiers()
143
kdDebug(125) << "KeyModule::initModifiers()" << endl;
145
KConfigGroupSaver cgs( KGlobal::config(), "Keyboard" );
146
bool bMacSwap = KGlobal::config()->readBoolEntry( "Mac Modifier Swap", false );
148
ModifiersModule::setupMacModifierKeys();
151
KDE_EXPORT void init_keys()
153
kdDebug(125) << "KeyModule::init()\n";
155
/*kdDebug(125) << "KKeyModule::init() - Initialize # Modifier Keys Settings\n";
156
KConfigGroupSaver cgs( KGlobal::config(), "Keyboard" );
157
QString fourMods = KGlobal::config()->readEntry( "Use Four Modifier Keys", KAccel::keyboardHasMetaKey() ? "true" : "false" );
158
KAccel::useFourModifierKeys( fourMods == "true" );
159
bool bUseFourModifierKeys = KAccel::useFourModifierKeys();
160
KGlobal::config()->writeEntry( "User Four Modifier Keys", bUseFourModifierKeys ? "true" : "false", true, true );
162
KAccelActions* keys = new KAccelActions();
164
kdDebug(125) << "KeyModule::init() - Load Included Bindings\n";
165
// this should match the included files above
167
#define SHIFT Qt::SHIFT
168
#define CTRL Qt::CTRL
170
#include "../../klipper/klipperbindings.cpp"
171
#include "../../kwin/kwinbindings.cpp"
172
#define KICKER_ALL_BINDINGS
173
#include "../../kicker/kicker/core/kickerbindings.cpp"
174
#include "../../kicker/taskbar/taskbarbindings.cpp"
175
#include "../../kdesktop/kdesktopbindings.cpp"
176
#include "../../kxkb/kxkbbindings.cpp"
178
// Write all the global keys to kdeglobals.
179
// This is needed to be able to check for conflicts with global keys in app's keyconfig
180
// dialogs, kdeglobals is empty as long as you don't apply any change in controlcenter/keys.
181
// However, avoid writing at every KDE startup, just update them after every rebuild of this file.
182
KConfigGroup group( KGlobal::config(), "Global Shortcuts" );
183
if( group.readEntry( "Defaults timestamp" ) != __DATE__ __TIME__ ) {
184
kdDebug(125) << "KeyModule::init() - Read Config Bindings\n";
185
// Check for old group,
186
if( KGlobal::config()->hasGroup( "Global Keys" ) ) {
187
keys->readActions( "Global Keys" );
188
KGlobal::config()->deleteGroup( "Global Keys", true, true );
190
keys->readActions( "Global Shortcuts" );
191
KGlobal::config()->deleteGroup( "Global Shortcuts", true, true );
193
kdDebug(125) << "KeyModule::init() - Write Config Bindings\n";
194
keys->writeActions( "Global Shortcuts", 0, true, true );
195
group.writeEntry( "Defaults timestamp", __DATE__ __TIME__, true, true );