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.
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
39 #include "moduleIface.h"
41 #include <kcmdlineargs.h>
42 #include <kaboutdata.h>
43 #include <kglobalsettings.h>
45 #include <kconfiggroup.h>
51 #include <QDesktopWidget>
55 KInfoCenterApp::KInfoCenterApp()
56 : KUniqueApplication()
59 toplevel
= new TopLevel();
61 // hmm? KApplication registers its KComponentData as the main and active component. Why is this
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");
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();
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
);
89 KInfoCenterApp::~KInfoCenterApp()
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());
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();
126 if (!KInfoCenterApp::start()) {
127 kDebug(1208) << "kinfocenter is already running!\n";