Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / apps / kinfocenter / main.cpp
bloba694ffb98b6fb1699aa1c1be166dc3bd2c802871
1 /*
2 Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
3 Copyright (c) 2000 Matthias Elter <elter@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * Howto debug:
23 * start "kinfocenter --nofork" in a debugger.
25 * If you want to test with command line arguments you need
26 * -after you have started kinfocenter in the debugger-
27 * open another shell and run kinfocenter with the desired
28 * command line arguments.
30 * The command line arguments will be passed to the version of
31 * kinfocenter in the debugger via DCOP and will cause a call
32 * to newInstance().
35 #include "main.h"
36 #include "version.h"
37 #include "toplevel.h"
38 #include "global.h"
39 #include "moduleIface.h"
41 #include <kcmdlineargs.h>
42 #include <kaboutdata.h>
43 #include <kglobalsettings.h>
44 #include <kconfig.h>
45 #include <kconfiggroup.h>
46 #include <kdebug.h>
47 #include <kglobal.h>
48 #include <klocale.h>
50 #include <QByteArray>
51 #include <QDesktopWidget>
53 #include "main.moc"
55 KInfoCenterApp::KInfoCenterApp()
56 : KUniqueApplication()
57 , toplevel(0)
59 toplevel = new TopLevel();
61 // hmm? KApplication registers its KComponentData as the main and active component. Why is this
62 // needed?
63 //KGlobal::setActiveComponent(this);
65 // KUniqueApplication does dcop regitration for us
66 ModuleIface *modIface = new ModuleIface(toplevel, "moduleIface");
68 connect (modIface, SIGNAL(helpClicked()), toplevel, SLOT(slotHelpRequest()));
70 QRect desk = KGlobalSettings::desktopGeometry(toplevel);
71 KConfigGroup config(KGlobal::config(), "General");
72 // Initial size is:
73 // never bigger than workspace as reported by desk
74 // 940x700 on 96 dpi, 12 pt font
75 // 800x600 on 72 dpi, 12 pt font
76 // --> 368 + 6 x dpiX, 312 + 4 x dpiY
77 // Adjusted for font size
78 int fontSize = toplevel->fontInfo().pointSize();
79 if (fontSize == 0)
80 fontSize = (toplevel->fontInfo().pixelSize() * 72) / toplevel->logicalDpiX();
81 int x = config.readEntry(QString::fromLatin1("InitialWidth %1").arg(desk.width()),
82 qMin( desk.width(), 368 + (6*toplevel->logicalDpiX()*fontSize)/12 ) );
83 int y = config.readEntry(QString::fromLatin1("InitialHeight %1").arg(desk.height()),
84 qMin( desk.height(), 312 + (4*toplevel->logicalDpiX()*fontSize)/12 ) );
85 toplevel->resize(x,y);
86 toplevel->show();
89 KInfoCenterApp::~KInfoCenterApp()
91 if (toplevel)
93 KConfigGroup config(KGlobal::config(), "General");
94 QDesktopWidget *desk = QApplication::desktop();
95 config.writeEntry(QString::fromLatin1("InitialWidth %1").arg(desk->width()), toplevel->width());
96 config.writeEntry(QString::fromLatin1("InitialHeight %1").arg(desk->height()), toplevel->height());
97 config.sync();
101 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
103 KLocale::setMainCatalog("kinfocenter");
105 KAboutData aboutKInfoCenter( "kinfocenter", 0, ki18n("KDE Info Center"),
106 KINFOCENTER_VERSION, ki18n("The KDE Info Center"), KAboutData::License_GPL,
107 ki18n("(c) 1998-2004, The KDE Control Center Developers"));
109 QByteArray argv_0 = argv[0];
110 KAboutData *aboutData;
111 aboutData = &aboutKInfoCenter;
112 KCGlobal::setIsInfoCenter(true);
113 kDebug(1208) << "Running as KInfoCenter!\n";
115 aboutData->addAuthor(ki18n("Helge Deller"), ki18n("Current Maintainer"), "deller@kde.org");
116 aboutData->addAuthor(ki18n("Matthias Hoelzer-Kluepfel"),KLocalizedString(), "hoelzer@kde.org");
117 aboutData->addAuthor(ki18n("Matthias Elter"),KLocalizedString(), "elter@kde.org");
118 aboutData->addAuthor(ki18n("Matthias Ettrich"),KLocalizedString(), "ettrich@kde.org");
119 aboutData->addAuthor(ki18n("Waldo Bastian"),KLocalizedString(), "bastian@kde.org");
121 KCmdLineArgs::init( argc, argv, aboutData );
122 KUniqueApplication::addCmdLineOptions();
124 KCGlobal::init();
126 if (!KInfoCenterApp::start()) {
127 kDebug(1208) << "kinfocenter is already running!\n";
128 return (0);
131 KInfoCenterApp app;
133 return app.exec();