]> cloud.milkyroute.net Git - dolphin.git/blob - src/main.cpp
Symlinking from .so.5 to .so.14.12.95 makes very little sense, name them 5.0.0
[dolphin.git] / src / main.cpp
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> *
5 * *
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. *
10 * *
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. *
15 * *
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 ***************************************************************************/
21
22 #include "dolphinmainwindow.h"
23 #include "dolphin_generalsettings.h"
24 #include "dbusinterface.h"
25 #include "global.h"
26 #include "dolphindebug.h"
27
28 #include <KDBusService>
29 #include <KAboutData>
30 #include <QCommandLineParser>
31 #include <QCommandLineOption>
32 #include <QApplication>
33 #include <KLocalizedString>
34 #include <Kdelibs4ConfigMigrator>
35
36 extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
37 {
38 QApplication app(argc, argv);
39 app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
40 app.setWindowIcon(QIcon::fromTheme("system-file-manager"));
41
42 Kdelibs4ConfigMigrator migrate(QStringLiteral("dolphin"));
43 migrate.setConfigFiles(QStringList() << QStringLiteral("dolphinrc"));
44 migrate.setUiFiles(QStringList() << QStringLiteral("dolphinpart.rc") << QStringLiteral("dolphinui.rc"));
45 migrate.migrate();
46
47 KAboutData aboutData("dolphin", i18n("Dolphin"), "14.12.95",
48 i18nc("@title", "File Manager"),
49 KAboutLicense::GPL,
50 i18nc("@info:credit", "(C) 2006-2014 Peter Penz, Frank Reininghaus, and Emmanuel Pescosta"));
51 aboutData.setHomepage("http://dolphin.kde.org");
52 aboutData.addAuthor(i18nc("@info:credit", "Emmanuel Pescosta"),
53 i18nc("@info:credit", "Maintainer (since 2014) and developer"),
54 "emmanuelpescosta099@gmail.com");
55 aboutData.addAuthor(i18nc("@info:credit", "Frank Reininghaus"),
56 i18nc("@info:credit", "Maintainer (2012-2014) and developer"),
57 "frank78ac@googlemail.com");
58 aboutData.addAuthor(i18nc("@info:credit", "Peter Penz"),
59 i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
60 "peter.penz19@gmail.com");
61 aboutData.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
62 i18nc("@info:credit", "Developer"),
63 "trueg@kde.org");
64 aboutData.addAuthor(i18nc("@info:credit", "David Faure"),
65 i18nc("@info:credit", "Developer"),
66 "faure@kde.org");
67 aboutData.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
68 i18nc("@info:credit", "Developer"),
69 "aseigo@kde.org");
70 aboutData.addAuthor(i18nc("@info:credit", "Rafael Fernández López"),
71 i18nc("@info:credit", "Developer"),
72 "ereslibre@kde.org");
73 aboutData.addAuthor(i18nc("@info:credit", "Kevin Ottens"),
74 i18nc("@info:credit", "Developer"),
75 "ervin@kde.org");
76 aboutData.addAuthor(i18nc("@info:credit", "Holger Freyther"),
77 i18nc("@info:credit", "Developer"),
78 "freyther@gmx.net");
79 aboutData.addAuthor(i18nc("@info:credit", "Max Blazejak"),
80 i18nc("@info:credit", "Developer"),
81 "m43ksrocks@gmail.com");
82 aboutData.addAuthor(i18nc("@info:credit", "Michael Austin"),
83 i18nc("@info:credit", "Documentation"),
84 "tuxedup@users.sourceforge.net");
85
86 KAboutData::setApplicationData(aboutData);
87
88 KDBusService dolphinDBusService;
89 DBusInterface interface;
90
91 QCommandLineParser parser;
92 parser.addVersionOption();
93 parser.addHelpOption();
94 aboutData.setupCommandLine(&parser);
95
96 // command line options
97 parser.addOption(QCommandLineOption(QStringList() << QLatin1String("select"), i18nc("@info:shell", "The files and directories passed as arguments "
98 "will be selected.")));
99 parser.addOption(QCommandLineOption(QStringList() << QLatin1String("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
100 parser.addOption(QCommandLineOption(QStringList() << QLatin1String("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface)")));
101 parser.addPositionalArgument(QLatin1String("+[Url]"), i18nc("@info:shell", "Document to open"));
102
103 parser.process(app);
104 aboutData.processCommandLine(&parser);
105
106 if (parser.isSet("daemon")) {
107 return app.exec();
108 }
109
110 const QStringList args = parser.positionalArguments();
111 QList<QUrl> urls = Dolphin::validateUris(args);
112
113 if (urls.isEmpty()) {
114 // We need at least one URL to open Dolphin
115 const QUrl homeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
116 urls.append(homeUrl);
117 }
118
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());
123 }
124
125 DolphinMainWindow* mainWindow = new DolphinMainWindow();
126 mainWindow->setAttribute(Qt::WA_DeleteOnClose);
127
128 if (parser.isSet("select")) {
129 mainWindow->openFiles(urls, splitView);
130 } else {
131 mainWindow->openDirectories(urls, splitView);
132 }
133
134 mainWindow->show();
135
136 if (app.isSessionRestored()) {
137 const QString className = KXmlGuiWindow::classNameOfToplevel(1);
138 if (className == QLatin1String("DolphinMainWindow")) {
139 mainWindow->restore(1);
140 } else {
141 qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!";
142 }
143 }
144
145 return app.exec(); // krazy:exclude=crash;
146 }