]> cloud.milkyroute.net Git - dolphin.git/blob - src/main.cpp
msvc compile++
[dolphin.git] / src / main.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * *
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. *
9 * *
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. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "dolphinapplication.h"
22 #include "dolphinmainwindow.h"
23 #include <kaboutdata.h>
24 #include <kcmdlineargs.h>
25 #include <klocale.h>
26 #include <krun.h>
27 #include <QDBusInterface>
28 #include <QDBusReply>
29
30 static KCmdLineOptions options[] =
31 {
32 { "+[Url]", I18N_NOOP( "Document to open" ), 0 },
33 KCmdLineLastOption
34 };
35
36 void openWindow(DolphinApplication* app, const QString& url = QString())
37 {
38 if (app != 0) {
39 app->openWindow(url);
40 return;
41 }
42
43 static QDBusInterface dbusIface("org.kde.dolphin", "/dolphin/Application", "",
44 QDBusConnection::connectToBus(QDBusConnection::SessionBus, "session_bus"));
45 QDBusReply<int> reply = dbusIface.call("openWindow", url);
46 }
47
48 int main(int argc, char **argv)
49 {
50 KAboutData about("dolphin",
51 I18N_NOOP("Dolphin"),
52 "0.8.0",
53 I18N_NOOP("File Manager"),
54 KAboutData::License_GPL,
55 "(C) 2006 Peter Penz");
56 about.setHomepage("http://enzosworld.gmxhome.de");
57 about.setBugAddress("peter.penz@gmx.at");
58 about.addAuthor("Peter Penz", I18N_NOOP("Maintainer and developer"), "peter.penz@gmx.at");
59 about.addAuthor("Cvetoslav Ludmiloff", I18N_NOOP("Developer"), "ludmiloff@gmail.com");
60 about.addAuthor("Stefan Monov", I18N_NOOP("Developer"), "logixoul@gmail.com");
61 about.addAuthor("Michael Austin", I18N_NOOP("Documentation"), "tuxedup@users.sourceforge.net");
62 about.addAuthor("Orville Bennett", I18N_NOOP("Documentation"), "obennett@hartford.edu");
63 about.addCredit("Aaron J. Seigo", I18N_NOOP("... for the great support and the amazing patches"));
64 about.addCredit("Patrice Tremblay and Gregor Kalisnik", I18N_NOOP("... for their patches"));
65 about.addCredit("Ain, Itai, Ivan, Stephane, Patrice, Piotr and Stefano",
66 I18N_NOOP("... for their translations"));
67
68 KCmdLineArgs::init(argc, argv, &about);
69 KCmdLineArgs::addCmdLineOptions(options);
70 DolphinApplication *app = 0;
71 if (DolphinApplication::start()) {
72 app = new DolphinApplication();
73 }
74
75
76 #ifdef __GNUC__
77 #warning TODO, SessionManagement
78 #endif
79 #if 0
80 if (false /* KDE4-TODO: app.isSessionRestored() */) {
81 int n = 1;
82 while (KMainWindow::canBeRestored(n)){
83 Dolphin::mainWin().restore(n);
84 ++n;
85 }
86 } else {
87 #endif
88
89 KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
90 if (args->count() > 0) {
91 for (int i = 0; i < args->count(); ++i) {
92 openWindow(app, args->arg(i));
93 }
94 }
95 else {
96 openWindow(app);
97 }
98 args->clear();
99 if (app != 0) {
100 return app->exec();
101 }
102 }