You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdebase/khotkeys/update/update.cpp

63 lines
1.8 KiB

/****************************************************************************
KHotKeys
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#define _UPDATE_CPP_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kstandarddirs.h>
#include <kconfig.h>
#include <kdebug.h>
#include <dcopclient.h>
#include <settings.h>
using namespace KHotKeys;
static const KCmdLineOptions options[] =
{
// no need for I18N_NOOP(), this is not supposed to be used directly
{ "id <id>", "Id of the script to add to khotkeysrc.", 0 },
KCmdLineLastOption
};
int main( int argc, char* argv[] )
{
KCmdLineArgs::init( argc, argv, "khotkeys_update", "KHotKeys Update",
"KHotKeys update utility", "1.0" );
KCmdLineArgs::addCmdLineOptions( options );
KApplication app( false, true ); // X11 connection is necessary for KKey* stuff :-/
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
TQCString id = args->getOption( "id" );
TQString file = locate( "data", "khotkeys/" + id + ".khotkeys" );
if( file.isEmpty())
{
kdWarning() << "File " << id << " not found!" << endl;
return 1;
}
init_global_data( false, TQT_TQOBJECT(&app) );
Settings settings;
settings.read_settings( true );
KConfig cfg( file, true );
if( !settings.import( cfg, false ))
{
kdWarning() << "Import of " << id << " failed!" << endl;
return 2;
}
settings.write_settings();
TQByteArray data;
kapp->dcopClient()->send( "khotkeys*", "khotkeys", "reread_configuration()", data );
return 0;
}