1 /****************************************************************************
5 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
13 #include <config-workspace.h>
15 #include <kapplication.h>
16 #include <kcmdlineargs.h>
17 #include <kstandarddirs.h>
20 #include <QtDBus/QtDBus>
22 #include "khotkeysiface.h"
23 #include "kglobalaccel.h"
27 using namespace KHotKeys
;
29 int main( int argc
, char* argv
[] )
31 KCmdLineArgs::init( argc
, argv
, "khotkeys", 0, ki18n("KHotKeys Update"), "1.0" ,
32 ki18n("KHotKeys update utility"));
34 KCmdLineOptions options
;
35 options
.add("id <id>", ki18n("Id of the script to add to %1").subs(KHOTKEYS_CONFIG_FILE
));
36 KCmdLineArgs::addCmdLineOptions( options
);
37 KApplication
app( true ); // X11 connection is necessary for KKey* stuff :-/
38 KCmdLineArgs
* args
= KCmdLineArgs::parsedArgs();
39 QString id
= args
->getOption( "id" );
40 QString file
= KStandardDirs::locate( "data", "khotkeys/" + id
+ ".khotkeys" );
43 kWarning() << "File " << id
<< " not found!" ;
46 KGlobalAccel::self()->overrideMainComponentData(KComponentData("khotkeys"));
47 init_global_data( false, &app
);
49 settings
.read_settings( true );
51 if( !settings
.import( cfg
, false ))
53 kWarning() << "Import of " << id
<< " failed!" ;
56 settings
.write_settings();
57 QDBusConnection bus
= QDBusConnection::sessionBus();
58 if( bus
.interface()->isServiceRegistered( "org.kde.kded" ))
60 org::kde::khotkeys
iface("org.kde.kded", "/modules/khotkeys", bus
);
61 iface
.reread_configuration();
62 kDebug() << "telling khotkeys daemon to reread configuration";