]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Update hidden state correctly
[dolphin.git] / src / dolphinmainwindow.cpp
index dd985fc1d1c939dfb75b5c704ebcee00e6cce6c3..75a340f0a5e14aa0b7b7432158cbb99384ff0337 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
  *   Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com>               *
  *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
  *                                                                         *
 
 #include "dolphinmainwindow.h"
 
-#include <assert.h>
-
-#include <kactioncollection.h>
-#include <ktoggleaction.h>
-#include <kbookmarkmanager.h>
-#include <kglobal.h>
-#include <kpropertiesdialog.h>
-#include <kicon.h>
-#include <kiconloader.h>
-#include <kdeversion.h>
-#include <kstatusbar.h>
-#include <kio/netaccess.h>
-#include <kfiledialog.h>
-#include <kconfig.h>
-#include <kurl.h>
-#include <kstdaccel.h>
-#include <kaction.h>
-#include <kstdaction.h>
-#include <kmenu.h>
-#include <kio/renamedlg.h>
-#include <kinputdialog.h>
-#include <kshell.h>
-#include <kdesktopfile.h>
-#include <kstandarddirs.h>
-#include <kprotocolinfo.h>
-#include <kmessagebox.h>
-#include <kservice.h>
-#include <kstandarddirs.h>
-#include <krun.h>
-#include <klocale.h>
-
-#include <qclipboard.h>
-#include <q3dragobject.h>
-//Added by qt3to4:
-#include <Q3ValueList>
+#include "global.h"
+#include "dolphindockwidget.h"
+#include "dolphincontextmenu.h"
+#include "dolphinnewfilemenu.h"
+#include "dolphinrecenttabsmenu.h"
+#include "dolphintabwidget.h"
+#include "dolphinviewcontainer.h"
+#include "dolphintabpage.h"
+#include "middleclickactioneventfilter.h"
+#include "panels/folders/folderspanel.h"
+#include "panels/places/placespanel.h"
+#include "panels/information/informationpanel.h"
+#include "panels/terminal/terminalpanel.h"
+#include "settings/dolphinsettingsdialog.h"
+#include "statusbar/dolphinstatusbar.h"
+#include "views/dolphinviewactionhandler.h"
+#include "views/dolphinremoteencoding.h"
+#include "views/draganddrophelper.h"
+#include "views/viewproperties.h"
+#include "views/dolphinnewfilemenuobserver.h"
+#include "dolphin_generalsettings.h"
+
+#include <KActionCollection>
+#include <KActionMenu>
+#include <KAuthorized>
+#include <KConfig>
+#include <KFileItemListProperties>
+#include <KHelpMenu>
+#include <KIO/JobUiDelegate>
+#include <KIO/OpenFileManagerWindowJob>
+#include <KJobWidgets>
+#include <KLocalizedString>
+#include <KMessageBox>
+#include <KProtocolInfo>
+#include <KProtocolManager>
+#include <KRun>
+#include <KShell>
+#include <KStandardAction>
+#include <KToggleAction>
+#include <KToolBar>
+#include <KToolInvocation>
+#include <KUrlComboBox>
+#include <KUrlNavigator>
+
+#include <QApplication>
+#include <QClipboard>
 #include <QCloseEvent>
-#include <QSplitter>
-#include <QDockWidget>
-
-#include "urlnavigator.h"
-#include "viewpropertiesdialog.h"
-#include "viewproperties.h"
-#include "dolphinsettings.h"
-#include "dolphinsettingsdialog.h"
-#include "dolphinstatusbar.h"
-#include "dolphinapplication.h"
-#include "undomanager.h"
-#include "progressindicator.h"
-#include "dolphinsettings.h"
-#include "bookmarkssidebarpage.h"
-#include "infosidebarpage.h"
-#include "generalsettings.h"
-#include "dolphinapplication.h"
-
-
-DolphinMainWindow::DolphinMainWindow() :
-    KMainWindow(0),
-    m_splitter(0),
-    m_activeView(0),
-    m_clipboardContainsCutData(false)
-{
-    setObjectName("Dolphin");
-    m_view[PrimaryIdx] = 0;
-    m_view[SecondaryIdx] = 0;
-
-    // TODO: the following members are not used yet. See documentation
-    // of DolphinMainWindow::linkGroupActions() and DolphinMainWindow::linkToDeviceActions()
-    // in the header file for details.
-}
-
-DolphinMainWindow::~DolphinMainWindow()
-{
-    qDeleteAll(m_fileGroupActions);
-    //qDeleteAll(m_linkToDeviceActions);
-    //qDeleteAll(m_linkGroupActions);
-    m_fileGroupActions.clear();
-    //m_linkGroupActions.clear();
-    //m_linkToDeviceActions.clear();
-
-    /*
-     * bye, bye managed window
-     */
-    DolphinApplication::app()->removeMainWindow( this );
+#include <QDialog>
+#include <QFileInfo>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QPushButton>
+#include <QShowEvent>
+#include <QStandardPaths>
+#include <QTimer>
+#include <QToolButton>
+#include <kdualaction.h>
+
+namespace {
+    // Used for GeneralSettings::version() to determine whether
+    // an updated version of Dolphin is running.
+    const int CurrentDolphinVersion = 200;
 }
 
-void DolphinMainWindow::setActiveView(DolphinView* view)
-{
-    assert((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx]));
-    if (m_activeView == view) {
-        return;
+DolphinMainWindow::DolphinMainWindow() :
+    KXmlGuiWindow(nullptr),
+    m_newFileMenu(nullptr),
+    m_tabWidget(nullptr),
+    m_activeViewContainer(nullptr),
+    m_actionHandler(nullptr),
+    m_remoteEncoding(nullptr),
+    m_settingsDialog(),
+    m_controlButton(nullptr),
+    m_updateToolBarTimer(nullptr),
+    m_lastHandleUrlStatJob(nullptr),
+    m_terminalPanel(nullptr),
+    m_placesPanel(nullptr),
+    m_tearDownFromPlacesRequested(false)
+{
+    Q_INIT_RESOURCE(dolphin);
+    setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
+    setObjectName(QStringLiteral("Dolphin#"));
+
+    connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
+            this, &DolphinMainWindow::showErrorMessage);
+
+    KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
+    undoManager->setUiInterface(new UndoUiInterface());
+
+    connect(undoManager, static_cast<void(KIO::FileUndoManager::*)(bool)>(&KIO::FileUndoManager::undoAvailable),
+            this, &DolphinMainWindow::slotUndoAvailable);
+    connect(undoManager, &KIO::FileUndoManager::undoTextChanged,
+            this, &DolphinMainWindow::slotUndoTextChanged);
+    connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted,
+            this, &DolphinMainWindow::clearStatusBar);
+    connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
+            this, &DolphinMainWindow::showCommand);
+
+    GeneralSettings* generalSettings = GeneralSettings::self();
+    const bool firstRun = (generalSettings->version() < 200);
+    if (firstRun) {
+        generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
     }
 
-    m_activeView = view;
+    setAcceptDrops(true);
 
-    updateHistory();
-    updateEditActions();
-    updateViewActions();
-    updateGoActions();
+    m_tabWidget = new DolphinTabWidget(this);
+    m_tabWidget->setObjectName("tabWidget");
+    connect(m_tabWidget, &DolphinTabWidget::activeViewChanged,
+            this, &DolphinMainWindow::activeViewChanged);
+    connect(m_tabWidget, &DolphinTabWidget::tabCountChanged,
+            this, &DolphinMainWindow::tabCountChanged);
+    connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged,
+            this, &DolphinMainWindow::updateWindowTitle);
+    setCentralWidget(m_tabWidget);
 
-    setCaption(m_activeView->url().fileName());
+    setupActions();
 
-    emit activeViewChanged();
-}
+    m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
+    connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
+    connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinMainWindow::createDirectory);
 
-void DolphinMainWindow::dropUrls(const KUrl::List& urls,
-                       const KUrl& destination)
-{
-    int selectedIndex = -1;
+    m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
+    connect(this, &DolphinMainWindow::urlChanged,
+            m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
+
+    setupDockWidgets();
 
-    /* KDE4-TODO
-    const ButtonState keyboardState = KApplication::keyboardMouseState();
-    const bool shiftPressed = (keyboardState & ShiftButton) > 0;
-    const bool controlPressed = (keyboardState & ControlButton) > 0;
+    setupGUI(Keys | Save | Create | ToolBar);
+    stateChanged(QStringLiteral("new_file"));
 
+    QClipboard* clipboard = QApplication::clipboard();
+    connect(clipboard, &QClipboard::dataChanged,
+            this, &DolphinMainWindow::updatePasteAction);
 
+    QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
+    showFilterBarAction->setChecked(generalSettings->filterBar());
 
-    if (shiftPressed && controlPressed) {
-        // shortcut for 'Linke Here' is used
-        selectedIndex = 2;
-    }
-    else if (controlPressed) {
-        // shortcut for 'Copy Here' is used
-        selectedIndex = 1;
-    }
-    else if (shiftPressed) {
-        // shortcut for 'Move Here' is used
-        selectedIndex = 0;
-    }
-    else*/ {
-        // no shortcut is used, hence open a popup menu
-        KMenu popup(this);
-
-        popup.insertItem(SmallIcon("goto"), i18n("&Move Here") + "\t" /* KDE4-TODO: + KKey::modFlagLabel(KKey::SHIFT)*/, 0);
-        popup.insertItem(SmallIcon("editcopy"), i18n( "&Copy Here" ) /* KDE4-TODO + "\t" + KKey::modFlagLabel(KKey::CTRL)*/, 1);
-        popup.insertItem(i18n("&Link Here") /* KDE4-TODO + "\t" + KKey::modFlagLabel((KKey::ModFlag)(KKey::CTRL|KKey::SHIFT)) */, 2);
-        popup.insertSeparator();
-        popup.insertItem(SmallIcon("stop"), i18n("Cancel"), 3);
-        popup.setAccel(i18n("Escape"), 3);
-
-        /* KDE4-TODO: selectedIndex = popup.exec(QCursor::pos()); */
-        popup.exec(QCursor::pos());
-        selectedIndex = 0; // KD4-TODO: use QAction instead of switch below
-        // See libkonq/konq_operations.cc: KonqOperations::doDropFileCopy() (and doDrop, the main method)
+    if (firstRun) {
+        menuBar()->setVisible(false);
+        // Assure a proper default size if Dolphin runs the first time
+        resize(750, 500);
     }
 
-    if (selectedIndex < 0) {
-        return;
+    const bool showMenu = !menuBar()->isHidden();
+    QAction* showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
+    showMenuBarAction->setChecked(showMenu);  // workaround for bug #171080
+    if (!showMenu) {
+        createControlButton();
     }
 
-    switch (selectedIndex) {
-        case 0: {
-            // 'Move Here' has been selected
-            updateViewProperties(urls);
-            moveUrls(urls, destination);
-            break;
-        }
-
-        case 1: {
-            // 'Copy Here' has been selected
-            updateViewProperties(urls);
-            copyUrls(urls, destination);
-            break;
-        }
-
-        case 2: {
-            // 'Link Here' has been selected
-            KIO::Job* job = KIO::link(urls, destination);
-            addPendingUndoJob(job, DolphinCommand::Link, urls, destination);
-            break;
-        }
-
-        default:
-            // 'Cancel' has been selected
-            break;
-    }
+    // enable middle-click on back/forward/up to open in a new tab
+    auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
+    connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked);
+    toolBar()->installEventFilter(middleClickEventFilter);
 }
 
-void DolphinMainWindow::refreshViews()
+DolphinMainWindow::~DolphinMainWindow()
 {
-    const bool split = DolphinSettings::instance().generalSettings()->splitView();
-    const bool isPrimaryViewActive = (m_activeView == m_view[PrimaryIdx]);
-    KUrl url;
-    for (int i = PrimaryIdx; i <= SecondaryIdx; ++i) {
-       if (m_view[i] != 0) {
-            url = m_view[i]->url();
-
-            // delete view instance...
-            m_view[i]->close();
-            m_view[i]->deleteLater();
-            m_view[i] = 0;
-        }
-
-        if (split || (i == PrimaryIdx)) {
-            // ... and recreate it
-            ViewProperties props(url);
-            m_view[i] = new DolphinView(this,
-                                        m_splitter,
-                                        url,
-                                        props.viewMode(),
-                                        props.showHiddenFiles());
-            connectViewSignals(i);
-            m_view[i]->show();
-        }
-    }
-
-    m_activeView = isPrimaryViewActive ? m_view[PrimaryIdx] : m_view[SecondaryIdx];
-    assert(m_activeView != 0);
-
-    updateViewActions();
-    emit activeViewChanged();
 }
 
-void DolphinMainWindow::slotViewModeChanged()
+void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView)
 {
-    updateViewActions();
+    m_tabWidget->openDirectories(dirs, splitView);
 }
 
-void DolphinMainWindow::slotShowHiddenFilesChanged()
+void DolphinMainWindow::openFiles(const QList<QUrl>& files, bool splitView)
 {
-    KToggleAction* showHiddenFilesAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
-    showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
+    m_tabWidget->openFiles(files, splitView);
 }
 
-void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
+void DolphinMainWindow::showCommand(CommandType command)
 {
-    QAction* action = 0;
-    switch (sorting) {
-        case DolphinView::SortByName:
-            action = actionCollection()->action("by_name");
-            break;
-        case DolphinView::SortBySize:
-            action = actionCollection()->action("by_size");
-            break;
-        case DolphinView::SortByDate:
-            action = actionCollection()->action("by_date");
-            break;
-        default:
-            break;
-    }
+    DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
+    switch (command) {
+    case KIO::FileUndoManager::Copy:
+        statusBar->setText(i18nc("@info:status", "Successfully copied."));
+        break;
+    case KIO::FileUndoManager::Move:
+        statusBar->setText(i18nc("@info:status", "Successfully moved."));
+        break;
+    case KIO::FileUndoManager::Link:
+        statusBar->setText(i18nc("@info:status", "Successfully linked."));
+        break;
+    case KIO::FileUndoManager::Trash:
+        statusBar->setText(i18nc("@info:status", "Successfully moved to trash."));
+        break;
+    case KIO::FileUndoManager::Rename:
+        statusBar->setText(i18nc("@info:status", "Successfully renamed."));
+        break;
+
+    case KIO::FileUndoManager::Mkdir:
+        statusBar->setText(i18nc("@info:status", "Created folder."));
+        break;
 
-    if (action != 0) {
-        KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
-        toggleAction->setChecked(true);
+    default:
+        break;
     }
 }
 
-void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
+void DolphinMainWindow::pasteIntoFolder()
 {
-    KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
-    const bool sortDescending = (order == Qt::Descending);
-    descending->setChecked(sortDescending);
+    m_activeViewContainer->view()->pasteIntoFolder();
 }
 
-void DolphinMainWindow::slotSelectionChanged()
+void DolphinMainWindow::changeUrl(const QUrl &url)
 {
-    updateEditActions();
-
-    assert(m_view[PrimaryIdx] != 0);
-    int selectedUrlsCount = m_view[PrimaryIdx]->selectedUrls().count();
-    if (m_view[SecondaryIdx] != 0) {
-        selectedUrlsCount += m_view[SecondaryIdx]->selectedUrls().count();
+    if (!KProtocolManager::supportsListing(url)) {
+        // The URL navigator only checks for validity, not
+        // if the URL can be listed. An error message is
+        // shown due to DolphinViewContainer::restoreView().
+        return;
     }
 
-    QAction* compareFilesAction = actionCollection()->action("compare_files");
-    compareFilesAction->setEnabled(selectedUrlsCount == 2);
-
-    m_activeView->updateStatusBar();
+    m_activeViewContainer->setUrl(url);
+    updateEditActions();
+    updatePasteAction();
+    updateViewActions();
+    updateGoActions();
 
-    emit selectionChanged();
+    emit urlChanged(url);
 }
 
-void DolphinMainWindow::slotHistoryChanged()
+void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
 {
-    updateHistory();
+    if (m_tearDownFromPlacesRequested && url == QUrl::fromLocalFile(QDir::homePath())) {
+        m_placesPanel->proceedWithTearDown();
+        m_tearDownFromPlacesRequested = false;
+    }
+
+    m_activeViewContainer->setAutoGrabFocus(false);
+    changeUrl(url);
+    m_activeViewContainer->setAutoGrabFocus(true);
 }
 
-void DolphinMainWindow::slotUrlChanged(const KUrl& url)
+void DolphinMainWindow::slotEditableStateChanged(bool editable)
 {
-    updateEditActions();
-    updateGoActions();
-    setCaption(url.fileName());
+    KToggleAction* editableLocationAction =
+        static_cast<KToggleAction*>(actionCollection()->action(QStringLiteral("editable_location")));
+    editableLocationAction->setChecked(editable);
 }
 
-void DolphinMainWindow::updateFilterBarAction(bool show)
+void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
 {
-    KToggleAction* showFilterBarAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
-    showFilterBarAction->setChecked(show);
+    updateEditActions();
+
+    const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount();
+
+    QAction* compareFilesAction = actionCollection()->action(QStringLiteral("compare_files"));
+    if (selectedUrlsCount == 2) {
+        compareFilesAction->setEnabled(isKompareInstalled());
+    } else {
+        compareFilesAction->setEnabled(false);
+    }
+
+    emit selectionChanged(selection);
 }
 
-void DolphinMainWindow::redo()
+void DolphinMainWindow::updateHistory()
 {
-    UndoManager::instance().redo(this);
+    const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    const int index = urlNavigator->historyIndex();
+
+    QAction* backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
+    if (backAction) {
+        backAction->setToolTip(i18nc("@info", "Go back"));
+        backAction->setEnabled(index < urlNavigator->historySize() - 1);
+    }
+
+    QAction* forwardAction = actionCollection()->action(KStandardAction::name(KStandardAction::Forward));
+    if (forwardAction) {
+        forwardAction->setToolTip(i18nc("@info", "Go forward"));
+        forwardAction->setEnabled(index > 0);
+    }
 }
 
-void DolphinMainWindow::undo()
+void DolphinMainWindow::updateFilterBarAction(bool show)
 {
-    UndoManager::instance().undo(this);
+    QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
+    showFilterBarAction->setChecked(show);
 }
 
 void DolphinMainWindow::openNewMainWindow()
 {
-    DolphinApplication::app()->createMainWindow()->show();
+    Dolphin::openNewWindow({m_activeViewContainer->url()}, this);
 }
 
-void DolphinMainWindow::closeEvent(QCloseEvent* event)
+void DolphinMainWindow::openNewActivatedTab()
 {
-    // KDE4-TODO
-    //KConfig* config = KGlobal::config();
-    //config->setGroup("General");
-    //config->writeEntry("First Run", false);
-
-    DolphinSettings& settings = DolphinSettings::instance();
-    GeneralSettings* generalSettings = settings.generalSettings();
-    generalSettings->setFirstRun(false);
-
-    settings.save();
-
-    KMainWindow::closeEvent(event);
+    m_tabWidget->openNewActivatedTab();
 }
 
-void DolphinMainWindow::saveProperties(KConfig* config)
+void DolphinMainWindow::openNewTab(const QUrl& url)
 {
-    config->setGroup("Primary view");
-    config->writeEntry("Url", m_view[PrimaryIdx]->url().url());
-    config->writeEntry("Editable Url", m_view[PrimaryIdx]->isUrlEditable());
-    if (m_view[SecondaryIdx] != 0) {
-        config->setGroup("Secondary view");
-        config->writeEntry("Url", m_view[SecondaryIdx]->url().url());
-        config->writeEntry("Editable Url", m_view[SecondaryIdx]->isUrlEditable());
-    }
+    m_tabWidget->openNewTab(url);
 }
 
-void DolphinMainWindow::readProperties(KConfig* config)
+void DolphinMainWindow::openInNewTab()
 {
-    config->setGroup("Primary view");
-    m_view[PrimaryIdx]->setUrl(config->readEntry("Url"));
-    m_view[PrimaryIdx]->setUrlEditable(config->readEntry("Editable Url", false));
-    if (config->hasGroup("Secondary view")) {
-        config->setGroup("Secondary view");
-        if (m_view[SecondaryIdx] == 0) {
-            toggleSplitView();
+    const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
+    bool tabCreated = false;
+
+    foreach (const KFileItem& item, list) {
+        const QUrl& url = DolphinView::openItemAsFolderUrl(item);
+        if (!url.isEmpty()) {
+            openNewTab(url);
+            tabCreated = true;
         }
-        m_view[SecondaryIdx]->setUrl(config->readEntry("Url"));
-        m_view[SecondaryIdx]->setUrlEditable(config->readEntry("Editable Url", false));
     }
-    else if (m_view[SecondaryIdx] != 0) {
-        toggleSplitView();
+
+    // if no new tab has been created from the selection
+    // open the current directory in a new tab
+    if (!tabCreated) {
+        openNewTab(m_activeViewContainer->url());
     }
 }
 
-void DolphinMainWindow::createFolder()
+void DolphinMainWindow::openInNewWindow()
 {
-    // Parts of the following code have been taken
-    // from the class KonqPopupMenu located in
-    // libqonq/konq_popupmenu.h of Konqueror.
-    // (Copyright (C) 2000  David Faure <faure@kde.org>,
-    // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
-
-    clearStatusBar();
-
-    DolphinStatusBar* statusBar = m_activeView->statusBar();
-    const KUrl baseUrl(m_activeView->url());
-
-    QString name(i18n("New Folder"));
-    baseUrl.path(KUrl::AddTrailingSlash);
-
-
-    if (baseUrl.isLocalFile() && QFileInfo(baseUrl.path(KUrl::AddTrailingSlash) + name).exists()) {
-        name = KIO::RenameDlg::suggestName(baseUrl, i18n("New Folder"));
-    }
+    QUrl newWindowUrl;
 
-    bool ok = false;
-    name = KInputDialog::getText(i18n("New Folder"),
-                                 i18n("Enter folder name:" ),
-                                 name,
-                                 &ok,
-                                 this);
-
-    if (!ok) {
-        // the user has pressed 'Cancel'
-        return;
+    const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+    if (list.isEmpty()) {
+        newWindowUrl = m_activeViewContainer->url();
+    } else if (list.count() == 1) {
+        const KFileItem& item = list.first();
+        newWindowUrl = DolphinView::openItemAsFolderUrl(item);
     }
 
-    assert(!name.isEmpty());
-
-    KUrl url;
-    if ((name[0] == '/') || (name[0] == '~')) {
-        url.setPath(KShell::tildeExpand(name));
-    }
-    else {
-        name = KIO::encodeFileName(name);
-        url = baseUrl;
-        url.addPath(name);
+    if (!newWindowUrl.isEmpty()) {
+        Dolphin::openNewWindow({newWindowUrl}, this);
     }
-    ok = KIO::NetAccess::mkdir(url, this);
-
-    // TODO: provide message type hint
-    if (ok) {
-        statusBar->setMessage(i18n("Created folder %1.",url.path()),
-                              DolphinStatusBar::OperationCompleted);
+}
 
-        DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url);
-        UndoManager::instance().addCommand(command);
+void DolphinMainWindow::showTarget()
+{
+    const auto link = m_activeViewContainer->view()->selectedItems().at(0);
+    const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir();
+    auto linkDestination = link.linkDest();
+    if (QFileInfo(linkDestination).isRelative()) {
+        linkDestination = linkLocationDir.filePath(linkDestination);
     }
-    else {
-        // Creating of the folder has been failed. Check whether the creating
-        // has been failed because a folder with the same name exists...
-        if (KIO::NetAccess::exists(url, true, this)) {
-            statusBar->setMessage(i18n("A folder named %1 already exists.",url.path()),
-                                  DolphinStatusBar::Error);
-        }
-        else {
-            statusBar->setMessage(i18n("Creating of folder %1 failed.",url.path()),
-                                  DolphinStatusBar::Error);
-        }
-
+    if (QFileInfo::exists(linkDestination)) {
+        KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)});
+    } else {
+        m_activeViewContainer->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination),
+                                           DolphinViewContainer::Warning);
     }
 }
 
-void DolphinMainWindow::createFile()
+void DolphinMainWindow::showEvent(QShowEvent* event)
 {
-    // Parts of the following code have been taken
-    // from the class KonqPopupMenu located in
-    // libqonq/konq_popupmenu.h of Konqueror.
-    // (Copyright (C) 2000  David Faure <faure@kde.org>,
-    // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
+    KXmlGuiWindow::showEvent(event);
 
-    clearStatusBar();
-
-    // TODO: const Entry& entry = m_createFileTemplates[QString(sender->name())];
-    // should be enough. Anyway: the implemantation of [] does a linear search internally too.
-    KSortableList<CreateFileEntry, QString>::ConstIterator it = m_createFileTemplates.begin();
-    KSortableList<CreateFileEntry, QString>::ConstIterator end = m_createFileTemplates.end();
-
-    const QString senderName(sender()->objectName());
-    bool found = false;
-    CreateFileEntry entry;
-    while (!found && (it != end)) {
-        if ((*it).key() == senderName) {
-            entry = (*it).value();
-            found = true;
-        }
-        else {
-            ++it;
-        }
-    }
-
-    DolphinStatusBar* statusBar = m_activeView->statusBar();
-    if (!found || !QFile::exists(entry.templatePath)) {
-        statusBar->setMessage(i18n("Could not create file."), DolphinStatusBar::Error);
-       return;
+    if (!event->spontaneous()) {
+        m_activeViewContainer->view()->setFocus();
     }
+}
 
-    // Get the source path of the template which should be copied.
-    // The source path is part of the Url entry of the desktop file.
-    const int pos = entry.templatePath.lastIndexOf('/');
-    QString sourcePath(entry.templatePath.left(pos + 1));
-    sourcePath += KDesktopFile(entry.templatePath, true).readPathEntry("Url");
-
-    QString name(i18n(entry.name.toAscii()));
-    // Most entry names end with "..." (e. g. "HTML File..."), which is ok for
-    // menus but no good choice for a new file name -> remove the dots...
-    name.replace("...", QString::null);
-
-    // add the file extension to the name
-    name.append(sourcePath.right(sourcePath.length() - sourcePath.lastIndexOf('.')));
-
-    // Check whether a file with the current name already exists. If yes suggest automatically
-    // a unique file name (e. g. "HTML File" will be replaced by "HTML File_1").
-    const KUrl viewUrl(m_activeView->url());
-    const bool fileExists = viewUrl.isLocalFile() &&
-                            QFileInfo(viewUrl.path(KUrl::AddTrailingSlash) + KIO::encodeFileName(name)).exists();
-    if (fileExists) {
-        name = KIO::RenameDlg::suggestName(viewUrl, name);
+void DolphinMainWindow::closeEvent(QCloseEvent* event)
+{
+    // Find out if Dolphin is closed directly by the user or
+    // by the session manager because the session is closed
+    bool closedByUser = true;
+    if (qApp->isSavingSession()) {
+        closedByUser = false;
     }
 
-    // let the user change the suggested file name
-    bool ok = false;
-    name = KInputDialog::getText(entry.name,
-                                 entry.comment,
-                                 name,
-                                 &ok,
-                                 this);
-    if (!ok) {
-        // the user has pressed 'Cancel'
-        return;
-    }
+    if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
+        // Ask the user if he really wants to quit and close all tabs.
+        // Open a confirmation dialog with 3 buttons:
+        // QDialogButtonBox::Yes    -> Quit
+        // QDialogButtonBox::No     -> Close only the current tab
+        // QDialogButtonBox::Cancel -> do nothing
+        QDialog *dialog = new QDialog(this, Qt::Dialog);
+        dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
+        dialog->setModal(true);
+        QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel);
+        KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", QGuiApplication::applicationDisplayName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
+        KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
+        KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
+        buttons->button(QDialogButtonBox::Yes)->setDefault(true);
+
+        bool doNotAskAgainCheckboxResult = false;
+
+        const int result = KMessageBox::createKMessageBox(dialog,
+            buttons,
+            QMessageBox::Warning,
+            i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
+            QStringList(),
+            i18n("Do not ask again"),
+            &doNotAskAgainCheckboxResult,
+            KMessageBox::Notify);
+
+        if (doNotAskAgainCheckboxResult) {
+            GeneralSettings::setConfirmClosingMultipleTabs(false);
+        }
 
-    // before copying the template to the destination path check whether a file
-    // with the given name already exists
-    const QString destPath(viewUrl.pathOrUrl() + "/" + KIO::encodeFileName(name));
-    const KUrl destUrl(destPath);
-    if (KIO::NetAccess::exists(destUrl, false, this)) {
-        statusBar->setMessage(i18n("A file named %1 already exists.",name),
-                              DolphinStatusBar::Error);
-        return;
+        switch (result) {
+            case QDialogButtonBox::Yes:
+                // Quit
+                break;
+            case QDialogButtonBox::No:
+                // Close only the current tab
+                m_tabWidget->closeTab();
+                Q_FALLTHROUGH();
+            default:
+                event->ignore();
+                return;
+        }
     }
 
-    // copy the template to the destination path
-    const KUrl sourceUrl(sourcePath);
-    KIO::CopyJob* job = KIO::copyAs(sourceUrl, destUrl);
-    job->setDefaultPermissions(true);
-    if (KIO::NetAccess::synchronousRun(job, this)) {
-        statusBar->setMessage(i18n("Created file %1.",name),
-                              DolphinStatusBar::OperationCompleted);
-
-        KUrl::List list;
-        list.append(sourceUrl);
-        DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
-        UndoManager::instance().addCommand(command);
+    GeneralSettings::setVersion(CurrentDolphinVersion);
+    GeneralSettings::self()->save();
 
-    }
-    else {
-        statusBar->setMessage(i18n("Creating of file %1 failed.",name),
-                              DolphinStatusBar::Error);
-    }
+    KXmlGuiWindow::closeEvent(event);
 }
 
-void DolphinMainWindow::rename()
+void DolphinMainWindow::saveProperties(KConfigGroup& group)
 {
-    clearStatusBar();
-    m_activeView->renameSelectedItems();
+    m_tabWidget->saveProperties(group);
 }
 
-void DolphinMainWindow::moveToTrash()
+void DolphinMainWindow::readProperties(const KConfigGroup& group)
 {
-    clearStatusBar();
-    KUrl::List selectedUrls = m_activeView->selectedUrls();
-    KIO::Job* job = KIO::trash(selectedUrls);
-    addPendingUndoJob(job, DolphinCommand::Trash, selectedUrls, m_activeView->url());
+    m_tabWidget->readProperties(group);
 }
 
-void DolphinMainWindow::deleteItems()
+void DolphinMainWindow::updateNewMenu()
 {
-    clearStatusBar();
-
-    KUrl::List list = m_activeView->selectedUrls();
-    const uint itemCount = list.count();
-    assert(itemCount >= 1);
-
-    QString text;
-    if (itemCount > 1) {
-        text = i18n("Do you really want to delete the %1 selected items?",itemCount);
-    }
-    else {
-        const KUrl& url = list.first();
-        text = i18n("Do you really want to delete '%1'?",url.fileName());
-    }
-
-    const bool del = KMessageBox::warningContinueCancel(this,
-                                                        text,
-                                                        QString::null,
-                                                        KGuiItem(i18n("Delete"), SmallIcon("editdelete"))
-                                                       ) == KMessageBox::Continue;
-    if (del) {
-        KIO::Job* job = KIO::del(list);
-        connect(job, SIGNAL(result(KJob*)),
-                this, SLOT(slotHandleJobError(KJob*)));
-        connect(job, SIGNAL(result(KJob*)),
-                this, SLOT(slotDeleteFileFinished(KJob*)));
-    }
+    m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
+    m_newFileMenu->checkUpToDate();
+    m_newFileMenu->setPopupFiles(activeViewContainer()->url());
 }
 
-void DolphinMainWindow::properties()
+void DolphinMainWindow::createDirectory()
 {
-    const KFileItemList list = m_activeView->selectedItems();
-    new KPropertiesDialog(list, this);
+    m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
+    m_newFileMenu->setPopupFiles(activeViewContainer()->url());
+    m_newFileMenu->createDirectory();
 }
 
 void DolphinMainWindow::quit()
@@ -597,1049 +469,1124 @@ void DolphinMainWindow::quit()
     close();
 }
 
-void DolphinMainWindow::slotHandleJobError(KJob* job)
+void DolphinMainWindow::showErrorMessage(const QString& message)
 {
-    if (job->error() != 0) {
-        m_activeView->statusBar()->setMessage(job->errorString(),
-                                              DolphinStatusBar::Error);
-    }
-}
-
-void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
-{
-    if (job->error() == 0) {
-        m_activeView->statusBar()->setMessage(i18n("Delete operation completed."),
-                                               DolphinStatusBar::OperationCompleted);
-
-        // TODO: In opposite to the 'Move to Trash' operation in the class KFileIconView
-        // no rearranging of the item position is done when a file has been deleted.
-        // This is bypassed by reloading the view, but it might be worth to investigate
-        // deeper for the root of this issue.
-        m_activeView->reload();
-    }
+    m_activeViewContainer->showMessage(message, DolphinViewContainer::Error);
 }
 
 void DolphinMainWindow::slotUndoAvailable(bool available)
 {
-    QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
-    if (undoAction != 0) {
+    QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+    if (undoAction) {
         undoAction->setEnabled(available);
     }
 }
 
 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
 {
-    QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
-    if (undoAction != 0) {
+    QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+    if (undoAction) {
         undoAction->setText(text);
     }
 }
 
-void DolphinMainWindow::slotRedoAvailable(bool available)
-{
-    QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
-    if (redoAction != 0) {
-        redoAction->setEnabled(available);
-    }
-}
-
-void DolphinMainWindow::slotRedoTextChanged(const QString& text)
+void DolphinMainWindow::undo()
 {
-    QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
-    if (redoAction != 0) {
-        redoAction->setText(text);
-    }
+    clearStatusBar();
+    KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
+    KIO::FileUndoManager::self()->undo();
 }
 
 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
-    // in libkonq
-    m_clipboardContainsCutData = true;
-
-    QMimeData* mimeData = new QMimeData();
-    const KUrl::List selectedUrls = m_activeView->selectedUrls();
-    selectedUrls.populateMimeData(mimeData);
-
-    QApplication::clipboard()->setMimeData(mimeData);
+    m_activeViewContainer->view()->cutSelectedItems();
 }
 
 void DolphinMainWindow::copy()
 {
-    m_clipboardContainsCutData = false;
-
-    QMimeData* mimeData = new QMimeData();
-    const KUrl::List selectedUrls = m_activeView->selectedUrls();
-    selectedUrls.populateMimeData(mimeData);
-
-    QApplication::clipboard()->setMimeData(mimeData);
+    m_activeViewContainer->view()->copySelectedItems();
 }
 
 void DolphinMainWindow::paste()
 {
-    QClipboard* clipboard = QApplication::clipboard();
-    const QMimeData* mimeData = clipboard->mimeData();
-
-    clearStatusBar();
-
-    const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
-
-    // per default the pasting is done into the current Url of the view
-    KUrl destUrl(m_activeView->url());
-
-    // check whether the pasting should be done into a selected directory
-    KUrl::List selectedUrls = m_activeView->selectedUrls();
-    if (selectedUrls.count() == 1) {
-        const KFileItem fileItem(S_IFDIR,
-                                 KFileItem::Unknown,
-                                 selectedUrls.first(),
-                                 true);
-        if (fileItem.isDir()) {
-            // only one item is selected which is a directory, hence paste
-            // into this directory
-            destUrl = selectedUrls.first();
-        }
-    }
+    m_activeViewContainer->view()->paste();
+}
 
-    // TODO #1: use libkonq commands (see doPaste() implementation
-    // KIO::Job* job = KIO::pasteClipboard(destUrl, this, false);
-    // ...
-    // TODO #2: 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
-    // in libkonq
-    if (m_clipboardContainsCutData) {
-        moveUrls(sourceUrls, destUrl);
-        m_clipboardContainsCutData = false;
-        clipboard->clear();
-    }
-    else {
-        copyUrls(sourceUrls, destUrl);
-    }
+void DolphinMainWindow::find()
+{
+    m_activeViewContainer->setSearchModeEnabled(true);
 }
 
 void DolphinMainWindow::updatePasteAction()
 {
-    QAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
-    if (pasteAction == 0) {
-        return;
-    }
-
-    QString text(i18n("Paste"));
-    QClipboard* clipboard = QApplication::clipboard();
-    const QMimeData* mimeData = clipboard->mimeData();
-
-    KUrl::List urls = KUrl::List::fromMimeData(mimeData);
-    if (!urls.isEmpty()) {
-        pasteAction->setEnabled(true);
+    QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
+    QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
+    pasteAction->setEnabled(pasteInfo.first);
+    pasteAction->setText(pasteInfo.second);
+}
 
-        const int count = urls.count();
-        if (count == 1) {
-            pasteAction->setText(i18n("Paste 1 File"));
-        }
-        else {
-            pasteAction->setText(i18n("Paste %1 Files").arg(count));
-        }
-    }
-    else {
-        pasteAction->setEnabled(false);
-        pasteAction->setText(i18n("Paste"));
-    }
+void DolphinMainWindow::slotDirectoryLoadingCompleted()
+{
+    updatePasteAction();
+}
 
-    if (pasteAction->isEnabled()) {
-        KUrl::List urls = m_activeView->selectedUrls();
-        const uint count = urls.count();
-        if (count > 1) {
-            // pasting should not be allowed when more than one file
-            // is selected
-            pasteAction->setEnabled(false);
-        }
-        else if (count == 1) {
-            // Only one file is selected. Pasting is only allowed if this
-            // file is a directory.
-            // TODO: this doesn't work with remote protocols; instead we need a
-            // m_activeView->selectedFileItems() to get the real KFileItems
-            const KFileItem fileItem(S_IFDIR,
-                                     KFileItem::Unknown,
-                                     urls.first(),
-                                     true);
-            pasteAction->setEnabled(fileItem.isDir());
-        }
+void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
+{
+    if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Back))) {
+        goBackInNewTab();
+    } else if (action == actionCollection()->action(KStandardAction::name(KStandardAction::Forward))) {
+        goForwardInNewTab();
+    } else if (action == actionCollection()->action(QStringLiteral("go_up"))) {
+        goUpInNewTab();
+    } else if (action == actionCollection()->action(QStringLiteral("go_home"))) {
+        goHomeInNewTab();
     }
 }
 
 void DolphinMainWindow::selectAll()
 {
     clearStatusBar();
-    m_activeView->selectAll();
+
+    // if the URL navigator is editable and focused, select the whole
+    // URL instead of all items of the view
+
+    KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses
+    const bool selectUrl = urlNavigator->isUrlEditable() &&
+                           lineEdit->hasFocus();
+    if (selectUrl) {
+        lineEdit->selectAll();
+    } else {
+        m_activeViewContainer->view()->selectAll();
+    }
 }
 
 void DolphinMainWindow::invertSelection()
 {
     clearStatusBar();
-    m_activeView->invertSelection();
+    m_activeViewContainer->view()->invertSelection();
 }
-void DolphinMainWindow::setIconsView()
+
+void DolphinMainWindow::toggleSplitView()
 {
-    m_activeView->setMode(DolphinView::IconsView);
+    DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
+    tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled());
+
+    updateViewActions();
 }
 
-void DolphinMainWindow::setDetailsView()
+void DolphinMainWindow::toggleSplitStash()
 {
-    m_activeView->setMode(DolphinView::DetailsView);
+    DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
+    tabPage->setSplitViewEnabled(false);
+    tabPage->setSplitViewEnabled(true, QUrl("stash:/"));
 }
 
-void DolphinMainWindow::sortByName()
+void DolphinMainWindow::reloadView()
 {
-    m_activeView->setSorting(DolphinView::SortByName);
+    clearStatusBar();
+    m_activeViewContainer->reload();
+    m_activeViewContainer->statusBar()->updateSpaceInfo();
 }
 
-void DolphinMainWindow::sortBySize()
+void DolphinMainWindow::stopLoading()
 {
-    m_activeView->setSorting(DolphinView::SortBySize);
+    m_activeViewContainer->view()->stopLoading();
 }
 
-void DolphinMainWindow::sortByDate()
+void DolphinMainWindow::enableStopAction()
 {
-    m_activeView->setSorting(DolphinView::SortByDate);
+    actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
 }
 
-void DolphinMainWindow::toggleSortOrder()
+void DolphinMainWindow::disableStopAction()
 {
-    const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ?
-                                Qt::Descending :
-                                Qt::Ascending;
-    m_activeView->setSortOrder(order);
+    actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
 }
 
-void DolphinMainWindow::toggleSplitView()
+void DolphinMainWindow::showFilterBar()
 {
-    if (m_view[SecondaryIdx] == 0) {
-        const int newWidth = (m_view[PrimaryIdx]->width() - m_splitter->handleWidth()) / 2;
-        // create a secondary view
-        m_view[SecondaryIdx] = new DolphinView(this,
-                                               0,
-                                               m_view[PrimaryIdx]->url(),
-                                               m_view[PrimaryIdx]->mode(),
-                                               m_view[PrimaryIdx]->showHiddenFiles());
-        connectViewSignals(SecondaryIdx);
-        m_splitter->addWidget(m_view[SecondaryIdx]);
-        m_splitter->setSizes(QList<int>() << newWidth << newWidth);
-        m_view[SecondaryIdx]->show();
-    }
-    else {
-        // remove secondary view
-        if (m_activeView == m_view[PrimaryIdx]) {
-            m_view[SecondaryIdx]->close();
-            m_view[SecondaryIdx]->deleteLater();
-            m_view[SecondaryIdx] = 0;
-            setActiveView(m_view[PrimaryIdx]);
-        }
-        else {
-            // The secondary view is active, hence from the users point of view
-            // the content of the secondary view should be moved to the primary view.
-            // From an implementation point of view it is more efficient to close
-            // the primary view and exchange the internal pointers afterwards.
-            m_view[PrimaryIdx]->close();
-            delete m_view[PrimaryIdx];
-            m_view[PrimaryIdx] = m_view[SecondaryIdx];
-            m_view[SecondaryIdx] = 0;
-            setActiveView(m_view[PrimaryIdx]);
-        }
-    }
+    m_activeViewContainer->setFilterBarVisible(true);
 }
 
-void DolphinMainWindow::reloadView()
+void DolphinMainWindow::toggleEditLocation()
 {
     clearStatusBar();
-    m_activeView->reload();
-}
 
-void DolphinMainWindow::stopLoading()
-{
+    QAction* action = actionCollection()->action(QStringLiteral("editable_location"));
+    KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    urlNavigator->setUrlEditable(action->isChecked());
 }
 
-void DolphinMainWindow::togglePreview()
+void DolphinMainWindow::replaceLocation()
 {
+    KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
+    navigator->setUrlEditable(true);
+    navigator->setFocus();
+
+    // select the whole text of the combo box editor
+    QLineEdit* lineEdit = navigator->editor()->lineEdit();  // krazy:exclude=qclasses
+    lineEdit->selectAll();
 }
 
-void DolphinMainWindow::toggleShowHiddenFiles()
+void DolphinMainWindow::togglePanelLockState()
 {
-    clearStatusBar();
+    const bool newLockState = !GeneralSettings::lockPanels();
+    foreach (QObject* child, children()) {
+        DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
+        if (dock) {
+            dock->setLocked(newLockState);
+        }
+    }
 
-    const KToggleAction* showHiddenFilesAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
-    const bool show = showHiddenFilesAction->isChecked();
-    m_activeView->setShowHiddenFiles(show);
+    GeneralSettings::setLockPanels(newLockState);
 }
 
-void DolphinMainWindow::showFilterBar()
+void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
 {
-    const KToggleAction* showFilterBarAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
-    const bool show = showFilterBarAction->isChecked();
-    m_activeView->slotShowFilterBar(show);
+    if (m_terminalPanel->isHiddenInVisibleWindow()) {
+        m_activeViewContainer->view()->setFocus();
+    }
 }
 
-void DolphinMainWindow::zoomIn()
+void DolphinMainWindow::goBack()
 {
-    m_activeView->zoomIn();
-    updateViewActions();
+    KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    urlNavigator->goBack();
+
+    if (urlNavigator->locationState().isEmpty()) {
+        // An empty location state indicates a redirection URL,
+        // which must be skipped too
+        urlNavigator->goBack();
+    }
 }
 
-void DolphinMainWindow::zoomOut()
+void DolphinMainWindow::goForward()
 {
-    m_activeView->zoomOut();
-    updateViewActions();
+    m_activeViewContainer->urlNavigator()->goForward();
 }
 
-void DolphinMainWindow::toggleEditLocation()
+void DolphinMainWindow::goUp()
 {
-    clearStatusBar();
-
-    KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
+    m_activeViewContainer->urlNavigator()->goUp();
+}
 
-    bool editOrBrowse = action->isChecked();
-//    action->setChecked(action->setChecked);
-    m_activeView->setUrlEditable(editOrBrowse);
+void DolphinMainWindow::goHome()
+{
+    m_activeViewContainer->urlNavigator()->goHome();
 }
 
-void DolphinMainWindow::editLocation()
+void DolphinMainWindow::goBackInNewTab()
 {
-    KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
-    action->setChecked(true);
-    m_activeView->setUrlEditable(true);
+    KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+    const int index = urlNavigator->historyIndex() + 1;
+    openNewTab(urlNavigator->locationUrl(index));
 }
 
-void DolphinMainWindow::adjustViewProperties()
+void DolphinMainWindow::goForwardInNewTab()
 {
-    clearStatusBar();
-    ViewPropertiesDialog dlg(m_activeView);
-    dlg.exec();
+    KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+    const int index = urlNavigator->historyIndex() - 1;
+    openNewTab(urlNavigator->locationUrl(index));
 }
 
-void DolphinMainWindow::goBack()
+void DolphinMainWindow::goUpInNewTab()
 {
-    clearStatusBar();
-    m_activeView->goBack();
+    const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl();
+    openNewTab(KIO::upUrl(currentUrl));
 }
 
-void DolphinMainWindow::goForward()
+void DolphinMainWindow::goHomeInNewTab()
 {
-    clearStatusBar();
-    m_activeView->goForward();
+    openNewTab(Dolphin::homeUrl());
 }
 
-void DolphinMainWindow::goUp()
+void DolphinMainWindow::compareFiles()
 {
-    clearStatusBar();
-    m_activeView->goUp();
+    const KFileItemList items = m_tabWidget->currentTabPage()->selectedItems();
+    if (items.count() != 2) {
+        // The action is disabled in this case, but it could have been triggered
+        // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
+        return;
+    }
+
+    QUrl urlA = items.at(0).url();
+    QUrl urlB = items.at(1).url();
+
+    QString command(QStringLiteral("kompare -c \""));
+    command.append(urlA.toDisplayString(QUrl::PreferLocalFile));
+    command.append("\" \"");
+    command.append(urlB.toDisplayString(QUrl::PreferLocalFile));
+    command.append('\"');
+    KRun::runCommand(command, QStringLiteral("Kompare"), QStringLiteral("kompare"), this);
 }
 
-void DolphinMainWindow::goHome()
+void DolphinMainWindow::toggleShowMenuBar()
 {
-    clearStatusBar();
-    m_activeView->goHome();
+    const bool visible = menuBar()->isVisible();
+    menuBar()->setVisible(!visible);
+    if (visible) {
+        createControlButton();
+    } else {
+        deleteControlButton();
+    }
 }
 
 void DolphinMainWindow::openTerminal()
 {
-    QString command("konsole --workdir \"");
-    command.append(m_activeView->url().path());
-    command.append('\"');
+    QString dir(QDir::homePath());
+
+    // If the given directory is not local, it can still be the URL of an
+    // ioslave using UDS_LOCAL_PATH which to be converted first.
+    KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
+    KJobWidgets::setWindow(statJob, this);
+    statJob->exec();
+    QUrl url = statJob->mostLocalUrl();
 
-    KRun::runCommand(command, "Konsole", "konsole");
+    //If the URL is local after the above conversion, set the directory.
+    if (url.isLocalFile()) {
+        dir = url.toLocalFile();
+    }
+
+    KToolInvocation::invokeTerminal(QString(), dir);
 }
 
-void DolphinMainWindow::findFile()
+void DolphinMainWindow::editSettings()
 {
-    KRun::run("kfind", m_activeView->url());
+    if (!m_settingsDialog) {
+        DolphinViewContainer* container = activeViewContainer();
+        container->view()->writeSettings();
+
+        const QUrl url = container->url();
+        DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
+        connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
+        settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
+        settingsDialog->show();
+        m_settingsDialog = settingsDialog;
+    } else {
+        m_settingsDialog.data()->raise();
+    }
 }
 
-void DolphinMainWindow::compareFiles()
+void DolphinMainWindow::handleUrl(const QUrl& url)
 {
-    // The method is only invoked if exactly 2 files have
-    // been selected. The selected files may be:
-    // - both in the primary view
-    // - both in the secondary view
-    // - one in the primary view and the other in the secondary
-    //   view
-    assert(m_view[PrimaryIdx] != 0);
-
-    KUrl urlA;
-    KUrl urlB;
-    KUrl::List urls = m_view[PrimaryIdx]->selectedUrls();
-
-    switch (urls.count()) {
-        case 0: {
-            assert(m_view[SecondaryIdx] != 0);
-            urls = m_view[SecondaryIdx]->selectedUrls();
-            assert(urls.count() == 2);
-            urlA = urls[0];
-            urlB = urls[1];
-            break;
-        }
+    delete m_lastHandleUrlStatJob;
+    m_lastHandleUrlStatJob = nullptr;
 
-        case 1: {
-            urlA = urls[0];
-            assert(m_view[SecondaryIdx] != 0);
-            urls = m_view[SecondaryIdx]->selectedUrls();
-            assert(urls.count() == 1);
-            urlB = urls[0];
-            break;
+    if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
+        activeViewContainer()->setUrl(url);
+    } else if (KProtocolManager::supportsListing(url)) {
+        // stat the URL to see if it is a dir or not
+        m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
+        if (m_lastHandleUrlStatJob->uiDelegate()) {
+            KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
         }
+        connect(m_lastHandleUrlStatJob, &KIO::Job::result,
+                this, &DolphinMainWindow::slotHandleUrlStatFinished);
 
-        case 2: {
-            urlA = urls[0];
-            urlB = urls[1];
-            break;
-        }
-
-        default: {
-            // may not happen: compareFiles may only get invoked if 2
-            // files are selected
-            assert(false);
-        }
+    } else {
+        new KRun(url, this); // Automatically deletes itself after being finished
     }
+}
 
-    QString command("kompare -c \"");
-    command.append(urlA.pathOrUrl());
-    command.append("\" \"");
-    command.append(urlB.pathOrUrl());
-    command.append('\"');
-    KRun::runCommand(command, "Kompare", "kompare");
-
+void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
+{
+    m_lastHandleUrlStatJob = nullptr;
+    const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
+    const QUrl url = static_cast<KIO::StatJob*>(job)->url();
+    if (entry.isDir()) {
+        activeViewContainer()->setUrl(url);
+    } else {
+        new KRun(url, this);  // Automatically deletes itself after being finished
+    }
 }
 
-void DolphinMainWindow::editSettings()
+void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
 {
-    // TODO: make a static method for opening the settings dialog
-    DolphinSettingsDialog dlg(this);
-    dlg.exec();
+    // trash:/ is writable but we don't want to create new items in it.
+    // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
+    newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash"));
 }
 
-void DolphinMainWindow::addUndoOperation(KJob* job)
+void DolphinMainWindow::openContextMenu(const QPoint& pos,
+                                        const KFileItem& item,
+                                        const QUrl& url,
+                                        const QList<QAction*>& customActions)
 {
-    if (job->error() != 0) {
-        slotHandleJobError(job);
+    QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
+    contextMenu.data()->setCustomActions(customActions);
+    const DolphinContextMenu::Command command = contextMenu.data()->open();
+
+    switch (command) {
+    case DolphinContextMenu::OpenParentFolder:
+        changeUrl(KIO::upUrl(item.url()));
+        m_activeViewContainer->view()->markUrlsAsSelected({item.url()});
+        m_activeViewContainer->view()->markUrlAsCurrent(item.url());
+        break;
+
+    case DolphinContextMenu::OpenParentFolderInNewWindow:
+        Dolphin::openNewWindow({item.url()}, this, Dolphin::OpenNewWindowFlag::Select);
+        break;
+
+    case DolphinContextMenu::OpenParentFolderInNewTab:
+        openNewTab(KIO::upUrl(item.url()));
+        break;
+
+    case DolphinContextMenu::None:
+    default:
+        break;
     }
-    else {
-        const int id = job->progressId();
-
-        // set iterator to the executed command with the current id...
-        Q3ValueList<UndoInfo>::Iterator it = m_pendingUndoJobs.begin();
-        const Q3ValueList<UndoInfo>::Iterator end = m_pendingUndoJobs.end();
-        bool found = false;
-        while (!found && (it != end)) {
-            if ((*it).id == id) {
-                found = true;
-            }
-            else {
-                ++it;
-            }
-        }
 
-        if (found) {
-            DolphinCommand command = (*it).command;
-            if (command.type() == DolphinCommand::Trash) {
-                // To be able to perform an undo for the 'Move to Trash' operation
-                // all source Urls must be updated with the trash Url. E. g. when moving
-                // a file "test.txt" and a second file "test.txt" to the trash,
-                // then the filenames in the trash are "0-test.txt" and "1-test.txt".
-                QMap<QString, QString> metaData;
-                KIO::Job *kiojob = qobject_cast<KIO::Job*>( job );
-                if ( kiojob )
-                {
-                    metaData = kiojob->metaData();
-                }
-                KUrl::List newSourceUrls;
-
-                KUrl::List sourceUrls = command.source();
-                KUrl::List::Iterator sourceIt = sourceUrls.begin();
-                const KUrl::List::Iterator sourceEnd = sourceUrls.end();
-
-                while (sourceIt != sourceEnd) {
-                    QMap<QString, QString>::ConstIterator metaIt = metaData.find("trashUrl-" + (*sourceIt).path());
-                    if (metaIt != metaData.end()) {
-                        newSourceUrls.append(KUrl(metaIt.value()));
-                    }
-                    ++sourceIt;
-                }
-                command.setSource(newSourceUrls);
-            }
-
-            UndoManager::instance().addCommand(command);
-            m_pendingUndoJobs.erase(it);
-
-            DolphinStatusBar* statusBar = m_activeView->statusBar();
-            switch (command.type()) {
-                case DolphinCommand::Copy:
-                    statusBar->setMessage(i18n("Copy operation completed."),
-                                          DolphinStatusBar::OperationCompleted);
-                    break;
-                case DolphinCommand::Move:
-                    statusBar->setMessage(i18n("Move operation completed."),
-                                          DolphinStatusBar::OperationCompleted);
-                    break;
-                case DolphinCommand::Trash:
-                    statusBar->setMessage(i18n("Move to trash operation completed."),
-                                          DolphinStatusBar::OperationCompleted);
-                    break;
-                default:
-                    break;
-            }
-        }
+    // Delete the menu, unless it has been deleted in its own nested event loop already.
+    if (contextMenu) {
+        contextMenu->deleteLater();
     }
 }
 
-void DolphinMainWindow::init()
+void DolphinMainWindow::updateControlMenu()
 {
-    // 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 = DolphinSettings::instance().generalSettings();
-    const bool firstRun = generalSettings->firstRun();
+    QMenu* menu = qobject_cast<QMenu*>(sender());
+    Q_ASSERT(menu);
 
-    setAcceptDrops(true);
+    // All actions get cleared by QMenu::clear(). This includes the sub-menus
+    // because 'menu' is their parent.
+    menu->clear();
 
-    m_splitter = new QSplitter(this);
+    KActionCollection* ac = actionCollection();
 
-    DolphinSettings& settings = DolphinSettings::instance();
+    // Add "Create New" menu
+    menu->addMenu(m_newFileMenu->menu());
 
-    KBookmarkManager* manager = settings.bookmarkManager();
-    assert(manager != 0);
-    KBookmarkGroup root = manager->root();
-    if (root.first().isNull()) {
-        root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder_home");
-        root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
-        root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network_local");
-        root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder_red");
-        root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
+    menu->addSeparator();
+
+    // Add "Edit" actions
+    bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
+                 addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) |
+                 addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
+                 addActionToMenu(ac->action(QStringLiteral("invert_selection")), menu);
+
+    if (added) {
+        menu->addSeparator();
     }
 
-    setupActions();
+    // Add "View" actions
+    if (!GeneralSettings::showZoomSlider()) {
+        addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
+        addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
+        menu->addSeparator();
+    }
 
-    const KUrl& homeUrl = root.first().url();
-    setCaption(homeUrl.fileName());
-    ViewProperties props(homeUrl);
-    m_view[PrimaryIdx] = new DolphinView(this,
-                                         m_splitter,
-                                         homeUrl,
-                                         props.viewMode(),
-                                         props.showHiddenFiles());
-    connectViewSignals(PrimaryIdx);
-    m_view[PrimaryIdx]->show();
+    added = addActionToMenu(ac->action(QStringLiteral("sort")), menu) |
+            addActionToMenu(ac->action(QStringLiteral("view_mode")), menu) |
+            addActionToMenu(ac->action(QStringLiteral("additional_info")), menu) |
+            addActionToMenu(ac->action(QStringLiteral("show_preview")), menu) |
+            addActionToMenu(ac->action(QStringLiteral("show_in_groups")), menu) |
+            addActionToMenu(ac->action(QStringLiteral("show_hidden_files")), menu);
 
-    m_activeView = m_view[PrimaryIdx];
+    if (added) {
+        menu->addSeparator();
+    }
 
-    setCentralWidget(m_splitter);
-    setupDockWidgets();
+    added = addActionToMenu(ac->action(QStringLiteral("split_view")), menu) |
+            addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Redisplay)), menu) |
+            addActionToMenu(ac->action(QStringLiteral("view_properties")), menu);
+    if (added) {
+        menu->addSeparator();
+    }
 
-    setupGUI(Keys|Save|Create|ToolBar);
-    createGUI();
+    addActionToMenu(ac->action(QStringLiteral("panels")), menu);
+    QMenu* locationBarMenu = new QMenu(i18nc("@action:inmenu", "Location Bar"), menu);
+    locationBarMenu->addAction(ac->action(QStringLiteral("editable_location")));
+    locationBarMenu->addAction(ac->action(QStringLiteral("replace_location")));
+    menu->addMenu(locationBarMenu);
 
-    stateChanged("new_file");
-    setAutoSaveSettings();
+    menu->addSeparator();
 
-    QClipboard* clipboard = QApplication::clipboard();
-    connect(clipboard, SIGNAL(dataChanged()),
-            this, SLOT(updatePasteAction()));
-    updatePasteAction();
-    updateGoActions();
+    // Add "Go" menu
+    QMenu* goMenu = new QMenu(i18nc("@action:inmenu", "Go"), menu);
+    goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Back)));
+    goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Forward)));
+    goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Up)));
+    goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Home)));
+    goMenu->addAction(ac->action(QStringLiteral("closed_tabs")));
+    menu->addMenu(goMenu);
 
-    setupCreateNewMenuActions();
+    // Add "Tool" menu
+    QMenu* toolsMenu = new QMenu(i18nc("@action:inmenu", "Tools"), menu);
+    toolsMenu->addAction(ac->action(QStringLiteral("show_filter_bar")));
+    toolsMenu->addAction(ac->action(QStringLiteral("compare_files")));
+    toolsMenu->addAction(ac->action(QStringLiteral("open_terminal")));
+    toolsMenu->addAction(ac->action(QStringLiteral("change_remote_encoding")));
+    menu->addMenu(toolsMenu);
 
-    loadSettings();
+    // Add "Settings" menu entries
+    addActionToMenu(ac->action(KStandardAction::name(KStandardAction::KeyBindings)), menu);
+    addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ConfigureToolbars)), menu);
+    addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Preferences)), menu);
 
-    if (firstRun) {
-        // assure a proper default size if Dolphin runs the first time
-        resize(640, 480);
-    }
+    // Add "Help" menu
+    auto helpMenu = new KHelpMenu(menu);
+    menu->addMenu(helpMenu->menu());
+
+    menu->addSeparator();
+    addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ShowMenubar)), menu);
 }
 
-void DolphinMainWindow::loadSettings()
+void DolphinMainWindow::updateToolBar()
 {
-    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
-
-    KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
-    if (settings->splitView()) {
-        splitAction->setChecked(true);
-        toggleSplitView();
+    if (!menuBar()->isVisible()) {
+        createControlButton();
     }
-
-    updateViewActions();
 }
 
-void DolphinMainWindow::setupActions()
+void DolphinMainWindow::slotControlButtonDeleted()
 {
-    // setup 'File' menu
-    KAction *action = new KAction(KIcon("window_new"),  i18n( "New &Window" ), actionCollection(), "new_window" );
-    connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
-
-    KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
-    createFolder->setIcon(KIcon("folder"));
-    createFolder->setShortcut(Qt::Key_N);
-    connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder()));
-
-    KAction* rename = new KAction(i18n("Rename"), actionCollection(), "rename");
-    rename->setShortcut(Qt::Key_F2);
-    connect(rename, SIGNAL(triggered()), this, SLOT(rename()));
-
-    KAction* moveToTrash = new KAction(i18n("Move to Trash"), actionCollection(), "move_to_trash");
-    moveToTrash->setIcon(KIcon("edittrash"));
-    moveToTrash->setShortcut(QKeySequence::Delete);
-    connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash()));
+    m_controlButton = nullptr;
+    m_updateToolBarTimer->start();
+}
 
-    KAction* deleteAction = new KAction(i18n("Delete"), actionCollection(), "delete");
-    deleteAction->setShortcut(Qt::ALT | Qt::Key_Delete);
-    deleteAction->setIcon(KIcon("editdelete"));
-    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));
+void DolphinMainWindow::slotPlaceActivated(const QUrl& url)
+{
+    DolphinViewContainer* view = activeViewContainer();
 
-    KAction* properties = new KAction(i18n("Propert&ies"), actionCollection(), "properties");
-    properties->setShortcut(Qt::Key_Alt | Qt::Key_Return);
-    connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
+    if (view->url() == url) {
+        // We can end up here if the user clicked a device in the Places Panel
+        // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
+        reloadView();
+    } else {
+        changeUrl(url);
+    }
+}
 
-    KStdAction::quit(this, SLOT(quit()), actionCollection());
+void DolphinMainWindow::closedTabsCountChanged(unsigned int count)
+{
+    actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count > 0);
+}
 
-    // setup 'Edit' menu
-    UndoManager& undoManager = UndoManager::instance();
-    KStdAction::undo(this,
-                     SLOT(undo()),
-                     actionCollection());
-    connect(&undoManager, SIGNAL(undoAvailable(bool)),
-            this, SLOT(slotUndoAvailable(bool)));
-    connect(&undoManager, SIGNAL(undoTextChanged(const QString&)),
-            this, SLOT(slotUndoTextChanged(const QString&)));
-
-    KStdAction::redo(this,
-                     SLOT(redo()),
-                     actionCollection());
-    connect(&undoManager, SIGNAL(redoAvailable(bool)),
-            this, SLOT(slotRedoAvailable(bool)));
-    connect(&undoManager, SIGNAL(redoTextChanged(const QString&)),
-            this, SLOT(slotRedoTextChanged(const QString&)));
-
-    KStdAction::cut(this, SLOT(cut()), actionCollection());
-    KStdAction::copy(this, SLOT(copy()), actionCollection());
-    KStdAction::paste(this, SLOT(paste()), actionCollection());
-
-    KAction* selectAll = new KAction(i18n("Select All"), actionCollection(), "select_all");
-    selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
-    connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
-
-    KAction* invertSelection = new KAction(i18n("Invert Selection"), actionCollection(), "invert_selection");
-    invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
-    connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
+void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
+{
+    DolphinViewContainer* oldViewContainer = m_activeViewContainer;
+    Q_ASSERT(viewContainer);
 
-    // setup 'View' menu
-    KStdAction::zoomIn(this,
-                       SLOT(zoomIn()),
-                       actionCollection());
+    m_activeViewContainer = viewContainer;
 
-    KStdAction::zoomOut(this,
-                        SLOT(zoomOut()),
-                        actionCollection());
+    if (oldViewContainer) {
+        // Disconnect all signals between the old view container (container,
+        // view and url navigator) and main window.
+        oldViewContainer->disconnect(this);
+        oldViewContainer->view()->disconnect(this);
+        oldViewContainer->urlNavigator()->disconnect(this);
+    }
 
-    KToggleAction* iconsView = new KToggleAction(i18n("Icons"), actionCollection(), "icons");
-    iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
-    iconsView->setIcon(KIcon("view_icon"));
-    connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView()));
+    connectViewSignals(viewContainer);
 
-    KToggleAction* detailsView = new KToggleAction(i18n("Details"), actionCollection(), "details");
-    detailsView->setShortcut(Qt::CTRL | Qt::Key_2);
-    detailsView->setIcon(KIcon("view_text"));
-    connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
+    m_actionHandler->setCurrentView(viewContainer->view());
 
-    QActionGroup* viewModeGroup = new QActionGroup(this);
-    viewModeGroup->addAction(iconsView);
-    viewModeGroup->addAction(detailsView);
+    updateHistory();
+    updateEditActions();
+    updatePasteAction();
+    updateViewActions();
+    updateGoActions();
 
-    KToggleAction* sortByName = new KToggleAction(i18n("By Name"), actionCollection(), "by_name");
-    connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
+    const QUrl url = viewContainer->url();
+    emit urlChanged(url);
+}
 
-    KToggleAction* sortBySize = new KToggleAction(i18n("By Size"), actionCollection(), "by_size");
-    connect(sortBySize, SIGNAL(triggered()), this, SLOT(sortBySize()));
+void DolphinMainWindow::tabCountChanged(int count)
+{
+    const bool enableTabActions = (count > 1);
+    actionCollection()->action(KStandardAction::name(KStandardAction::Close))->setEnabled(enableTabActions);
+    actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
+    actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
+}
 
-    KToggleAction* sortByDate = new KToggleAction(i18n("By Date"), actionCollection(), "by_date");
-    connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate()));
+void DolphinMainWindow::updateWindowTitle()
+{
+    setWindowTitle(m_activeViewContainer->caption());
+}
 
-    QActionGroup* sortGroup = new QActionGroup(this);
-    sortGroup->addAction(sortByName);
-    sortGroup->addAction(sortBySize);
-    sortGroup->addAction(sortByDate);
+void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
+{
+    if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+        m_tearDownFromPlacesRequested = true;
+        m_terminalPanel->goHome();
+        // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
+    } else {
+        m_placesPanel->proceedWithTearDown();
+    }
+}
 
-    KToggleAction* sortDescending = new KToggleAction(i18n("Descending"), actionCollection(), "descending");
-    connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
+void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
+{
+    if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+        m_tearDownFromPlacesRequested = false;
+        m_terminalPanel->goHome();
+    }
+}
 
-    KToggleAction* showPreview = new KToggleAction(i18n("Show Preview"), actionCollection(), "show_preview");
-    connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
+void DolphinMainWindow::setupActions()
+{
+    // setup 'File' menu
+    m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
+    m_newFileMenu->setObjectName("newFileMenu");
+    QMenu* menu = m_newFileMenu->menu();
+    menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
+    menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
+    m_newFileMenu->setDelayed(false);
+    connect(menu, &QMenu::aboutToShow,
+            this, &DolphinMainWindow::updateNewMenu);
+
+    QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
+    newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
+
+    QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
+    newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
+    newTab->setText(i18nc("@action:inmenu File", "New Tab"));
+    actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N});
+    connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
+
+    QAction* closeTab = KStandardAction::close(
+            m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab), actionCollection());
+    closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
+    closeTab->setEnabled(false);
+
+    KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
 
-    KToggleAction* showHiddenFiles = new KToggleAction(i18n("Show Hidden Files"), actionCollection(), "show_hidden_files");
-    //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_      KDE4-TODO: what Qt-Key represents '.'?
-    connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
+    // setup 'Edit' menu
+    KStandardAction::undo(this,
+                          &DolphinMainWindow::undo,
+                          actionCollection());
 
-    KToggleAction* split = new KToggleAction(i18n("Split View"), actionCollection(), "split_view");
-    split->setShortcut(Qt::Key_F10);
-    split->setIcon(KIcon("view_left_right"));
-    connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
 
-    KAction* reload = new KAction(i18n("Reload"), "F5", actionCollection(), "reload");
-    reload->setShortcut(Qt::Key_F5);
-    reload->setIcon(KIcon("reload"));
-    connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
+    KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection());
+    KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection());
+    QAction* paste = KStandardAction::paste(this, &DolphinMainWindow::paste, actionCollection());
+    // The text of the paste-action is modified dynamically by Dolphin
+    // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
+    // due to the long text, the text "Paste" is used:
+    paste->setIconText(i18nc("@action:inmenu Edit", "Paste"));
 
-    KAction* stop = new KAction(i18n("Stop"), actionCollection(), "stop");
-    stop->setIcon(KIcon("stop"));
-    connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
+    KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
 
-    KToggleAction* showFullLocation = new KToggleAction(i18n("Show Full Location"), actionCollection(), "editable_location");
-    showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
-    connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
+    KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
 
-    KToggleAction* editLocation = new KToggleAction(i18n("Edit Location"), actionCollection(), "edit_location");
-    editLocation->setShortcut(Qt::Key_F6);
-    connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
+    QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
+    invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
+    invertSelection->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
+    actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL + Qt::SHIFT + Qt::Key_A);
+    connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
 
-    KAction* adjustViewProps = new KAction(i18n("Adjust View Properties..."), actionCollection(), "view_properties");
-    connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
+    // setup 'View' menu
+    // (note that most of it is set up in DolphinViewActionHandler)
+
+    QAction* split = actionCollection()->addAction(QStringLiteral("split_view"));
+    actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
+    connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
+
+    QAction* stashSplit = actionCollection()->addAction(QStringLiteral("split_stash"));
+    actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL + Qt::Key_S);
+    stashSplit->setText(i18nc("@action:intoolbar Stash", "Stash"));
+    stashSplit->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
+    stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
+    stashSplit->setCheckable(false);
+    stashSplit->setVisible(KProtocolInfo::isKnownProtocol("stash"));
+    connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
+
+    KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
+
+    QAction* stop = actionCollection()->addAction(QStringLiteral("stop"));
+    stop->setText(i18nc("@action:inmenu View", "Stop"));
+    stop->setToolTip(i18nc("@info", "Stop loading"));
+    stop->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
+    connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading);
+
+    KToggleAction* editableLocation = actionCollection()->add<KToggleAction>(QStringLiteral("editable_location"));
+    editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
+    actionCollection()->setDefaultShortcut(editableLocation, Qt::Key_F6);
+    connect(editableLocation, &KToggleAction::triggered, this, &DolphinMainWindow::toggleEditLocation);
+
+    QAction* replaceLocation = actionCollection()->addAction(QStringLiteral("replace_location"));
+    replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
+    actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL + Qt::Key_L);
+    connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
 
     // setup 'Go' menu
-    KStdAction::back(this, SLOT(goBack()), actionCollection());
-    KStdAction::forward(this, SLOT(goForward()), actionCollection());
-    KStdAction::up(this, SLOT(goUp()), actionCollection());
-    KStdAction::home(this, SLOT(goHome()), actionCollection());
+    QAction* backAction = KStandardAction::back(this, &DolphinMainWindow::goBack, actionCollection());
+    auto backShortcuts = backAction->shortcuts();
+    backShortcuts.append(QKeySequence(Qt::Key_Backspace));
+    actionCollection()->setDefaultShortcuts(backAction, backShortcuts);
+
+    DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this);
+    actionCollection()->addAction(QStringLiteral("closed_tabs"), recentTabsMenu);
+    connect(m_tabWidget, &DolphinTabWidget::rememberClosedTab,
+            recentTabsMenu, &DolphinRecentTabsMenu::rememberClosedTab);
+    connect(recentTabsMenu, &DolphinRecentTabsMenu::restoreClosedTab,
+            m_tabWidget, &DolphinTabWidget::restoreClosedTab);
+    connect(recentTabsMenu, &DolphinRecentTabsMenu::closedTabsCountChanged,
+            this, &DolphinMainWindow::closedTabsCountChanged);
+
+    QAction* undoCloseTab = actionCollection()->addAction(QStringLiteral("undo_close_tab"));
+    undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
+    actionCollection()->setDefaultShortcut(undoCloseTab, Qt::CTRL + Qt::SHIFT + Qt::Key_T);
+    undoCloseTab->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
+    undoCloseTab->setEnabled(false);
+    connect(undoCloseTab, &QAction::triggered, recentTabsMenu, &DolphinRecentTabsMenu::undoCloseTab);
+
+    auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+    undoAction->setEnabled(false); // undo should be disabled by default
+
+    KStandardAction::forward(this, &DolphinMainWindow::goForward, actionCollection());
+    KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection());
+    KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection());
 
     // setup 'Tools' menu
-    KAction* openTerminal = new KAction(i18n("Open Terminal"), actionCollection(), "open_terminal");
-    openTerminal->setShortcut(Qt::Key_F4);
-    openTerminal->setIcon(KIcon("konsole"));
-    connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
-
-    KAction* findFile = new KAction(i18n("Find File..."), actionCollection(), "find_file");
-    findFile->setShortcut(Qt::Key_F);
-    findFile->setIcon(KIcon("filefind"));
-    connect(findFile, SIGNAL(triggered()), this, SLOT(findFile()));
-
-    KToggleAction* showFilterBar = new KToggleAction(i18n("Show Filter Bar"), actionCollection(), "show_filter_bar");
-    showFilterBar->setShortcut(Qt::Key_Slash);
-    connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
-
-    KAction* compareFiles = new KAction(i18n("Compare Files"), actionCollection(), "compare_files");
-    compareFiles->setIcon(KIcon("kompare"));
+    QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
+    showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
+    showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
+    actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash});
+    connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
+
+    QAction* compareFiles = actionCollection()->addAction(QStringLiteral("compare_files"));
+    compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
+    compareFiles->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
     compareFiles->setEnabled(false);
-    connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
+    connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
+
+#ifndef Q_OS_WIN
+    if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
+        QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
+        openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
+        openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
+        actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
+        connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
+    }
+#endif
 
     // setup 'Settings' menu
-    KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
+    KToggleAction* showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
+    connect(showMenuBar, &KToggleAction::triggered,                   // Fixes #286822
+            this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
+    KStandardAction::preferences(this, &DolphinMainWindow::editSettings, actionCollection());
+
+    // not in menu actions
+    QList<QKeySequence> nextTabKeys = KStandardShortcut::tabNext();
+    nextTabKeys.append(QKeySequence(Qt::CTRL + Qt::Key_Tab));
+
+    QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
+    prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
+
+    QAction* activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab"));
+    activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
+    activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
+    activateNextTab->setEnabled(false);
+    connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab);
+    actionCollection()->setDefaultShortcuts(activateNextTab, nextTabKeys);
+
+    QAction* activatePrevTab = actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
+    activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab"));
+    activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
+    activatePrevTab->setEnabled(false);
+    connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab);
+    actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys);
+
+    // for context menu
+    QAction* showTarget = actionCollection()->addAction(QStringLiteral("show_target"));
+    showTarget->setText(i18nc("@action:inmenu", "Show Target"));
+    showTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
+    showTarget->setEnabled(false);
+    connect(showTarget, &QAction::triggered, this, &DolphinMainWindow::showTarget);
+
+    QAction* openInNewTab = actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
+    openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
+    openInNewTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
+    connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
+
+    QAction* openInNewTabs = actionCollection()->addAction(QStringLiteral("open_in_new_tabs"));
+    openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs"));
+    openInNewTabs->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
+    connect(openInNewTabs, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
+
+    QAction* openInNewWindow = actionCollection()->addAction(QStringLiteral("open_in_new_window"));
+    openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
+    openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
+    connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
 }
 
 void DolphinMainWindow::setupDockWidgets()
 {
-    QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
-
-    shortcutsDock->setObjectName("shortcutsDock");
-    shortcutsDock->setWidget(new BookmarksSidebarPage(this));
+    const bool lock = GeneralSettings::lockPanels();
 
-    shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane");
-    shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel"));
-    actionCollection()->insert(shortcutsDock->toggleViewAction());
+    KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>(QStringLiteral("lock_panels"));
+    lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
+    lockLayoutAction->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
+    lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
+    lockLayoutAction->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
+    lockLayoutAction->setActive(lock);
+    connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState);
 
-    addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
+    // Setup "Information"
+    DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
+    infoDock->setLocked(lock);
+    infoDock->setObjectName(QStringLiteral("infoDock"));
+    infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
 
-    QDockWidget *infoDock = new QDockWidget(i18n("Information"));
+#ifdef HAVE_BALOO
+    InformationPanel* infoPanel = new InformationPanel(infoDock);
+    infoPanel->setCustomContextMenuActions({lockLayoutAction});
+    connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
+    infoDock->setWidget(infoPanel);
 
-    infoDock->setObjectName("infoDock");
-    infoDock->setWidget(new InfoSidebarPage(this));
-
-    infoDock->toggleViewAction()->setObjectName("show_info_pane");
-    infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
-    actionCollection()->insert(infoDock->toggleViewAction());
+    QAction* infoAction = infoDock->toggleViewAction();
+    createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoAction, QStringLiteral("show_information_panel"));
 
     addDockWidget(Qt::RightDockWidgetArea, infoDock);
-}
-
-void DolphinMainWindow::setupCreateNewMenuActions()
-{
-    // Parts of the following code have been taken
-    // from the class KNewMenu located in
-    // libqonq/knewmenu.h of Konqueror.
-    //  Copyright (C) 1998, 1999 David Faure <faure@kde.org>
-    //                2003       Sven Leiber <s.leiber@web.de>
-
-    QStringList files = actionCollection()->instance()->dirs()->findAllResources("templates");
-    for (QStringList::Iterator it = files.begin() ; it != files.end(); ++it) {
-        if ((*it)[0] != '.' ) {
-            KSimpleConfig config(*it, true);
-            config.setDesktopGroup();
-
-            // tricky solution to ensure that TextFile is at the beginning
-            // because this filetype is the most used (according kde-core discussion)
-            const QString name(config.readEntry("Name"));
-            QString key(name);
-
-            const QString path(config.readPathEntry("Url"));
-            if (!path.endsWith("emptydir")) {
-                if (path.endsWith("TextFile.txt")) {
-                    key = "1" + key;
-                }
-                else if (!KDesktopFile::isDesktopFile(path)) {
-                    key = "2" + key;
-                }
-                else if (path.endsWith("Url.desktop")){
-                    key = "3" + key;
-                }
-                else if (path.endsWith("Program.desktop")){
-                    key = "4" + key;
-                }
-                else {
-                    key = "5";
-                }
-
-                const QString icon(config.readEntry("Icon"));
-                const QString comment(config.readEntry("Comment"));
-                const QString type(config.readEntry("Type"));
-
-                const QString filePath(*it);
-
-
-                if (type == "Link") {
-                    CreateFileEntry entry;
-                    entry.name = name;
-                    entry.icon = icon;
-                    entry.comment = comment;
-                    entry.templatePath = filePath;
-                    m_createFileTemplates.insert(key, entry);
-                }
-            }
+    connect(this, &DolphinMainWindow::urlChanged,
+            infoPanel, &InformationPanel::setUrl);
+    connect(this, &DolphinMainWindow::selectionChanged,
+            infoPanel, &InformationPanel::setSelection);
+    connect(this, &DolphinMainWindow::requestItemInfo,
+            infoPanel, &InformationPanel::requestDelayedItemInfo);
+#endif
+
+    // Setup "Folders"
+    DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
+    foldersDock->setLocked(lock);
+    foldersDock->setObjectName(QStringLiteral("foldersDock"));
+    foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+    FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
+    foldersPanel->setCustomContextMenuActions({lockLayoutAction});
+    foldersDock->setWidget(foldersPanel);
+
+    QAction* foldersAction = foldersDock->toggleViewAction();
+    createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersAction, QStringLiteral("show_folders_panel"));
+
+    addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
+    connect(this, &DolphinMainWindow::urlChanged,
+            foldersPanel, &FoldersPanel::setUrl);
+    connect(foldersPanel, &FoldersPanel::folderActivated,
+            this, &DolphinMainWindow::changeUrl);
+    connect(foldersPanel, &FoldersPanel::folderMiddleClicked,
+            this, &DolphinMainWindow::openNewTab);
+    connect(foldersPanel, &FoldersPanel::errorMessage,
+            this, &DolphinMainWindow::showErrorMessage);
+
+    // Setup "Terminal"
+#ifndef Q_OS_WIN
+    if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
+        DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
+        terminalDock->setLocked(lock);
+        terminalDock->setObjectName(QStringLiteral("terminalDock"));
+        m_terminalPanel = new TerminalPanel(terminalDock);
+        m_terminalPanel->setCustomContextMenuActions({lockLayoutAction});
+        terminalDock->setWidget(m_terminalPanel);
+
+        connect(m_terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
+        connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
+        connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+                m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
+        connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+                this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
+
+        QAction* terminalAction = terminalDock->toggleViewAction();
+        createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
+
+        addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
+        connect(this, &DolphinMainWindow::urlChanged,
+                m_terminalPanel, &TerminalPanel::setUrl);
+
+        if (GeneralSettings::version() < 200) {
+            terminalDock->hide();
         }
     }
-    m_createFileTemplates.sort();
-
-    unplugActionList("create_actions");
-    KSortableList<CreateFileEntry, QString>::ConstIterator it = m_createFileTemplates.begin();
-    KSortableList<CreateFileEntry, QString>::ConstIterator end = m_createFileTemplates.end();
-    /* KDE4-TODO: don't port this code; use KNewMenu instead
-    while (it != end) {
-        CreateFileEntry entry = (*it).value();
-        KAction* action = new KAction(entry.name);
-        action->setIcon(entry.icon);
-        action->setName((*it).index());
-        connect(action, SIGNAL(activated()),
-                this, SLOT(createFile()));
-
-        const QChar section = ((*it).index()[0]);
-        switch (section) {
-            case '1':
-            case '2': {
-                m_fileGroupActions.append(action);
-                break;
-            }
-
-            case '3':
-            case '4': {
-                // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
-                // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
-                //m_linkGroupActions.append(action);
-                break;
-            }
+#endif
 
-            case '5': {
-                // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
-                // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
-                //m_linkToDeviceActions.append(action);
-                break;
-            }
-            default:
-                break;
-        }
-        ++it;
+    if (GeneralSettings::version() < 200) {
+        infoDock->hide();
+        foldersDock->hide();
     }
 
-    plugActionList("create_file_group", m_fileGroupActions);
-    //plugActionList("create_link_group", m_linkGroupActions);
-    //plugActionList("link_to_device", m_linkToDeviceActions);*/
+    // Setup "Places"
+    DolphinDockWidget* placesDock = new DolphinDockWidget(i18nc("@title:window", "Places"));
+    placesDock->setLocked(lock);
+    placesDock->setObjectName(QStringLiteral("placesDock"));
+    placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+
+    m_placesPanel = new PlacesPanel(placesDock);
+    m_placesPanel->setCustomContextMenuActions({lockLayoutAction});
+    placesDock->setWidget(m_placesPanel);
+
+    QAction *placesAction = placesDock->toggleViewAction();
+    createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel"));
+
+    addDockWidget(Qt::LeftDockWidgetArea, placesDock);
+    connect(m_placesPanel, &PlacesPanel::placeActivated,
+            this, &DolphinMainWindow::slotPlaceActivated);
+    connect(m_placesPanel, &PlacesPanel::placeMiddleClicked,
+            this, &DolphinMainWindow::openNewTab);
+    connect(m_placesPanel, &PlacesPanel::errorMessage,
+            this, &DolphinMainWindow::showErrorMessage);
+    connect(this, &DolphinMainWindow::urlChanged,
+            m_placesPanel, &PlacesPanel::setUrl);
+    connect(placesDock, &DolphinDockWidget::visibilityChanged,
+            m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
+    connect(this, &DolphinMainWindow::settingsChanged,
+        m_placesPanel, &PlacesPanel::readSettings);
+    connect(m_placesPanel, &PlacesPanel::storageTearDownRequested,
+            this, &DolphinMainWindow::slotStorageTearDownFromPlacesRequested);
+    connect(m_placesPanel, &PlacesPanel::storageTearDownExternallyRequested,
+            this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
+    m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
+
+    // Add actions into the "Panels" menu
+    KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
+    actionCollection()->addAction(QStringLiteral("panels"), panelsMenu);
+    panelsMenu->setDelayed(false);
+    const KActionCollection* ac = actionCollection();
+    panelsMenu->addAction(ac->action(QStringLiteral("show_places_panel")));
+#ifdef HAVE_BALOO
+    panelsMenu->addAction(ac->action(QStringLiteral("show_information_panel")));
+#endif
+    panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel")));
+    panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel")));
+    panelsMenu->addSeparator();
+    panelsMenu->addAction(lockLayoutAction);
 }
 
-void DolphinMainWindow::updateHistory()
+void DolphinMainWindow::updateEditActions()
 {
-    int index = 0;
-    const Q3ValueList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
-
-    QAction* backAction = actionCollection()->action("go_back");
-    if (backAction != 0) {
-        backAction->setEnabled(index < static_cast<int>(list.count()) - 1);
-    }
-
-    QAction* forwardAction = actionCollection()->action("go_forward");
-    if (forwardAction != 0) {
-        forwardAction->setEnabled(index > 0);
+    const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+    if (list.isEmpty()) {
+        stateChanged(QStringLiteral("has_no_selection"));
+    } else {
+        stateChanged(QStringLiteral("has_selection"));
+
+        KActionCollection* col = actionCollection();
+        QAction* renameAction            = col->action(KStandardAction::name(KStandardAction::RenameFile));
+        QAction* moveToTrashAction       = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
+        QAction* deleteAction            = col->action(KStandardAction::name(KStandardAction::DeleteFile));
+        QAction* cutAction               = col->action(KStandardAction::name(KStandardAction::Cut));
+        QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
+        QAction* showTarget              = col->action(QStringLiteral("show_target"));
+
+        KFileItemListProperties capabilities(list);
+        const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
+
+        renameAction->setEnabled(capabilities.supportsMoving());
+        moveToTrashAction->setEnabled(enableMoveToTrash);
+        deleteAction->setEnabled(capabilities.supportsDeleting());
+        deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
+        cutAction->setEnabled(capabilities.supportsMoving());
+        showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
     }
 }
 
-void DolphinMainWindow::updateEditActions()
+void DolphinMainWindow::updateViewActions()
 {
-    const KFileItemList list = m_activeView->selectedItems();
-    if (list.isEmpty()) {
-        stateChanged("has_no_selection");
-    }
-    else {
-        stateChanged("has_selection");
+    m_actionHandler->updateViewActions();
 
-        QAction* renameAction = actionCollection()->action("rename");
-        if (renameAction != 0) {
-            renameAction->setEnabled(list.count() >= 1);
-        }
+    QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar"));
+    showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
 
-        bool enableMoveToTrash = true;
-
-        KFileItemList::const_iterator it = list.begin();
-        const KFileItemList::const_iterator end = list.end();
-        while (it != end) {
-            KFileItem* item = *it;
-            const KUrl& url = item->url();
-            // only enable the 'Move to Trash' action for local files
-            if (!url.isLocalFile()) {
-                enableMoveToTrash = false;
-            }
-            ++it;
-        }
+    updateSplitAction();
 
-        QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
-        moveToTrashAction->setEnabled(enableMoveToTrash);
-    }
-    updatePasteAction();
+    QAction* editableLocactionAction = actionCollection()->action(QStringLiteral("editable_location"));
+    const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
 }
 
-void DolphinMainWindow::updateViewActions()
+void DolphinMainWindow::updateGoActions()
 {
-    QAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
-    if (zoomInAction != 0) {
-        zoomInAction->setEnabled(m_activeView->isZoomInPossible());
-    }
-
-    QAction* zoomOutAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomOut));
-    if (zoomOutAction != 0) {
-        zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
-    }
+    QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
+    const QUrl currentUrl = m_activeViewContainer->url();
+    goUpAction->setEnabled(KIO::upUrl(currentUrl) != currentUrl);
+}
 
-    QAction* action = 0;
-    switch (m_activeView->mode()) {
-        case DolphinView::IconsView:
-            action = actionCollection()->action("icons");
-            break;
-        case DolphinView::DetailsView:
-            action = actionCollection()->action("details");
-            break;
-        //case DolphinView::PreviewsView:
-        //    action = actionCollection()->action("previews");
-        //    break;
-        default:
-            break;
+void DolphinMainWindow::createControlButton()
+{
+    if (m_controlButton) {
+        return;
     }
+    Q_ASSERT(!m_controlButton);
 
-    if (action != 0) {
-        KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
-        toggleAction->setChecked(true);
-    }
+    m_controlButton = new QToolButton(this);
+    m_controlButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu")));
+    m_controlButton->setText(i18nc("@action", "Control"));
+    m_controlButton->setPopupMode(QToolButton::InstantPopup);
+    m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
 
-    slotSortingChanged(m_activeView->sorting());
-    slotSortOrderChanged(m_activeView->sortOrder());
+    QMenu* controlMenu = new QMenu(m_controlButton);
+    connect(controlMenu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu);
 
-    KToggleAction* showFilterBarAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
-    showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
+    m_controlButton->setMenu(controlMenu);
 
-    KToggleAction* showHiddenFilesAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
-    showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
+    toolBar()->addWidget(m_controlButton);
+    connect(toolBar(), &KToolBar::iconSizeChanged,
+            m_controlButton, &QToolButton::setIconSize);
+    connect(toolBar(), &KToolBar::toolButtonStyleChanged,
+            m_controlButton, &QToolButton::setToolButtonStyle);
 
-    KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
-    splitAction->setChecked(m_view[SecondaryIdx] != 0);
+    // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
+    // gets edited. In this case we must add them again. The adding is done asynchronously by
+    // m_updateToolBarTimer.
+    connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted);
+    m_updateToolBarTimer = new QTimer(this);
+    m_updateToolBarTimer->setInterval(500);
+    connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar);
 }
 
-void DolphinMainWindow::updateGoActions()
+void DolphinMainWindow::deleteControlButton()
 {
-    QAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
-    const KUrl& currentUrl = m_activeView->url();
-    goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
+    delete m_controlButton;
+    m_controlButton = nullptr;
+
+    delete m_updateToolBarTimer;
+    m_updateToolBarTimer = nullptr;
 }
 
-void DolphinMainWindow::updateViewProperties(const KUrl::List& urls)
+bool DolphinMainWindow::addActionToMenu(QAction* action, QMenu* menu)
 {
-    if (urls.isEmpty()) {
-        return;
+    Q_ASSERT(action);
+    Q_ASSERT(menu);
+
+    const KToolBar* toolBarWidget = toolBar();
+    foreach (const QWidget* widget, action->associatedWidgets()) {
+        if (widget == toolBarWidget) {
+            return false;
+        }
     }
 
-    // Updating the view properties might take up to several seconds
-    // 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(this,
-                                        i18n("Updating view properties..."),
-                                        QString::null,
-                                        urls.count());
-
-    KUrl::List::ConstIterator end = urls.end();
-    for(KUrl::List::ConstIterator it = urls.begin(); it != end; ++it) {
-        progressIndicator.execOperation();
-
-        ViewProperties props(*it);
-        props.save();
+    menu->addAction(action);
+    return true;
+}
+
+void DolphinMainWindow::refreshViews()
+{
+    m_tabWidget->refreshViews();
+
+    if (GeneralSettings::modifiedStartupSettings()) {
+        // The startup settings have been changed by the user (see bug #254947).
+        // Synchronize the split-view setting with the active view:
+        const bool splitView = GeneralSettings::splitView();
+        m_tabWidget->currentTabPage()->setSplitViewEnabled(splitView);
+        updateSplitAction();
+        updateWindowTitle();
     }
+
+    emit settingsChanged();
 }
 
-void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
+void DolphinMainWindow::clearStatusBar()
 {
-    KIO::Job* job = KIO::copy(source, dest);
-    addPendingUndoJob(job, DolphinCommand::Copy, source, dest);
+    m_activeViewContainer->statusBar()->resetToDefaultText();
+}
+
+void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
+{
+    connect(container, &DolphinViewContainer::showFilterBarChanged,
+            this, &DolphinMainWindow::updateFilterBarAction);
+    connect(container, &DolphinViewContainer::writeStateChanged,
+            this, &DolphinMainWindow::slotWriteStateChanged);
+
+    const DolphinView* view = container->view();
+    connect(view, &DolphinView::selectionChanged,
+            this, &DolphinMainWindow::slotSelectionChanged);
+    connect(view, &DolphinView::requestItemInfo,
+            this, &DolphinMainWindow::requestItemInfo);
+    connect(view, &DolphinView::tabRequested,
+            this, &DolphinMainWindow::openNewTab);
+    connect(view, &DolphinView::requestContextMenu,
+            this, &DolphinMainWindow::openContextMenu);
+    connect(view, &DolphinView::directoryLoadingStarted,
+            this, &DolphinMainWindow::enableStopAction);
+    connect(view, &DolphinView::directoryLoadingCompleted,
+            this, &DolphinMainWindow::disableStopAction);
+    connect(view, &DolphinView::directoryLoadingCompleted,
+            this, &DolphinMainWindow::slotDirectoryLoadingCompleted);
+    connect(view, &DolphinView::goBackRequested,
+            this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goBack));
+    connect(view, &DolphinView::goForwardRequested,
+            this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goForward));
+    connect(view, &DolphinView::urlActivated,
+            this, &DolphinMainWindow::handleUrl);
+
+    const KUrlNavigator* navigator = container->urlNavigator();
+    connect(navigator, &KUrlNavigator::urlChanged,
+            this, &DolphinMainWindow::changeUrl);
+    connect(navigator, &KUrlNavigator::historyChanged,
+            this, &DolphinMainWindow::updateHistory);
+    connect(navigator, &KUrlNavigator::editableStateChanged,
+            this, &DolphinMainWindow::slotEditableStateChanged);
+    connect(navigator, &KUrlNavigator::tabRequested,
+            this, &DolphinMainWindow::openNewTab);
+}
+
+void DolphinMainWindow::updateSplitAction()
+{
+    QAction* splitAction = actionCollection()->action(QStringLiteral("split_view"));
+    const DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
+    if (tabPage->splitViewEnabled()) {
+        if (tabPage->primaryViewActive()) {
+            splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
+            splitAction->setToolTip(i18nc("@info", "Close left view"));
+            splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
+        } else {
+            splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
+            splitAction->setToolTip(i18nc("@info", "Close right view"));
+            splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
+        }
+    } else {
+        splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
+        splitAction->setToolTip(i18nc("@info", "Split view"));
+        splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
+    }
 }
 
-void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
+bool DolphinMainWindow::isKompareInstalled() const
 {
-    KIO::Job* job = KIO::move(source, dest);
-    addPendingUndoJob(job, DolphinCommand::Move, source, dest);
+    static bool initialized = false;
+    static bool installed = false;
+    if (!initialized) {
+        // TODO: maybe replace this approach later by using a menu
+        // plugin like kdiff3plugin.cpp
+        installed = !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
+        initialized = true;
+    }
+    return installed;
 }
 
-void DolphinMainWindow::addPendingUndoJob(KIO::Job* job,
-                                          DolphinCommand::Type commandType,
-                                          const KUrl::List& source,
-                                          const KUrl& dest)
+void DolphinMainWindow::createPanelAction(const QIcon& icon,
+                                          const QKeySequence& shortcut,
+                                          QAction* dockAction,
+                                          const QString& actionName)
 {
-    connect(job, SIGNAL(result(KJob*)),
-            this, SLOT(addUndoOperation(KJob*)));
+    QAction* panelAction = actionCollection()->addAction(actionName);
+    panelAction->setCheckable(true);
+    panelAction->setChecked(dockAction->isChecked());
+    panelAction->setText(dockAction->text());
+    panelAction->setIcon(icon);
+    actionCollection()->setDefaultShortcut(panelAction, shortcut);
 
-    UndoInfo undoInfo;
-    undoInfo.id = job->progressId();
-    undoInfo.command = DolphinCommand(commandType, source, dest);
-    m_pendingUndoJobs.append(undoInfo);
+    connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
+    connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked);
 }
 
-void DolphinMainWindow::clearStatusBar()
+DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
+    KIO::FileUndoManager::UiInterface()
 {
-    m_activeView->statusBar()->clear();
 }
 
-void DolphinMainWindow::connectViewSignals(int viewIndex)
+DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
 {
-    DolphinView* view = m_view[viewIndex];
-    connect(view, SIGNAL(modeChanged()),
-            this, SLOT(slotViewModeChanged()));
-    connect(view, SIGNAL(showHiddenFilesChanged()),
-            this, SLOT(slotShowHiddenFilesChanged()));
-    connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
-            this, SLOT(slotSortingChanged(DolphinView::Sorting)));
-    connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
-            this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
-    connect(view, SIGNAL(selectionChanged()),
-            this, SLOT(slotSelectionChanged()));
-    connect(view, SIGNAL(showFilterBarChanged(bool)),
-            this, SLOT(updateFilterBarAction(bool)));
-
-    const UrlNavigator* navigator = view->urlNavigator();
-    connect(navigator, SIGNAL(urlChanged(const KUrl&)),
-            this, SLOT(slotUrlChanged(const KUrl&)));
-    connect(navigator, SIGNAL(historyChanged()),
-            this, SLOT(slotHistoryChanged()));
+}
 
+void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
+{
+    DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
+    if (mainWin) {
+        DolphinViewContainer* container = mainWin->activeViewContainer();
+        container->showMessage(job->errorString(), DolphinViewContainer::Error);
+    } else {
+        KIO::FileUndoManager::UiInterface::jobError(job);
+    }
 }
 
-#include "dolphinmainwindow.moc"