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