mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 00:11:21 +00:00
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
This commit is contained in:
parent
a19e78d75b
commit
de077f8477
|
@ -159,13 +159,6 @@ if(NOT WIN32)
|
||||||
set(dolphin_SRCS ${dolphin_SRCS} panels/terminal/terminalpanel.cpp)
|
set(dolphin_SRCS ${dolphin_SRCS} panels/terminal/terminalpanel.cpp)
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
qt4_add_dbus_adaptor(dolphin_SRCS
|
|
||||||
org.kde.dolphin.Application.xml
|
|
||||||
dolphinapplication.h DolphinApplication)
|
|
||||||
qt4_add_dbus_adaptor(dolphin_SRCS
|
|
||||||
org.kde.dolphin.MainWindow.xml
|
|
||||||
dolphinmainwindow.h DolphinMainWindow)
|
|
||||||
|
|
||||||
kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
|
kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
|
||||||
|
|
||||||
kde4_add_kdeinit_executable(dolphin ${dolphin_SRCS})
|
kde4_add_kdeinit_executable(dolphin ${dolphin_SRCS})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
* Copyright (C) 2006-2011 by Peter Penz <peter.penz19@gmail.com> *
|
||||||
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
|
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
@ -20,26 +20,60 @@
|
||||||
|
|
||||||
#include "dolphinapplication.h"
|
#include "dolphinapplication.h"
|
||||||
#include "dolphinmainwindow.h"
|
#include "dolphinmainwindow.h"
|
||||||
#include "dolphinviewcontainer.h"
|
#include "dolphin_generalsettings.h"
|
||||||
|
#include "settings/dolphinsettings.h"
|
||||||
|
|
||||||
#include <applicationadaptor.h>
|
|
||||||
#include <KCmdLineArgs>
|
#include <KCmdLineArgs>
|
||||||
|
#include <KDebug>
|
||||||
|
#include <KRun>
|
||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
#include <QtDBus/QDBusConnection>
|
|
||||||
|
|
||||||
DolphinApplication::DolphinApplication() :
|
DolphinApplication::DolphinApplication() :
|
||||||
m_lastId(0)
|
m_mainWindow(0)
|
||||||
{
|
{
|
||||||
new ApplicationAdaptor(this);
|
m_mainWindow = new DolphinMainWindow();
|
||||||
QDBusConnection::sessionBus().registerObject("/dolphin/Application", this);
|
m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
m_mainWindow->show();
|
||||||
|
|
||||||
|
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int argsCount = args->count();
|
||||||
|
if (argsCount > 0) {
|
||||||
|
QList<KUrl> urls;
|
||||||
|
for (int i = 0; i < argsCount; ++i) {
|
||||||
|
const KUrl url = args->url(i);
|
||||||
|
if (url.isValid()) {
|
||||||
|
urls.append(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!urls.isEmpty()) {
|
||||||
|
if (args->isSet("select")) {
|
||||||
|
m_mainWindow->openFiles(urls);
|
||||||
|
} else {
|
||||||
|
m_mainWindow->openDirectories(urls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args->clear();
|
||||||
|
|
||||||
|
if (resetSplitSettings) {
|
||||||
|
generalSettings->setSplitView(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinApplication::~DolphinApplication()
|
DolphinApplication::~DolphinApplication()
|
||||||
{
|
{
|
||||||
// cleanup what ever is left from the MainWindows
|
|
||||||
while (!m_mainWindows.isEmpty()) {
|
|
||||||
delete m_mainWindows.takeFirst();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinApplication* DolphinApplication::app()
|
DolphinApplication* DolphinApplication::app()
|
||||||
|
@ -47,65 +81,14 @@ DolphinApplication* DolphinApplication::app()
|
||||||
return qobject_cast<DolphinApplication*>(qApp);
|
return qobject_cast<DolphinApplication*>(qApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinMainWindow* DolphinApplication::createMainWindow()
|
void DolphinApplication::restoreSession()
|
||||||
{
|
{
|
||||||
DolphinMainWindow* mainWindow = new DolphinMainWindow(m_lastId);
|
const QString className = KXmlGuiWindow::classNameOfToplevel(0);
|
||||||
++m_lastId;
|
if (className == QLatin1String("DolphinMainWindow")) {
|
||||||
mainWindow->init();
|
m_mainWindow->restore(0);
|
||||||
|
|
||||||
m_mainWindows.append(mainWindow);
|
|
||||||
return mainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinApplication::removeMainWindow(DolphinMainWindow* mainWindow)
|
|
||||||
{
|
|
||||||
m_mainWindows.removeAll(mainWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinApplication::refreshMainWindows()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_mainWindows.count(); ++i) {
|
|
||||||
m_mainWindows[i]->refreshViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int DolphinApplication::newInstance()
|
|
||||||
{
|
|
||||||
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
|
|
||||||
static bool first = true;
|
|
||||||
|
|
||||||
const int argsCount = args->count();
|
|
||||||
if ((argsCount > 0) || !first || !isSessionRestored()) {
|
|
||||||
QList<KUrl> urls;
|
|
||||||
for (int i = 0; i < argsCount; ++i) {
|
|
||||||
urls.append(args->url(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinMainWindow* win = createMainWindow();
|
|
||||||
if (urls.count() > 0) {
|
|
||||||
if (args->isSet("select")) {
|
|
||||||
win->openFiles(urls);
|
|
||||||
} else {
|
} else {
|
||||||
win->openDirectories(urls);
|
kWarning() << "Unknown class " << className << " in session saved data!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
win->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
first = false;
|
|
||||||
args->clear();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DolphinApplication::openWindow(const QString& urlString)
|
|
||||||
{
|
|
||||||
DolphinMainWindow* win = createMainWindow();
|
|
||||||
const KUrl url(urlString);
|
|
||||||
if (!url.isEmpty()) {
|
|
||||||
win->openDirectories(QList<KUrl>() << url);
|
|
||||||
}
|
|
||||||
win->show();
|
|
||||||
return win->getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "dolphinapplication.moc"
|
#include "dolphinapplication.moc"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
* Copyright (C) 2006-2011 by Peter Penz <peter.penz19@gmail.com> *
|
||||||
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
|
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
@ -18,24 +18,16 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef _DOLPHIN_APPLICATION_H
|
#ifndef DOLPHIN_APPLICATION_H
|
||||||
#define _DOLPHIN_APPLICATION_H
|
#define DOLPHIN_APPLICATION_H
|
||||||
|
|
||||||
#include <kuniqueapplication.h>
|
#include <KApplication>
|
||||||
|
|
||||||
class DolphinMainWindow;
|
class DolphinMainWindow;
|
||||||
|
|
||||||
/**
|
class DolphinApplication : public KApplication
|
||||||
* @brief Holds the application data which can be accessed.
|
|
||||||
* At first this will hold a list of DolphinMainWindows which
|
|
||||||
* we will delete on application exit.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class DolphinApplication : public KUniqueApplication
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.Application")
|
|
||||||
friend class DolphinMainWindow;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DolphinApplication();
|
DolphinApplication();
|
||||||
|
@ -43,26 +35,10 @@ public:
|
||||||
|
|
||||||
static DolphinApplication* app();
|
static DolphinApplication* app();
|
||||||
|
|
||||||
/**
|
void restoreSession();
|
||||||
* Construct a new mainwindow which is owned
|
|
||||||
* by the application.
|
|
||||||
*/
|
|
||||||
DolphinMainWindow* createMainWindow();
|
|
||||||
void refreshMainWindows();
|
|
||||||
|
|
||||||
/** @see KUniqueApplication::newInstance(). */
|
|
||||||
virtual int newInstance();
|
|
||||||
|
|
||||||
/** Interface implementation for D-Bus Interface. */
|
|
||||||
int openWindow(const QString& urlString);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Called by the DolphinMainWindow to deregister. */
|
DolphinMainWindow* m_mainWindow;
|
||||||
void removeMainWindow(DolphinMainWindow* mainWindow);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<DolphinMainWindow*> m_mainWindows;
|
|
||||||
int m_lastId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "dolphincontextmenu.h"
|
#include "dolphincontextmenu.h"
|
||||||
#include "dolphinnewfilemenu.h"
|
#include "dolphinnewfilemenu.h"
|
||||||
#include "dolphinviewcontainer.h"
|
#include "dolphinviewcontainer.h"
|
||||||
#include "mainwindowadaptor.h"
|
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
#include "panels/search/searchpanel.h"
|
#include "panels/search/searchpanel.h"
|
||||||
#include <Nepomuk/ResourceManager>
|
#include <Nepomuk/ResourceManager>
|
||||||
|
@ -122,18 +121,17 @@ struct ClosedTab
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(ClosedTab)
|
Q_DECLARE_METATYPE(ClosedTab)
|
||||||
|
|
||||||
DolphinMainWindow::DolphinMainWindow(int id) :
|
DolphinMainWindow::DolphinMainWindow() :
|
||||||
KXmlGuiWindow(0),
|
KXmlGuiWindow(0),
|
||||||
m_newFileMenu(0),
|
m_newFileMenu(0),
|
||||||
m_tabBar(0),
|
m_tabBar(0),
|
||||||
m_activeViewContainer(0),
|
m_activeViewContainer(0),
|
||||||
m_centralWidgetLayout(0),
|
m_centralWidgetLayout(0),
|
||||||
m_id(id),
|
|
||||||
m_tabIndex(0),
|
m_tabIndex(0),
|
||||||
m_viewTab(),
|
m_viewTab(),
|
||||||
m_actionHandler(0),
|
m_actionHandler(0),
|
||||||
m_remoteEncoding(0),
|
m_remoteEncoding(0),
|
||||||
m_settingsDialog(0),
|
m_settingsDialog(),
|
||||||
m_toolBarSpacer(0),
|
m_toolBarSpacer(0),
|
||||||
m_openToolBarMenuButton(0),
|
m_openToolBarMenuButton(0),
|
||||||
m_updateToolBarTimer(0),
|
m_updateToolBarTimer(0),
|
||||||
|
@ -149,9 +147,6 @@ DolphinMainWindow::DolphinMainWindow(int id) :
|
||||||
|
|
||||||
m_viewTab.append(ViewTab());
|
m_viewTab.append(ViewTab());
|
||||||
|
|
||||||
new MainWindowAdaptor(this);
|
|
||||||
QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
|
|
||||||
|
|
||||||
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
|
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
|
||||||
undoManager->setUiInterface(new UndoUiInterface());
|
undoManager->setUiInterface(new UndoUiInterface());
|
||||||
|
|
||||||
|
@ -167,11 +162,106 @@ DolphinMainWindow::DolphinMainWindow(int id) :
|
||||||
this, SLOT(showErrorMessage(const QString&)));
|
this, SLOT(showErrorMessage(const QString&)));
|
||||||
connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)),
|
connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)),
|
||||||
this, SLOT(showErrorMessage(const QString&)));
|
this, SLOT(showErrorMessage(const QString&)));
|
||||||
|
|
||||||
|
const DolphinSettings& settings = DolphinSettings::instance();
|
||||||
|
|
||||||
|
GeneralSettings* generalSettings = settings.generalSettings();
|
||||||
|
const bool firstRun = generalSettings->firstRun();
|
||||||
|
if (firstRun) {
|
||||||
|
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
m_viewTab[m_tabIndex].splitter = new QSplitter(this);
|
||||||
|
m_viewTab[m_tabIndex].splitter->setChildrenCollapsible(false);
|
||||||
|
|
||||||
|
setupActions();
|
||||||
|
|
||||||
|
const KUrl homeUrl(generalSettings->homeUrl());
|
||||||
|
setUrlAsCaption(homeUrl);
|
||||||
|
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
||||||
|
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
|
||||||
|
connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
|
||||||
|
|
||||||
|
m_viewTab[m_tabIndex].primaryView = createViewContainer(homeUrl, m_viewTab[m_tabIndex].splitter);
|
||||||
|
|
||||||
|
m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
|
||||||
|
connectViewSignals(m_activeViewContainer);
|
||||||
|
DolphinView* view = m_activeViewContainer->view();
|
||||||
|
m_activeViewContainer->show();
|
||||||
|
m_actionHandler->setCurrentView(view);
|
||||||
|
|
||||||
|
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
||||||
|
connect(this, SIGNAL(urlChanged(const KUrl&)),
|
||||||
|
m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
|
||||||
|
|
||||||
|
m_tabBar = new KTabBar(this);
|
||||||
|
m_tabBar->setMovable(true);
|
||||||
|
m_tabBar->setTabsClosable(true);
|
||||||
|
connect(m_tabBar, SIGNAL(currentChanged(int)),
|
||||||
|
this, SLOT(setActiveTab(int)));
|
||||||
|
connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
|
||||||
|
this, SLOT(closeTab(int)));
|
||||||
|
connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
|
||||||
|
this, SLOT(openTabContextMenu(int, const QPoint&)));
|
||||||
|
connect(m_tabBar, SIGNAL(newTabRequest()),
|
||||||
|
this, SLOT(openNewTab()));
|
||||||
|
connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
|
||||||
|
this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
|
||||||
|
connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
|
||||||
|
this, SLOT(closeTab(int)));
|
||||||
|
connect(m_tabBar, SIGNAL(tabMoved(int, int)),
|
||||||
|
this, SLOT(slotTabMoved(int, int)));
|
||||||
|
connect(m_tabBar, SIGNAL(receivedDropEvent(int, QDropEvent*)),
|
||||||
|
this, SLOT(tabDropEvent(int, QDropEvent*)));
|
||||||
|
|
||||||
|
m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
|
||||||
|
|
||||||
|
QWidget* centralWidget = new QWidget(this);
|
||||||
|
m_centralWidgetLayout = new QVBoxLayout(centralWidget);
|
||||||
|
m_centralWidgetLayout->setSpacing(0);
|
||||||
|
m_centralWidgetLayout->setMargin(0);
|
||||||
|
m_centralWidgetLayout->addWidget(m_tabBar);
|
||||||
|
m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
|
||||||
|
|
||||||
|
setCentralWidget(centralWidget);
|
||||||
|
setupDockWidgets();
|
||||||
|
emit urlChanged(homeUrl);
|
||||||
|
|
||||||
|
setupGUI(Keys | Save | Create | ToolBar);
|
||||||
|
stateChanged("new_file");
|
||||||
|
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
connect(clipboard, SIGNAL(dataChanged()),
|
||||||
|
this, SLOT(updatePasteAction()));
|
||||||
|
|
||||||
|
if (generalSettings->splitView()) {
|
||||||
|
toggleSplitView();
|
||||||
|
}
|
||||||
|
updateEditActions();
|
||||||
|
updateViewActions();
|
||||||
|
updateGoActions();
|
||||||
|
|
||||||
|
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
|
||||||
|
showFilterBarAction->setChecked(generalSettings->filterBar());
|
||||||
|
|
||||||
|
if (firstRun) {
|
||||||
|
menuBar()->setVisible(false);
|
||||||
|
// Assure a proper default size if Dolphin runs the first time
|
||||||
|
resize(750, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool showMenu = !menuBar()->isHidden();
|
||||||
|
QAction* showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
|
||||||
|
showMenuBarAction->setChecked(showMenu); // workaround for bug #171080
|
||||||
|
if (!showMenu) {
|
||||||
|
createToolBarMenuButton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinMainWindow::~DolphinMainWindow()
|
DolphinMainWindow::~DolphinMainWindow()
|
||||||
{
|
{
|
||||||
DolphinApplication::app()->removeMainWindow(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
|
void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
|
||||||
|
@ -204,7 +294,7 @@ void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the previously opened tabs
|
// Remove the previously opened tabs
|
||||||
for (int i = 0; i < oldOpenTabsCount; ++i) {
|
for (int i = 0; i < oldOpenTabsCount; ++i) {
|
||||||
closeTab(0);
|
closeTab(0);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +487,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show)
|
||||||
|
|
||||||
void DolphinMainWindow::openNewMainWindow()
|
void DolphinMainWindow::openNewMainWindow()
|
||||||
{
|
{
|
||||||
DolphinApplication::app()->createMainWindow()->show();
|
KRun::run("dolphin", KUrl::List(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::openNewTab()
|
void DolphinMainWindow::openNewTab()
|
||||||
|
@ -507,9 +597,7 @@ void DolphinMainWindow::openInNewWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newWindowUrl.isEmpty()) {
|
if (!newWindowUrl.isEmpty()) {
|
||||||
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
|
KRun::run("dolphin", KUrl::List() << newWindowUrl, this);
|
||||||
window->changeUrl(newWindowUrl);
|
|
||||||
window->show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,11 +1130,13 @@ void DolphinMainWindow::editSettings()
|
||||||
{
|
{
|
||||||
if (!m_settingsDialog) {
|
if (!m_settingsDialog) {
|
||||||
const KUrl url = activeViewContainer()->url();
|
const KUrl url = activeViewContainer()->url();
|
||||||
m_settingsDialog = new DolphinSettingsDialog(url, this);
|
DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
|
||||||
m_settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
|
connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(reloadView()));
|
||||||
m_settingsDialog->show();
|
settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
settingsDialog->show();
|
||||||
|
m_settingsDialog = settingsDialog;
|
||||||
} else {
|
} else {
|
||||||
m_settingsDialog->raise();
|
m_settingsDialog.data()->raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,25 +1243,20 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
|
||||||
openNewTab(url);
|
openNewTab(url);
|
||||||
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
||||||
} else if (selectedAction == detachTabAction) {
|
} else if (selectedAction == detachTabAction) {
|
||||||
|
const QString separator(QLatin1Char(' '));
|
||||||
|
QString command = QLatin1String("dolphin");
|
||||||
|
|
||||||
const ViewTab& tab = m_viewTab[index];
|
const ViewTab& tab = m_viewTab[index];
|
||||||
Q_ASSERT(tab.primaryView);
|
Q_ASSERT(tab.primaryView);
|
||||||
const KUrl primaryUrl = tab.primaryView->url();
|
|
||||||
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
|
|
||||||
window->changeUrl(primaryUrl);
|
|
||||||
|
|
||||||
|
command += separator + tab.primaryView->url().url();
|
||||||
if (tab.secondaryView) {
|
if (tab.secondaryView) {
|
||||||
const KUrl secondaryUrl = tab.secondaryView->url();
|
command += separator + tab.secondaryView->url().url();
|
||||||
if (!window->m_viewTab[0].secondaryView) {
|
command += separator + QLatin1String("-split");
|
||||||
window->toggleSplitView();
|
|
||||||
}
|
}
|
||||||
window->m_viewTab[0].secondaryView->setUrl(secondaryUrl);
|
|
||||||
if (tab.primaryView->isActive()) {
|
KRun::runCommand(command, this);
|
||||||
window->m_viewTab[0].primaryView->setActive(true);
|
|
||||||
} else {
|
|
||||||
window->m_viewTab[0].secondaryView->setActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
window->show();
|
|
||||||
closeTab(index);
|
closeTab(index);
|
||||||
} else if (selectedAction == closeOtherTabsAction) {
|
} else if (selectedAction == closeOtherTabsAction) {
|
||||||
const int count = m_tabBar->count();
|
const int count = m_tabBar->count();
|
||||||
|
@ -1306,9 +1391,7 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item,
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case DolphinContextMenu::OpenParentFolderInNewWindow: {
|
case DolphinContextMenu::OpenParentFolderInNewWindow: {
|
||||||
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
|
KRun::run("dolphin", KUrl::List() << item.url().upUrl(), this);
|
||||||
window->changeUrl(item.url().upUrl());
|
|
||||||
window->show();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1443,107 +1526,6 @@ void DolphinMainWindow::slotToolBarIconSizeChanged(const QSize& iconSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::init()
|
|
||||||
{
|
|
||||||
DolphinSettings& settings = DolphinSettings::instance();
|
|
||||||
|
|
||||||
// Check whether Dolphin runs the first time. If yes then
|
|
||||||
// a proper default window size is given at the end of DolphinMainWindow::init().
|
|
||||||
GeneralSettings* generalSettings = settings.generalSettings();
|
|
||||||
const bool firstRun = generalSettings->firstRun();
|
|
||||||
if (firstRun) {
|
|
||||||
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
setAcceptDrops(true);
|
|
||||||
|
|
||||||
m_viewTab[m_tabIndex].splitter = new QSplitter(this);
|
|
||||||
m_viewTab[m_tabIndex].splitter->setChildrenCollapsible(false);
|
|
||||||
|
|
||||||
setupActions();
|
|
||||||
|
|
||||||
const KUrl homeUrl(generalSettings->homeUrl());
|
|
||||||
setUrlAsCaption(homeUrl);
|
|
||||||
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
|
||||||
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
|
|
||||||
connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
|
|
||||||
|
|
||||||
m_viewTab[m_tabIndex].primaryView = createViewContainer(homeUrl, m_viewTab[m_tabIndex].splitter);
|
|
||||||
|
|
||||||
m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
|
|
||||||
connectViewSignals(m_activeViewContainer);
|
|
||||||
DolphinView* view = m_activeViewContainer->view();
|
|
||||||
m_activeViewContainer->show();
|
|
||||||
m_actionHandler->setCurrentView(view);
|
|
||||||
|
|
||||||
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
|
||||||
connect(this, SIGNAL(urlChanged(const KUrl&)),
|
|
||||||
m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
|
|
||||||
|
|
||||||
m_tabBar = new KTabBar(this);
|
|
||||||
m_tabBar->setMovable(true);
|
|
||||||
m_tabBar->setTabsClosable(true);
|
|
||||||
connect(m_tabBar, SIGNAL(currentChanged(int)),
|
|
||||||
this, SLOT(setActiveTab(int)));
|
|
||||||
connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
|
|
||||||
this, SLOT(closeTab(int)));
|
|
||||||
connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
|
|
||||||
this, SLOT(openTabContextMenu(int, const QPoint&)));
|
|
||||||
connect(m_tabBar, SIGNAL(newTabRequest()),
|
|
||||||
this, SLOT(openNewTab()));
|
|
||||||
connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
|
|
||||||
this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
|
|
||||||
connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
|
|
||||||
this, SLOT(closeTab(int)));
|
|
||||||
connect(m_tabBar, SIGNAL(tabMoved(int, int)),
|
|
||||||
this, SLOT(slotTabMoved(int, int)));
|
|
||||||
connect(m_tabBar, SIGNAL(receivedDropEvent(int, QDropEvent*)),
|
|
||||||
this, SLOT(tabDropEvent(int, QDropEvent*)));
|
|
||||||
|
|
||||||
m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
|
|
||||||
|
|
||||||
QWidget* centralWidget = new QWidget(this);
|
|
||||||
m_centralWidgetLayout = new QVBoxLayout(centralWidget);
|
|
||||||
m_centralWidgetLayout->setSpacing(0);
|
|
||||||
m_centralWidgetLayout->setMargin(0);
|
|
||||||
m_centralWidgetLayout->addWidget(m_tabBar);
|
|
||||||
m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
|
|
||||||
|
|
||||||
setCentralWidget(centralWidget);
|
|
||||||
setupDockWidgets();
|
|
||||||
emit urlChanged(homeUrl);
|
|
||||||
|
|
||||||
setupGUI(Keys | Save | Create | ToolBar);
|
|
||||||
stateChanged("new_file");
|
|
||||||
|
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
|
||||||
connect(clipboard, SIGNAL(dataChanged()),
|
|
||||||
this, SLOT(updatePasteAction()));
|
|
||||||
|
|
||||||
if (generalSettings->splitView()) {
|
|
||||||
toggleSplitView();
|
|
||||||
}
|
|
||||||
updateEditActions();
|
|
||||||
updateViewActions();
|
|
||||||
updateGoActions();
|
|
||||||
|
|
||||||
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
|
|
||||||
showFilterBarAction->setChecked(generalSettings->filterBar());
|
|
||||||
|
|
||||||
if (firstRun) {
|
|
||||||
menuBar()->setVisible(false);
|
|
||||||
// Assure a proper default size if Dolphin runs the first time
|
|
||||||
resize(750, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool showMenu = !menuBar()->isHidden();
|
|
||||||
QAction* showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
|
|
||||||
showMenuBarAction->setChecked(showMenu); // workaround for bug #171080
|
|
||||||
if (!showMenu) {
|
|
||||||
createToolBarMenuButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
|
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
|
||||||
{
|
{
|
||||||
Q_ASSERT(viewContainer);
|
Q_ASSERT(viewContainer);
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#ifndef DOLPHIN_MAINWINDOW_H
|
#ifndef DOLPHIN_MAINWINDOW_H
|
||||||
#define DOLPHIN_MAINWINDOW_H
|
#define DOLPHIN_MAINWINDOW_H
|
||||||
|
|
||||||
#include "panels/panel.h"
|
|
||||||
|
|
||||||
#include <config-nepomuk.h>
|
#include <config-nepomuk.h>
|
||||||
|
|
||||||
#include <KFileItemDelegate>
|
#include <KFileItemDelegate>
|
||||||
|
@ -32,9 +30,8 @@
|
||||||
#include <kxmlguiwindow.h>
|
#include <kxmlguiwindow.h>
|
||||||
#include <KActionMenu>
|
#include <KActionMenu>
|
||||||
|
|
||||||
#include "views/dolphinview.h"
|
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QWeakPointer>
|
||||||
|
|
||||||
typedef KIO::FileUndoManager::CommandType CommandType;
|
typedef KIO::FileUndoManager::CommandType CommandType;
|
||||||
|
|
||||||
|
@ -44,12 +41,15 @@ class DolphinSettingsDialog;
|
||||||
class DolphinViewContainer;
|
class DolphinViewContainer;
|
||||||
class DolphinRemoteEncoding;
|
class DolphinRemoteEncoding;
|
||||||
class KAction;
|
class KAction;
|
||||||
|
class KFileItem;
|
||||||
|
class KFileItemList;
|
||||||
class KJob;
|
class KJob;
|
||||||
class KNewFileMenu;
|
class KNewFileMenu;
|
||||||
class KTabBar;
|
class KTabBar;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
class QVBoxLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short Main window for Dolphin.
|
* @short Main window for Dolphin.
|
||||||
|
@ -64,6 +64,7 @@ class DolphinMainWindow: public KXmlGuiWindow
|
||||||
friend class DolphinApplication;
|
friend class DolphinApplication;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
DolphinMainWindow();
|
||||||
virtual ~DolphinMainWindow();
|
virtual ~DolphinMainWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,9 +449,6 @@ private slots:
|
||||||
void slotToolBarIconSizeChanged(const QSize& iconSize);
|
void slotToolBarIconSizeChanged(const QSize& iconSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinMainWindow(int id);
|
|
||||||
void init();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activates the given view, which means that
|
* Activates the given view, which means that
|
||||||
* all menu actions are applied to this view. When
|
* all menu actions are applied to this view. When
|
||||||
|
@ -567,7 +565,7 @@ private:
|
||||||
|
|
||||||
DolphinViewActionHandler* m_actionHandler;
|
DolphinViewActionHandler* m_actionHandler;
|
||||||
DolphinRemoteEncoding* m_remoteEncoding;
|
DolphinRemoteEncoding* m_remoteEncoding;
|
||||||
QPointer<DolphinSettingsDialog> m_settingsDialog;
|
QWeakPointer<DolphinSettingsDialog> m_settingsDialog;
|
||||||
|
|
||||||
// Members for the toolbar menu that is shown when the menubar is hidden:
|
// Members for the toolbar menu that is shown when the menubar is hidden:
|
||||||
QWidget* m_toolBarSpacer;
|
QWidget* m_toolBarSpacer;
|
||||||
|
|
17
src/main.cpp
17
src/main.cpp
|
@ -72,28 +72,15 @@ KDE_EXPORT int kdemain(int argc, char **argv)
|
||||||
|
|
||||||
options.add("select", ki18nc("@info:shell", "The files and directories passed as arguments "
|
options.add("select", ki18nc("@info:shell", "The files and directories passed as arguments "
|
||||||
"will be selected."));
|
"will be selected."));
|
||||||
|
options.add("split", ki18nc("@info:shell", "Dolphin will get started with a split view."));
|
||||||
options.add("+[Url]", ki18nc("@info:shell", "Document to open"));
|
options.add("+[Url]", ki18nc("@info:shell", "Document to open"));
|
||||||
KCmdLineArgs::addCmdLineOptions(options);
|
KCmdLineArgs::addCmdLineOptions(options);
|
||||||
|
|
||||||
if (!DolphinApplication::start()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinApplication app;
|
DolphinApplication app;
|
||||||
KGlobal::locale()->insertCatalog("libkonq"); // needed for applications using libkonq
|
KGlobal::locale()->insertCatalog("libkonq"); // needed for applications using libkonq
|
||||||
|
|
||||||
if (app.isSessionRestored()) {
|
if (app.isSessionRestored()) {
|
||||||
int n = 1;
|
app.restoreSession();
|
||||||
while (KMainWindow::canBeRestored(n)) {
|
|
||||||
const QString className = KXmlGuiWindow::classNameOfToplevel(n);
|
|
||||||
if (className == QLatin1String("DolphinMainWindow")) {
|
|
||||||
DolphinMainWindow* win = app.createMainWindow();
|
|
||||||
win->restore(n);
|
|
||||||
} else {
|
|
||||||
kWarning() << "Unknown class " << className << " in session saved data!";
|
|
||||||
}
|
|
||||||
++n;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
app.exec(); // krazy:exclude=crashy
|
app.exec(); // krazy:exclude=crashy
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
|
||||||
<node>
|
|
||||||
<interface name="org.kde.dolphin.Application">
|
|
||||||
<method name="openWindow">
|
|
||||||
<arg type="i" direction="out"/>
|
|
||||||
<arg name="url" type="s" direction="in"/>
|
|
||||||
</method>
|
|
||||||
</interface>
|
|
||||||
</node>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
|
||||||
<node>
|
|
||||||
<interface name="org.kde.dolphin.MainWindow">
|
|
||||||
<method name="getId">
|
|
||||||
<arg type="i" direction="out"/>
|
|
||||||
</method>
|
|
||||||
<method name="changeUrl">
|
|
||||||
<arg name="url" type="s" direction="in"/>
|
|
||||||
</method>
|
|
||||||
<method name="quit">
|
|
||||||
</method>
|
|
||||||
</interface>
|
|
||||||
</node>
|
|
|
@ -129,7 +129,6 @@ void DolphinSettingsDialog::applySettings()
|
||||||
foreach (SettingsPageBase* page, m_pages) {
|
foreach (SettingsPageBase* page, m_pages) {
|
||||||
page->applySettings();
|
page->applySettings();
|
||||||
}
|
}
|
||||||
DolphinApplication::app()->refreshMainWindows();
|
|
||||||
|
|
||||||
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
|
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
|
||||||
if (settings->modifiedStartupSettings()) {
|
if (settings->modifiedStartupSettings()) {
|
||||||
|
@ -140,6 +139,8 @@ void DolphinSettingsDialog::applySettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
enableButtonApply(false);
|
enableButtonApply(false);
|
||||||
|
|
||||||
|
emit settingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinSettingsDialog::restoreDefaults()
|
void DolphinSettingsDialog::restoreDefaults()
|
||||||
|
|
|
@ -39,6 +39,9 @@ public:
|
||||||
explicit DolphinSettingsDialog(const KUrl& url, QWidget* parent = 0);
|
explicit DolphinSettingsDialog(const KUrl& url, QWidget* parent = 0);
|
||||||
virtual ~DolphinSettingsDialog();
|
virtual ~DolphinSettingsDialog();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void settingsChanged();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
/** @see KDialog::slotButtonClicked() */
|
/** @see KDialog::slotButtonClicked() */
|
||||||
virtual void slotButtonClicked(int button);
|
virtual void slotButtonClicked(int button);
|
||||||
|
|
Loading…
Reference in a new issue