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>
32 #include <QCommandLineParser>
33 #include <QCommandLineOption>
34 #include <QApplication>
35 #include <KLocalizedString>
36 #include <Kdelibs4ConfigMigrator>
38 extern "C" Q_DECL_EXPORT
int kdemain(int argc
, char **argv
)
40 QApplication
app(argc
, argv
);
41 app
.setAttribute(Qt::AA_UseHighDpiPixmaps
, true);
42 app
.setWindowIcon(QIcon::fromTheme("system-file-manager"));
46 Kdelibs4ConfigMigrator
migrate(QStringLiteral("dolphin"));
47 migrate
.setConfigFiles(QStringList() << QStringLiteral("dolphinrc"));
48 migrate
.setUiFiles(QStringList() << QStringLiteral("dolphinpart.rc") << QStringLiteral("dolphinui.rc"));
51 KLocalizedString::setApplicationDomain("dolphin");
53 KAboutData
aboutData("dolphin", i18n("Dolphin"), QStringLiteral(DOLPHIN_VERSION_STRING
),
54 i18nc("@title", "File Manager"),
56 i18nc("@info:credit", "(C) 2006-2014 Peter Penz, Frank Reininghaus, and Emmanuel Pescosta"));
57 aboutData
.setHomepage("http://dolphin.kde.org");
58 aboutData
.addAuthor(i18nc("@info:credit", "Emmanuel Pescosta"),
59 i18nc("@info:credit", "Maintainer (since 2014) and developer"),
60 "emmanuelpescosta099@gmail.com");
61 aboutData
.addAuthor(i18nc("@info:credit", "Frank Reininghaus"),
62 i18nc("@info:credit", "Maintainer (2012-2014) and developer"),
63 "frank78ac@googlemail.com");
64 aboutData
.addAuthor(i18nc("@info:credit", "Peter Penz"),
65 i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
66 "peter.penz19@gmail.com");
67 aboutData
.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
68 i18nc("@info:credit", "Developer"),
70 aboutData
.addAuthor(i18nc("@info:credit", "David Faure"),
71 i18nc("@info:credit", "Developer"),
73 aboutData
.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
74 i18nc("@info:credit", "Developer"),
76 aboutData
.addAuthor(i18nc("@info:credit", "Rafael Fernández López"),
77 i18nc("@info:credit", "Developer"),
79 aboutData
.addAuthor(i18nc("@info:credit", "Kevin Ottens"),
80 i18nc("@info:credit", "Developer"),
82 aboutData
.addAuthor(i18nc("@info:credit", "Holger Freyther"),
83 i18nc("@info:credit", "Developer"),
85 aboutData
.addAuthor(i18nc("@info:credit", "Max Blazejak"),
86 i18nc("@info:credit", "Developer"),
87 "m43ksrocks@gmail.com");
88 aboutData
.addAuthor(i18nc("@info:credit", "Michael Austin"),
89 i18nc("@info:credit", "Documentation"),
90 "tuxedup@users.sourceforge.net");
92 KAboutData::setApplicationData(aboutData
);
94 KDBusService dolphinDBusService
;
95 DBusInterface interface
;
97 QCommandLineParser parser
;
98 parser
.addVersionOption();
99 parser
.addHelpOption();
100 aboutData
.setupCommandLine(&parser
);
102 // command line options
103 parser
.addOption(QCommandLineOption(QStringList() << QLatin1String("select"), i18nc("@info:shell", "The files and directories passed as arguments "
104 "will be selected.")));
105 parser
.addOption(QCommandLineOption(QStringList() << QLatin1String("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
106 parser
.addOption(QCommandLineOption(QStringList() << QLatin1String("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface)")));
107 parser
.addPositionalArgument(QLatin1String("+[Url]"), i18nc("@info:shell", "Document to open"));
110 aboutData
.processCommandLine(&parser
);
112 if (parser
.isSet("daemon")) {
116 const QStringList args
= parser
.positionalArguments();
117 QList
<QUrl
> urls
= Dolphin::validateUris(args
);
119 if (urls
.isEmpty()) {
120 // We need at least one URL to open Dolphin
121 urls
.append(Dolphin::homeUrl());
124 const bool splitView
= parser
.isSet("split") || GeneralSettings::splitView();
125 if (splitView
&& urls
.size() < 2) {
126 // Split view does only make sense if we have at least 2 URLs
127 urls
.append(urls
.last());
130 DolphinMainWindow
* mainWindow
= new DolphinMainWindow();
131 mainWindow
->setAttribute(Qt::WA_DeleteOnClose
);
133 if (parser
.isSet("select")) {
134 mainWindow
->openFiles(urls
, splitView
);
136 mainWindow
->openDirectories(urls
, splitView
);
141 if (app
.isSessionRestored()) {
142 const QString className
= KXmlGuiWindow::classNameOfToplevel(1);
143 if (className
== QLatin1String("DolphinMainWindow")) {
144 mainWindow
->restore(1);
146 qCWarning(DolphinDebug
) << "Unknown class " << className
<< " in session saved data!";
150 return app
.exec(); // krazy:exclude=crash;