┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHolger Freyther <[email protected]>2006-11-29 00:02:19 +0000
committerHolger Freyther <[email protected]>2006-11-29 00:02:19 +0000
commitf31a541925033c2ef5e27b85c099d47791b50121 (patch)
tree11cc728aa7d247ca5b075776c438be0f381be765 /src
parent68e81f7280c810e26cabf6cd2897b9dc8466f458 (diff)
Make it (almost) possible to have more than one Dolphin KMainWindow
Create a DolphinApplication, holding DolphinMainWindows and update the code to use the DolphinView to get the MainWindow, or get a ptr to the MainWindow directly. Or if all windows are effected go through the DolphinApplication to update every mainwindow. The UndowManager and ProgressIndicator have a rather strange relationship and will need some more attention but as UndoManager will be killed anyway I have skipped this. More cleanup, debugging and thinking is needed. svn path=/trunk/playground/utils/dolphin/; revision=608945
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/THOUGHTS.zecke36
-rw-r--r--src/bookmarkselector.cpp6
-rw-r--r--src/bookmarkssidebarpage.cpp13
-rw-r--r--src/bookmarkssidebarpage.h2
-rw-r--r--src/dolphinapplication.cpp64
-rw-r--r--src/dolphinapplication.h64
-rw-r--r--src/dolphincontextmenu.cpp38
-rw-r--r--src/dolphiniconsview.cpp7
-rw-r--r--src/dolphinmainwindow.cpp (renamed from src/dolphin.cpp)238
-rw-r--r--src/dolphinmainwindow.h (renamed from src/dolphin.h)31
-rw-r--r--src/dolphinsettings.cpp3
-rw-r--r--src/dolphinsettingsdialog.cpp12
-rw-r--r--src/dolphinsettingsdialog.h4
-rw-r--r--src/dolphinview.cpp57
-rw-r--r--src/dolphinview.h22
-rw-r--r--src/filterbar.cpp11
-rw-r--r--src/filterbar.h4
-rw-r--r--src/generalsettingspage.cpp7
-rw-r--r--src/generalsettingspage.h4
-rw-r--r--src/infosidebarpage.cpp18
-rw-r--r--src/infosidebarpage.h2
-rw-r--r--src/main.cpp25
-rw-r--r--src/progressindicator.cpp19
-rw-r--r--src/progressindicator.h7
-rw-r--r--src/sidebar.cpp7
-rw-r--r--src/sidebar.h4
-rw-r--r--src/sidebarpage.cpp13
-rw-r--r--src/sidebarpage.h9
-rw-r--r--src/undomanager.cpp29
-rw-r--r--src/undomanager.h6
-rw-r--r--src/urlbutton.cpp4
-rw-r--r--src/urlnavigator.cpp4
-rw-r--r--src/urlnavigator.h2
-rw-r--r--src/urlnavigatorbutton.cpp6
35 files changed, 506 insertions, 275 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c701e14a7..7ea5426bb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,7 +9,8 @@ include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
set(dolphin_SRCS
main.cpp
- dolphin.cpp
+ dolphinapplication.cpp
+ dolphinmainwindow.cpp
dolphinview.cpp
urlnavigator.cpp
urlnavigatorbutton.cpp
diff --git a/src/THOUGHTS.zecke b/src/THOUGHTS.zecke
new file mode 100644
index 000000000..3b9f383fc
--- /dev/null
+++ b/src/THOUGHTS.zecke
@@ -0,0 +1,36 @@
+Zecke's Implementation Thoughts
+
+
+Task: Kill the Dolphin Singleton
+Reasoning: Have more than one Dolphin TLW
+Approach:
+ 1. Create DolphinApplication to hold all TLW's.
+ 2. Make dolphin.h dolphomainwindow.h
+ 3. Change the Views to have a DolphinMainWindow
+ parameter
+
+Reasoning:
+ I find it more natural that the DolphinApplication
+ holds and controls the list of managed MainWindows and
+ will control the life time of them, specially deleting
+ them on exit.
+ The downside is that DolphinApplication and DolphinMainWindow
+ need to work together but this is managable
+
+ Making DolphinView::mainWindow() public. Most users of the
+ current Dolphin::mainView have a pointer to the current view
+ already. We could pass a second pointer for the mainwindow each
+ time but the same can be achieved by using the appropriate
+ DolphinView::mainWindow.
+ Another approach would be to ask the DolphinView to execute
+ actions on the MainWindow like it is done with declareViewActive
+ in DolphinView. I'm not entirely sure which one wins but currently
+ using mainWindow() does not show any negative impact.
+
+ 2 times Dolphin::mainWin was used to check if the view is current.
+ this can be made a method of of the view
+
+ 1 time we want the viewChanged signal of our mainwindow to update,
+ the UrlNavigator could connect a signal to a signal to allow this
+
+ 12 times this was used to access the actionCollection
diff --git a/src/bookmarkselector.cpp b/src/bookmarkselector.cpp
index 73e063fda..7b489b8fa 100644
--- a/src/bookmarkselector.cpp
+++ b/src/bookmarkselector.cpp
@@ -31,7 +31,7 @@
#include "bookmarkselector.h"
#include "dolphinsettings.h"
#include "dolphinview.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "urlnavigator.h"
BookmarkSelector::BookmarkSelector(UrlNavigator* parent) :
@@ -134,9 +134,9 @@ void BookmarkSelector::paintEvent(QPaintEvent* event)
// dimm the colors if the parent view does not have the focus
const DolphinView* parentView = urlNavigator()->dolphinView();
- const Dolphin& dolphin = Dolphin::mainWin();
+ const DolphinMainWindow* dolphin = parentView->mainWindow();
- const bool isActive = (dolphin.activeView() == parentView);
+ const bool isActive = (dolphin->activeView() == parentView);
if (!isActive) {
QColor dimmColor(colorGroup().background());
foregroundColor = mixColors(foregroundColor, dimmColor);
diff --git a/src/bookmarkssidebarpage.cpp b/src/bookmarkssidebarpage.cpp
index b3861aa2f..7eced5a01 100644
--- a/src/bookmarkssidebarpage.cpp
+++ b/src/bookmarkssidebarpage.cpp
@@ -36,12 +36,11 @@
#include <klocale.h>
#include "dolphinsettings.h"
-#include "dolphin.h"
-#include "dolphinview.h"
+#include "dolphinmainwindow.h"
#include "editbookmarkdialog.h"
-BookmarksSidebarPage::BookmarksSidebarPage(QWidget* parent) :
- SidebarPage(parent)
+BookmarksSidebarPage::BookmarksSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) :
+ SidebarPage(mainWindow, parent)
{
Q3VBoxLayout* layout = new Q3VBoxLayout(this);
m_bookmarksList = new BookmarksListBox(this);
@@ -98,7 +97,7 @@ void BookmarksSidebarPage::slotMouseButtonClicked(int button, Q3ListBoxItem* ite
const int index = m_bookmarksList->index(item);
KBookmark bookmark = DolphinSettings::instance().bookmark(index);
- Dolphin::mainWin().activeView()->setUrl(bookmark.url());
+ mainWindow()->activeView()->setUrl(bookmark.url());
}
void BookmarksSidebarPage::slotContextMenuRequested(Q3ListBoxItem* item,
@@ -187,7 +186,7 @@ void BookmarksSidebarPage::slotContextMenuRequested(Q3ListBoxItem* item,
delete popup;
popup = 0;
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
adjustSelection(view->url());
}
@@ -241,7 +240,7 @@ void BookmarksSidebarPage::slotUrlChanged(const KUrl& url)
void BookmarksSidebarPage::connectToActiveView()
{
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
adjustSelection(view->url());
connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
this, SLOT(slotUrlChanged(const KUrl&)));
diff --git a/src/bookmarkssidebarpage.h b/src/bookmarkssidebarpage.h
index 37a500987..953755399 100644
--- a/src/bookmarkssidebarpage.h
+++ b/src/bookmarkssidebarpage.h
@@ -41,7 +41,7 @@ class BookmarksSidebarPage : public SidebarPage
Q_OBJECT
public:
- BookmarksSidebarPage(QWidget* parent);
+ BookmarksSidebarPage(DolphinMainWindow *mainWindow, QWidget* parent);
virtual ~BookmarksSidebarPage();
protected:
diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp
new file mode 100644
index 000000000..a27a4cb27
--- /dev/null
+++ b/src/dolphinapplication.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2006 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
+
+DolphinApplication::DolphinApplication()
+{
+}
+
+/*
+ * cleanup what ever is left from the MainWindows
+ */
+DolphinApplication::~DolphinApplication()
+{
+ while( m_mainWindows.count() != 0 )
+ delete m_mainWindows.takeFirst();
+}
+
+DolphinApplication* DolphinApplication::app()
+{
+ return qobject_cast<DolphinApplication*>(qApp);
+}
+
+DolphinMainWindow* DolphinApplication::createMainWindow()
+{
+ DolphinMainWindow* mainwindow = new DolphinMainWindow;
+ mainwindow->init();
+
+ m_mainWindows.append( mainwindow );
+ return mainwindow;
+}
+
+void DolphinApplication::removeMainWindow( DolphinMainWindow *mainwindow )
+{
+ m_mainWindows.remove( mainwindow );
+}
+
+void DolphinApplication::refreshMainWindows()
+{
+ for( int i = 0; i < m_mainWindows.count(); ++i ) {
+ m_mainWindows[i]->refreshViews();
+ }
+}
+
+#include "dolphinapplication.moc"
+
diff --git a/src/dolphinapplication.h b/src/dolphinapplication.h
new file mode 100644
index 000000000..a8474bd36
--- /dev/null
+++ b/src/dolphinapplication.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2006 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#ifndef _DOLPHIN_APPLICATION_H
+#define _DOLPHIN_APPLICATION_H
+
+#include <kapplication.h>
+
+class DolphinMainWindow;
+
+/**
+ *
+ * DolphinApplication will hold application wide data which
+ * can be accessed.
+ * At first this will hold a list of DolphinMainWindows which
+ * we will delete on application exit.
+ */
+
+class DolphinApplication : public KApplication {
+ Q_OBJECT
+ friend class DolphinMainWindow;
+public:
+ DolphinApplication();
+ ~DolphinApplication();
+
+ static DolphinApplication* app();
+
+ /**
+ * Construct a new mainwindow which is owned
+ * by the application.
+ */
+ DolphinMainWindow* createMainWindow();
+ void refreshMainWindows();
+
+protected:
+ /**
+ * called by the MainWindow to deregister
+ */
+ void removeMainWindow( DolphinMainWindow* );
+
+private:
+ QList<DolphinMainWindow*> m_mainWindows;
+};
+
+
+#endif
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index d53aa3f17..1da2443db 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -40,7 +40,7 @@
#include <kmenu.h>
#include <kstdaction.h>
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinview.h"
#include "editbookmarkdialog.h"
#include "dolphinsettings.h"
@@ -79,12 +79,12 @@ void DolphinContextMenu::openViewportContextMenu()
assert(m_fileInfo == 0);
KMenu* popup = new KMenu(m_dolphinView);
- Dolphin& dolphin = Dolphin::mainWin();
+ DolphinMainWindow *dolphin = m_dolphinView->mainWindow();
// setup 'Create New' menu
KMenu* createNewMenu = new KMenu();
- KAction* createFolderAction = dolphin.actionCollection()->action("create_folder");
+ KAction* createFolderAction = dolphin->actionCollection()->action("create_folder");
if (createFolderAction != 0) {
createFolderAction->plug(createNewMenu);
}
@@ -93,7 +93,7 @@ void DolphinContextMenu::openViewportContextMenu()
KAction* action = 0;
- Q3PtrListIterator<KAction> fileGrouptIt(dolphin.fileGroupActions());
+ Q3PtrListIterator<KAction> fileGrouptIt(dolphin->fileGroupActions());
while ((action = fileGrouptIt.current()) != 0) {
action->plug(createNewMenu);
++fileGrouptIt;
@@ -104,14 +104,14 @@ void DolphinContextMenu::openViewportContextMenu()
//
//createNewMenu->insertSeparator();
//
- //QPtrListIterator<KAction> linkGroupIt(dolphin.linkGroupActions());
+ //QPtrListIterator<KAction> linkGroupIt(dolphin->linkGroupActions());
//while ((action = linkGroupIt.current()) != 0) {
// action->plug(createNewMenu);
// ++linkGroupIt;
//}
//
//KMenu* linkToDeviceMenu = new KMenu();
- //QPtrListIterator<KAction> linkToDeviceIt(dolphin.linkToDeviceActions());
+ //QPtrListIterator<KAction> linkToDeviceIt(dolphin->linkToDeviceActions());
//while ((action = linkToDeviceIt.current()) != 0) {
// action->plug(linkToDeviceMenu);
// ++linkToDeviceIt;
@@ -122,19 +122,19 @@ void DolphinContextMenu::openViewportContextMenu()
popup->insertItem(SmallIcon("filenew"), i18n("Create New"), createNewMenu);
popup->insertSeparator();
- KAction* pasteAction = dolphin.actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
+ KAction* pasteAction = dolphin->actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
pasteAction->plug(popup);
// setup 'View Mode' menu
KMenu* viewModeMenu = new KMenu();
- KAction* iconsMode = dolphin.actionCollection()->action("icons");
+ KAction* iconsMode = dolphin->actionCollection()->action("icons");
iconsMode->plug(viewModeMenu);
- KAction* detailsMode = dolphin.actionCollection()->action("details");
+ KAction* detailsMode = dolphin->actionCollection()->action("details");
detailsMode->plug(viewModeMenu);
- KAction* previewsMode = dolphin.actionCollection()->action("previews");
+ KAction* previewsMode = dolphin->actionCollection()->action("previews");
previewsMode->plug(viewModeMenu);
popup->insertItem(i18n("View Mode"), viewModeMenu);
@@ -147,10 +147,10 @@ void DolphinContextMenu::openViewportContextMenu()
QAction *activatedAction = popup->exec(m_pos);
if (activatedAction == propertiesAction) {
- new KPropertiesDialog(dolphin.activeView()->url());
+ new KPropertiesDialog(dolphin->activeView()->url());
}
else if (activatedAction == bookmarkAction) {
- const KUrl& url = dolphin.activeView()->url();
+ const KUrl& url = dolphin->activeView()->url();
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add folder as bookmark"),
url.fileName(),
url,
@@ -176,14 +176,14 @@ void DolphinContextMenu::openItemContextMenu()
assert(m_fileInfo != 0);
KMenu* popup = new KMenu(m_dolphinView);
- Dolphin& dolphin = Dolphin::mainWin();
+ DolphinMainWindow* dolphin = m_dolphinView->mainWindow();
const KUrl::List urls = m_dolphinView->selectedUrls();
// insert 'Cut', 'Copy' and 'Paste'
const KStdAction::StdAction actionNames[] = { KStdAction::Cut, KStdAction::Copy, KStdAction::Paste };
const int count = sizeof(actionNames) / sizeof(KStdAction::StdAction);
for (int i = 0; i < count; ++i) {
- KAction* action = dolphin.actionCollection()->action(KStdAction::stdName(actionNames[i]));
+ KAction* action = dolphin->actionCollection()->action(KStdAction::stdName(actionNames[i]));
if (action != 0) {
action->plug(popup);
}
@@ -191,17 +191,17 @@ void DolphinContextMenu::openItemContextMenu()
popup->insertSeparator();
// insert 'Rename'
- KAction* renameAction = dolphin.actionCollection()->action("rename");
+ KAction* renameAction = dolphin->actionCollection()->action("rename");
renameAction->plug(popup);
// insert 'Move to Trash' for local Urls, otherwise insert 'Delete'
- const KUrl& url = dolphin.activeView()->url();
+ const KUrl& url = dolphin->activeView()->url();
if (url.isLocalFile()) {
- KAction* moveToTrashAction = dolphin.actionCollection()->action("move_to_trash");
+ KAction* moveToTrashAction = dolphin->actionCollection()->action("move_to_trash");
moveToTrashAction->plug(popup);
}
else {
- KAction* deleteAction = dolphin.actionCollection()->action("delete");
+ KAction* deleteAction = dolphin->actionCollection()->action("delete");
deleteAction->plug(popup);
}
@@ -225,7 +225,7 @@ void DolphinContextMenu::openItemContextMenu()
// insert 'Properties...' entry
popup->insertSeparator();
- KAction* propertiesAction = dolphin.actionCollection()->action("properties");
+ KAction* propertiesAction = dolphin->actionCollection()->action("properties");
propertiesAction->plug(popup);
QAction *activatedAction = popup->exec(m_pos);
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 7cbe3297d..9372ae9e0 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -20,11 +20,10 @@
#include "dolphiniconsview.h"
#include "dolphinview.h"
-#include "dolphin.h"
DolphinIconsView::DolphinIconsView(DolphinView* parent) :
- QListView(parent)
- , m_parentView( parent )
+ QListView(parent),
+ m_parentView( parent )
{
setResizeMode( QListView::Adjust );
}
@@ -36,7 +35,7 @@ DolphinIconsView::~DolphinIconsView()
void DolphinIconsView::mouseReleaseEvent(QMouseEvent *e)
{
QListView::mouseReleaseEvent(e);
- Dolphin::mainWin().setActiveView(m_parentView);
+ m_parentView->declareViewActive();
}
#include "dolphiniconsview.moc"
diff --git a/src/dolphin.cpp b/src/dolphinmainwindow.cpp
index db4f46889..0d4667db7 100644
--- a/src/dolphin.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -19,7 +19,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include <assert.h>
@@ -65,28 +65,44 @@
#include "dolphinsettings.h"
#include "dolphinsettingsdialog.h"
#include "dolphinstatusbar.h"
+#include "dolphinapplication.h"
#include "undomanager.h"
#include "progressindicator.h"
#include "dolphinsettings.h"
#include "sidebar.h"
#include "sidebarsettings.h"
#include "generalsettings.h"
+#include "dolphinapplication.h"
-Dolphin& Dolphin::mainWin()
+
+DolphinMainWindow::DolphinMainWindow() :
+ KMainWindow(0, "Dolphin"),
+ m_splitter(0),
+ m_sidebar(0),
+ m_activeView(0),
+ m_clipboardContainsCutData(false)
{
- static Dolphin* instance = 0;
- if (instance == 0) {
- instance = new Dolphin();
- instance->init();
- }
- return *instance;
+ m_view[PrimaryIdx] = 0;
+ m_view[SecondaryIdx] = 0;
+
+ m_fileGroupActions.setAutoDelete(true);
+
+ // TODO: the following members are not used yet. See documentation
+ // of DolphinMainWindow::linkGroupActions() and DolphinMainWindow::linkToDeviceActions()
+ // in the header file for details.
+ //m_linkGroupActions.setAutoDelete(true);
+ //m_linkToDeviceActions.setAutoDelete(true);
}
-Dolphin::~Dolphin()
+DolphinMainWindow::~DolphinMainWindow()
{
+ /*
+ * bye, bye managed window
+ */
+ DolphinApplication::app()->removeMainWindow( this );
}
-void Dolphin::setActiveView(DolphinView* view)
+void DolphinMainWindow::setActiveView(DolphinView* view)
{
assert((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx]));
if (m_activeView == view) {
@@ -105,7 +121,7 @@ void Dolphin::setActiveView(DolphinView* view)
emit activeViewChanged();
}
-void Dolphin::dropUrls(const KUrl::List& urls,
+void DolphinMainWindow::dropUrls(const KUrl::List& urls,
const KUrl& destination)
{
int selectedIndex = -1;
@@ -178,7 +194,7 @@ void Dolphin::dropUrls(const KUrl::List& urls,
}
}
-void Dolphin::refreshViews()
+void DolphinMainWindow::refreshViews()
{
const bool split = DolphinSettings::instance().generalSettings()->splitView();
const bool isPrimaryViewActive = (m_activeView == m_view[PrimaryIdx]);
@@ -196,7 +212,8 @@ void Dolphin::refreshViews()
if (split || (i == PrimaryIdx)) {
// ... and recreate it
ViewProperties props(url);
- m_view[i] = new DolphinView(m_splitter,
+ m_view[i] = new DolphinView(this,
+ m_splitter,
url,
props.viewMode(),
props.isShowHiddenFilesEnabled());
@@ -211,44 +228,44 @@ void Dolphin::refreshViews()
emit activeViewChanged();
}
-void Dolphin::slotHistoryChanged()
+void DolphinMainWindow::slotHistoryChanged()
{
updateHistory();
}
-void Dolphin::slotUrlChanged(const KUrl& url)
+void DolphinMainWindow::slotUrlChanged(const KUrl& url)
{
updateEditActions();
updateGoActions();
setCaption(url.fileName());
}
-void Dolphin::slotUrlChangeRequest(const KUrl& url)
+void DolphinMainWindow::slotUrlChangeRequest(const KUrl& url)
{
clearStatusBar();
m_activeView->setUrl(url);
}
-void Dolphin::slotViewModeChanged()
+void DolphinMainWindow::slotViewModeChanged()
{
updateViewActions();
}
-void Dolphin::slotShowHiddenFilesChanged()
+void DolphinMainWindow::slotShowHiddenFilesChanged()
{
KToggleAction* showHiddenFilesAction =
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
}
-void Dolphin::slotShowFilterBarChanged()
+void DolphinMainWindow::slotShowFilterBarChanged()
{
KToggleAction* showFilterBarAction =
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
}
-void Dolphin::slotSortingChanged(DolphinView::Sorting sorting)
+void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
{
KAction* action = 0;
switch (sorting) {
@@ -271,14 +288,14 @@ void Dolphin::slotSortingChanged(DolphinView::Sorting sorting)
}
}
-void Dolphin::slotSortOrderChanged(Qt::SortOrder order)
+void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
{
KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
const bool sortDescending = (order == Qt::Descending);
descending->setChecked(sortDescending);
}
-void Dolphin::slotSelectionChanged()
+void DolphinMainWindow::slotSelectionChanged()
{
updateEditActions();
@@ -296,7 +313,7 @@ void Dolphin::slotSelectionChanged()
emit selectionChanged();
}
-void Dolphin::closeEvent(QCloseEvent* event)
+void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
// KDE4-TODO
//KConfig* config = KGlobal::config();
@@ -319,7 +336,7 @@ void Dolphin::closeEvent(QCloseEvent* event)
KMainWindow::closeEvent(event);
}
-void Dolphin::saveProperties(KConfig* config)
+void DolphinMainWindow::saveProperties(KConfig* config)
{
config->setGroup("Primary view");
config->writeEntry("Url", m_view[PrimaryIdx]->url().url());
@@ -331,7 +348,7 @@ void Dolphin::saveProperties(KConfig* config)
}
}
-void Dolphin::readProperties(KConfig* config)
+void DolphinMainWindow::readProperties(KConfig* config)
{
config->setGroup("Primary view");
m_view[PrimaryIdx]->setUrl(config->readEntry("Url"));
@@ -349,7 +366,7 @@ void Dolphin::readProperties(KConfig* config)
}
}
-void Dolphin::createFolder()
+void DolphinMainWindow::createFolder()
{
// Parts of the following code have been taken
// from the class KonqPopupMenu located in
@@ -400,7 +417,7 @@ void Dolphin::createFolder()
statusBar->setMessage(i18n("Created folder %1.",url.path()),
DolphinStatusBar::OperationCompleted);
- DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url);
+ DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url, this);
UndoManager::instance().addCommand(command);
}
else {
@@ -418,7 +435,7 @@ void Dolphin::createFolder()
}
}
-void Dolphin::createFile()
+void DolphinMainWindow::createFile()
{
// Parts of the following code have been taken
// from the class KonqPopupMenu located in
@@ -507,7 +524,7 @@ void Dolphin::createFile()
KUrl::List list;
list.append(sourceUrl);
- DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
+ DolphinCommand command(DolphinCommand::CreateFile, list, destUrl, this);
UndoManager::instance().addCommand(command);
}
@@ -517,13 +534,13 @@ void Dolphin::createFile()
}
}
-void Dolphin::rename()
+void DolphinMainWindow::rename()
{
clearStatusBar();
m_activeView->renameSelectedItems();
}
-void Dolphin::moveToTrash()
+void DolphinMainWindow::moveToTrash()
{
clearStatusBar();
KUrl::List selectedUrls = m_activeView->selectedUrls();
@@ -531,7 +548,7 @@ void Dolphin::moveToTrash()
addPendingUndoJob(job, DolphinCommand::Trash, selectedUrls, m_activeView->url());
}
-void Dolphin::deleteItems()
+void DolphinMainWindow::deleteItems()
{
clearStatusBar();
@@ -562,7 +579,7 @@ void Dolphin::deleteItems()
}
}
-void Dolphin::properties()
+void DolphinMainWindow::properties()
{
const KFileItemList* sourceList = m_activeView->selectedItems();
if (sourceList == 0) {
@@ -581,12 +598,12 @@ void Dolphin::properties()
new KPropertiesDialog(list, this);
}
-void Dolphin::quit()
+void DolphinMainWindow::quit()
{
close();
}
-void Dolphin::slotHandleJobError(KJob* job)
+void DolphinMainWindow::slotHandleJobError(KJob* job)
{
if (job->error() != 0) {
m_activeView->statusBar()->setMessage(job->errorString(),
@@ -594,7 +611,7 @@ void Dolphin::slotHandleJobError(KJob* job)
}
}
-void Dolphin::slotDeleteFileFinished(KJob* job)
+void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
{
if (job->error() == 0) {
m_activeView->statusBar()->setMessage(i18n("Delete operation completed."),
@@ -608,7 +625,7 @@ void Dolphin::slotDeleteFileFinished(KJob* job)
}
}
-void Dolphin::slotUndoAvailable(bool available)
+void DolphinMainWindow::slotUndoAvailable(bool available)
{
KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
if (undoAction != 0) {
@@ -616,7 +633,7 @@ void Dolphin::slotUndoAvailable(bool available)
}
}
-void Dolphin::slotUndoTextChanged(const QString& text)
+void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
if (undoAction != 0) {
@@ -624,7 +641,7 @@ void Dolphin::slotUndoTextChanged(const QString& text)
}
}
-void Dolphin::slotRedoAvailable(bool available)
+void DolphinMainWindow::slotRedoAvailable(bool available)
{
KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
if (redoAction != 0) {
@@ -632,7 +649,7 @@ void Dolphin::slotRedoAvailable(bool available)
}
}
-void Dolphin::slotRedoTextChanged(const QString& text)
+void DolphinMainWindow::slotRedoTextChanged(const QString& text)
{
KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
if (redoAction != 0) {
@@ -640,7 +657,7 @@ void Dolphin::slotRedoTextChanged(const QString& text)
}
}
-void Dolphin::cut()
+void DolphinMainWindow::cut()
{
// TODO: this boolean doesn't work between instances of dolphin or with konqueror or with other
// apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData
@@ -651,7 +668,7 @@ void Dolphin::cut()
QApplication::clipboard()->setData(data);*/
}
-void Dolphin::copy()
+void DolphinMainWindow::copy()
{
m_clipboardContainsCutData = false;
/* KDE4-TODO:
@@ -660,7 +677,7 @@ void Dolphin::copy()
QApplication::clipboard()->setData(data);*/
}
-void Dolphin::paste()
+void DolphinMainWindow::paste()
{
/* KDE4-TODO: - see KonqOperations::doPaste
QClipboard* clipboard = QApplication::clipboard();
@@ -703,7 +720,7 @@ void Dolphin::paste()
}*/
}
-void Dolphin::updatePasteAction()
+void DolphinMainWindow::updatePasteAction()
{
KAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
if (pasteAction == 0) {
@@ -754,48 +771,48 @@ void Dolphin::updatePasteAction()
}
}
-void Dolphin::selectAll()
+void DolphinMainWindow::selectAll()
{
clearStatusBar();
m_activeView->selectAll();
}
-void Dolphin::invertSelection()
+void DolphinMainWindow::invertSelection()
{
clearStatusBar();
m_activeView->invertSelection();
}
-void Dolphin::setIconsView()
+void DolphinMainWindow::setIconsView()
{
m_activeView->setMode(DolphinView::IconsView);
}
-void Dolphin::setDetailsView()
+void DolphinMainWindow::setDetailsView()
{
m_activeView->setMode(DolphinView::DetailsView);
}
-void Dolphin::setPreviewsView()
+void DolphinMainWindow::setPreviewsView()
{
m_activeView->setMode(DolphinView::PreviewsView);
}
-void Dolphin::sortByName()
+void DolphinMainWindow::sortByName()
{
m_activeView->setSorting(DolphinView::SortByName);
}
-void Dolphin::sortBySize()
+void DolphinMainWindow::sortBySize()
{
m_activeView->setSorting(DolphinView::SortBySize);
}
-void Dolphin::sortByDate()
+void DolphinMainWindow::sortByDate()
{
m_activeView->setSorting(DolphinView::SortByDate);
}
-void Dolphin::toggleSortOrder()
+void DolphinMainWindow::toggleSortOrder()
{
const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ?
Qt::Descending :
@@ -803,11 +820,12 @@ void Dolphin::toggleSortOrder()
m_activeView->setSortOrder(order);
}
-void Dolphin::toggleSplitView()
+void DolphinMainWindow::toggleSplitView()
{
if (m_view[SecondaryIdx] == 0) {
// create a secondary view
- m_view[SecondaryIdx] = new DolphinView(m_splitter,
+ m_view[SecondaryIdx] = new DolphinView(this,
+ m_splitter,
m_view[PrimaryIdx]->url(),
m_view[PrimaryIdx]->mode(),
m_view[PrimaryIdx]->isShowHiddenFilesEnabled());
@@ -835,17 +853,17 @@ void Dolphin::toggleSplitView()
}
}
-void Dolphin::reloadView()
+void DolphinMainWindow::reloadView()
{
clearStatusBar();
m_activeView->reload();
}
-void Dolphin::stopLoading()
+void DolphinMainWindow::stopLoading()
{
}
-void Dolphin::showHiddenFiles()
+void DolphinMainWindow::showHiddenFiles()
{
clearStatusBar();
@@ -855,7 +873,7 @@ void Dolphin::showHiddenFiles()
m_activeView->setShowHiddenFilesEnabled(show);
}
-void Dolphin::showFilterBar()
+void DolphinMainWindow::showFilterBar()
{
const KToggleAction* showFilterBarAction =
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
@@ -863,19 +881,19 @@ void Dolphin::showFilterBar()
m_activeView->slotShowFilterBar(show);
}
-void Dolphin::zoomIn()
+void DolphinMainWindow::zoomIn()
{
m_activeView->zoomIn();
updateViewActions();
}
-void Dolphin::zoomOut()
+void DolphinMainWindow::zoomOut()
{
m_activeView->zoomOut();
updateViewActions();
}
-void Dolphin::toggleEditLocation()
+void DolphinMainWindow::toggleEditLocation()
{
clearStatusBar();
@@ -886,45 +904,45 @@ void Dolphin::toggleEditLocation()
m_activeView->setUrlEditable(editOrBrowse);
}
-void Dolphin::editLocation()
+void DolphinMainWindow::editLocation()
{
KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
action->setChecked(true);
m_activeView->setUrlEditable(true);
}
-void Dolphin::adjustViewProperties()
+void DolphinMainWindow::adjustViewProperties()
{
clearStatusBar();
ViewPropertiesDialog dlg(m_activeView);
dlg.exec();
}
-void Dolphin::goBack()
+void DolphinMainWindow::goBack()
{
clearStatusBar();
m_activeView->goBack();
}
-void Dolphin::goForward()
+void DolphinMainWindow::goForward()
{
clearStatusBar();
m_activeView->goForward();
}
-void Dolphin::goUp()
+void DolphinMainWindow::goUp()
{
clearStatusBar();
m_activeView->goUp();
}
-void Dolphin::goHome()
+void DolphinMainWindow::goHome()
{
clearStatusBar();
m_activeView->goHome();
}
-void Dolphin::openTerminal()
+void DolphinMainWindow::openTerminal()
{
QString command("konsole --workdir \"");
command.append(m_activeView->url().path());
@@ -933,12 +951,12 @@ void Dolphin::openTerminal()
KRun::runCommand(command, "Konsole", "konsole");
}
-void Dolphin::findFile()
+void DolphinMainWindow::findFile()
{
KRun::run("kfind", m_activeView->url());
}
-void Dolphin::compareFiles()
+void DolphinMainWindow::compareFiles()
{
// The method is only invoked if exactly 2 files have
// been selected. The selected files may be:
@@ -993,14 +1011,14 @@ void Dolphin::compareFiles()
}
-void Dolphin::editSettings()
+void DolphinMainWindow::editSettings()
{
// TODO: make a static method for opening the settings dialog
- DolphinSettingsDialog dlg;
+ DolphinSettingsDialog dlg(this);
dlg.exec();
}
-void Dolphin::addUndoOperation(KJob* job)
+void DolphinMainWindow::addUndoOperation(KJob* job)
{
if (job->error() != 0) {
slotHandleJobError(job);
@@ -1074,7 +1092,7 @@ void Dolphin::addUndoOperation(KJob* job)
}
}
-void Dolphin::toggleSidebar()
+void DolphinMainWindow::toggleSidebar()
{
if (m_sidebar == 0) {
openSidebar();
@@ -1087,7 +1105,7 @@ void Dolphin::toggleSidebar()
sidebarAction->setChecked(m_sidebar != 0);
}
-void Dolphin::closeSidebar()
+void DolphinMainWindow::closeSidebar()
{
if (m_sidebar == 0) {
// the sidebar has already been closed
@@ -1103,29 +1121,11 @@ void Dolphin::closeSidebar()
m_sidebar = 0;
}
-Dolphin::Dolphin() :
- KMainWindow(0, "Dolphin"),
- m_splitter(0),
- m_sidebar(0),
- m_activeView(0),
- m_clipboardContainsCutData(false)
-{
- m_view[PrimaryIdx] = 0;
- m_view[SecondaryIdx] = 0;
-
- m_fileGroupActions.setAutoDelete(true);
-
- // TODO: the following members are not used yet. See documentation
- // of Dolphin::linkGroupActions() and Dolphin::linkToDeviceActions()
- // in the header file for details.
- //m_linkGroupActions.setAutoDelete(true);
- //m_linkToDeviceActions.setAutoDelete(true);
-}
-void Dolphin::init()
+void DolphinMainWindow::init()
{
// Check whether Dolphin runs the first time. If yes then
- // a proper default window size is given at the end of Dolphin::init().
+ // a proper default window size is given at the end of DolphinMainWindow::init().
GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
const bool firstRun = generalSettings->firstRun();
@@ -1152,7 +1152,8 @@ void Dolphin::init()
const KUrl& homeUrl = root.first().url();
setCaption(homeUrl.fileName());
ViewProperties props(homeUrl);
- m_view[PrimaryIdx] = new DolphinView(m_splitter,
+ m_view[PrimaryIdx] = new DolphinView(this,
+ m_splitter,
homeUrl,
props.viewMode(),
props.isShowHiddenFilesEnabled());
@@ -1189,7 +1190,7 @@ void Dolphin::init()
}
}
-void Dolphin::loadSettings()
+void DolphinMainWindow::loadSettings()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
@@ -1202,7 +1203,7 @@ void Dolphin::loadSettings()
updateViewActions();
}
-void Dolphin::setupActions()
+void DolphinMainWindow::setupActions()
{
// setup 'File' menu
KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
@@ -1369,7 +1370,7 @@ void Dolphin::setupActions()
KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
}
-void Dolphin::setupCreateNewMenuActions()
+void DolphinMainWindow::setupCreateNewMenuActions()
{
// Parts of the following code have been taken
// from the class KNewMenu located in
@@ -1448,15 +1449,15 @@ void Dolphin::setupCreateNewMenuActions()
case '3':
case '4': {
- // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
- // and Dolphin::linkToDeviceActions() in the header file for details.
+ // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
+ // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
//m_linkGroupActions.append(action);
break;
}
case '5': {
- // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
- // and Dolphin::linkToDeviceActions() in the header file for details.
+ // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
+ // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
//m_linkToDeviceActions.append(action);
break;
}
@@ -1471,7 +1472,7 @@ void Dolphin::setupCreateNewMenuActions()
//plugActionList("link_to_device", m_linkToDeviceActions);*/
}
-void Dolphin::updateHistory()
+void DolphinMainWindow::updateHistory()
{
int index = 0;
const Q3ValueList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
@@ -1487,7 +1488,7 @@ void Dolphin::updateHistory()
}
}
-void Dolphin::updateEditActions()
+void DolphinMainWindow::updateEditActions()
{
const KFileItemList* list = m_activeView->selectedItems();
if ((list == 0) || (*list).isEmpty()) {
@@ -1521,7 +1522,7 @@ void Dolphin::updateEditActions()
updatePasteAction();
}
-void Dolphin::updateViewActions()
+void DolphinMainWindow::updateViewActions()
{
KAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
if (zoomInAction != 0) {
@@ -1571,14 +1572,14 @@ void Dolphin::updateViewActions()
sidebarAction->setChecked(m_sidebar != 0);
}
-void Dolphin::updateGoActions()
+void DolphinMainWindow::updateGoActions()
{
KAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
const KUrl& currentUrl = m_activeView->url();
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
}
-void Dolphin::updateViewProperties(const KUrl::List& urls)
+void DolphinMainWindow::updateViewProperties(const KUrl::List& urls)
{
if (urls.isEmpty()) {
return;
@@ -1588,7 +1589,8 @@ void Dolphin::updateViewProperties(const KUrl::List& urls)
// when dragging several thousand Urls. Writing a KIO slave for this
// use case is not worth the effort, but at least the main widget
// must be disabled and a progress should be shown.
- ProgressIndicator progressIndicator(i18n("Updating view properties..."),
+ ProgressIndicator progressIndicator(this,
+ i18n("Updating view properties..."),
QString::null,
urls.count());
@@ -1601,19 +1603,19 @@ void Dolphin::updateViewProperties(const KUrl::List& urls)
}
}
-void Dolphin::copyUrls(const KUrl::List& source, const KUrl& dest)
+void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
{
KIO::Job* job = KIO::copy(source, dest);
addPendingUndoJob(job, DolphinCommand::Copy, source, dest);
}
-void Dolphin::moveUrls(const KUrl::List& source, const KUrl& dest)
+void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
{
KIO::Job* job = KIO::move(source, dest);
addPendingUndoJob(job, DolphinCommand::Move, source, dest);
}
-void Dolphin::addPendingUndoJob(KIO::Job* job,
+void DolphinMainWindow::addPendingUndoJob(KIO::Job* job,
DolphinCommand::Type commandType,
const KUrl::List& source,
const KUrl& dest)
@@ -1623,23 +1625,23 @@ void Dolphin::addPendingUndoJob(KIO::Job* job,
UndoInfo undoInfo;
undoInfo.id = job->progressId();
- undoInfo.command = DolphinCommand(commandType, source, dest);
+ undoInfo.command = DolphinCommand(commandType, source, dest, this);
m_pendingUndoJobs.append(undoInfo);
}
-void Dolphin::clearStatusBar()
+void DolphinMainWindow::clearStatusBar()
{
m_activeView->statusBar()->clear();
}
-void Dolphin::openSidebar()
+void DolphinMainWindow::openSidebar()
{
if (m_sidebar != 0) {
// the sidebar is already open
return;
}
- m_sidebar = new Sidebar(m_splitter);
+ m_sidebar = new Sidebar(this, m_splitter);
m_sidebar->show();
connect(m_sidebar, SIGNAL(urlChanged(const KUrl&)),
@@ -1652,4 +1654,4 @@ void Dolphin::openSidebar()
settings->setVisible(true);
}
-#include "dolphin.moc"
+#include "dolphinmainwindow.moc"
diff --git a/src/dolphin.h b/src/dolphinmainwindow.h
index 0013b4de8..6e9f75b7f 100644
--- a/src/dolphin.h
+++ b/src/dolphinmainwindow.h
@@ -19,8 +19,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _DOLPHIN_H_
-#define _DOLPHIN_H_
+#ifndef _DOLPHIN_MAINWINDOW_H_
+#define _DOLPHIN_MAINWINDOW_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -49,6 +49,7 @@ class QSplitter;
class KAction;
class UrlNavigator;
class Sidebar;
+class DolphinApplication;
/**
* @short Main window for Dolphin.
@@ -57,18 +58,12 @@ class Sidebar;
*
* @author Peter Penz <[email protected]>
*/
-class Dolphin : public KMainWindow
+class DolphinMainWindow: public KMainWindow
{
Q_OBJECT
-
+ friend class DolphinApplication;
public:
- /**
- * Returns the instance for the Dolphin main window.
- */
- // KXMLGUIClient::instance() already in use :-(
- static Dolphin& mainWin();
-
- virtual ~Dolphin();
+ virtual ~DolphinMainWindow();
/**
* Activates the given view, which means that
@@ -80,7 +75,7 @@ public:
/**
* Returns the currently active view. See
- * Dolphin::setActiveView() for more details.
+ * DolphinMainWindow::setActiveView() for more details.
*/
DolphinView* activeView() const { return m_activeView; }
@@ -378,7 +373,7 @@ private slots:
void closeSidebar();
private:
- Dolphin();
+ DolphinMainWindow();
void init();
void loadSettings();
@@ -404,7 +399,7 @@ private:
DolphinView* m_activeView;
/**
- * Dolphin supports only one or two views, which
+ * DolphinMainWindowsupports only one or two views, which
* are handled internally as primary and secondary view.
*/
enum ViewIndex
@@ -423,8 +418,8 @@ private:
* operation is started, it is added to a pending undo jobs list in the meantime.
* As soon as the job has been finished, the operation is added to the undo mangager.
* @see UndoManager
- * @see Dolphin::addPendingUndoJob
- * @see Dolphin::addUndoOperation
+ * @see DolphinMainWindow::addPendingUndoJob
+ * @see DolphinMainWindow::addUndoOperation
*/
struct UndoInfo
{
@@ -446,8 +441,8 @@ private:
Q3PtrList<KAction> m_fileGroupActions;
KSortableList<CreateFileEntry,QString> m_createFileTemplates;
- // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
- // and Dolphin::linkToDeviceActions() in for details.
+ // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
+ // and DolphinMainWindow::linkToDeviceActions() in for details.
//QPtrList<KAction> m_linkGroupActions;
//QPtrList<KAction> m_linkToDeviceActions;
};
diff --git a/src/dolphinsettings.cpp b/src/dolphinsettings.cpp
index ccb9442d2..f197d36f0 100644
--- a/src/dolphinsettings.cpp
+++ b/src/dolphinsettings.cpp
@@ -30,13 +30,14 @@
#include <klocale.h>
#include <kstandarddirs.h>
-#include "dolphin.h"
#include "generalsettings.h"
#include "iconsmodesettings.h"
#include "previewsmodesettings.h"
#include "detailsmodesettings.h"
#include "sidebarsettings.h"
+#include <Q3IconView>
+
DolphinSettings& DolphinSettings::instance()
{
static DolphinSettings* instance = 0;
diff --git a/src/dolphinsettingsdialog.cpp b/src/dolphinsettingsdialog.cpp
index e3561af48..9cfee7d4e 100644
--- a/src/dolphinsettingsdialog.cpp
+++ b/src/dolphinsettingsdialog.cpp
@@ -24,19 +24,21 @@
#include "generalsettingspage.h"
#include "viewsettingspage.h"
#include "bookmarkssettingspage.h"
-#include "dolphin.h"
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
//Added by qt3to4:
#include <QFrame>
-DolphinSettingsDialog::DolphinSettingsDialog() :
- KPageDialog()
+DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
+ KPageDialog(),
+ m_mainWindow(mainWindow)
{
setFaceType( List);
setCaption(i18n("Dolphin Preferences"));
setButtons(Ok|Apply|Cancel);
setDefaultButton(Ok);
- m_generalSettingsPage = new GeneralSettingsPage(this);
+ m_generalSettingsPage = new GeneralSettingsPage(mainWindow, this);
KPageWidgetItem* generalSettingsFrame = addPage(m_generalSettingsPage, i18n("General"));
generalSettingsFrame->setIcon(KIcon("exec"));
@@ -66,7 +68,7 @@ void DolphinSettingsDialog::applySettings()
m_generalSettingsPage->applySettings();
m_viewSettingsPage->applySettings();
m_bookmarksSettingsPage->applySettings();
- Dolphin::mainWin().refreshViews();
+ DolphinApplication::app()->refreshMainWindows();
}
#include "dolphinsettingsdialog.moc"
diff --git a/src/dolphinsettingsdialog.h b/src/dolphinsettingsdialog.h
index f3e8da5c3..23072188e 100644
--- a/src/dolphinsettingsdialog.h
+++ b/src/dolphinsettingsdialog.h
@@ -25,6 +25,7 @@
class GeneralSettingsPage;
class ViewSettingsPage;
class BookmarksSettingsPage;
+class DolphinMainWindow;
/**
* @brief Settings dialog for Dolphin.
@@ -38,13 +39,14 @@ class DolphinSettingsDialog : public KPageDialog {
Q_OBJECT
public:
- DolphinSettingsDialog();
+ DolphinSettingsDialog(DolphinMainWindow* mainWindow);
virtual ~DolphinSettingsDialog();
protected slots:
virtual void slotButtonClicked(int button);
private:
+ DolphinMainWindow* m_mainWindow;
GeneralSettingsPage* m_generalSettingsPage;
ViewSettingsPage* m_viewSettingsPage;
BookmarksSettingsPage* m_bookmarksSettingsPage;
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index abc27167d..7dbebeab5 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -38,7 +38,7 @@
#include "urlnavigator.h"
#include "dolphinstatusbar.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphindirlister.h"
#include "viewproperties.h"
#include "dolphindetailsview.h"
@@ -50,11 +50,13 @@
#include "filterbar.h"
-DolphinView::DolphinView(QWidget *parent,
+DolphinView::DolphinView(DolphinMainWindow *mainWindow,
+ QWidget *parent,
const KUrl& url,
Mode mode,
bool showHiddenFiles) :
QWidget(parent),
+ m_mainWindow(mainWindow),
m_refreshing(false),
m_showProgress(false),
m_mode(mode),
@@ -67,24 +69,22 @@ DolphinView::DolphinView(QWidget *parent,
setFocusPolicy(Qt::StrongFocus);
m_topLayout = new Q3VBoxLayout(this);
- Dolphin& dolphin = Dolphin::mainWin();
-
connect(this, SIGNAL(signalModeChanged()),
- &dolphin, SLOT(slotViewModeChanged()));
+ mainWindow, SLOT(slotViewModeChanged()));
connect(this, SIGNAL(signalShowHiddenFilesChanged()),
- &dolphin, SLOT(slotShowHiddenFilesChanged()));
+ mainWindow, SLOT(slotShowHiddenFilesChanged()));
connect(this, SIGNAL(signalSortingChanged(DolphinView::Sorting)),
- &dolphin, SLOT(slotSortingChanged(DolphinView::Sorting)));
+ mainWindow, SLOT(slotSortingChanged(DolphinView::Sorting)));
connect(this, SIGNAL(signalSortOrderChanged(Qt::SortOrder)),
- &dolphin, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+ mainWindow, SLOT(slotSortOrderChanged(Qt::SortOrder)));
m_urlNavigator = new UrlNavigator(url, this);
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
this, SLOT(slotUrlChanged(const KUrl&)));
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
- &dolphin, SLOT(slotUrlChanged(const KUrl&)));
+ mainWindow, SLOT(slotUrlChanged(const KUrl&)));
connect(m_urlNavigator, SIGNAL(historyChanged()),
- &dolphin, SLOT(slotHistoryChanged()));
+ mainWindow, SLOT(slotHistoryChanged()));
m_statusBar = new DolphinStatusBar(this);
@@ -119,7 +119,7 @@ DolphinView::DolphinView(QWidget *parent,
m_iconSize = K3Icon::SizeMedium;
- m_filterBar = new FilterBar(this);
+ m_filterBar = new FilterBar(mainWindow, this);
m_filterBar->hide();
connect(m_filterBar, SIGNAL(signalFilterChanged(const QString&)),
this, SLOT(slotChangeNameFilter(const QString&)));
@@ -150,12 +150,12 @@ const KUrl& DolphinView::url() const
void DolphinView::requestActivation()
{
- Dolphin::mainWin().setActiveView(this);
+ mainWindow()->setActiveView(this);
}
bool DolphinView::isActive() const
{
- return (Dolphin::mainWin().activeView() == this);
+ return (mainWindow()->activeView() == this);
}
void DolphinView::setMode(Mode mode)
@@ -221,7 +221,7 @@ void DolphinView::renameSelectedItems()
return;
}
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
const QString& newName = dialog.newName();
if (newName.isEmpty()) {
view->statusBar()->setMessage(i18n("The new item name is invalid."),
@@ -235,7 +235,8 @@ void DolphinView::renameSelectedItems()
const int urlsCount = urls.count();
ProgressIndicator* progressIndicator =
- new ProgressIndicator(i18n("Renaming items..."),
+ new ProgressIndicator(mainWindow(),
+ i18n("Renaming items..."),
i18n("Renaming finished."),
urlsCount);
@@ -262,7 +263,7 @@ void DolphinView::renameSelectedItems()
else if (KIO::NetAccess::file_move(source, dest)) {
// TODO: From the users point of view he executed one 'rename n files' operation,
// but internally we store it as n 'rename 1 file' operations for the undo mechanism.
- DolphinCommand command(DolphinCommand::Rename, source, dest);
+ DolphinCommand command(DolphinCommand::Rename, source, dest, mainWindow());
undoMan.addCommand(command);
}
}
@@ -530,7 +531,7 @@ void DolphinView::rename(const KUrl& source, const QString& newName)
const bool destExists = KIO::NetAccess::exists(dest,
false,
- Dolphin::mainWin().activeView());
+ mainWindow()->activeView());
if (destExists) {
// the destination already exists, hence ask the user
// how to proceed...
@@ -568,7 +569,7 @@ void DolphinView::rename(const KUrl& source, const QString& newName)
m_statusBar->setMessage(i18n("Renamed file '%1' to '%2'.",source.fileName(), dest.fileName()),
DolphinStatusBar::OperationCompleted);
- DolphinCommand command(DolphinCommand::Rename, source, dest);
+ DolphinCommand command(DolphinCommand::Rename, source, dest, mainWindow());
UndoManager::instance().addCommand(command);
}
else {
@@ -601,13 +602,18 @@ void DolphinView::slotUrlListDropped(QDropEvent* /* event */,
}
}
- Dolphin::mainWin().dropUrls(urls, destination);
+ mainWindow()->dropUrls(urls, destination);
}
void DolphinView::mouseReleaseEvent(QMouseEvent* event)
{
QWidget::mouseReleaseEvent(event);
- Dolphin::mainWin().setActiveView(this);
+ mainWindow()->setActiveView(this);
+}
+
+DolphinMainWindow* DolphinView::mainWindow() const
+{
+ return m_mainWindow;
}
void DolphinView::slotUrlChanged(const KUrl& url)
@@ -628,7 +634,7 @@ void DolphinView::slotUrlChanged(const KUrl& url)
// created. The application does not care whether a view is represented by a
// different instance, hence inform the application that the selection might have
// changed so that it can update it's actions.
- Dolphin::mainWin().slotSelectionChanged();
+ mainWindow()->slotSelectionChanged();
emit signalUrlChanged(url);
}
@@ -644,7 +650,7 @@ void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
// Updating the Url must be done outside the scope of this slot,
// as iconview items will get deleted.
QTimer::singleShot(0, this, SLOT(updateUrl()));
- Dolphin::mainWin().setActiveView(this);
+ mainWindow()->setActiveView(this);
}
}
@@ -795,7 +801,7 @@ void DolphinView::slotErrorMessage(const QString& msg)
void DolphinView::slotGrabActivation()
{
- Dolphin::mainWin().setActiveView(this);
+ mainWindow()->setActiveView(this);
}
void DolphinView::slotContentsMoving(int x, int y)
@@ -969,6 +975,11 @@ void DolphinView::slotShowFilterBar(bool show)
}
}
+void DolphinView::declareViewActive()
+{
+ mainWindow()->setActiveView( this );
+}
+
void DolphinView::slotChangeNameFilter(const QString& nameFilter)
{
// The name filter of KDirLister does a 'hard' filtering, which
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 5c7fb5c2c..69b0022d8 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -46,7 +46,7 @@ class Q3IconViewItem;
class Q3ListViewItem;
class Q3VBoxLayout;
//class KFileView;
-class Dolphin;
+class DolphinMainWindow;
class DolphinDirLister;
class DolphinStatusBar;
class DolphinIconsView;
@@ -115,7 +115,8 @@ public:
MaxSortEnum = SortByDate
};
- DolphinView(QWidget* parent,
+ DolphinView(DolphinMainWindow* mainwindow,
+ QWidget *parent,
const KUrl& url,
Mode mode = IconsView,
bool showHiddenFiles = false);
@@ -326,6 +327,12 @@ public:
*/
bool isFilterBarVisible();
+ /**
+ * Return the DolphinMainWindow this View belongs to. It is guranteed
+ * that we have one.
+ */
+ DolphinMainWindow* mainWindow() const ;
+
public slots:
void reload();
void slotUrlListDropped(QDropEvent* event,
@@ -337,6 +344,11 @@ public slots:
*/
void slotShowFilterBar(bool show);
+ /**
+ * Declare this View as the activeview of the mainWindow()
+ */
+ void declareViewActive();
+
signals:
/** Is emitted if Url of the view has been changed to \a url. */
void signalUrlChanged(const KUrl& url);
@@ -367,8 +379,8 @@ signals:
/**
* Is emitted whenever the selection has been changed. The current selection can
- * be retrieved by Dolphin::mainWin().activeView()->selectedItems() or by
- * Dolphin::mainWin().activeView()->selectedUrls().
+ * be retrieved by mainWindow()->activeView()->selectedItems() or by
+ * mainWindow()->activeView()->selectedUrls().
*/
void signalSelectionChanged();
@@ -381,6 +393,7 @@ protected:
/** @see QWidget::mouseReleaseEvent */
virtual void mouseReleaseEvent(QMouseEvent* event);
+
private slots:
void slotUrlChanged(const KUrl& kurl);
void triggerIconsViewItem(Q3IconViewItem *item);
@@ -440,6 +453,7 @@ private:
*/
void applyModeToView();
+ DolphinMainWindow *m_mainWindow;
bool m_refreshing;
bool m_showProgress;
Mode m_mode;
diff --git a/src/filterbar.cpp b/src/filterbar.cpp
index 0982a61c7..f05d0d77d 100644
--- a/src/filterbar.cpp
+++ b/src/filterbar.cpp
@@ -29,10 +29,11 @@
#include <klineedit.h>
#include <kiconloader.h>
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
-FilterBar::FilterBar(QWidget *parent, const char *name) :
- QWidget(parent, name)
+FilterBar::FilterBar(DolphinMainWindow* mainWindow, QWidget *parent, const char *name) :
+ QWidget(parent, name),
+ m_mainWindow(mainWindow)
{
const int gap = 3;
@@ -62,7 +63,7 @@ FilterBar::FilterBar(QWidget *parent, const char *name) :
this, SIGNAL(signalFilterChanged(const QString&)));
connect(m_close, SIGNAL(clicked()), this, SLOT(hide()));
connect(m_close, SIGNAL(clicked()),
- &Dolphin::mainWin(), SLOT(slotShowFilterBarChanged()));
+ mainWindow, SLOT(slotShowFilterBarChanged()));
}
FilterBar::~FilterBar()
@@ -89,7 +90,7 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
QWidget::keyReleaseEvent(event);
if ((event->key() == Qt::Key_Escape)) {
hide();
- Dolphin::mainWin().slotShowFilterBarChanged();
+ m_mainWindow->slotShowFilterBarChanged();
}
}
diff --git a/src/filterbar.h b/src/filterbar.h
index 3f5c3cbfd..ef8bd52b7 100644
--- a/src/filterbar.h
+++ b/src/filterbar.h
@@ -25,6 +25,7 @@
class QLabel;
class QToolButton;
class KLineEdit;
+class DolphinMainWindow;
/**
* @brief Provides an input field for filtering the currently shown items.
@@ -36,7 +37,7 @@ class FilterBar : public QWidget
Q_OBJECT
public:
- FilterBar(QWidget *parent = 0, const char *name = 0);
+ FilterBar(DolphinMainWindow* mainWindow, QWidget *parent = 0, const char *name = 0);
virtual ~FilterBar();
signals:
@@ -52,6 +53,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent* event);
private:
+ DolphinMainWindow *m_mainWindow;
QLabel* m_filter;
KLineEdit* m_filterInput;
QToolButton* m_close;
diff --git a/src/generalsettingspage.cpp b/src/generalsettingspage.cpp
index d7b72aa6a..d858906cb 100644
--- a/src/generalsettingspage.cpp
+++ b/src/generalsettingspage.cpp
@@ -38,12 +38,13 @@
#include <kvbox.h>
#include "dolphinsettings.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinview.h"
#include "generalsettings.h"
-GeneralSettingsPage::GeneralSettingsPage(QWidget* parent) :
+GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* parent) :
SettingsPageBase(parent),
+ m_mainWindow(mainWin),
m_homeUrl(0),
m_startSplit(0),
m_startEditable(0)
@@ -158,7 +159,7 @@ void GeneralSettingsPage::selectHomeUrl()
void GeneralSettingsPage::useCurrentLocation()
{
- const DolphinView* view = Dolphin::mainWin().activeView();
+ const DolphinView* view = m_mainWindow->activeView();
m_homeUrl->setText(view->url().prettyUrl());
}
diff --git a/src/generalsettingspage.h b/src/generalsettingspage.h
index 246b150ed..f5e952b2f 100644
--- a/src/generalsettingspage.h
+++ b/src/generalsettingspage.h
@@ -24,6 +24,7 @@
class QLineEdit;
class QRadioButton;
class QCheckBox;
+class DolphinMainWindow;
/**
* @brief Page for the 'General' settings of the Dolphin settings dialog.
@@ -38,7 +39,7 @@ class GeneralSettingsPage : public SettingsPageBase
Q_OBJECT
public:
- GeneralSettingsPage(QWidget* parent);
+ GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
virtual ~GeneralSettingsPage();
@@ -51,6 +52,7 @@ private slots:
void useDefaulLocation();
private:
+ DolphinMainWindow *m_mainWindow;
QLineEdit* m_homeUrl;
QRadioButton* m_iconsView;
QRadioButton* m_detailsView;
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp
index bf3d5f4fc..296be528b 100644
--- a/src/infosidebarpage.cpp
+++ b/src/infosidebarpage.cpp
@@ -47,12 +47,12 @@
#include <kfilemetainfo.h>
#include <kvbox.h>
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "pixmapviewer.h"
#include "dolphinsettings.h"
-InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
- SidebarPage(parent),
+InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) :
+ SidebarPage(mainWindow, parent),
m_multipleSelection(false),
m_pendingPreview(false),
m_timer(0),
@@ -111,7 +111,7 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
layout->addWidget(m_actionBox);
layout->addWidget(dummy);
- connect(&Dolphin::mainWin(), SIGNAL(selectionChanged()),
+ connect(mainWindow, SIGNAL(selectionChanged()),
this, SLOT(showItemInfo()));
connectToActiveView();
@@ -153,7 +153,7 @@ void InfoSidebarPage::showItemInfo()
m_multipleSelection = false;
// show the preview...
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
const KFileItemList* selectedItems = view->selectedItems();
if ((selectedItems != 0) && selectedItems->count() > 1) {
m_multipleSelection = true;
@@ -218,7 +218,7 @@ void InfoSidebarPage::gotPreview(const KFileItem* /* item */,
void InfoSidebarPage::startService(int index)
{
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
if (view->hasSelection()) {
KUrl::List selectedUrls = view->selectedUrls();
KDEDesktopMimeType::executeService(selectedUrls, m_actionsVector[index]);
@@ -232,7 +232,7 @@ void InfoSidebarPage::connectToActiveView()
{
cancelRequest();
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
connect(view, SIGNAL(signalRequestItemInfo(const KUrl&)),
this, SLOT(requestDelayedItemInfo(const KUrl&)));
connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
@@ -279,7 +279,7 @@ void InfoSidebarPage::createMetaInfo()
// The methods beginInfoLines(), addInfoLine() and endInfoLines()
// take care of this.
beginInfoLines();
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
if (!view->hasSelection()) {
KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
fileItem.refresh();
@@ -430,7 +430,7 @@ void InfoSidebarPage::insertActions()
// by the given Url 'url' is created and added to the list.
KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
KFileItemList localList;
- const KFileItemList* itemList = Dolphin::mainWin().activeView()->selectedItems();
+ const KFileItemList* itemList = mainWindow()->activeView()->selectedItems();
if ((itemList == 0) || itemList->isEmpty()) {
fileItem.refresh();
localList.append(&fileItem);
diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h
index 8f2efcc73..edd43229e 100644
--- a/src/infosidebarpage.h
+++ b/src/infosidebarpage.h
@@ -59,7 +59,7 @@ class InfoSidebarPage : public SidebarPage
Q_OBJECT
public:
- InfoSidebarPage(QWidget* parent);
+ InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent);
virtual ~InfoSidebarPage();
protected:
diff --git a/src/main.cpp b/src/main.cpp
index eacff0cba..6d71bd720 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -18,7 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#include "dolphin.h"
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
@@ -54,11 +55,11 @@ int main(int argc, char **argv)
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions(options);
- KApplication app;
+ DolphinApplication app;
- Dolphin& mainWin = Dolphin::mainWin();
- mainWin.show();
+#warning TODO, SessionManagement
+#if 0
if (false /* KDE4-TODO: app.isSessionRestored() */) {
int n = 1;
while (KMainWindow::canBeRestored(n)){
@@ -66,16 +67,20 @@ int main(int argc, char **argv)
++n;
}
} else {
+#endif
+
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
if (args->count() > 0) {
- mainWin.activeView()->setUrl(args->url(0));
-
- for (int i = 1; i < args->count(); ++i) {
- KRun::run("dolphin", args->url(i));
+ for (int i = 0; i < args->count(); ++i) {
+ DolphinMainWindow *win = app.createMainWindow();
+ win->activeView()->setUrl(args->url(i));
+ win->show();
}
+ } else {
+ DolphinMainWindow* mainWin = app.createMainWindow();
+ mainWin->show();
}
args->clear();
- }
-
+
return app.exec();
}
diff --git a/src/progressindicator.cpp b/src/progressindicator.cpp
index a09552c06..b42bc2ea5 100644
--- a/src/progressindicator.cpp
+++ b/src/progressindicator.cpp
@@ -19,19 +19,21 @@
***************************************************************************/
#include "progressindicator.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinstatusbar.h"
-ProgressIndicator::ProgressIndicator(const QString& progressText,
+ProgressIndicator::ProgressIndicator(DolphinMainWindow* mainWindow,
+ const QString& progressText,
const QString& finishedText,
int operationsCount)
- : m_showProgress(false),
+ : m_mainWindow(mainWindow),
+ m_showProgress(false),
m_operationsCount(operationsCount),
m_operationsIndex(0),
m_startTime(QTime::currentTime()),
m_finishedText(finishedText)
{
- DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
+ DolphinStatusBar* statusBar = mainWindow->activeView()->statusBar();
statusBar->clear();
statusBar->setProgressText(progressText);
statusBar->setProgress(0);
@@ -40,13 +42,13 @@ ProgressIndicator::ProgressIndicator(const QString& progressText,
ProgressIndicator::~ProgressIndicator()
{
- DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
+ DolphinStatusBar* statusBar = m_mainWindow->activeView()->statusBar();
statusBar->setProgressText(QString::null);
statusBar->setProgress(100);
statusBar->setMessage(m_finishedText, DolphinStatusBar::OperationCompleted);
if (m_showProgress) {
- Dolphin::mainWin().setEnabled(true);
+ m_mainWindow->setEnabled(true);
}
}
@@ -59,7 +61,7 @@ void ProgressIndicator::execOperation()
if (elapsed > 500) {
// the operations took already more than 500 milliseconds,
// therefore show a progress indication
- Dolphin::mainWin().setEnabled(false);
+ m_mainWindow->setEnabled(false);
m_showProgress = true;
}
}
@@ -69,8 +71,9 @@ void ProgressIndicator::execOperation()
if (m_startTime.msecsTo(currentTime) > 100) {
m_startTime = currentTime;
- DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
+ DolphinStatusBar* statusBar = m_mainWindow->activeView()->statusBar();
statusBar->setProgress((m_operationsIndex * 100) / m_operationsCount);
+#warning "EVIL, DANGER, FIRE"
kapp->processEvents();
statusBar->repaint();
}
diff --git a/src/progressindicator.h b/src/progressindicator.h
index cc5c64ad4..637ca10ec 100644
--- a/src/progressindicator.h
+++ b/src/progressindicator.h
@@ -22,6 +22,8 @@
#include <qdatetime.h>
+class DolphinMainWindow;
+
/**
* Allows to show a progress of synchronous operations. Sample code:
* \code
@@ -46,12 +48,14 @@ class ProgressIndicator
{
public:
/**
+ * @param mainWindow The mainwindow this statusbar should operate on
* @param progressText Text for the progress bar (e. g. "Loading...").
* @param finishedText Text which is displayed after the operations have been finished
* (e. g. "Loading finished.").
* @param operationsCount Number of operations.
*/
- ProgressIndicator(const QString& progressText,
+ ProgressIndicator(DolphinMainWindow *mainWindow,
+ const QString& progressText,
const QString& finishedText,
int operationsCount);
@@ -68,6 +72,7 @@ public:
void execOperation();
private:
+ DolphinMainWindow *m_mainWindow;
bool m_showProgress;
int m_operationsCount;
int m_operationsIndex;
diff --git a/src/sidebar.cpp b/src/sidebar.cpp
index d67f68180..26cfa0c46 100644
--- a/src/sidebar.cpp
+++ b/src/sidebar.cpp
@@ -30,8 +30,9 @@
#include "bookmarkssidebarpage.h"
#include "infosidebarpage.h"
-Sidebar::Sidebar(QWidget* parent) :
+Sidebar::Sidebar(DolphinMainWindow* mainWindow, QWidget* parent) :
QWidget(parent),
+ m_mainWindow(mainWindow),
m_pagesSelector(0),
m_page(0),
m_layout(0)
@@ -83,8 +84,8 @@ void Sidebar::createPage(int index)
}
switch (index) {
- case 0: m_page = new InfoSidebarPage(this); break;
- case 1: m_page = new BookmarksSidebarPage(this); break;
+ case 0: m_page = new InfoSidebarPage(m_mainWindow, this); break;
+ case 1: m_page = new BookmarksSidebarPage(m_mainWindow, this); break;
default: break;
}
diff --git a/src/sidebar.h b/src/sidebar.h
index 772d2d4f9..6c7abab34 100644
--- a/src/sidebar.h
+++ b/src/sidebar.h
@@ -28,6 +28,7 @@ class KUrl;
class QComboBox;
class Q3VBoxLayout;
class SidebarPage;
+class DolphinMainWindow;
/**
* @brief The sidebar allows to access bookmarks, history items and TODO...
@@ -39,7 +40,7 @@ class Sidebar : public QWidget
Q_OBJECT
public:
- Sidebar(QWidget* parent);
+ Sidebar(DolphinMainWindow* mainwindow, QWidget* parent);
virtual ~Sidebar();
virtual QSize sizeHint() const;
@@ -57,6 +58,7 @@ private slots:
private:
int indexForName(const QString& name) const;
+ DolphinMainWindow *m_mainWindow;
QComboBox* m_pagesSelector;
SidebarPage* m_page;
QVBoxLayout* m_layout;
diff --git a/src/sidebarpage.cpp b/src/sidebarpage.cpp
index 0b633335b..5a57ad282 100644
--- a/src/sidebarpage.cpp
+++ b/src/sidebarpage.cpp
@@ -18,12 +18,13 @@
***************************************************************************/
#include "sidebarpage.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
-SidebarPage::SidebarPage(QWidget* parent) :
- QWidget(parent)
+SidebarPage::SidebarPage(DolphinMainWindow *mainWindow, QWidget* parent) :
+ QWidget(parent),
+ m_mainWindow(mainWindow)
{
- connect(&Dolphin::mainWin(), SIGNAL(activeViewChanged()),
+ connect(mainWindow, SIGNAL(activeViewChanged()),
this, SLOT(activeViewChanged()));
}
@@ -35,4 +36,8 @@ void SidebarPage::activeViewChanged()
{
}
+DolphinMainWindow* SidebarPage::mainWindow() const {
+ return m_mainWindow;
+}
+
#include "sidebarpage.moc"
diff --git a/src/sidebarpage.h b/src/sidebarpage.h
index 50a7b598f..e97b0c9cf 100644
--- a/src/sidebarpage.h
+++ b/src/sidebarpage.h
@@ -23,6 +23,7 @@
#include <qwidget.h>
+class DolphinMainWindow;
class Sidebar;
/**
@@ -35,7 +36,7 @@ class SidebarPage : public QWidget
Q_OBJECT
public:
- SidebarPage(QWidget* parent);
+ SidebarPage(DolphinMainWindow* mainwindow, QWidget* parent);
virtual ~SidebarPage();
protected slots:
@@ -44,6 +45,12 @@ protected slots:
* The active view can be retrieved by Dolphin::mainWin().activeView();
*/
virtual void activeViewChanged();
+
+protected:
+ DolphinMainWindow* mainWindow() const;
+
+private:
+ DolphinMainWindow *m_mainWindow;
};
#endif // _SIDEBARPAGE_H_
diff --git a/src/undomanager.cpp b/src/undomanager.cpp
index 4e3ec054b..7d21896e1 100644
--- a/src/undomanager.cpp
+++ b/src/undomanager.cpp
@@ -24,13 +24,14 @@
#include <qtimer.h>
#include <assert.h>
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinstatusbar.h"
#include "progressindicator.h"
DolphinCommand::DolphinCommand() :
m_type(Copy),
- m_macroIndex(-1)
+ m_macroIndex(-1),
+ m_mainWindow(0)
{
// Implementation note: DolphinCommands are stored in a QValueList, whereas
// QValueList requires a default constructor of the added class.
@@ -43,11 +44,13 @@ DolphinCommand::DolphinCommand() :
DolphinCommand::DolphinCommand(Type type,
const KUrl::List& source,
- const KUrl& dest) :
+ const KUrl& dest,
+ DolphinMainWindow* mainWindow) :
m_type(type),
m_macroIndex(-1),
m_source(source),
- m_dest(dest)
+ m_dest(dest),
+ m_mainWindow(mainWindow)
{
}
@@ -60,6 +63,7 @@ DolphinCommand& DolphinCommand::operator = (const DolphinCommand& command)
m_type = command.m_type;
m_source = command.m_source;
m_dest = command.m_dest;
+ m_mainWindow = command.m_mainWindow;
return *this;
}
@@ -124,7 +128,7 @@ void UndoManager::undo()
int macroCount = 1;
calcStepsCount(macroCount, progressCount);
- m_progressIndicator = new ProgressIndicator(i18n("Executing undo operation..."),
+ m_progressIndicator = new ProgressIndicator(0, i18n("Executing undo operation..."),
i18n("Executed undo operation."),
progressCount);
@@ -201,7 +205,7 @@ void UndoManager::undo()
case DolphinCommand::CreateFolder:
case DolphinCommand::CreateFile: {
- KIO::NetAccess::del(command.destination(), &Dolphin::mainWin());
+ KIO::NetAccess::del(command.destination(), command.mainWindow() );
break;
}
}
@@ -211,7 +215,7 @@ void UndoManager::undo()
// information to the Dolphin statusbar.
connect(job, SIGNAL(percent(KIO::Job*, unsigned long)),
this, SLOT(slotPercent(KIO::Job*, unsigned long)));
- KIO::NetAccess::synchronousRun(job, &Dolphin::mainWin());
+ KIO::NetAccess::synchronousRun(job, command.mainWindow() );
}
m_progressIndicator->execOperation();
@@ -237,7 +241,8 @@ void UndoManager::redo()
int macroCount = 1;
calcStepsCount(macroCount, progressCount);
- m_progressIndicator = new ProgressIndicator(i18n("Executing redo operation..."),
+#warning "TOUGH"
+ m_progressIndicator = new ProgressIndicator(0, i18n("Executing redo operation..."),
i18n("Executed redo operation."),
progressCount);
@@ -254,8 +259,6 @@ void UndoManager::redo()
emit undoAvailable(true);
emit undoTextChanged(i18n("Undo: %1",commandText(command)));
- Dolphin& dolphin = Dolphin::mainWin();
-
KUrl::List sourceUrls = command.source();
KUrl::List::Iterator it = sourceUrls.begin();
const KUrl::List::Iterator end = sourceUrls.end();
@@ -286,7 +289,7 @@ void UndoManager::redo()
const QString originalFileName((*it).fileName().section('-', 1));
KUrl originalSourceUrl(destUrl + "/" + originalFileName);
KIO::Job* moveToTrashJob = KIO::trash(originalSourceUrl);
- KIO::NetAccess::synchronousRun(moveToTrashJob, &dolphin);
+ KIO::NetAccess::synchronousRun(moveToTrashJob, command.mainWindow() );
++it;
m_progressIndicator->execOperation();
@@ -295,7 +298,7 @@ void UndoManager::redo()
}
case DolphinCommand::CreateFolder: {
- KIO::NetAccess::mkdir(command.destination(), &dolphin);
+ KIO::NetAccess::mkdir(command.destination(), command.mainWindow());
break;
}
@@ -315,7 +318,7 @@ void UndoManager::redo()
// information to the Dolphin statusbar.
connect(job, SIGNAL(percent(KJob*, unsigned long)),
this, SLOT(slotPercent(KJob*, unsigned long)));
- KIO::NetAccess::synchronousRun(job, &dolphin);
+ KIO::NetAccess::synchronousRun(job, command.mainWindow());
}
++m_historyIndex;
diff --git a/src/undomanager.h b/src/undomanager.h
index ac2c2bb37..bf9a80c90 100644
--- a/src/undomanager.h
+++ b/src/undomanager.h
@@ -22,11 +22,13 @@
#define UNDOMANAGER_H
#include <qobject.h>
+#include <QPointer>
#include <q3valuelist.h>
#include <kurl.h>
#include <kio/jobclasses.h>
class ProgressIndicator;
+class DolphinMainWindow;
/**
* @short Represents a file manager command which can be undone and redone.
@@ -54,7 +56,7 @@ public:
};
DolphinCommand();
- DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest);
+ DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest, DolphinMainWindow* mainWindow);
~DolphinCommand(); // non-virtual
DolphinCommand& operator = (const DolphinCommand& command);
@@ -62,12 +64,14 @@ public:
void setSource(const KUrl::List source) { m_source = source; }
const KUrl::List& source() const { return m_source; }
const KUrl& destination() const { return m_dest; }
+ DolphinMainWindow* mainWindow() const { return m_mainWindow; }
private:
Type m_type;
int m_macroIndex;
KUrl::List m_source;
KUrl m_dest;
+ QPointer<DolphinMainWindow> m_mainWindow;
friend class UndoManager; // allow to modify m_macroIndex
};
diff --git a/src/urlbutton.cpp b/src/urlbutton.cpp
index a4415707a..f2bf8ccda 100644
--- a/src/urlbutton.cpp
+++ b/src/urlbutton.cpp
@@ -29,7 +29,7 @@
#include <klocale.h>
#include "urlnavigator.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
UrlButton::UrlButton(UrlNavigator* parent)
@@ -42,7 +42,7 @@ UrlButton::UrlButton(UrlNavigator* parent)
setMinimumHeight(parent->minimumHeight());
connect(this, SIGNAL(clicked()), parent, SLOT(slotRequestActivation()));
- connect(&Dolphin::mainWin(), SIGNAL(activeViewChanged()),
+ connect(parent->dolphinView()->mainWindow(), SIGNAL(activeViewChanged()),
this, SLOT(update()));
}
diff --git a/src/urlnavigator.cpp b/src/urlnavigator.cpp
index ae2e06cbd..bc2c5914e 100644
--- a/src/urlnavigator.cpp
+++ b/src/urlnavigator.cpp
@@ -51,7 +51,7 @@
#include <kvbox.h>
#include "bookmarkselector.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinsettings.h"
#include "dolphinstatusbar.h"
#include "dolphinview.h"
@@ -470,7 +470,7 @@ void UrlNavigator::updateContent()
QToolTip::remove(m_toggleButton);
QString path(url().pathOrUrl());
- const KAction* action = Dolphin::mainWin().actionCollection()->action("editable_location");
+ const KAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location");
// TODO: registry of default shortcuts
QString shortcut = action? action->shortcut().toString() : "Ctrl+L";
if (m_toggleButton->isChecked()) {
diff --git a/src/urlnavigator.h b/src/urlnavigator.h
index 0b25e136d..1ae1dc040 100644
--- a/src/urlnavigator.h
+++ b/src/urlnavigator.h
@@ -103,7 +103,7 @@ public:
int m_contentsY;
};
- UrlNavigator(const KUrl& url, DolphinView* dolphinView);;
+ UrlNavigator(const KUrl& url, DolphinView* dolphinView);
virtual ~UrlNavigator();
/**
diff --git a/src/urlnavigatorbutton.cpp b/src/urlnavigatorbutton.cpp
index f9c5b407b..5e800c1a2 100644
--- a/src/urlnavigatorbutton.cpp
+++ b/src/urlnavigatorbutton.cpp
@@ -40,7 +40,7 @@
#include "urlnavigator.h"
#include "dolphinview.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
UrlNavigatorButton::UrlNavigatorButton(int index, UrlNavigator* parent) :
UrlButton(parent),
@@ -117,9 +117,9 @@ void UrlNavigatorButton::paintEvent(QPaintEvent* event)
// dimm the colors if the parent view does not have the focus
const DolphinView* parentView = urlNavigator()->dolphinView();
- const Dolphin& dolphin = Dolphin::mainWin();
+ const DolphinMainWindow* dolphin = parentView->mainWindow();
- const bool isActive = (dolphin.activeView() == parentView);
+ const bool isActive = (dolphin->activeView() == parentView);
if (!isActive) {
QColor dimmColor(colorGroup().background());
foregroundColor = mixColors(foregroundColor, dimmColor);