1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2015 by Mathieu Tarral <mathieu.tarral@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #include "dolphin_version.h"
23 #include "dolphinmainwindow.h"
24 #include "dolphin_generalsettings.h"
25 #include "dbusinterface.h"
27 #include "dolphindebug.h"
29 #include <KDBusService>
31 #include <QCommandLineParser>
32 #include <QCommandLineOption>
33 #include <QApplication>
34 #include <KLocalizedString>
35 #include <Kdelibs4ConfigMigrator>
37 extern "C" Q_DECL_EXPORT
int kdemain(int argc
, char **argv
)
39 QApplication
app(argc
, argv
);
40 app
.setAttribute(Qt::AA_UseHighDpiPixmaps
, true);
41 app
.setWindowIcon(QIcon::fromTheme("system-file-manager"));
43 Kdelibs4ConfigMigrator
migrate(QStringLiteral("dolphin"));
44 migrate
.setConfigFiles(QStringList() << QStringLiteral("dolphinrc"));
45 migrate
.setUiFiles(QStringList() << QStringLiteral("dolphinpart.rc") << QStringLiteral("dolphinui.rc"));
48 KAboutData
aboutData("dolphin", i18n("Dolphin"), QStringLiteral(DOLPHIN_VERSION_STRING
),
49 i18nc("@title", "File Manager"),
51 i18nc("@info:credit", "(C) 2006-2014 Peter Penz, Frank Reininghaus, and Emmanuel Pescosta"));
52 aboutData
.setHomepage("http://dolphin.kde.org");
53 aboutData
.addAuthor(i18nc("@info:credit", "Emmanuel Pescosta"),
54 i18nc("@info:credit", "Maintainer (since 2014) and developer"),
55 "emmanuelpescosta099@gmail.com");
56 aboutData
.addAuthor(i18nc("@info:credit", "Frank Reininghaus"),
57 i18nc("@info:credit", "Maintainer (2012-2014) and developer"),
58 "frank78ac@googlemail.com");
59 aboutData
.addAuthor(i18nc("@info:credit", "Peter Penz"),
60 i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
61 "peter.penz19@gmail.com");
62 aboutData
.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
63 i18nc("@info:credit", "Developer"),
65 aboutData
.addAuthor(i18nc("@info:credit", "David Faure"),
66 i18nc("@info:credit", "Developer"),
68 aboutData
.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
69 i18nc("@info:credit", "Developer"),
71 aboutData
.addAuthor(i18nc("@info:credit", "Rafael Fernández López"),
72 i18nc("@info:credit", "Developer"),
74 aboutData
.addAuthor(i18nc("@info:credit", "Kevin Ottens"),
75 i18nc("@info:credit", "Developer"),
77 aboutData
.addAuthor(i18nc("@info:credit", "Holger Freyther"),
78 i18nc("@info:credit", "Developer"),
80 aboutData
.addAuthor(i18nc("@info:credit", "Max Blazejak"),
81 i18nc("@info:credit", "Developer"),
82 "m43ksrocks@gmail.com");
83 aboutData
.addAuthor(i18nc("@info:credit", "Michael Austin"),
84 i18nc("@info:credit", "Documentation"),
85 "tuxedup@users.sourceforge.net");
87 KAboutData::setApplicationData(aboutData
);
89 KDBusService dolphinDBusService
;
90 DBusInterface interface
;
92 QCommandLineParser parser
;
93 parser
.addVersionOption();
94 parser
.addHelpOption();
95 aboutData
.setupCommandLine(&parser
);
97 // command line options
98 parser
.addOption(QCommandLineOption(QStringList() << QLatin1String("select"), i18nc("@info:shell", "The files and directories passed as arguments "
99 "will be selected.")));
100 parser
.addOption(QCommandLineOption(QStringList() << QLatin1String("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
101 parser
.addOption(QCommandLineOption(QStringList() << QLatin1String("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface)")));
102 parser
.addPositionalArgument(QLatin1String("+[Url]"), i18nc("@info:shell", "Document to open"));
105 aboutData
.processCommandLine(&parser
);
107 if (parser
.isSet("daemon")) {
111 const QStringList args
= parser
.positionalArguments();
112 QList
<QUrl
> urls
= Dolphin::validateUris(args
);
114 if (urls
.isEmpty()) {
115 // We need at least one URL to open Dolphin
116 urls
.append(Dolphin::homeUrl());
119 const bool splitView
= parser
.isSet("split") || GeneralSettings::splitView();
120 if (splitView
&& urls
.size() < 2) {
121 // Split view does only make sense if we have at least 2 URLs
122 urls
.append(urls
.last());
125 DolphinMainWindow
* mainWindow
= new DolphinMainWindow();
126 mainWindow
->setAttribute(Qt::WA_DeleteOnClose
);
128 if (parser
.isSet("select")) {
129 mainWindow
->openFiles(urls
, splitView
);
131 mainWindow
->openDirectories(urls
, splitView
);
136 if (app
.isSessionRestored()) {
137 const QString className
= KXmlGuiWindow::classNameOfToplevel(1);
138 if (className
== QLatin1String("DolphinMainWindow")) {
139 mainWindow
->restore(1);
141 qCWarning(DolphinDebug
) << "Unknown class " << className
<< " in session saved data!";
145 return app
.exec(); // krazy:exclude=crash;