]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinapplication.cpp
1 /***************************************************************************
2 * Copyright (C) 2006-2011 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
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. *
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. *
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 ***************************************************************************/
21 #include "dolphinapplication.h"
22 #include "dolphinmainwindow.h"
23 #include "dolphin_generalsettings.h"
25 #include <KCmdLineArgs>
31 DolphinApplication::DolphinApplication() :
34 //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
35 //KLocale::global()->insertCatalog("libkonq"); // Needed for applications using libkonq
37 m_mainWindow
= new DolphinMainWindow();
38 m_mainWindow
->setAttribute(Qt::WA_DeleteOnClose
);
40 KCmdLineArgs
* args
= KCmdLineArgs::parsedArgs();
42 const int argsCount
= args
->count();
45 for (int i
= 0; i
< argsCount
; ++i
) {
46 const KUrl url
= args
->url(i
);
52 bool resetSplitSettings
= false;
53 if (args
->isSet("split") && !GeneralSettings::splitView()) {
54 // Dolphin should be opened with a split view although this is not
55 // set in the GeneralSettings. Temporary adjust the setting until
56 // all passed URLs have been opened.
57 GeneralSettings::setSplitView(true);
58 resetSplitSettings
= true;
60 // We need 2 URLs to open Dolphin in split view mode
61 if (urls
.isEmpty()) { // No URL given - Open home URL in all two views
62 urls
.append(GeneralSettings::homeUrl());
63 urls
.append(GeneralSettings::homeUrl());
64 } else if (urls
.length() == 1) { // Only 1 URL given - Open given URL in all two views
65 urls
.append(urls
.at(0));
69 if (!urls
.isEmpty()) {
70 if (args
->isSet("select")) {
71 m_mainWindow
->openFiles(urls
);
73 m_mainWindow
->openDirectories(urls
);
76 const KUrl
homeUrl(GeneralSettings::homeUrl());
77 m_mainWindow
->openNewActivatedTab(homeUrl
);
80 if (resetSplitSettings
) {
81 GeneralSettings::setSplitView(false);
89 DolphinApplication::~DolphinApplication()
93 DolphinApplication
* DolphinApplication::app()
95 return qobject_cast
<DolphinApplication
*>(qApp
);
98 void DolphinApplication::restoreSession()
100 const QString className
= KXmlGuiWindow::classNameOfToplevel(1);
101 if (className
== QLatin1String("DolphinMainWindow")) {
102 m_mainWindow
->restore(1);
104 kWarning() << "Unknown class " << className
<< " in session saved data!";