blob: 41812aaa9071614a1db7db112abde6d796c9bb38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/***************************************************************************
* Copyright (C) 2006-2011 by Peter Penz <[email protected]> *
* Copyright (C) 2006 by Holger 'zecke' Freyther <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "dolphinapplication.h"
#include "dolphinmainwindow.h"
#include "dolphin_generalsettings.h"
#include <KCmdLineArgs>
#include <KDebug>
#include <KRun>
#include <KUrl>
#include <KGlobal>
DolphinApplication::DolphinApplication() :
m_mainWindow(0)
{
//KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
//KLocale::global()->insertCatalog("libkonq"); // Needed for applications using libkonq
m_mainWindow = new DolphinMainWindow();
m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
const int argsCount = args->count();
QList<KUrl> urls;
for (int i = 0; i < argsCount; ++i) {
const KUrl url = args->url(i);
if (url.isValid()) {
urls.append(url);
}
}
bool resetSplitSettings = false;
if (args->isSet("split") && !GeneralSettings::splitView()) {
// Dolphin should be opened with a split view although this is not
// set in the GeneralSettings. Temporary adjust the setting until
// all passed URLs have been opened.
GeneralSettings::setSplitView(true);
resetSplitSettings = true;
// We need 2 URLs to open Dolphin in split view mode
if (urls.isEmpty()) { // No URL given - Open home URL in all two views
urls.append(GeneralSettings::homeUrl());
urls.append(GeneralSettings::homeUrl());
} else if (urls.length() == 1) { // Only 1 URL given - Open given URL in all two views
urls.append(urls.at(0));
}
}
if (!urls.isEmpty()) {
if (args->isSet("select")) {
m_mainWindow->openFiles(urls);
} else {
m_mainWindow->openDirectories(urls);
}
} else {
const KUrl homeUrl(GeneralSettings::homeUrl());
m_mainWindow->openNewActivatedTab(homeUrl);
}
if (resetSplitSettings) {
GeneralSettings::setSplitView(false);
}
args->clear();
m_mainWindow->show();
}
DolphinApplication::~DolphinApplication()
{
}
DolphinApplication* DolphinApplication::app()
{
return qobject_cast<DolphinApplication*>(qApp);
}
void DolphinApplication::restoreSession()
{
const QString className = KXmlGuiWindow::classNameOfToplevel(1);
if (className == QLatin1String("DolphinMainWindow")) {
m_mainWindow->restore(1);
} else {
kWarning() << "Unknown class " << className << " in session saved data!";
}
}
|