┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinapplication.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-04-12 20:01:31 +0200
committerPeter Penz <[email protected]>2011-04-12 20:08:08 +0200
commitde077f8477c0b7077ed9239be8741fcb67658ffa (patch)
tree2057f6b2e6aa34d20b997cebb7a60ce6a0dff334 /src/dolphinapplication.cpp
parenta19e78d75b0bc451685d2248be0ec474b3c18966 (diff)
Let each DolphinMainWindow run in a custom process
A possible crash in one Dolphin window should not result in crashing other Dolphin windows. Beside this it also prevents issues with modal dialogs or notifications. BUG: 269950 BUG: 206053 BUG: 196034 FIXED-IN: 4.7.0
Diffstat (limited to 'src/dolphinapplication.cpp')
-rw-r--r--src/dolphinapplication.cpp107
1 files changed, 45 insertions, 62 deletions
diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp
index 468c7a0f7..9dc0cf0f7 100644
--- a/src/dolphinapplication.cpp
+++ b/src/dolphinapplication.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
+ * 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 *
@@ -20,92 +20,75 @@
#include "dolphinapplication.h"
#include "dolphinmainwindow.h"
-#include "dolphinviewcontainer.h"
+#include "dolphin_generalsettings.h"
+#include "settings/dolphinsettings.h"
-#include <applicationadaptor.h>
#include <KCmdLineArgs>
+#include <KDebug>
+#include <KRun>
#include <KUrl>
-#include <QtDBus/QDBusConnection>
DolphinApplication::DolphinApplication() :
- m_lastId(0)
+ m_mainWindow(0)
{
- new ApplicationAdaptor(this);
- QDBusConnection::sessionBus().registerObject("/dolphin/Application", this);
-}
-
-DolphinApplication::~DolphinApplication()
-{
- // cleanup what ever is left from the MainWindows
- while (!m_mainWindows.isEmpty()) {
- delete m_mainWindows.takeFirst();
- }
-}
-
-DolphinApplication* DolphinApplication::app()
-{
- return qobject_cast<DolphinApplication*>(qApp);
-}
+ m_mainWindow = new DolphinMainWindow();
+ m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
+ m_mainWindow->show();
-DolphinMainWindow* DolphinApplication::createMainWindow()
-{
- DolphinMainWindow* mainWindow = new DolphinMainWindow(m_lastId);
- ++m_lastId;
- mainWindow->init();
-
- m_mainWindows.append(mainWindow);
- return mainWindow;
-}
-
-void DolphinApplication::removeMainWindow(DolphinMainWindow* mainWindow)
-{
- m_mainWindows.removeAll(mainWindow);
-}
+ KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
-void DolphinApplication::refreshMainWindows()
-{
- for (int i = 0; i < m_mainWindows.count(); ++i) {
- m_mainWindows[i]->refreshViews();
+ bool resetSplitSettings = false;
+ GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
+ 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;
}
-}
-
-int DolphinApplication::newInstance()
-{
- KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
- static bool first = true;
const int argsCount = args->count();
- if ((argsCount > 0) || !first || !isSessionRestored()) {
+ if (argsCount > 0) {
QList<KUrl> urls;
for (int i = 0; i < argsCount; ++i) {
- urls.append(args->url(i));
+ const KUrl url = args->url(i);
+ if (url.isValid()) {
+ urls.append(url);
+ }
}
- DolphinMainWindow* win = createMainWindow();
- if (urls.count() > 0) {
+ if (!urls.isEmpty()) {
if (args->isSet("select")) {
- win->openFiles(urls);
+ m_mainWindow->openFiles(urls);
} else {
- win->openDirectories(urls);
+ m_mainWindow->openDirectories(urls);
}
}
- win->show();
}
-
- first = false;
args->clear();
- return 0;
+
+ if (resetSplitSettings) {
+ generalSettings->setSplitView(false);
+ }
+}
+
+DolphinApplication::~DolphinApplication()
+{
+}
+
+DolphinApplication* DolphinApplication::app()
+{
+ return qobject_cast<DolphinApplication*>(qApp);
}
-int DolphinApplication::openWindow(const QString& urlString)
+void DolphinApplication::restoreSession()
{
- DolphinMainWindow* win = createMainWindow();
- const KUrl url(urlString);
- if (!url.isEmpty()) {
- win->openDirectories(QList<KUrl>() << url);
+ const QString className = KXmlGuiWindow::classNameOfToplevel(0);
+ if (className == QLatin1String("DolphinMainWindow")) {
+ m_mainWindow->restore(0);
+ } else {
+ kWarning() << "Unknown class " << className << " in session saved data!";
}
- win->show();
- return win->getId();
}
#include "dolphinapplication.moc"