not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / kxkb / kxkbapp.cpp
blob15799890905113e548c51766370abb00131b0ec6
1 /*
2 Copyright (C) 2001, S.R.Haque <srhaque@iee.org>.
3 Copyright (C) 2006, Andriy Rysin <rysin@kde.org>. Derived from an
4 original by Matthias H�zer-Klpfel released under the QPL.
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
22 DESCRIPTION
24 KDE Keyboard Tool. Manages XKB keyboard mappings.
27 #include <kaboutdata.h>
28 #include <kcmdlineargs.h>
29 #include <klocale.h>
30 #include <kglobal.h>
32 #include "kxkb_adaptor.h"
34 #include "kxkbapp.h"
35 #include "kxkbwidget.h"
37 #include "kxkbapp.moc"
40 KXKBApp::KXKBApp(bool allowStyles, bool GUIenabled)
41 : KUniqueApplication(allowStyles, GUIenabled)
43 setQuitOnLastWindowClosed(false);
45 m_kxkbCore = new KxkbCore( KxkbCore::KXKB_MAIN );
47 if( isError() ) {
48 exit(2); // failed XKB
49 return;
54 KXKBApp::~KXKBApp()
58 int KXKBApp::newInstance()
60 int res = m_kxkbCore->newInstance();
61 if( isError() ) {
62 exit(0); // not using kxkb from settings
63 return res;
66 KxkbWidget* kxkbWidget = new KxkbSysTrayIcon(KxkbWidget::MENU_FULL);
67 m_kxkbCore->setWidget(kxkbWidget);
69 new KXKBAdaptor( this );
71 return res;
75 const char * DESCRIPTION =
76 I18N_NOOP("A utility to switch keyboard maps");
78 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
80 KAboutData about("kxkb", 0, ki18n("KDE Keyboard Layout Switcher"), "2.0",
81 ki18n(DESCRIPTION), KAboutData::License_GPL,
82 ki18n("Copyright (C) 2006-2007 Andriy Rysin"));
83 KCmdLineArgs::init(argc, argv, &about);
84 KXKBApp::addCmdLineOptions();
86 if (!KXKBApp::start())
87 return 0;
89 KXKBApp app;
90 if( ! app.isError() ) {
91 app.disableSessionManagement();
92 app.exec();
94 return 0;