]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Merge remote-tracking branch 'fork/work/zakharafoniam/useful-groups'
[dolphin.git] / src / dolphinmainwindow.cpp
index 1ce51935f7b638cfeabec8b2565b58d5367f90c4..d08d6f6b396fe75bc9dda6cb48d67eabe354e41d 100644 (file)
-/***************************************************************************
- *   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>       *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Stefan Monov <logixoul@gmail.com>
+ * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphinmainwindow.h"
 
-#include "dolphinapplication.h"
-#include "dolphindockwidget.h"
+#include "admin/workerintegration.h"
+#include "dolphin_generalsettings.h"
+#include "dolphinbookmarkhandler.h"
 #include "dolphincontextmenu.h"
+#include "dolphindockwidget.h"
+#include "dolphinmainwindowadaptor.h"
+#include "dolphinnavigatorswidgetaction.h"
 #include "dolphinnewfilemenu.h"
+#include "dolphinplacesmodelsingleton.h"
+#include "dolphinrecenttabsmenu.h"
+#include "dolphintabpage.h"
+#include "dolphinurlnavigatorscontroller.h"
 #include "dolphinviewcontainer.h"
+#include "global.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 "search/dolphinquery.h"
+#include "selectionmode/actiontexthelper.h"
 #include "settings/dolphinsettingsdialog.h"
+#include "statusbar/diskspaceusagemenu.h"
 #include "statusbar/dolphinstatusbar.h"
-#include "views/dolphinviewactionhandler.h"
+#include "views/dolphinnewfilemenuobserver.h"
 #include "views/dolphinremoteencoding.h"
+#include "views/dolphinviewactionhandler.h"
 #include "views/draganddrophelper.h"
 #include "views/viewproperties.h"
 
-#ifndef Q_OS_WIN
-#include "panels/terminal/terminalpanel.h"
-#endif
-
-#include "dolphin_generalsettings.h"
-
-#include <KAcceleratorManager>
-#include <KAction>
 #include <KActionCollection>
 #include <KActionMenu>
+#include <KAuthorized>
+#include <KColorSchemeManager>
 #include <KConfig>
+#include <KConfigGui>
 #include <KDesktopFile>
-#include <kdeversion.h>
-#include <kdualaction.h>
-#include <KFileDialog>
-#include <KGlobal>
-#include <KLineEdit>
-#include <KToolBar>
-#include <KIcon>
-#include <KIconLoader>
-#include <KIO/NetAccess>
-#include <KIO/JobUiDelegate>
-#include <KInputDialog>
-#include <KLocale>
-#include <KProtocolManager>
-#include <KMenu>
-#include <KMenuBar>
-#include <KMessageBox>
+#include <KDialogJobUiDelegate>
+#include <KDualAction>
 #include <KFileItemListProperties>
-#include <konqmimedata.h>
+#include <KIO/CommandLauncherJob>
+#include <KIO/JobUiDelegateFactory>
+#include <KIO/OpenFileManagerWindowJob>
+#include <KIO/OpenUrlJob>
+#include <KJobWidgets>
+#include <KLocalizedString>
+#include <KMessageBox>
 #include <KProtocolInfo>
-#include <KRun>
+#include <KProtocolManager>
+#include <KRecentFilesAction>
+#include <KRuntimePlatform>
 #include <KShell>
-#include <KStandardDirs>
-#include <kstatusbar.h>
+#include <KShortcutsDialog>
 #include <KStandardAction>
-#include <ktabbar.h>
+#include <KSycoca>
+#include <KTerminalLauncherJob>
 #include <KToggleAction>
-#include <KUrlNavigator>
-#include <KUrl>
+#include <KToolBar>
+#include <KToolBarPopupAction>
 #include <KUrlComboBox>
-#include <KToolInvocation>
+#include <KUrlNavigator>
+#include <KWindowSystem>
+#include <KXMLGUIFactory>
 
-#include <QDesktopWidget>
-#include <QDBusMessage>
-#include <QKeyEvent>
+#include <kwidgetsaddons_version.h>
+
+#include <QApplication>
 #include <QClipboard>
+#include <QCloseEvent>
+#include <QDesktopServices>
+#include <QDialog>
+#include <QDomDocument>
+#include <QFileInfo>
+#include <QLineEdit>
+#include <QMenuBar>
+#include <QPushButton>
+#include <QShowEvent>
+#include <QStandardPaths>
+#include <QTimer>
 #include <QToolButton>
-#include <QSplitter>
+#include <QtConcurrentRun>
+#include <dolphindebug.h>
 
-namespace {
-    // Used for GeneralSettings::version() to determine whether
-    // an updated version of Dolphin is running.
-    const int CurrentDolphinVersion = 200;
-};
+#include <algorithm>
 
-/*
- * Remembers the tab configuration if a tab has been closed.
- * Each closed tab can be restored by the menu
- * "Go -> Recently Closed Tabs".
- */
-struct ClosedTab
-{
-    KUrl primaryUrl;
-    KUrl secondaryUrl;
-    bool isSplit;
-};
-Q_DECLARE_METATYPE(ClosedTab)
-
-DolphinMainWindow::DolphinMainWindow() :
-    KXmlGuiWindow(0),
-    m_newFileMenu(0),
-    m_tabBar(0),
-    m_activeViewContainer(0),
-    m_centralWidgetLayout(0),
-    m_tabIndex(0),
-    m_viewTab(),
-    m_actionHandler(0),
-    m_remoteEncoding(0),
-    m_settingsDialog(),
-    m_controlButton(0),
-    m_updateToolBarTimer(0),
-    m_lastHandleUrlStatJob(0)
-{
-    // Workaround for a X11-issue in combination with KModifierInfo
-    // (see DolphinContextMenu::initializeModifierKeyInfo() for
-    // more information):
-    DolphinContextMenu::initializeModifierKeyInfo();
-
-    setObjectName("Dolphin#");
-
-    m_viewTab.append(ViewTab());
-    ViewTab& viewTab = m_viewTab[m_tabIndex];
-    viewTab.wasActive = true; // The first opened tab is automatically active
-
-    KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
+#if HAVE_X11
+#include <KStartupInfo>
+#endif
+
+namespace
+{
+// Used for GeneralSettings::version() to determine whether
+// an updated version of Dolphin is running, so as to migrate
+// removed/renamed ...etc config entries; increment it in such
+// cases
+const int CurrentDolphinVersion = 202;
+// The maximum number of entries in the back/forward popup menu
+const int MaxNumberOfNavigationentries = 12;
+// The maximum number of "Go to Tab" shortcuts
+const int MaxActivateTabShortcuts = 9;
+}
+
+DolphinMainWindow::DolphinMainWindow()
+    : KXmlGuiWindow(nullptr)
+    , m_newFileMenu(nullptr)
+    , m_tabWidget(nullptr)
+    , m_activeViewContainer(nullptr)
+    , m_actionHandler(nullptr)
+    , m_remoteEncoding(nullptr)
+    , m_settingsDialog()
+    , m_bookmarkHandler(nullptr)
+    , m_disabledActionNotifier(nullptr)
+    , m_lastHandleUrlOpenJob(nullptr)
+    , m_terminalPanel(nullptr)
+    , m_placesPanel(nullptr)
+    , m_tearDownFromPlacesRequested(false)
+    , m_backAction(nullptr)
+    , m_forwardAction(nullptr)
+    , m_splitViewAction(nullptr)
+    , m_splitViewMenuAction(nullptr)
+    , m_diskSpaceUsageMenu(nullptr)
+    , m_sessionSaveTimer(nullptr)
+    , m_sessionSaveWatcher(nullptr)
+    , m_sessionSaveScheduled(false)
+{
+    Q_INIT_RESOURCE(dolphin);
+
+    new MainWindowAdaptor(this);
+
+#ifndef Q_OS_WIN
+    setWindowFlags(Qt::WindowContextHelpButtonHint);
+#endif
+    setComponentName(QStringLiteral("dolphin"), QGuiApplication::applicationDisplayName());
+    setObjectName(QStringLiteral("Dolphin#"));
+
+    setStateConfigGroup("State");
+
+#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
+    new KColorSchemeManager(this); // Sets a sensible color scheme which fixes unreadable icons and text on Windows.
+#endif
+
+    connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, this, &DolphinMainWindow::showErrorMessage);
+
+    KIO::FileUndoManager *undoManager = KIO::FileUndoManager::self();
     undoManager->setUiInterface(new UndoUiInterface());
 
-    connect(undoManager, SIGNAL(undoAvailable(bool)),
-            this, SLOT(slotUndoAvailable(bool)));
-    connect(undoManager, SIGNAL(undoTextChanged(QString)),
-            this, SLOT(slotUndoTextChanged(QString)));
-    connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
-            this, SLOT(clearStatusBar()));
-    connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
-            this, SLOT(showCommand(CommandType)));
-
-    GeneralSettings* generalSettings = GeneralSettings::self();
-    const bool firstRun = (generalSettings->version() < 200);
+    connect(undoManager, &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);
+
+    const bool firstRun = (GeneralSettings::version() < 200);
     if (firstRun) {
-        generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
+        GeneralSettings::setViewPropsTimestamp(QDateTime::currentDateTime());
     }
 
     setAcceptDrops(true);
 
-    viewTab.splitter = new QSplitter(this);
-    viewTab.splitter->setChildrenCollapsible(false);
+    auto *navigatorsWidgetAction = new DolphinNavigatorsWidgetAction(this);
+    actionCollection()->addAction(QStringLiteral("url_navigators"), navigatorsWidgetAction);
+    m_tabWidget = new DolphinTabWidget(navigatorsWidgetAction, 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);
 
+    m_actionTextHelper = new SelectionMode::ActionTextHelper(this);
     setupActions();
 
-    const KUrl homeUrl(generalSettings->homeUrl());
-    setUrlAsCaption(homeUrl);
-    m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
-    connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
-    connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
+    m_actionHandler = new DolphinViewActionHandler(actionCollection(), m_actionTextHelper, this);
+    connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
+    connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory);
+    connect(m_actionHandler, &DolphinViewActionHandler::createFileTriggered, this, &DolphinMainWindow::createFile);
+    connect(m_actionHandler, &DolphinViewActionHandler::selectionModeChangeTriggered, this, &DolphinMainWindow::slotSetSelectionMode);
 
-    viewTab.primaryView = createViewContainer(homeUrl, viewTab.splitter);
+    QAction *newDirAction = actionCollection()->action(QStringLiteral("create_dir"));
+    Q_CHECK_PTR(newDirAction);
+    m_newFileMenu->setNewFolderShortcutAction(newDirAction);
 
-    m_activeViewContainer = viewTab.primaryView;
-    connectViewSignals(m_activeViewContainer);
-    DolphinView* view = m_activeViewContainer->view();
-    m_activeViewContainer->show();
-    m_actionHandler->setCurrentView(view);
+    QAction *newFileAction = actionCollection()->action(QStringLiteral("create_file"));
+    Q_CHECK_PTR(newFileAction);
+    m_newFileMenu->setNewFileShortcutAction(newFileAction);
 
     m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
-    connect(this, SIGNAL(urlChanged(KUrl)),
-            m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
-
-    m_tabBar = new KTabBar(this);
-    m_tabBar->setMovable(true);
-    m_tabBar->setTabsClosable(true);
-    connect(m_tabBar, SIGNAL(currentChanged(int)),
-            this, SLOT(setActiveTab(int)));
-    connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
-            this, SLOT(closeTab(int)));
-    connect(m_tabBar, SIGNAL(contextMenu(int,QPoint)),
-            this, SLOT(openTabContextMenu(int,QPoint)));
-    connect(m_tabBar, SIGNAL(newTabRequest()),
-            this, SLOT(openNewTab()));
-    connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)),
-            this, SLOT(slotTestCanDecode(const QDragMoveEvent*,bool&)));
-    connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
-            this, SLOT(closeTab(int)));
-    connect(m_tabBar, SIGNAL(tabMoved(int,int)),
-            this, SLOT(slotTabMoved(int,int)));
-    connect(m_tabBar, SIGNAL(receivedDropEvent(int,QDropEvent*)),
-            this, SLOT(tabDropEvent(int,QDropEvent*)));
-
-    m_tabBar->blockSignals(true);  // signals get unblocked after at least 2 tabs are open
-
-    QWidget* centralWidget = new QWidget(this);
-    m_centralWidgetLayout = new QVBoxLayout(centralWidget);
-    m_centralWidgetLayout->setSpacing(0);
-    m_centralWidgetLayout->setMargin(0);
-    m_centralWidgetLayout->addWidget(m_tabBar);
-    m_centralWidgetLayout->addWidget(viewTab.splitter, 1);
-
-    setCentralWidget(centralWidget);
-    setupDockWidgets();
-    emit urlChanged(homeUrl);
+    connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
 
-    setupGUI(Keys | Save | Create | ToolBar);
-    stateChanged("new_file");
+    m_disabledActionNotifier = new DisabledActionNotifier(this);
+    connect(m_disabledActionNotifier, &DisabledActionNotifier::disabledActionTriggered, this, [this](const QAction *, QString reason) {
+        m_activeViewContainer->showMessage(reason, KMessageWidget::Warning);
+    });
 
-    QClipboard* clipboard = QApplication::clipboard();
-    connect(clipboard, SIGNAL(dataChanged()),
-            this, SLOT(updatePasteAction()));
+    setupDockWidgets();
 
-    if (generalSettings->splitView()) {
-        toggleSplitView();
-    }
-    updateEditActions();
-    updateViewActions();
-    updateGoActions();
+    const bool usePhoneUi{KRuntimePlatform::runtimePlatform().contains(QLatin1String("phone"))};
+    setupGUI(Save | Create | ToolBar, usePhoneUi ? QStringLiteral("dolphinuiforphones.rc") : QString() /* load the default dolphinui.rc file */);
+    stateChanged(QStringLiteral("new_file"));
+
+    QClipboard *clipboard = QApplication::clipboard();
+    connect(clipboard, &QClipboard::dataChanged, this, &DolphinMainWindow::updatePasteAction);
 
-    QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
-    showFilterBarAction->setChecked(generalSettings->filterBar());
+    QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+    toggleFilterBarAction->setChecked(GeneralSettings::filterBar());
 
     if (firstRun) {
         menuBar()->setVisible(false);
-        // Assure a proper default size if Dolphin runs the first time
-        resize(750, 500);
+
+        if (usePhoneUi) {
+            Q_ASSERT(qobject_cast<QDockWidget *>(m_placesPanel->parent()));
+            m_placesPanel->parentWidget()->hide();
+            auto settings = GeneralSettings::self();
+            settings->setShowZoomSlider(false); // Zooming can be done with pinch gestures instead and we are short on horizontal space.
+            settings->setRenameInline(false); // This works around inline renaming currently not working well with virtual keyboards.
+            settings->save(); // Otherwise the RenameInline setting is not picked up for the first time Dolphin is used.
+        }
     }
 
     const bool showMenu = !menuBar()->isHidden();
-    QAction* showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
-    showMenuBarAction->setChecked(showMenu);  // workaround for bug #171080
-    if (!showMenu) {
-        createControlButton();
+    QAction *showMenuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
+    showMenuBarAction->setChecked(showMenu); // workaround for bug #171080
+
+    auto hamburgerMenu = static_cast<KHamburgerMenu *>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu)));
+    hamburgerMenu->setMenuBar(menuBar());
+    hamburgerMenu->setShowMenuBarAction(showMenuBarAction);
+    connect(hamburgerMenu, &KHamburgerMenu::aboutToShowMenu, this, &DolphinMainWindow::updateHamburgerMenu);
+    hamburgerMenu->hideActionsOf(toolBar());
+    if (GeneralSettings::version() < 201 && !toolBar()->actions().contains(hamburgerMenu)) {
+        addHamburgerMenuToToolbar();
     }
+
+    updateAllowedToolbarAreas();
+    updateNavigatorsBackground();
+
+    // 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);
+
+    setupWhatsThis();
+
+    connect(KSycoca::self(), &KSycoca::databaseChanged, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction);
+
+    QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction);
+
+    m_fileItemActions.setParentWidget(this);
+    connect(&m_fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) {
+        showErrorMessage(errorMessage);
+    });
+
+    connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged, this, &DolphinMainWindow::slotSplitViewChanged);
 }
 
 DolphinMainWindow::~DolphinMainWindow()
 {
+    // This fixes a crash on Wayland when closing the mainwindow while another dialog is open.
+    disconnect(QGuiApplication::clipboard(), &QClipboard::dataChanged, this, &DolphinMainWindow::updatePasteAction);
+
+    // This fixes a crash in dolphinmainwindowtest where the connection below fires even though the KMainWindow destructor of this object is already running.
+    Q_CHECK_PTR(qobject_cast<DolphinDockWidget *>(m_placesPanel->parent()));
+    disconnect(static_cast<DolphinDockWidget *>(m_placesPanel->parent()),
+               &DolphinDockWidget::visibilityChanged,
+               this,
+               &DolphinMainWindow::slotPlacesPanelVisibilityChanged);
 }
 
-void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
+QVector<DolphinViewContainer *> DolphinMainWindow::viewContainers() const
 {
-    if (dirs.isEmpty()) {
-        return;
-    }
+    QVector<DolphinViewContainer *> viewContainers;
 
-    if (dirs.count() == 1) {
-        m_activeViewContainer->setUrl(dirs.first());
-        return;
+    for (int i = 0; i < m_tabWidget->count(); ++i) {
+        DolphinTabPage *tabPage = m_tabWidget->tabPageAt(i);
+
+        viewContainers << tabPage->primaryViewContainer();
+        if (tabPage->splitViewEnabled()) {
+            viewContainers << tabPage->secondaryViewContainer();
+        }
     }
+    return viewContainers;
+}
+
+void DolphinMainWindow::openDirectories(const QList<QUrl> &dirs, bool splitView)
+{
+    m_tabWidget->openDirectories(dirs, splitView);
+}
+
+void DolphinMainWindow::openDirectories(const QStringList &dirs, bool splitView)
+{
+    openDirectories(QUrl::fromStringList(dirs), splitView);
+}
 
-    const int oldOpenTabsCount = m_viewTab.count();
+void DolphinMainWindow::openFiles(const QList<QUrl> &files, bool splitView)
+{
+    m_tabWidget->openFiles(files, splitView);
+}
 
-    const bool hasSplitView = GeneralSettings::splitView();
+bool DolphinMainWindow::isFoldersPanelEnabled() const
+{
+    return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
+}
 
-    // Open each directory inside a new tab. If the "split view" option has been enabled,
-    // always show two directories within one tab.
-    QList<KUrl>::const_iterator it = dirs.begin();
-    while (it != dirs.end()) {
-        openNewTab(*it);
-        ++it;
+bool DolphinMainWindow::isInformationPanelEnabled() const
+{
+#if HAVE_BALOO
+    return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
+#else
+    return false;
+#endif
+}
 
-        if (hasSplitView && (it != dirs.end())) {
-            const int tabIndex = m_viewTab.count() - 1;
-            m_viewTab[tabIndex].secondaryView->setUrl(*it);
-            ++it;
-        }
-    }
+bool DolphinMainWindow::isSplitViewEnabledInCurrentTab() const
+{
+    return m_tabWidget->currentTabPage()->splitViewEnabled();
+}
 
-    // Remove the previously opened tabs
-    for (int i = 0; i < oldOpenTabsCount; ++i) {
-        closeTab(0);
-    }
+void DolphinMainWindow::openFiles(const QStringList &files, bool splitView)
+{
+    openFiles(QUrl::fromStringList(files), splitView);
 }
 
-void DolphinMainWindow::openFiles(const QList<KUrl>& files)
+void DolphinMainWindow::activateWindow(const QString &activationToken)
 {
-    if (files.isEmpty()) {
-        return;
-    }
+    window()->setAttribute(Qt::WA_NativeWindow, true);
 
-    // Get all distinct directories from 'files' and open a tab
-    // for each directory. If the "split view" option is enabled, two
-    // directories are shown inside one tab (see openDirectories()).
-    QList<KUrl> dirs;
-    foreach (const KUrl& url, files) {
-        const KUrl dir(url.directory());
-        if (!dirs.contains(dir)) {
-            dirs.append(dir);
-        }
+    if (KWindowSystem::isPlatformWayland()) {
+        KWindowSystem::setCurrentXdgActivationToken(activationToken);
+    } else if (KWindowSystem::isPlatformX11()) {
+#if HAVE_X11
+        KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken.toUtf8());
+#endif
     }
 
-    openDirectories(dirs);
+    KWindowSystem::activateWindow(window()->windowHandle());
+}
 
-    // Select the files. Although the files can be split between several
-    // tabs, there is no need to split 'files' accordingly, as
-    // the DolphinView will just ignore invalid selections.
-    const int tabCount = m_viewTab.count();
-    for (int i = 0; i < tabCount; ++i) {
-        m_viewTab[i].primaryView->view()->markUrlsAsSelected(files);
-        m_viewTab[i].primaryView->view()->markUrlAsCurrent(files.at(0));
-        if (m_viewTab[i].secondaryView) {
-            m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files);
-            m_viewTab[i].secondaryView->view()->markUrlAsCurrent(files.at(0));
-        }
-    }
+bool DolphinMainWindow::isActiveWindow()
+{
+    return window()->isActiveWindow();
 }
 
 void DolphinMainWindow::showCommand(CommandType command)
 {
-    DolphinStatusBarstatusBar = m_activeViewContainer->statusBar();
+    DolphinStatusBar *statusBar = m_activeViewContainer->statusBar();
     switch (command) {
     case KIO::FileUndoManager::Copy:
         statusBar->setText(i18nc("@info:status", "Successfully copied."));
@@ -344,7 +380,7 @@ void DolphinMainWindow::pasteIntoFolder()
     m_activeViewContainer->view()->pasteIntoFolder();
 }
 
-void DolphinMainWindow::changeUrl(const KUrl& url)
+void DolphinMainWindow::changeUrl(const QUrl &url)
 {
     if (!KProtocolManager::supportsListing(url)) {
         // The URL navigator only checks for validity, not
@@ -353,356 +389,454 @@ void DolphinMainWindow::changeUrl(const KUrl& url)
         return;
     }
 
-    DolphinViewContainer* view = activeViewContainer();
-    if (view) {
-        view->setUrl(url);
-        updateEditActions();
-        updateViewActions();
-        updateGoActions();
-        setUrlAsCaption(url);
-        if (m_viewTab.count() > 1) {
-            m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(m_activeViewContainer->url())));
-        }
-        const QString iconName = KMimeType::iconNameForUrl(url);
-        m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName));
-        emit urlChanged(url);
-    }
+    m_activeViewContainer->setUrl(url);
+    updateFileAndEditActions();
+    updatePasteAction();
+    updateViewActions();
+    updateGoActions();
+    m_diskSpaceUsageMenu->setUrl(url);
+
+    // will signal used urls to activities manager, too
+    m_recentFiles->addUrl(url, QString(), "inode/directory");
+
+    Q_EMIT urlChanged(url);
 }
 
-void DolphinMainWindow::slotTerminalDirectoryChanged(const KUrl& url)
+void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl &url)
 {
-    m_activeViewContainer->setAutoGrabFocus(false);
+    if (m_tearDownFromPlacesRequested && url == QUrl::fromLocalFile(QDir::homePath())) {
+        m_placesPanel->proceedWithTearDown();
+        m_tearDownFromPlacesRequested = false;
+    }
+
+    m_activeViewContainer->setGrabFocusOnUrlChange(false);
     changeUrl(url);
-    m_activeViewContainer->setAutoGrabFocus(true);
+    m_activeViewContainer->setGrabFocusOnUrlChange(true);
 }
 
 void DolphinMainWindow::slotEditableStateChanged(bool editable)
 {
-    KToggleAction* editableLocationAction =
-        static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
+    KToggleAction *editableLocationAction = static_cast<KToggleAction *>(actionCollection()->action(QStringLiteral("editable_location")));
     editableLocationAction->setChecked(editable);
 }
 
-void DolphinMainWindow::slotSelectionChanged(const KFileItemListselection)
+void DolphinMainWindow::slotSelectionChanged(const KFileItemList &selection)
 {
-    updateEditActions();
+    updateFileAndEditActions();
 
-    Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
-    int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount();
-    if (m_viewTab[m_tabIndex].secondaryView) {
-        selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedItemsCount();
-    }
+    const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount();
 
-    QAction* compareFilesAction = actionCollection()->action("compare_files");
+    QAction *compareFilesAction = actionCollection()->action(QStringLiteral("compare_files"));
     if (selectedUrlsCount == 2) {
         compareFilesAction->setEnabled(isKompareInstalled());
     } else {
         compareFilesAction->setEnabled(false);
     }
 
-    emit selectionChanged(selection);
-}
-
-void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
-{
-    emit requestItemInfo(item);
+    Q_EMIT selectionChanged(selection);
 }
 
 void DolphinMainWindow::updateHistory()
 {
-    const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
     const int index = urlNavigator->historyIndex();
 
-    QAction* backAction = actionCollection()->action("go_back");
+    QAction *backAction = actionCollection()->action(KStandardAction::name(KStandardAction::Back));
     if (backAction) {
         backAction->setToolTip(i18nc("@info", "Go back"));
+        backAction->setWhatsThis(i18nc("@info:whatsthis go back", "Return to the previously viewed folder."));
         backAction->setEnabled(index < urlNavigator->historySize() - 1);
     }
 
-    QAction* forwardAction = actionCollection()->action("go_forward");
+    QAction *forwardAction = actionCollection()->action(KStandardAction::name(KStandardAction::Forward));
     if (forwardAction) {
         forwardAction->setToolTip(i18nc("@info", "Go forward"));
+        forwardAction->setWhatsThis(xi18nc("@info:whatsthis go forward", "This undoes a <interface>Go|Back</interface> action."));
         forwardAction->setEnabled(index > 0);
     }
 }
 
 void DolphinMainWindow::updateFilterBarAction(bool show)
 {
-    QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
-    showFilterBarAction->setChecked(show);
+    QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+    toggleFilterBarAction->setChecked(show);
 }
 
 void DolphinMainWindow::openNewMainWindow()
 {
-    KRun::run("dolphin", KUrl::List(), this);
+    Dolphin::openNewWindow({m_activeViewContainer->url()}, this);
 }
 
-void DolphinMainWindow::openNewTab()
+void DolphinMainWindow::openNewActivatedTab()
 {
-    const bool isUrlEditable =  m_activeViewContainer->urlNavigator()->isUrlEditable();
-
-    openNewTab(m_activeViewContainer->url());
-    m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
-
-    // The URL navigator of the new tab should have the same editable state
-    // as the current tab
-    KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
-    navigator->setUrlEditable(isUrlEditable);
-
-    if (isUrlEditable) {
-        // If a new tab is opened and the URL is editable, assure that
-        // the user can edit the URL without manually setting the focus
-        navigator->setFocus();
-    }
+    // keep browsers compatibility, new tab is always after last one
+    auto openNewTabAfterLastTabConfigured = GeneralSettings::openNewTabAfterLastTab();
+    GeneralSettings::setOpenNewTabAfterLastTab(true);
+    m_tabWidget->openNewActivatedTab();
+    GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured);
 }
 
-void DolphinMainWindow::openNewTab(const KUrl& url)
+void DolphinMainWindow::addToPlaces()
 {
-    QWidget* focusWidget = QApplication::focusWidget();
-
-    if (m_viewTab.count() == 1) {
-        // Only one view is open currently and hence no tab is shown at
-        // all. Before creating a tab for 'url', provide a tab for the current URL.
-        const KUrl currentUrl = m_activeViewContainer->url();
-        m_tabBar->addTab(KIcon(KMimeType::iconNameForUrl(currentUrl)),
-                         squeezedText(tabName(currentUrl)));
-        m_tabBar->blockSignals(false);
-    }
-
-    m_tabBar->addTab(KIcon(KMimeType::iconNameForUrl(url)),
-                     squeezedText(tabName(url)));
-
-    ViewTab viewTab;
-    viewTab.splitter = new QSplitter(this);
-    viewTab.splitter->setChildrenCollapsible(false);
-    viewTab.primaryView = createViewContainer(url, viewTab.splitter);
-    viewTab.primaryView->setActive(false);
-    connectViewSignals(viewTab.primaryView);
-
-    m_viewTab.append(viewTab);
-
-    actionCollection()->action("close_tab")->setEnabled(true);
+    QUrl url;
+    QString name;
 
-    // Provide a split view, if the startup settings are set this way
-    if (GeneralSettings::splitView()) {
-        const int newTabIndex = m_viewTab.count() - 1;
-        createSecondaryView(newTabIndex);
-        m_viewTab[newTabIndex].secondaryView->setActive(true);
-        m_viewTab[newTabIndex].isPrimaryViewActive = false;
+    // If nothing is selected, act on the current dir
+    if (m_activeViewContainer->view()->selectedItems().isEmpty()) {
+        url = m_activeViewContainer->url();
+        name = m_activeViewContainer->placesText();
+    } else {
+        const auto dirToAdd = m_activeViewContainer->view()->selectedItems().first();
+        url = dirToAdd.url();
+        name = dirToAdd.name();
+    }
+    if (url.isValid()) {
+        QString icon;
+        if (isSearchUrl(url)) {
+            icon = QStringLiteral("folder-saved-search-symbolic");
+        } else {
+            icon = KIO::iconNameForUrl(url);
+        }
+        DolphinPlacesModelSingleton::instance().placesModel()->addPlace(name, url, icon);
     }
+}
 
-    if (focusWidget) {
-        // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
-        // in background, assure that the previous focused widget gets the focus back.
-        focusWidget->setFocus();
-    }
+DolphinTabPage *DolphinMainWindow::openNewTab(const QUrl &url)
+{
+    return m_tabWidget->openNewTab(url, QUrl());
 }
 
-void DolphinMainWindow::openNewActivatedTab(const KUrl& url)
+void DolphinMainWindow::openNewTabAndActivate(const QUrl &url)
 {
-    openNewTab(url);
-    m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+    m_tabWidget->openNewActivatedTab(url, QUrl());
 }
 
-void DolphinMainWindow::activateNextTab()
+void DolphinMainWindow::openNewWindow(const QUrl &url)
 {
-    if (m_viewTab.count() >= 2) {
-        const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
-        m_tabBar->setCurrentIndex(tabIndex);
-    }
+    Dolphin::openNewWindow({url}, this);
 }
 
-void DolphinMainWindow::activatePrevTab()
+void DolphinMainWindow::slotSplitViewChanged()
 {
-    if (m_viewTab.count() >= 2) {
-        int tabIndex = m_tabBar->currentIndex() - 1;
-        if (tabIndex == -1) {
-            tabIndex = m_tabBar->count() - 1;
-        }
-        m_tabBar->setCurrentIndex(tabIndex);
-    }
+    m_tabWidget->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation);
+    updateSplitActions();
 }
 
 void DolphinMainWindow::openInNewTab()
 {
-    const KFileItemList list = m_activeViewContainer->view()->selectedItems();
-    if (list.isEmpty()) {
+    const KFileItemList &list = m_activeViewContainer->view()->selectedItems();
+    bool tabCreated = false;
+
+    for (const KFileItem &item : list) {
+        const QUrl &url = DolphinView::openItemAsFolderUrl(item);
+        if (!url.isEmpty()) {
+            openNewTab(url);
+            tabCreated = true;
+        }
+    }
+
+    // if no new tab has been created from the selection
+    // open the current directory in a new tab
+    if (!tabCreated) {
         openNewTab(m_activeViewContainer->url());
-    } else if ((list.count() == 1) && list[0].isDir()) {
-        openNewTab(list[0].url());
     }
 }
 
 void DolphinMainWindow::openInNewWindow()
 {
-    KUrl newWindowUrl;
+    QUrl newWindowUrl;
 
     const KFileItemList list = m_activeViewContainer->view()->selectedItems();
     if (list.isEmpty()) {
         newWindowUrl = m_activeViewContainer->url();
-    } else if ((list.count() == 1) && list[0].isDir()) {
-        newWindowUrl = list[0].url();
+    } else if (list.count() == 1) {
+        const KFileItem &item = list.first();
+        newWindowUrl = DolphinView::openItemAsFolderUrl(item);
     }
 
     if (!newWindowUrl.isEmpty()) {
-        KRun::run("dolphin", KUrl::List() << newWindowUrl, this);
+        Dolphin::openNewWindow({newWindowUrl}, this);
     }
 }
 
-void DolphinMainWindow::toggleActiveView()
+void DolphinMainWindow::openInSplitView(const QUrl &url)
 {
-    if (!m_viewTab[m_tabIndex].secondaryView) {
-        // only one view is available
+    QUrl newSplitViewUrl = url;
+
+    if (newSplitViewUrl.isEmpty()) {
+        const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+        if (list.count() == 1) {
+            const KFileItem &item = list.first();
+            newSplitViewUrl = DolphinView::openItemAsFolderUrl(item);
+        }
+    }
+
+    if (newSplitViewUrl.isEmpty()) {
         return;
     }
 
-    Q_ASSERT(m_activeViewContainer);
-    Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
+    DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+    if (tabPage->splitViewEnabled()) {
+        tabPage->switchActiveView();
+        tabPage->activeViewContainer()->setUrl(newSplitViewUrl);
+    } else {
+        tabPage->setSplitViewEnabled(true, WithAnimation, newSplitViewUrl);
+        updateViewActions();
+    }
+}
+
+void DolphinMainWindow::showTarget()
+{
+    const KFileItem link = m_activeViewContainer->view()->selectedItems().at(0);
+    const QUrl destinationUrl = link.url().resolved(QUrl(link.linkDest()));
+
+    auto job = KIO::stat(destinationUrl, KIO::StatJob::SourceSide, KIO::StatNoDetails);
+
+    connect(job, &KJob::finished, this, [this, destinationUrl](KJob *job) {
+        KIO::StatJob *statJob = static_cast<KIO::StatJob *>(job);
+
+        if (statJob->error()) {
+            m_activeViewContainer->showMessage(job->errorString(), KMessageWidget::Error);
+        } else {
+            KIO::highlightInFileManager({destinationUrl});
+        }
+    });
+}
+
+bool DolphinMainWindow::event(QEvent *event)
+{
+    if (event->type() == QEvent::ShortcutOverride) {
+        const QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+        if (keyEvent->key() == Qt::Key_Space && m_activeViewContainer->view()->handleSpaceAsNormalKey()) {
+            event->accept();
+            return true;
+        }
+    }
 
-    DolphinViewContainer* left  = m_viewTab[m_tabIndex].primaryView;
-    DolphinViewContainer* right = m_viewTab[m_tabIndex].secondaryView;
-    setActiveViewContainer(m_activeViewContainer == right ? left : right);
+    return KXmlGuiWindow::event(event);
 }
 
-void DolphinMainWindow::showEvent(QShowEventevent)
+void DolphinMainWindow::showEvent(QShowEvent *event)
 {
     KXmlGuiWindow::showEvent(event);
-    if (!event->spontaneous()) {
+
+    if (!event->spontaneous() && m_activeViewContainer) {
         m_activeViewContainer->view()->setFocus();
     }
 }
 
-void DolphinMainWindow::closeEvent(QCloseEventevent)
+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;
-    DolphinApplication *application = qobject_cast<DolphinApplication*>(qApp);
-    if (application && application->sessionSaving()) {
+    if (qApp->isSavingSession()) {
         closedByUser = false;
     }
 
-    if (m_viewTab.count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
+    if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && !GeneralSettings::rememberOpenedTabs() && closedByUser) {
         // Ask the user if he really wants to quit and close all tabs.
         // Open a confirmation dialog with 3 buttons:
-        // KDialog::Yes    -> Quit
-        // KDialog::No     -> Close only the current tab
-        // KDialog::Cancel -> do nothing
-        KDialog *dialog = new KDialog(this, Qt::Dialog);
-        dialog->setCaption(i18nc("@title:window", "Confirmation"));
-        dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
+        // 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 auto 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);
+        }
+
+        switch (result) {
+        case QDialogButtonBox::Yes:
+            // Quit
+            break;
+        case QDialogButtonBox::No:
+            // Close only the current tab
+            m_tabWidget->closeTab();
+            Q_FALLTHROUGH();
+        default:
+            event->ignore();
+            return;
+        }
+    }
+
+    if (m_terminalPanel && m_terminalPanel->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser) {
+        // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
+        // Open a confirmation dialog with 3 buttons:
+        // QDialogButtonBox::Yes    -> Quit
+        // QDialogButtonBox::No     -> Show Terminal Panel
+        // QDialogButtonBox::Cancel -> do nothing
+        QDialog *dialog = new QDialog(this, Qt::Dialog);
+        dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
         dialog->setModal(true);
-        dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit());
-        dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")));
-        dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel());
-        dialog->setDefaultButton(KDialog::Yes);
+        auto standardButtons = QDialogButtonBox::Yes | QDialogButtonBox::Cancel;
+        if (!m_terminalPanel->isVisible()) {
+            standardButtons |= QDialogButtonBox::No;
+        }
+        QDialogButtonBox *buttons = new QDialogButtonBox(standardButtons);
+        KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit());
+        if (!m_terminalPanel->isVisible()) {
+            KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
+        }
+        KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
 
         bool doNotAskAgainCheckboxResult = false;
 
-        const int result = KMessageBox::createKMessageBox(dialog,
+        const auto result = KMessageBox::createKMessageBox(
+            dialog,
+            buttons,
             QMessageBox::Warning,
-            i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
+            i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel->runningProgramName()),
             QStringList(),
             i18n("Do not ask again"),
             &doNotAskAgainCheckboxResult,
-            KMessageBox::Notify);
+            KMessageBox::Notify | KMessageBox::Dangerous);
 
         if (doNotAskAgainCheckboxResult) {
-            GeneralSettings::setConfirmClosingMultipleTabs(false);
+            GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
         }
 
         switch (result) {
-            case KDialog::Yes:
-                // Quit
-                break;
-            case KDialog::No:
-                // Close only the current tab
-              closeTab();
-            default:
-                event->ignore();
-                return;
+        case QDialogButtonBox::Yes:
+            // Quit
+            break;
+        case QDialogButtonBox::No:
+            actionCollection()->action("show_terminal_panel")->trigger();
+            // Do not quit, ignore quit event
+            Q_FALLTHROUGH();
+        default:
+            event->ignore();
+            return;
+        }
+    }
+
+    if (m_sessionSaveTimer && (m_sessionSaveTimer->isActive() || m_sessionSaveWatcher->isRunning())) {
+        const bool sessionSaveTimerActive = m_sessionSaveTimer->isActive();
+
+        m_sessionSaveTimer->stop();
+        m_sessionSaveWatcher->disconnect();
+        m_sessionSaveWatcher->waitForFinished();
+
+        if (sessionSaveTimerActive || m_sessionSaveScheduled) {
+            slotSaveSession();
         }
     }
 
     GeneralSettings::setVersion(CurrentDolphinVersion);
-    GeneralSettings::self()->writeConfig();
+    GeneralSettings::self()->save();
 
     KXmlGuiWindow::closeEvent(event);
 }
 
-void DolphinMainWindow::saveProperties(KConfigGroup& group)
+void DolphinMainWindow::slotSaveSession()
 {
-    const int tabCount = m_viewTab.count();
-    group.writeEntry("Tab Count", tabCount);
-    group.writeEntry("Active Tab Index", m_tabBar->currentIndex());
+    m_sessionSaveScheduled = false;
 
-    for (int i = 0; i < tabCount; ++i) {
-        const DolphinViewContainer* cont = m_viewTab[i].primaryView;
-        group.writeEntry(tabProperty("Primary URL", i), cont->url().url());
-        group.writeEntry(tabProperty("Primary Editable", i),
-                         cont->urlNavigator()->isUrlEditable());
+    if (m_sessionSaveWatcher->isRunning()) {
+        // The previous session is still being saved - schedule another save.
+        m_sessionSaveWatcher->disconnect();
+        connect(m_sessionSaveWatcher, &QFutureWatcher<void>::finished, this, &DolphinMainWindow::slotSaveSession, Qt::SingleShotConnection);
+        m_sessionSaveScheduled = true;
+    } else if (!m_sessionSaveTimer->isActive()) {
+        // No point in saving the session if the timer is running (since it will save the session again when it times out).
+        KConfigGui::setSessionConfig(QStringLiteral("dolphin"), QStringLiteral("dolphin"));
+        KConfig *config = KConfigGui::sessionConfig();
+        saveGlobalProperties(config);
+        savePropertiesInternal(config, 1);
+        KConfigGroup group = config->group(QStringLiteral("Number"));
+        group.writeEntry("NumberOfWindows", 1); // Makes session restore aware that there is a window to restore.
 
-        cont = m_viewTab[i].secondaryView;
-        if (cont) {
-            group.writeEntry(tabProperty("Secondary URL", i), cont->url().url());
-            group.writeEntry(tabProperty("Secondary Editable", i),
-                             cont->urlNavigator()->isUrlEditable());
-        }
+        auto future = QtConcurrent::run([config]() {
+            config->sync();
+        });
+        m_sessionSaveWatcher->setFuture(future);
     }
 }
 
-void DolphinMainWindow::readProperties(const KConfigGroup& group)
+void DolphinMainWindow::setSessionAutoSaveEnabled(bool enable)
 {
-    const int tabCount = group.readEntry("Tab Count", 1);
-    for (int i = 0; i < tabCount; ++i) {
-        DolphinViewContainer* cont = m_viewTab[i].primaryView;
+    if (enable) {
+        if (!m_sessionSaveTimer) {
+            m_sessionSaveTimer = new QTimer(this);
+            m_sessionSaveWatcher = new QFutureWatcher<void>(this);
+            m_sessionSaveTimer->setSingleShot(true);
+            m_sessionSaveTimer->setInterval(22000);
 
-        cont->setUrl(group.readEntry(tabProperty("Primary URL", i)));
-        const bool editable = group.readEntry(tabProperty("Primary Editable", i), false);
-        cont->urlNavigator()->setUrlEditable(editable);
+            connect(m_sessionSaveTimer, &QTimer::timeout, this, &DolphinMainWindow::slotSaveSession);
+        }
 
-        cont = m_viewTab[i].secondaryView;
-        const QString secondaryUrl = group.readEntry(tabProperty("Secondary URL", i));
-        if (!secondaryUrl.isEmpty()) {
-            if (!cont) {
-                // a secondary view should be shown, but no one is available
-                // currently -> create a new view
-                toggleSplitView();
-                cont = m_viewTab[i].secondaryView;
-                Q_ASSERT(cont);
-            }
+        connect(m_tabWidget, &DolphinTabWidget::urlChanged, m_sessionSaveTimer, qOverload<>(&QTimer::start), Qt::UniqueConnection);
+        connect(m_tabWidget, &DolphinTabWidget::tabCountChanged, m_sessionSaveTimer, qOverload<>(&QTimer::start), Qt::UniqueConnection);
+        connect(m_tabWidget, &DolphinTabWidget::activeViewChanged, m_sessionSaveTimer, qOverload<>(&QTimer::start), Qt::UniqueConnection);
+    } else if (m_sessionSaveTimer) {
+        m_sessionSaveTimer->stop();
+        m_sessionSaveWatcher->disconnect();
+        m_sessionSaveScheduled = false;
 
-            cont->setUrl(secondaryUrl);
-            const bool editable = group.readEntry(tabProperty("Secondary Editable", i), false);
-            cont->urlNavigator()->setUrlEditable(editable);
-        } else if (cont) {
-            // no secondary view should be shown, but the default setting shows
-            // one already -> close the view
-            toggleSplitView();
-        }
+        m_sessionSaveWatcher->waitForFinished();
 
-        // openNewTab() needs to be called only tabCount - 1 times
-        if (i != tabCount - 1) {
-             openNewTab();
-        }
+        m_sessionSaveTimer->deleteLater();
+        m_sessionSaveWatcher->deleteLater();
+        m_sessionSaveTimer = nullptr;
+        m_sessionSaveWatcher = nullptr;
     }
+}
 
-    const int index = group.readEntry("Active Tab Index", 0);
-    m_tabBar->setCurrentIndex(index);
+void DolphinMainWindow::saveProperties(KConfigGroup &group)
+{
+    m_tabWidget->saveProperties(group);
+}
+
+void DolphinMainWindow::readProperties(const KConfigGroup &group)
+{
+    m_tabWidget->readProperties(group);
 }
 
 void DolphinMainWindow::updateNewMenu()
 {
-    m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
     m_newFileMenu->checkUpToDate();
-    m_newFileMenu->setPopupFiles(activeViewContainer()->url());
+    m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
 }
 
 void DolphinMainWindow::createDirectory()
 {
-    m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
-    m_newFileMenu->setPopupFiles(activeViewContainer()->url());
-    m_newFileMenu->createDirectory();
+    // When creating directory, namejob is being run. In network folders,
+    // this job can take long time, so instead of starting multiple namejobs,
+    // just check if we are already running one. This prevents opening multiple
+    // dialogs. BUG:481401
+    if (!m_newFileMenu->isCreateDirectoryRunning()) {
+        m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
+        m_newFileMenu->createDirectory();
+    }
+}
+
+void DolphinMainWindow::createFile()
+{
+    // Use the same logic as in createDirectory()
+    if (!m_newFileMenu->isCreateFileRunning()) {
+        m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
+        m_newFileMenu->createFile();
+    }
 }
 
 void DolphinMainWindow::quit()
@@ -710,51 +844,22 @@ void DolphinMainWindow::quit()
     close();
 }
 
-void DolphinMainWindow::showErrorMessage(const QStringmessage)
+void DolphinMainWindow::showErrorMessage(const QString &message)
 {
-    m_activeViewContainer->showMessage(message, DolphinViewContainer::Error);
+    m_activeViewContainer->showMessage(message, KMessageWidget::Error);
 }
 
 void DolphinMainWindow::slotUndoAvailable(bool available)
 {
-    QActionundoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+    QAction *undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
     if (undoAction) {
         undoAction->setEnabled(available);
     }
 }
 
-void DolphinMainWindow::restoreClosedTab(QAction* action)
-{
-    if (action->data().toBool()) {
-        // clear all actions except the "Empty Recently Closed Tabs"
-        // action and the separator
-        QList<QAction*> actions = m_recentTabsMenu->menu()->actions();
-        const int count = actions.size();
-        for (int i = 2; i < count; ++i) {
-            m_recentTabsMenu->menu()->removeAction(actions.at(i));
-        }
-    } else {
-        const ClosedTab closedTab = action->data().value<ClosedTab>();
-        openNewTab(closedTab.primaryUrl);
-        m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
-
-        if (closedTab.isSplit) {
-            // create secondary view
-            toggleSplitView();
-            m_viewTab[m_tabIndex].secondaryView->setUrl(closedTab.secondaryUrl);
-        }
-
-        m_recentTabsMenu->removeAction(action);
-    }
-
-    if (m_recentTabsMenu->menu()->actions().count() == 2) {
-        m_recentTabsMenu->setEnabled(false);
-    }
-}
-
-void DolphinMainWindow::slotUndoTextChanged(const QString& text)
+void DolphinMainWindow::slotUndoTextChanged(const QString &text)
 {
-    QActionundoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+    QAction *undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
     if (undoAction) {
         undoAction->setText(text);
     }
@@ -769,12 +874,22 @@ void DolphinMainWindow::undo()
 
 void DolphinMainWindow::cut()
 {
-    m_activeViewContainer->view()->cutSelectedItems();
+    if (m_activeViewContainer->view()->selectedItems().isEmpty()) {
+        m_activeViewContainer->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CutContents);
+    } else {
+        m_activeViewContainer->view()->cutSelectedItemsToClipboard();
+        m_activeViewContainer->setSelectionModeEnabled(false);
+    }
 }
 
 void DolphinMainWindow::copy()
 {
-    m_activeViewContainer->view()->copySelectedItems();
+    if (m_activeViewContainer->view()->selectedItems().isEmpty()) {
+        m_activeViewContainer->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CopyContents);
+    } else {
+        m_activeViewContainer->view()->copySelectedItemsToClipboard();
+        m_activeViewContainer->setSelectionModeEnabled(false);
+    }
 }
 
 void DolphinMainWindow::paste()
@@ -784,145 +899,319 @@ void DolphinMainWindow::paste()
 
 void DolphinMainWindow::find()
 {
-    m_activeViewContainer->setSearchModeEnabled(true);
+    m_activeViewContainer->setSearchBarVisible(true);
+    m_activeViewContainer->setFocusToSearchBar();
+}
+
+void DolphinMainWindow::updateSearchAction()
+{
+    QAction *toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
+    toggleSearchAction->setChecked(m_activeViewContainer->isSearchBarVisible());
 }
 
 void DolphinMainWindow::updatePasteAction()
 {
-    QActionpasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
+    QAction *pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
     QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
     pasteAction->setEnabled(pasteInfo.first);
+    m_disabledActionNotifier->setDisabledReason(pasteAction,
+                                                m_activeViewContainer->rootItem().isWritable()
+                                                    ? i18nc("@info", "Cannot paste: The clipboard is empty.")
+                                                    : i18nc("@info", "Cannot paste: You do not have permission to write into this folder."));
     pasteAction->setText(pasteInfo.second);
 }
 
-void DolphinMainWindow::selectAll()
+void DolphinMainWindow::slotDirectoryLoadingCompleted()
 {
-    clearStatusBar();
-
-    // 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();
-    }
+    updatePasteAction();
 }
 
-void DolphinMainWindow::invertSelection()
+void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
 {
-    clearStatusBar();
-    m_activeViewContainer->view()->invertSelection();
+    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::toggleSplitView()
+QAction *DolphinMainWindow::urlNavigatorHistoryAction(const KUrlNavigator *urlNavigator, int historyIndex, QObject *parent)
 {
-    if (!m_viewTab[m_tabIndex].secondaryView) {
-        createSecondaryView(m_tabIndex);
-        setActiveViewContainer(m_viewTab[m_tabIndex].secondaryView);
-    } else if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
-        // remove secondary view
-        m_viewTab[m_tabIndex].secondaryView->close();
-        m_viewTab[m_tabIndex].secondaryView->deleteLater();
-        m_viewTab[m_tabIndex].secondaryView = 0;
+    const QUrl url = urlNavigator->locationUrl(historyIndex);
+
+    QString text;
 
-        setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
+    if (isSearchUrl(url)) {
+        text = Search::DolphinQuery(url, QUrl{}).title();
+    } else if (urlNavigator->showFullPath()) {
+        text = url.toDisplayString(QUrl::PreferLocalFile);
     } else {
-        // The primary view is active and should be closed. Hence from a 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.
+        const KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
 
-        m_viewTab[m_tabIndex].primaryView->close();
-        m_viewTab[m_tabIndex].primaryView->deleteLater();
-        m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
-        m_viewTab[m_tabIndex].secondaryView = 0;
+        const QModelIndex closestIdx = placesModel->closestItem(url);
+        if (closestIdx.isValid()) {
+            const QUrl placeUrl = placesModel->url(closestIdx);
+
+            text = placesModel->text(closestIdx);
+
+            QString pathInsidePlace = url.path().mid(placeUrl.path().length());
+
+            if (!pathInsidePlace.isEmpty() && !pathInsidePlace.startsWith(QLatin1Char('/'))) {
+                pathInsidePlace.prepend(QLatin1Char('/'));
+            }
 
-        setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
+            if (pathInsidePlace != QLatin1Char('/')) {
+                text.append(pathInsidePlace);
+            }
+        }
     }
 
-    updateViewActions();
+    QAction *action = new QAction(QIcon::fromTheme(KIO::iconNameForUrl(url)), text, parent);
+    action->setData(historyIndex);
+    return action;
 }
 
-void DolphinMainWindow::reloadView()
+void DolphinMainWindow::slotAboutToShowBackPopupMenu()
 {
-    clearStatusBar();
-    m_activeViewContainer->view()->reload();
+    const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
+    int entries = 0;
+    QMenu *menu = m_backAction->popupMenu();
+    menu->clear();
+    for (int i = urlNavigator->historyIndex() + 1; i < urlNavigator->historySize() && entries < MaxNumberOfNavigationentries; ++i, ++entries) {
+        QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu);
+        menu->addAction(action);
+    }
 }
 
-void DolphinMainWindow::stopLoading()
+void DolphinMainWindow::slotGoBack(QAction *action)
 {
-    m_activeViewContainer->view()->stopLoading();
+    int gotoIndex = action->data().value<int>();
+    const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
+    for (int i = gotoIndex - urlNavigator->historyIndex(); i > 0; --i) {
+        goBack();
+    }
 }
 
-void DolphinMainWindow::enableStopAction()
+void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction *action)
 {
-    actionCollection()->action("stop")->setEnabled(true);
+    if (action) {
+        const KUrlNavigator *urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
+        openNewTab(urlNavigator->locationUrl(action->data().value<int>()));
+    }
 }
 
-void DolphinMainWindow::disableStopAction()
+void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
 {
-    actionCollection()->action("stop")->setEnabled(false);
+    const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
+    int entries = 0;
+    QMenu *menu = m_forwardAction->popupMenu();
+    menu->clear();
+    for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) {
+        QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu);
+        menu->addAction(action);
+    }
 }
 
-void DolphinMainWindow::showFilterBar()
+void DolphinMainWindow::slotGoForward(QAction *action)
 {
-    m_activeViewContainer->setFilterBarVisible(true);
+    int gotoIndex = action->data().value<int>();
+    const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
+    for (int i = urlNavigator->historyIndex() - gotoIndex; i > 0; --i) {
+        goForward();
+    }
 }
 
-void DolphinMainWindow::toggleEditLocation()
+void DolphinMainWindow::slotSetSelectionMode(bool enabled, SelectionMode::BottomBar::Contents bottomBarContents)
 {
-    clearStatusBar();
-
-    QAction* action = actionCollection()->action("editable_location");
-    KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
-    urlNavigator->setUrlEditable(action->isChecked());
+    m_activeViewContainer->setSelectionModeEnabled(enabled, actionCollection(), bottomBarContents);
 }
 
-void DolphinMainWindow::replaceLocation()
+void DolphinMainWindow::selectAll()
 {
-    KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
-    navigator->setUrlEditable(true);
-    navigator->setFocus();
+    clearStatusBar();
 
-    // select the whole text of the combo box editor
-    QLineEdit* lineEdit = navigator->editor()->lineEdit();  // krazy:exclude=qclasses
-    lineEdit->selectAll();
-}
+    // if the URL navigator is editable and focused, select the whole
+    // URL instead of all items of the view
 
-void DolphinMainWindow::togglePanelLockState()
-{
-    const bool newLockState = !GeneralSettings::lockPanels();
-    foreach (QObject* child, children()) {
-        DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
-        if (dock) {
+    KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigator();
+    QLineEdit *lineEdit = urlNavigator->editor()->lineEdit();
+    const bool selectUrl = urlNavigator->isUrlEditable() && lineEdit->hasFocus();
+    if (selectUrl) {
+        lineEdit->selectAll();
+    } else {
+        m_activeViewContainer->view()->selectAll();
+    }
+}
+
+void DolphinMainWindow::invertSelection()
+{
+    clearStatusBar();
+    m_activeViewContainer->view()->invertSelection();
+}
+
+void DolphinMainWindow::toggleSplitView()
+{
+    QUrl newSplitViewUrl;
+    const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+    if (list.count() == 1) {
+        const KFileItem &item = list.first();
+        newSplitViewUrl = DolphinView::openItemAsFolderUrl(item);
+    }
+
+    DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+    tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled(), WithAnimation, newSplitViewUrl);
+    m_tabWidget->updateTabName(m_tabWidget->indexOf(tabPage));
+    updateViewActions();
+}
+
+void DolphinMainWindow::popoutSplitView()
+{
+    DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+    if (!tabPage->splitViewEnabled())
+        return;
+    openNewWindow((GeneralSettings::closeActiveSplitView() ? tabPage->activeViewContainer() : tabPage->inactiveViewContainer())->url());
+    tabPage->setSplitViewEnabled(false, WithAnimation);
+    updateSplitActions();
+}
+
+void DolphinMainWindow::toggleSplitStash()
+{
+    DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+    tabPage->setSplitViewEnabled(false, WithAnimation);
+    tabPage->setSplitViewEnabled(true, WithAnimation, QUrl("stash:/"));
+}
+
+void DolphinMainWindow::copyToInactiveSplitView()
+{
+    if (m_activeViewContainer->view()->selectedItems().isEmpty()) {
+        m_activeViewContainer->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::CopyToOtherViewContents);
+    } else {
+        m_tabWidget->copyToInactiveSplitView();
+        m_activeViewContainer->setSelectionModeEnabled(false);
+    }
+}
+
+void DolphinMainWindow::moveToInactiveSplitView()
+{
+    if (m_activeViewContainer->view()->selectedItems().isEmpty()) {
+        m_activeViewContainer->setSelectionModeEnabled(true, actionCollection(), SelectionMode::BottomBar::Contents::MoveToOtherViewContents);
+    } else {
+        m_tabWidget->moveToInactiveSplitView();
+        m_activeViewContainer->setSelectionModeEnabled(false);
+    }
+}
+
+void DolphinMainWindow::reloadView()
+{
+    clearStatusBar();
+    m_activeViewContainer->reload();
+    m_activeViewContainer->statusBar()->updateSpaceInfo();
+}
+
+void DolphinMainWindow::stopLoading()
+{
+    m_activeViewContainer->view()->stopLoading();
+}
+
+void DolphinMainWindow::enableStopAction()
+{
+    actionCollection()->action(QStringLiteral("stop"))->setEnabled(true);
+}
+
+void DolphinMainWindow::disableStopAction()
+{
+    actionCollection()->action(QStringLiteral("stop"))->setEnabled(false);
+}
+
+void DolphinMainWindow::toggleSelectionMode()
+{
+    const bool checked = !m_activeViewContainer->isSelectionModeEnabled();
+
+    m_activeViewContainer->setSelectionModeEnabled(checked, actionCollection(), SelectionMode::BottomBar::Contents::GeneralContents);
+    actionCollection()->action(QStringLiteral("toggle_selection_mode"))->setChecked(checked);
+}
+
+void DolphinMainWindow::showFilterBar()
+{
+    m_activeViewContainer->setFilterBarVisible(true);
+}
+
+void DolphinMainWindow::toggleFilterBar()
+{
+    const bool checked = !m_activeViewContainer->isFilterBarVisible();
+    m_activeViewContainer->setFilterBarVisible(checked);
+
+    QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+    toggleFilterBarAction->setChecked(checked);
+}
+
+void DolphinMainWindow::toggleEditLocation()
+{
+    clearStatusBar();
+
+    QAction *action = actionCollection()->action(QStringLiteral("editable_location"));
+    KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigator();
+    urlNavigator->setUrlEditable(action->isChecked());
+}
+
+void DolphinMainWindow::replaceLocation()
+{
+    KUrlNavigator *navigator = m_activeViewContainer->urlNavigator();
+    QLineEdit *lineEdit = navigator->editor()->lineEdit();
+
+    // If the text field currently has focus and everything is selected,
+    // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
+    // and goes back to the view, just like how it was before this action was triggered the first time.
+    if (navigator->isUrlEditable() && lineEdit->hasFocus() && lineEdit->selectedText() == lineEdit->text()) {
+        navigator->setUrlEditable(false);
+        m_activeViewContainer->view()->setFocus();
+    } else {
+        navigator->setUrlEditable(true);
+        navigator->setFocus();
+        lineEdit->selectAll();
+    }
+}
+
+void DolphinMainWindow::togglePanelLockState()
+{
+    const bool newLockState = !GeneralSettings::lockPanels();
+    const auto childrenObjects = children();
+    for (QObject *child : childrenObjects) {
+        DolphinDockWidget *dock = qobject_cast<DolphinDockWidget *>(child);
+        if (dock) {
             dock->setLocked(newLockState);
         }
     }
 
+    DolphinPlacesModelSingleton::instance().placesModel()->setPanelsLocked(newLockState);
+
     GeneralSettings::setLockPanels(newLockState);
 }
 
+void DolphinMainWindow::slotTerminalPanelVisibilityChanged(bool visible)
+{
+    if (!visible && m_activeViewContainer) {
+        m_activeViewContainer->view()->setFocus();
+    }
+    // Putting focus to the Terminal is not handled here but in TerminalPanel::showEvent().
+}
+
 void DolphinMainWindow::slotPlacesPanelVisibilityChanged(bool visible)
 {
-    const int tabCount = m_viewTab.count();
-    for (int i = 0; i < tabCount; ++i) {
-        ViewTab& tab = m_viewTab[i];
-        Q_ASSERT(tab.primaryView);
-        tab.primaryView->urlNavigator()->setPlacesSelectorVisible(!visible);
-        if (tab.secondaryView) {
-            tab.secondaryView->urlNavigator()->setPlacesSelectorVisible(!visible);
-        }
+    if (!visible && m_activeViewContainer) {
+        m_activeViewContainer->view()->setFocus();
+        return;
     }
+    m_placesPanel->setFocus();
 }
 
 void DolphinMainWindow::goBack()
 {
-    KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
+    DolphinUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
     urlNavigator->goBack();
 
     if (urlNavigator->locationState().isEmpty()) {
@@ -934,1106 +1223,1576 @@ void DolphinMainWindow::goBack()
 
 void DolphinMainWindow::goForward()
 {
-    m_activeViewContainer->urlNavigator()->goForward();
+    m_activeViewContainer->urlNavigatorInternalWithHistory()->goForward();
 }
 
 void DolphinMainWindow::goUp()
 {
-    m_activeViewContainer->urlNavigator()->goUp();
+    m_activeViewContainer->urlNavigatorInternalWithHistory()->goUp();
 }
 
 void DolphinMainWindow::goHome()
 {
-    m_activeViewContainer->urlNavigator()->goHome();
+    m_activeViewContainer->urlNavigatorInternalWithHistory()->goHome();
 }
 
-void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
+void DolphinMainWindow::goBackInNewTab()
 {
-    // The default case (left button pressed) is handled in goBack().
-    if (buttons == Qt::MidButton) {
-        KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
-        const int index = urlNavigator->historyIndex() + 1;
-        openNewTab(urlNavigator->locationUrl(index));
-    }
+    const KUrlNavigator *urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
+    const int index = urlNavigator->historyIndex() + 1;
+    openNewTab(urlNavigator->locationUrl(index));
 }
 
-void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
+void DolphinMainWindow::goForwardInNewTab()
 {
-    // The default case (left button pressed) is handled in goForward().
-    if (buttons == Qt::MidButton) {
-        KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
-        const int index = urlNavigator->historyIndex() - 1;
-        openNewTab(urlNavigator->locationUrl(index));
-    }
+    const KUrlNavigator *urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
+    const int index = urlNavigator->historyIndex() - 1;
+    openNewTab(urlNavigator->locationUrl(index));
 }
 
-void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
+void DolphinMainWindow::goUpInNewTab()
 {
-    // The default case (left button pressed) is handled in goUp().
-    if (buttons == Qt::MidButton) {
-        openNewTab(activeViewContainer()->url().upUrl());
-    }
+    const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl();
+    openNewTab(KIO::upUrl(currentUrl));
 }
 
-void DolphinMainWindow::goHome(Qt::MouseButtons buttons)
+void DolphinMainWindow::goHomeInNewTab()
 {
-    // The default case (left button pressed) is handled in goHome().
-    if (buttons == Qt::MidButton) {
-        openNewTab(GeneralSettings::self()->homeUrl());
-    }
+    openNewTab(Dolphin::homeUrl());
 }
 
 void DolphinMainWindow::compareFiles()
 {
-    // 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
-    Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
-
-    KUrl urlA;
-    KUrl urlB;
-
-    KFileItemList items = m_viewTab[m_tabIndex].primaryView->view()->selectedItems();
-
-    switch (items.count()) {
-    case 0: {
-        Q_ASSERT(m_viewTab[m_tabIndex].secondaryView);
-        items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems();
-        Q_ASSERT(items.count() == 2);
-        urlA = items[0].url();
-        urlB = items[1].url();
-        break;
-    }
-
-    case 1: {
-        urlA = items[0].url();
-        Q_ASSERT(m_viewTab[m_tabIndex].secondaryView);
-        items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems();
-        Q_ASSERT(items.count() == 1);
-        urlB = items[0].url();
-        break;
+    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;
     }
 
-    case 2: {
-        urlA = items[0].url();
-        urlB = items[1].url();
-        break;
-    }
+    QUrl urlA = items.at(0).url();
+    QUrl urlB = items.at(1).url();
 
-    default: {
-        // may not happen: compareFiles may only get invoked if 2
-        // files are selected
-        Q_ASSERT(false);
-    }
-    }
-
-    QString command("kompare -c \"");
-    command.append(urlA.pathOrUrl());
+    QString command(QStringLiteral("kompare -c \""));
+    command.append(urlA.toDisplayString(QUrl::PreferLocalFile));
     command.append("\" \"");
-    command.append(urlB.pathOrUrl());
+    command.append(urlB.toDisplayString(QUrl::PreferLocalFile));
     command.append('\"');
-    KRun::runCommand(command, "Kompare", "kompare", this);
+
+    KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(command, this);
+    job->setDesktopName(QStringLiteral("org.kde.kompare"));
+    job->start();
 }
 
 void DolphinMainWindow::toggleShowMenuBar()
 {
     const bool visible = menuBar()->isVisible();
     menuBar()->setVisible(!visible);
-    if (visible) {
-        createControlButton();
-    } else {
-        deleteControlButton();
-    }
 }
 
-void DolphinMainWindow::openTerminal()
+QPointer<QAction> DolphinMainWindow::preferredSearchTool()
 {
-    QString dir(QDir::homePath());
+    m_searchTools.clear();
 
-    // 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.
-    KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
+    KService::Ptr kfind = KService::serviceByDesktopName(QStringLiteral("org.kde.kfind"));
 
-    //If the URL is local after the above conversion, set the directory.
-    if (url.isLocalFile()) {
-        dir = url.toLocalFile();
+    if (!kfind) {
+        return nullptr;
     }
 
-    KToolInvocation::invokeTerminal(QString(), dir);
-}
+    auto *action = new QAction(QIcon::fromTheme(kfind->icon()), kfind->name(), this);
 
-void DolphinMainWindow::editSettings()
-{
-    if (!m_settingsDialog) {
-        DolphinViewContainer* container = activeViewContainer();
-        container->view()->writeSettings();
+    connect(action, &QAction::triggered, this, [this, kfind] {
+        auto *job = new KIO::ApplicationLauncherJob(kfind);
+        job->setUrls({m_activeViewContainer->url()});
+        job->start();
+    });
 
-        const KUrl url = container->url();
-        DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
-        connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(refreshViews()));
-        settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
-        settingsDialog->show();
-        m_settingsDialog = settingsDialog;
-    } else {
-        m_settingsDialog.data()->raise();
-    }
+    return action;
 }
 
-void DolphinMainWindow::setActiveTab(int index)
+void DolphinMainWindow::updateOpenPreferredSearchToolAction()
 {
-    Q_ASSERT(index >= 0);
-    Q_ASSERT(index < m_viewTab.count());
-    if (index == m_tabIndex) {
+    QAction *openPreferredSearchTool = actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
+    if (!openPreferredSearchTool) {
         return;
     }
-
-    // hide current tab content
-    ViewTab& hiddenTab = m_viewTab[m_tabIndex];
-    hiddenTab.isPrimaryViewActive = hiddenTab.primaryView->isActive();
-    hiddenTab.primaryView->setActive(false);
-    if (hiddenTab.secondaryView) {
-        hiddenTab.secondaryView->setActive(false);
-    }
-    QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
-    splitter->hide();
-    m_centralWidgetLayout->removeWidget(splitter);
-
-    // show active tab content
-    m_tabIndex = index;
-
-    ViewTab& viewTab = m_viewTab[index];
-    m_centralWidgetLayout->addWidget(viewTab.splitter, 1);
-    viewTab.primaryView->show();
-    if (viewTab.secondaryView) {
-        viewTab.secondaryView->show();
-    }
-    viewTab.splitter->show();
-
-    if (!viewTab.wasActive) {
-        viewTab.wasActive = true;
-
-        // If the tab has not been activated yet the size of the KItemListView is
-        // undefined and results in an unwanted animation. To prevent this a
-        // reloading of the directory gets triggered.
-        viewTab.primaryView->view()->reload();
-        if (viewTab.secondaryView) {
-            viewTab.secondaryView->view()->reload();
+    QPointer<QAction> tool = preferredSearchTool();
+    if (tool) {
+        openPreferredSearchTool->setVisible(true);
+        openPreferredSearchTool->setText(i18nc("@action:inmenu Tools", "Open %1", tool->text()));
+        // Only override with the app icon if it is the default, i.e. the user hasn't configured one manually
+        // https://bugs.kde.org/show_bug.cgi?id=442815
+        if (openPreferredSearchTool->icon().name() == QLatin1String("search")) {
+            openPreferredSearchTool->setIcon(tool->icon());
         }
+    } else {
+        openPreferredSearchTool->setVisible(false);
+        // still visible in Shortcuts configuration window
+        openPreferredSearchTool->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
+        openPreferredSearchTool->setIcon(QIcon::fromTheme(QStringLiteral("search")));
     }
+}
 
-    setActiveViewContainer(viewTab.isPrimaryViewActive ? viewTab.primaryView :
-                                                         viewTab.secondaryView);
+void DolphinMainWindow::openPreferredSearchTool()
+{
+    QPointer<QAction> tool = preferredSearchTool();
+    if (tool) {
+        tool->trigger();
+    }
 }
 
-void DolphinMainWindow::closeTab()
+void DolphinMainWindow::openTerminal()
 {
-    closeTab(m_tabBar->currentIndex());
+    openTerminalJob(m_activeViewContainer->url());
 }
 
-void DolphinMainWindow::closeTab(int index)
+void DolphinMainWindow::openTerminalHere()
 {
-    Q_ASSERT(index >= 0);
-    Q_ASSERT(index < m_viewTab.count());
-    if (m_viewTab.count() == 1) {
-        // the last tab may never get closed
-        return;
-    }
+    QList<QUrl> urls = {};
 
-    if (index == m_tabIndex) {
-        // The tab that should be closed is the active tab. Activate the
-        // previous tab before closing the tab.
-        m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
+    const auto selectedItems = m_activeViewContainer->view()->selectedItems();
+    for (const KFileItem &item : selectedItems) {
+        QUrl url = item.targetUrl();
+        if (item.isFile()) {
+            url.setPath(QFileInfo(url.path()).absolutePath());
+        }
+        if (!urls.contains(url)) {
+            urls << url;
+        }
     }
-    rememberClosedTab(index);
 
-    // delete tab
-    m_viewTab[index].primaryView->deleteLater();
-    if (m_viewTab[index].secondaryView) {
-        m_viewTab[index].secondaryView->deleteLater();
+    // No items are selected. Open a terminal window for the current location.
+    if (urls.count() == 0) {
+        openTerminal();
+        return;
     }
-    m_viewTab[index].splitter->deleteLater();
-    m_viewTab.erase(m_viewTab.begin() + index);
-
-    m_tabBar->blockSignals(true);
-    m_tabBar->removeTab(index);
 
-    if (m_tabIndex > index) {
-        m_tabIndex--;
-        Q_ASSERT(m_tabIndex >= 0);
+    if (urls.count() > 5) {
+        QString question = i18np("Are you sure you want to open 1 terminal window?", "Are you sure you want to open %1 terminal windows?", urls.count());
+        const int answer = KMessageBox::warningContinueCancel(
+            this,
+            question,
+            {},
+            KGuiItem(i18ncp("@action:button", "Open %1 Terminal", "Open %1 Terminals", urls.count()), QStringLiteral("utilities-terminal")),
+            KStandardGuiItem::cancel(),
+            QStringLiteral("ConfirmOpenManyTerminals"));
+        if (answer != KMessageBox::PrimaryAction && answer != KMessageBox::Continue) {
+            return;
+        }
     }
 
-    // if only one tab is left, also remove the tab entry so that
-    // closing the last tab is not possible
-    if (m_viewTab.count() == 1) {
-        m_tabBar->removeTab(0);
-        actionCollection()->action("close_tab")->setEnabled(false);
-    } else {
-        m_tabBar->blockSignals(false);
+    for (const QUrl &url : std::as_const(urls)) {
+        openTerminalJob(url);
     }
 }
 
-void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
+void DolphinMainWindow::openTerminalJob(const QUrl &url)
 {
-    KMenu menu(this);
-
-    QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
-    newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
-
-    QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
-
-    QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
-
-    QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
-    closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
-    QAction* selectedAction = menu.exec(pos);
-    if (selectedAction == newTabAction) {
-        const ViewTab& tab = m_viewTab[index];
-        Q_ASSERT(tab.primaryView);
-        const KUrl url = tab.secondaryView && tab.secondaryView->isActive() ?
-                         tab.secondaryView->url() : tab.primaryView->url();
-        openNewTab(url);
-        m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
-    } else if (selectedAction == detachTabAction) {
-        const QString separator(QLatin1Char(' '));
-        QString command = QLatin1String("dolphin");
-
-        const ViewTab& tab = m_viewTab[index];
-        Q_ASSERT(tab.primaryView);
+    if (url.isLocalFile()) {
+        auto job = new KTerminalLauncherJob(QString());
+        job->setWorkingDirectory(url.toLocalFile());
+        job->start();
+        return;
+    }
 
-        command += separator + tab.primaryView->url().url();
-        if (tab.secondaryView) {
-            command += separator + tab.secondaryView->url().url();
-            command += separator + QLatin1String("-split");
-        }
+    // Not a local file, with protocol Class ":local", try stat'ing
+    if (KProtocolInfo::protocolClass(url.scheme()) == QLatin1String(":local")) {
+        KIO::StatJob *job = KIO::mostLocalUrl(url);
+        KJobWidgets::setWindow(job, this);
+        connect(job, &KJob::result, this, [job]() {
+            QUrl statUrl;
+            if (!job->error()) {
+                statUrl = job->mostLocalUrl();
+            }
 
-        KRun::runCommand(command, this);
+            auto job = new KTerminalLauncherJob(QString());
+            job->setWorkingDirectory(statUrl.isLocalFile() ? statUrl.toLocalFile() : QDir::homePath());
+            job->start();
+        });
 
-        closeTab(index);
-    } else if (selectedAction == closeOtherTabsAction) {
-        const int count = m_tabBar->count();
-        for (int i = 0; i < index; ++i) {
-            closeTab(0);
-        }
-        for (int i = index + 1; i < count; ++i) {
-            closeTab(1);
-        }
-    } else if (selectedAction == closeTabAction) {
-        closeTab(index);
+        return;
     }
-}
-
-void DolphinMainWindow::slotTabMoved(int from, int to)
-{
-    m_viewTab.move(from, to);
-    m_tabIndex = m_tabBar->currentIndex();
-}
 
-void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& canDecode)
-{
-    canDecode = KUrl::List::canDecode(event->mimeData());
+    // Nothing worked, just use $HOME
+    auto job = new KTerminalLauncherJob(QString());
+    job->setWorkingDirectory(QDir::homePath());
+    job->start();
 }
 
-void DolphinMainWindow::handleUrl(const KUrl& url)
+void DolphinMainWindow::editSettings()
 {
-    delete m_lastHandleUrlStatJob;
-    m_lastHandleUrlStatJob = 0;
-
-    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->ui()) {
-            m_lastHandleUrlStatJob->ui()->setWindow(this);
-        }
-        connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)),
-                this, SLOT(slotHandleUrlStatFinished(KJob*)));
+    if (!m_settingsDialog) {
+        DolphinViewContainer *container = activeViewContainer();
+        container->view()->writeSettings();
 
+        const QUrl url = container->url();
+        DolphinSettingsDialog *settingsDialog = new DolphinSettingsDialog(url, this, actionCollection());
+        connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
+        connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, &DolphinUrlNavigatorsController::slotReadSettings);
+        settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
+        settingsDialog->show();
+        m_settingsDialog = settingsDialog;
     } else {
-        new KRun(url, this); // Automatically deletes itself after being finished
+        m_settingsDialog.data()->raise();
     }
 }
 
-void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
+void DolphinMainWindow::handleUrl(const QUrl &url)
 {
-    m_lastHandleUrlStatJob = 0;
-    const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
-    const KUrl url = static_cast<KIO::StatJob*>(job)->url();
-    if (entry.isDir()) {
+    delete m_lastHandleUrlOpenJob;
+    m_lastHandleUrlOpenJob = nullptr;
+
+    if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
         activeViewContainer()->setUrl(url);
     } else {
-        new KRun(url, this);  // Automatically deletes itself after being finished
-    }
-}
+        m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url);
+        m_lastHandleUrlOpenJob->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+        m_lastHandleUrlOpenJob->setShowOpenOrExecuteDialog(true);
+
+        connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this, [this, url](const QString &mimetype) {
+            if (mimetype == QLatin1String("inode/directory")) {
+                // If it's a dir, we'll take it from here
+                m_lastHandleUrlOpenJob->kill();
+                m_lastHandleUrlOpenJob = nullptr;
+                activeViewContainer()->setUrl(url);
+            }
+        });
 
-void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
-{
-    const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
-    if (!urls.isEmpty() && tab != -1) {
-        const ViewTab& viewTab = m_viewTab[tab];
-        const DolphinView* view = viewTab.isPrimaryViewActive ? viewTab.primaryView->view()
-                                                              : viewTab.secondaryView->view();
-        const QString error = DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event);
-        if (!error.isEmpty()) {
-            activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
-        }
+        connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::result, this, [this]() {
+            m_lastHandleUrlOpenJob = nullptr;
+        });
+
+        m_lastHandleUrlOpenJob->start();
     }
 }
 
 void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
 {
-    newFileMenu()->setEnabled(isFolderWritable);
+    // 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"));
+    // When the menu is disabled, actions in it are disabled later in the event loop, and we need to set the disabled reason after that.
+    QTimer::singleShot(0, this, [this]() {
+        m_disabledActionNotifier->setDisabledReason(actionCollection()->action(QStringLiteral("create_file")),
+                                                    i18nc("@info", "Cannot create new file: You do not have permission to create items in this folder."));
+        m_disabledActionNotifier->setDisabledReason(actionCollection()->action(QStringLiteral("create_dir")),
+                                                    i18nc("@info", "Cannot create new folder: You do not have permission to create items in this folder."));
+    });
 }
 
-void DolphinMainWindow::openContextMenu(const QPoint& pos,
-                                        const KFileItem& item,
-                                        const KUrl& url,
-                                        const QList<QAction*>& customActions)
+void DolphinMainWindow::openContextMenu(const QPoint &pos, const KFileItem &item, const KFileItemList &selectedItems, const QUrl &url)
 {
-    QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
-    contextMenu.data()->setCustomActions(customActions);
-    const DolphinContextMenu::Command command = contextMenu.data()->open();
-
-    switch (command) {
-    case DolphinContextMenu::OpenParentFolderInNewWindow: {
-        KRun::run("dolphin", KUrl::List() << item.url().upUrl(), this);
-        break;
-    }
-
-    case DolphinContextMenu::OpenParentFolderInNewTab:
-        openNewTab(item.url().upUrl());
-        break;
+    QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, item, selectedItems, url, &m_fileItemActions);
+    contextMenu->exec(pos);
 
-    case DolphinContextMenu::None:
-    default:
-        break;
+    // Delete the menu, unless it has been deleted in its own nested event loop already.
+    if (contextMenu) {
+        contextMenu->deleteLater();
     }
-
-    delete contextMenu.data();
 }
 
-void DolphinMainWindow::updateControlMenu()
+QMenu *DolphinMainWindow::createPopupMenu()
 {
-    KMenu* menu = qobject_cast<KMenu*>(sender());
-    Q_ASSERT(menu);
-
-    // All actions get cleared by KMenu::clear(). The sub-menus are deleted
-    // by connecting to the aboutToHide() signal from the parent-menu.
-    menu->clear();
+    QMenu *menu = KXmlGuiWindow::createPopupMenu();
 
-    KActionCollection* ac = actionCollection();
+    menu->addSeparator();
+    menu->addAction(actionCollection()->action(QStringLiteral("lock_panels")));
 
-    // Add "Edit" actions
-    bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
-                 addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) |
-                 addActionToMenu(ac->action("select_all"), menu) |
-                 addActionToMenu(ac->action("invert_selection"), menu);
+    return menu;
+}
 
-    if (added) {
-        menu->addSeparator();
+void DolphinMainWindow::updateHamburgerMenu()
+{
+    KActionCollection *ac = actionCollection();
+    auto hamburgerMenu = static_cast<KHamburgerMenu *>(ac->action(KStandardAction::name(KStandardAction::HamburgerMenu)));
+    auto menu = hamburgerMenu->menu();
+    if (!menu) {
+        menu = new QMenu(this);
+        hamburgerMenu->setMenu(menu);
+        hamburgerMenu->hideActionsOf(ac->action(QStringLiteral("basic_actions"))->menu());
+        hamburgerMenu->hideActionsOf(qobject_cast<KToolBarPopupAction *>(ac->action(QStringLiteral("zoom")))->popupMenu());
+    } else {
+        menu->clear();
     }
+    const QList<QAction *> toolbarActions = toolBar()->actions();
 
-    // Add "View" actions
-    if (!GeneralSettings::showZoomSlider()) {
-        addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
-        addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
+    if (!toolBar()->isVisible()) {
+        // If neither the menu bar nor the toolbar are visible, these actions should be available.
+        menu->addAction(ac->action(KStandardAction::name(KStandardAction::ShowMenubar)));
+        menu->addAction(toolBarMenuAction());
         menu->addSeparator();
     }
 
-    added = addActionToMenu(ac->action("view_mode"), menu) |
-            addActionToMenu(ac->action("sort"), menu) |
-            addActionToMenu(ac->action("additional_info"), menu) |
-            addActionToMenu(ac->action("show_preview"), menu) |
-            addActionToMenu(ac->action("show_in_groups"), menu) |
-            addActionToMenu(ac->action("show_hidden_files"), menu);
+    // This group of actions (until the next separator) contains all the most basic actions
+    // necessary to use Dolphin effectively.
+    menu->addAction(ac->action(QStringLiteral("go_back")));
+    menu->addAction(ac->action(QStringLiteral("go_forward")));
 
-    if (added) {
-        menu->addSeparator();
+    menu->addMenu(m_newFileMenu->menu());
+    if (!toolBar()->isVisible() || !toolbarActions.contains(ac->action(QStringLiteral("toggle_selection_mode_tool_bar")))) {
+        menu->addAction(ac->action(QStringLiteral("toggle_selection_mode")));
     }
-
-    added = addActionToMenu(ac->action("split_view"), menu) |
-            addActionToMenu(ac->action("reload"), menu) |
-            addActionToMenu(ac->action("view_properties"), menu);
-    if (added) {
-        menu->addSeparator();
+    menu->addAction(ac->action(QStringLiteral("basic_actions")));
+    menu->addAction(ac->action(KStandardAction::name(KStandardAction::Undo)));
+    if (!toolBar()->isVisible()
+        || (!toolbarActions.contains(ac->action(QStringLiteral("toggle_search")))
+            && !toolbarActions.contains(ac->action(QStringLiteral("open_preferred_search_tool"))))) {
+        menu->addAction(ac->action(KStandardAction::name(KStandardAction::Find)));
+        // This way a search action will only be added if none of the three available
+        // search actions is present on the toolbar.
+    }
+    if (!toolBar()->isVisible() || !toolbarActions.contains(ac->action(QStringLiteral("toggle_filter")))) {
+        menu->addAction(ac->action(QStringLiteral("show_filter_bar")));
+        // This way a filter action will only be added if none of the two available
+        // filter actions is present on the toolbar.
     }
-
-    addActionToMenu(ac->action("panels"), menu);
-    KMenu* locationBarMenu = new KMenu(i18nc("@action:inmenu", "Location Bar"), menu);
-    locationBarMenu->addAction(ac->action("editable_location"));
-    locationBarMenu->addAction(ac->action("replace_location"));
-    menu->addMenu(locationBarMenu);
-
     menu->addSeparator();
 
-    // Add "Go" menu
-    KMenu* goMenu = new KMenu(i18nc("@action:inmenu", "Go"), menu);
-    connect(menu, SIGNAL(aboutToHide()), goMenu, SLOT(deleteLater()));
-    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("closed_tabs"));
-    menu->addMenu(goMenu);
-
-    // Add "Tool" menu
-    KMenu* toolsMenu = new KMenu(i18nc("@action:inmenu", "Tools"), menu);
-    connect(menu, SIGNAL(aboutToHide()), toolsMenu, SLOT(deleteLater()));
-    toolsMenu->addAction(ac->action("show_filter_bar"));
-    toolsMenu->addAction(ac->action("compare_files"));
-    toolsMenu->addAction(ac->action("open_terminal"));
-    toolsMenu->addAction(ac->action("change_remote_encoding"));
-    menu->addMenu(toolsMenu);
-
-    // 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);
-
-    // Add "Help" menu
-    KMenu* helpMenu = new KMenu(i18nc("@action:inmenu", "Help"), menu);
-    connect(menu, SIGNAL(aboutToHide()), helpMenu, SLOT(deleteLater()));
-    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::HelpContents)));
-    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::WhatsThis)));
-    helpMenu->addSeparator();
-    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::ReportBug)));
-    helpMenu->addSeparator();
-    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage)));
-    helpMenu->addSeparator();
-    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutApp)));
-    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutKDE)));
-    menu->addMenu(helpMenu);
-
+    // The second group of actions (up until the next separator) contains actions for opening
+    // additional views to interact with the file system.
+    menu->addAction(ac->action(QStringLiteral("file_new")));
+    menu->addAction(ac->action(QStringLiteral("new_tab")));
+    if (ac->action(QStringLiteral("undo_close_tab"))->isEnabled()) {
+        menu->addAction(ac->action(QStringLiteral("closed_tabs")));
+    }
+    menu->addAction(ac->action(QStringLiteral("open_terminal")));
     menu->addSeparator();
-    addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ShowMenubar)), menu);
-}
 
-void DolphinMainWindow::updateToolBar()
-{
-    if (!menuBar()->isVisible()) {
-        createControlButton();
+    // The third group contains actions to change what one sees in the view
+    // and to change the more general UI.
+    if (!toolBar()->isVisible()
+        || ((!toolbarActions.contains(ac->action(QStringLiteral("icons"))) && !toolbarActions.contains(ac->action(QStringLiteral("compact")))
+             && !toolbarActions.contains(ac->action(QStringLiteral("details"))) && !toolbarActions.contains(ac->action(QStringLiteral("view_mode"))))
+            && !toolbarActions.contains(ac->action(QStringLiteral("view_settings"))))) {
+        menu->addAction(ac->action(QStringLiteral("view_mode")));
+    }
+    if (!toolBar()->isVisible() || !toolbarActions.contains(ac->action(QStringLiteral("view_settings")))) {
+           menu->addAction(ac->action(QStringLiteral("show_hidden_files")));
+           menu->addAction(ac->action(QStringLiteral("sort")));
+           menu->addAction(ac->action(QStringLiteral("group")));
+           menu->addAction(ac->action(QStringLiteral("additional_info")));
+           if (!GeneralSettings::showStatusBar() || !GeneralSettings::showZoomSlider()) {
+                       menu->addAction(ac->action(QStringLiteral("zoom")));
+               }
     }
+    menu->addAction(ac->action(QStringLiteral("panels")));
+
+    // The "Configure" menu is not added to the actionCollection() because there is hardly
+    // a good reason for users to put it on their toolbar.
+    auto configureMenu = menu->addMenu(QIcon::fromTheme(QStringLiteral("configure")), i18nc("@action:inmenu menu for configure actions", "Configure"));
+    configureMenu->addAction(ac->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage)));
+    configureMenu->addAction(ac->action(KStandardAction::name(KStandardAction::KeyBindings)));
+    configureMenu->addAction(ac->action(KStandardAction::name(KStandardAction::ConfigureToolbars)));
+    configureMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Preferences)));
+    hamburgerMenu->hideActionsOf(configureMenu);
 }
 
-void DolphinMainWindow::slotControlButtonDeleted()
+void DolphinMainWindow::slotPlaceActivated(const QUrl &url)
 {
-    m_controlButton = 0;
-    m_updateToolBarTimer->start();
+    DolphinViewContainer *view = activeViewContainer();
+
+    if (view->url() == url) {
+        view->clearFilterBar(); // Fixes bug 259382.
+
+        // 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();
+
+        m_activeViewContainer->view()->setFocus(); // We always want the focus on the view after activating a place.
+    } else {
+        view->disableUrlNavigatorSelectionRequests();
+        changeUrl(url);
+        view->enableUrlNavigatorSelectionRequests();
+    }
 }
 
-void DolphinMainWindow::slotPanelErrorMessage(const QString& error)
+void DolphinMainWindow::closedTabsCountChanged(unsigned int count)
 {
-    activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
+    actionCollection()->action(QStringLiteral("undo_close_tab"))->setEnabled(count > 0);
 }
 
-void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
+void DolphinMainWindow::activeViewChanged(DolphinViewContainer *viewContainer)
 {
+    DolphinViewContainer *oldViewContainer = m_activeViewContainer;
     Q_ASSERT(viewContainer);
-    Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) ||
-             (viewContainer == m_viewTab[m_tabIndex].secondaryView));
-    if (m_activeViewContainer == viewContainer) {
-        return;
-    }
 
-    m_activeViewContainer->setActive(false);
     m_activeViewContainer = viewContainer;
 
-    // Activating the view container might trigger a recursive setActiveViewContainer() call
-    // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
-    // disconnect the activated() signal in this case:
-    disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
-    m_activeViewContainer->setActive(true);
-    connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
+    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->urlNavigatorInternalWithHistory()->disconnect(this);
+        auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators")));
+        navigators->primaryUrlNavigator()->disconnect(this);
+        if (auto secondaryUrlNavigator = navigators->secondaryUrlNavigator()) {
+            secondaryUrlNavigator->disconnect(this);
+        }
+        oldViewContainer->disconnect(m_diskSpaceUsageMenu);
+
+        // except the requestItemInfo so that on hover the information panel can still be updated
+        connect(oldViewContainer->view(), &DolphinView::requestItemInfo, this, &DolphinMainWindow::requestItemInfo);
+
+        // Disconnect other slots.
+        disconnect(oldViewContainer,
+                   &DolphinViewContainer::selectionModeChanged,
+                   actionCollection()->action(QStringLiteral("toggle_selection_mode")),
+                   &QAction::setChecked);
+    }
+
+    connectViewSignals(viewContainer);
 
     m_actionHandler->setCurrentView(viewContainer->view());
 
     updateHistory();
-    updateEditActions();
+    updateFileAndEditActions();
+    updatePasteAction();
     updateViewActions();
     updateGoActions();
+    updateSearchAction();
+    connect(m_diskSpaceUsageMenu,
+            &DiskSpaceUsageMenu::showMessage,
+            viewContainer,
+            [viewContainer](const QString &message, KMessageWidget::MessageType messageType) {
+                viewContainer->showMessage(message, messageType);
+            });
+    connect(m_diskSpaceUsageMenu, &DiskSpaceUsageMenu::showInstallationProgress, viewContainer, &DolphinViewContainer::showProgress);
+
+    const QUrl url = viewContainer->url();
+    Q_EMIT urlChanged(url);
+    Q_EMIT selectionChanged(m_activeViewContainer->view()->selectedItems());
+}
+
+void DolphinMainWindow::tabCountChanged(int count)
+{
+    const bool enableTabActions = (count > 1);
+    for (int i = 0; i < MaxActivateTabShortcuts; ++i) {
+        actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i))->setEnabled(enableTabActions);
+    }
+    actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions);
+    actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
+    actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
+}
 
-    const KUrl url = m_activeViewContainer->url();
-    setUrlAsCaption(url);
-    if (m_viewTab.count() > 1) {
-        m_tabBar->setTabText(m_tabIndex, tabName(url));
-        m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url)));
+void DolphinMainWindow::updateWindowTitle()
+{
+    const QString newTitle = m_activeViewContainer->captionWindowTitle();
+    if (windowTitle() != newTitle) {
+        setWindowTitle(newTitle);
     }
+}
+
+void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString &mountPath)
+{
+    connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+        setViewsToHomeIfMountPathOpen(mountPath);
+    });
 
-    emit urlChanged(url);
+    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsChildOf(mountPath)) {
+        m_tearDownFromPlacesRequested = true;
+        m_terminalPanel->goHome();
+        // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
+    } else {
+        m_placesPanel->proceedWithTearDown();
+    }
 }
 
-DolphinViewContainer* DolphinMainWindow::createViewContainer(const KUrl& url, QWidget* parent)
+void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString &mountPath)
 {
-    DolphinViewContainer* container = new DolphinViewContainer(url, parent);
+    connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+        setViewsToHomeIfMountPathOpen(mountPath);
+    });
+
+    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsChildOf(mountPath)) {
+        m_tearDownFromPlacesRequested = false;
+        m_terminalPanel->goHome();
+    }
+}
 
-    // The places-selector from the URL navigator should only be shown
-    // if the places dock is invisible
-    QDockWidget* placesDock = findChild<QDockWidget*>("placesDock");
-    container->urlNavigator()->setPlacesSelectorVisible(!placesDock || !placesDock->isVisible());
+void DolphinMainWindow::slotKeyBindings()
+{
+    KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
+    dialog.addCollection(actionCollection());
+    if (m_terminalPanel) {
+        KActionCollection *konsolePartActionCollection = m_terminalPanel->actionCollection();
+        if (konsolePartActionCollection) {
+            dialog.addCollection(konsolePartActionCollection, QStringLiteral("KonsolePart"));
+        }
+    }
+    dialog.configure();
+}
 
-    return container;
+void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString &mountPath)
+{
+    const QVector<DolphinViewContainer *> theViewContainers = viewContainers();
+    for (DolphinViewContainer *viewContainer : theViewContainers) {
+        if (!viewContainer) {
+            continue;
+        }
+        const auto viewPath = viewContainer->url().toLocalFile();
+        if (viewPath.startsWith(mountPath + QLatin1String("/")) || viewPath == mountPath) {
+            viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+        }
+    }
+    disconnect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, nullptr, nullptr);
 }
 
 void DolphinMainWindow::setupActions()
 {
+    auto hamburgerMenuAction = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
+
     // setup 'File' menu
-    m_newFileMenu = new DolphinNewFileMenu(this);
-    KMenu* menu = m_newFileMenu->menu();
+    m_newFileMenu = new DolphinNewFileMenu(nullptr, nullptr, this);
+    actionCollection()->addAction(QStringLiteral("new_menu"), m_newFileMenu);
+    QMenu *menu = m_newFileMenu->menu();
     menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
-    menu->setIcon(KIcon("document-new"));
-    connect(menu, SIGNAL(aboutToShow()),
-            this, SLOT(updateNewMenu()));
+    menu->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
+    m_newFileMenu->setPopupMode(QToolButton::InstantPopup);
+    connect(menu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateNewMenu);
 
-    KAction* newWindow = actionCollection()->addAction("new_window");
-    newWindow->setIcon(KIcon("window-new"));
+    QAction *newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
     newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
-    newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
-    connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
-
-    KAction* newTab = actionCollection()->addAction("new_tab");
-    newTab->setIcon(KIcon("tab-new"));
+    newWindow->setToolTip(i18nc("@info", "Open a new Dolphin window"));
+    newWindow->setWhatsThis(xi18nc("@info:whatsthis",
+                                   "This opens a new "
+                                   "window just like this one with the current location."
+                                   "<nl/>You can drag and drop items between windows."));
+    newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
+
+    QAction *newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
+    newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
     newTab->setText(i18nc("@action:inmenu File", "New Tab"));
-    newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N));
-    connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
-
-    KAction* closeTab = actionCollection()->addAction("close_tab");
-    closeTab->setIcon(KIcon("tab-close"));
+    newTab->setWhatsThis(xi18nc("@info:whatsthis",
+                                "This opens a new "
+                                "<emphasis>Tab</emphasis> with the current location."
+                                "<nl/>Tabs allow you to quickly switch between multiple locations and views within this window. "
+                                "You can drag and drop items between tabs."));
+    actionCollection()->setDefaultShortcut(newTab, Qt::CTRL | Qt::Key_T);
+    connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab);
+
+    QAction *addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places"));
+    addToPlaces->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
+    addToPlaces->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
+    addToPlaces->setWhatsThis(xi18nc("@info:whatsthis",
+                                     "This adds the selected folder "
+                                     "to the Places panel."));
+    connect(addToPlaces, &QAction::triggered, this, &DolphinMainWindow::addToPlaces);
+
+    QAction *closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection());
     closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
-    closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
-    closeTab->setEnabled(false);
-    connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
+    closeTab->setToolTip(i18nc("@info", "Close Tab"));
+    closeTab->setWhatsThis(i18nc("@info:whatsthis",
+                                 "This closes the "
+                                 "currently viewed tab. If no more tabs are left, this closes "
+                                 "the whole window instead."));
 
-    KStandardAction::quit(this, SLOT(quit()), actionCollection());
+    QAction *quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
+    quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window."));
 
     // setup 'Edit' menu
-    KStandardAction::undo(this,
-                          SLOT(undo()),
-                          actionCollection());
-
-    // need to remove shift+del from cut action, else the shortcut for deletejob
-    // doesn't work
-    KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
-    KShortcut cutShortcut = cut->shortcut();
-    cutShortcut.remove(Qt::SHIFT | Qt::Key_Delete, KShortcut::KeepEmpty);
-    cut->setShortcut(cutShortcut);
-    KStandardAction::copy(this, SLOT(copy()), actionCollection());
-    KAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
+    KStandardAction::undo(this, &DolphinMainWindow::undo, actionCollection());
+
+    // i18n: This will be the last paragraph for the whatsthis for all three:
+    // Cut, Copy and Paste
+    const QString cutCopyPastePara = xi18nc("@info:whatsthis",
+                                            "<para><emphasis>Cut, "
+                                            "Copy</emphasis> and <emphasis>Paste</emphasis> work between many "
+                                            "applications and are among the most used commands. That's why their "
+                                            "<emphasis>keyboard shortcuts</emphasis> are prominently placed right "
+                                            "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, "
+                                            "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>");
+    QAction *cutAction = KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection());
+    m_actionTextHelper->registerTextWhenNothingIsSelected(cutAction, i18nc("@action", "Cut…"));
+    cutAction->setWhatsThis(xi18nc("@info:whatsthis cut",
+                                   "This copies the items "
+                                   "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>"
+                                   "Use the <emphasis>Paste</emphasis> action afterwards to copy them from "
+                                   "the clipboard to a new location. The items will be removed from their "
+                                   "initial location.")
+                            + cutCopyPastePara);
+    QAction *copyAction = KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection());
+    m_actionTextHelper->registerTextWhenNothingIsSelected(copyAction, i18nc("@action", "Copy…"));
+    copyAction->setWhatsThis(xi18nc("@info:whatsthis copy",
+                                    "This copies the "
+                                    "items in your current selection to the <emphasis>clipboard</emphasis>."
+                                    "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them "
+                                    "from the clipboard to a new location.")
+                             + cutCopyPastePara);
+    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"));
-
-    KStandardAction::find(this, SLOT(find()), actionCollection());
-
-    KAction* selectAll = actionCollection()->addAction("select_all");
-    selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
-    selectAll->setShortcut(Qt::CTRL | Qt::Key_A);
-    connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
-
-    KAction* invertSelection = actionCollection()->addAction("invert_selection");
+    paste->setWhatsThis(xi18nc("@info:whatsthis paste",
+                               "This copies the items from "
+                               "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>"
+                               "If the items were added to the clipboard by the <emphasis>Cut</emphasis> "
+                               "action they are removed from their old location.")
+                        + cutCopyPastePara);
+
+    QAction *copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
+    copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Other View"));
+    m_actionTextHelper->registerTextWhenNothingIsSelected(copyToOtherViewAction, i18nc("@action:inmenu", "Copy to Other View…"));
+    copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy",
+                                               "This copies the selected items from "
+                                               "the view in focus to the other view. "
+                                               "(Only available while in Split View mode.)"));
+    copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
+    copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to Other View"));
+    actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT | Qt::Key_F5);
+    connect(copyToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::copyToInactiveSplitView);
+
+    QAction *moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
+    moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Other View"));
+    m_actionTextHelper->registerTextWhenNothingIsSelected(moveToOtherViewAction, i18nc("@action:inmenu", "Move to Other View…"));
+    moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move",
+                                               "This moves the selected items from "
+                                               "the view in focus to the other view. "
+                                               "(Only available while in Split View mode.)"));
+    moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
+    moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to Other View"));
+    actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT | Qt::Key_F6);
+    connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToInactiveSplitView);
+
+    QAction *showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
+    showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter…"));
+    showFilterBar->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
+    showFilterBar->setWhatsThis(xi18nc("@info:whatsthis",
+                                       "This opens the "
+                                       "<emphasis>Filter Bar</emphasis> at the bottom of the window.<nl/> "
+                                       "There you can enter text to filter the files and folders currently displayed. "
+                                       "Only those that contain the text in their name will be kept in view."));
+    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);
+
+    // toggle_filter acts as a copy of the main showFilterBar to be used mainly
+    // in the toolbar, with no default shortcut attached, to avoid messing with
+    // existing workflows (filter bar always open and Ctrl-I to focus)
+    QAction *toggleFilter = actionCollection()->addAction(QStringLiteral("toggle_filter"));
+    toggleFilter->setText(i18nc("@action:inmenu", "Toggle Filter Bar"));
+    toggleFilter->setIconText(i18nc("@action:intoolbar", "Filter"));
+    toggleFilter->setIcon(showFilterBar->icon());
+    toggleFilter->setToolTip(showFilterBar->toolTip());
+    toggleFilter->setWhatsThis(showFilterBar->whatsThis());
+    toggleFilter->setCheckable(true);
+    connect(toggleFilter, &QAction::triggered, this, &DolphinMainWindow::toggleFilterBar);
+
+    QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
+    searchAction->setText(i18n("Search…"));
+    searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
+    searchAction->setWhatsThis(xi18nc("@info:whatsthis find",
+                                      "<para>This helps you "
+                                      "find files and folders by opening a <emphasis>search bar</emphasis>. "
+                                      "There you can enter search terms and specify settings to find the "
+                                      "items you are looking for.</para>"));
+
+    // toggle_search acts as a copy of the main searchAction to be used mainly
+    // in the toolbar, with no default shortcut attached, to avoid messing with
+    // existing workflows (search bar always open and Ctrl-F to focus)
+    QAction *toggleSearchAction = actionCollection()->addAction(QStringLiteral("toggle_search"));
+    toggleSearchAction->setText(i18nc("@action:inmenu", "Toggle Search Bar"));
+    toggleSearchAction->setIconText(i18nc("@action:intoolbar", "Search"));
+    toggleSearchAction->setIcon(searchAction->icon());
+    toggleSearchAction->setToolTip(searchAction->toolTip());
+    toggleSearchAction->setWhatsThis(searchAction->whatsThis());
+    toggleSearchAction->setCheckable(true);
+    connect(toggleSearchAction, &QAction::triggered, this, [this](bool checked) {
+        if (checked) {
+            find();
+        } else {
+            m_activeViewContainer->setSearchBarVisible(false);
+        }
+    });
+
+    QAction *toggleSelectionModeAction = actionCollection()->addAction(QStringLiteral("toggle_selection_mode"));
+    // i18n: This action toggles a selection mode.
+    toggleSelectionModeAction->setText(i18nc("@action:inmenu", "Select Files and Folders"));
+    // i18n: Opens a selection mode for selecting files/folders.
+    // The text is kept so unspecific because it will be shown on the toolbar where space is at a premium.
+    toggleSelectionModeAction->setIconText(i18nc("@action:intoolbar", "Select"));
+    toggleSelectionModeAction->setWhatsThis(xi18nc(
+        "@info:whatsthis",
+        "<para>This application only knows which files or folders should be acted on if they are"
+        " <emphasis>selected</emphasis> first. Press this to toggle a <emphasis>Selection Mode</emphasis> which makes selecting and deselecting as easy as "
+        "pressing an item once.</para><para>While in this mode, a quick access bar at the bottom shows available actions for the currently selected items."
+        "</para>"));
+    toggleSelectionModeAction->setIcon(QIcon::fromTheme(QStringLiteral("quickwizard")));
+    toggleSelectionModeAction->setCheckable(true);
+    actionCollection()->setDefaultShortcut(toggleSelectionModeAction, Qt::Key_Space);
+    connect(toggleSelectionModeAction, &QAction::triggered, this, &DolphinMainWindow::toggleSelectionMode);
+
+    // A special version of the toggleSelectionModeAction for the toolbar that also contains a menu
+    // with the selectAllAction and invertSelectionAction.
+    auto *toggleSelectionModeToolBarAction =
+        new KToolBarPopupAction(toggleSelectionModeAction->icon(), toggleSelectionModeAction->iconText(), actionCollection());
+    toggleSelectionModeToolBarAction->setToolTip(toggleSelectionModeAction->text());
+    toggleSelectionModeToolBarAction->setWhatsThis(toggleSelectionModeAction->whatsThis());
+    actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction);
+    toggleSelectionModeToolBarAction->setCheckable(true);
+    toggleSelectionModeToolBarAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
+    connect(toggleSelectionModeToolBarAction, &QAction::triggered, toggleSelectionModeAction, &QAction::trigger);
+    connect(toggleSelectionModeAction, &QAction::toggled, toggleSelectionModeToolBarAction, &QAction::setChecked);
+
+    QAction *selectAllAction = KStandardAction::selectAll(this, &DolphinMainWindow::selectAll, actionCollection());
+    selectAllAction->setWhatsThis(xi18nc("@info:whatsthis",
+                                         "This selects all "
+                                         "files and folders in the current location."));
+
+    QAction *invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
     invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
-    invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
-    connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
+    invertSelection->setWhatsThis(xi18nc("@info:whatsthis invert",
+                                         "This selects all "
+                                         "items that you have currently <emphasis>not</emphasis> selected instead."));
+    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);
+
+    QMenu *toggleSelectionModeActionMenu = new QMenu(this);
+    toggleSelectionModeActionMenu->addAction(selectAllAction);
+    toggleSelectionModeActionMenu->addAction(invertSelection);
+    toggleSelectionModeToolBarAction->setMenu(toggleSelectionModeActionMenu);
 
     // setup 'View' menu
     // (note that most of it is set up in DolphinViewActionHandler)
 
-    KAction* split = actionCollection()->addAction("split_view");
-    split->setShortcut(Qt::Key_F3);
-    updateSplitAction();
-    connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
-
-    KAction* reload = actionCollection()->addAction("reload");
-    reload->setText(i18nc("@action:inmenu View", "Reload"));
-    reload->setShortcut(Qt::Key_F5);
-    reload->setIcon(KIcon("view-refresh"));
-    connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
-
-    KAction* stop = actionCollection()->addAction("stop");
+    Admin::WorkerIntegration::createActAsAdminAction(actionCollection(), this);
+
+    m_splitViewAction = actionCollection()->add<KActionMenu>(QStringLiteral("split_view"));
+    m_splitViewMenuAction = actionCollection()->addAction(QStringLiteral("split_view_menu"));
+
+    m_splitViewAction->setWhatsThis(xi18nc("@info:whatsthis split",
+                                           "<para>This presents "
+                                           "a second view side-by-side with the current view, so you can see "
+                                           "the contents of two folders at once and easily move items between "
+                                           "them.</para><para>The view that is not \"in focus\" will be dimmed. "
+                                           "</para>Click this button again to close one of the views."));
+    m_splitViewMenuAction->setWhatsThis(m_splitViewAction->whatsThis());
+
+    // only set it for the menu version
+    actionCollection()->setDefaultShortcut(m_splitViewMenuAction, Qt::Key_F3);
+
+    connect(m_splitViewAction, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
+    connect(m_splitViewMenuAction, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
+
+    QAction *popoutSplit = actionCollection()->addAction(QStringLiteral("popout_split_view"));
+    popoutSplit->setWhatsThis(xi18nc("@info:whatsthis",
+                                     "If the view has been split, this will pop the view in focus "
+                                     "out into a new window."));
+    popoutSplit->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
+    actionCollection()->setDefaultShortcut(popoutSplit, Qt::SHIFT | Qt::Key_F3);
+    connect(popoutSplit, &QAction::triggered, this, &DolphinMainWindow::popoutSplitView);
+
+    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);
+    QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
+    stashSplit->setVisible(sessionInterface && sessionInterface->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
+    connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
+
+    QAction *redisplay = KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
+    redisplay->setToolTip(i18nc("@info:tooltip", "Refresh view"));
+    redisplay->setWhatsThis(xi18nc("@info:whatsthis refresh",
+                                   "<para>This refreshes "
+                                   "the folder view.</para>"
+                                   "<para>If the contents of this folder have changed, refreshing will re-scan this folder "
+                                   "and show you a newly-updated view of the files and folders contained here.</para>"
+                                   "<para>If the view is split, this refreshes the one that is currently in focus.</para>"));
+
+    QAction *stop = actionCollection()->addAction(QStringLiteral("stop"));
     stop->setText(i18nc("@action:inmenu View", "Stop"));
     stop->setToolTip(i18nc("@info", "Stop loading"));
-    stop->setIcon(KIcon("process-stop"));
-    connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
+    stop->setWhatsThis(i18nc("@info", "This stops the loading of the contents of the current folder."));
+    stop->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
+    connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading);
 
-    KToggleAction* editableLocation = actionCollection()->add<KToggleAction>("editable_location");
+    KToggleAction *editableLocation = actionCollection()->add<KToggleAction>(QStringLiteral("editable_location"));
     editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
-    editableLocation->setShortcut(Qt::CTRL | Qt::Key_L);
-    connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
-
-    KAction* replaceLocation = actionCollection()->addAction("replace_location");
+    editableLocation->setWhatsThis(xi18nc("@info:whatsthis",
+                                          "This toggles the <emphasis>Location Bar</emphasis> to be "
+                                          "editable so you can directly enter a location you want to go to.<nl/>"
+                                          "You can also switch to editing by clicking to the right of the "
+                                          "location and switch back by confirming the edited 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"));
-    replaceLocation->setShortcut(Qt::Key_F6);
-    connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation()));
+    // i18n: "enter" is used both in the meaning of "writing" and "going to" a new location here.
+    // Both meanings are useful but not necessary to understand the use of "Replace Location".
+    // So you might want to be more verbose in your language to convey the meaning but it's up to you.
+    replaceLocation->setWhatsThis(xi18nc("@info:whatsthis",
+                                         "This switches to editing the location and selects it "
+                                         "so you can quickly enter a different location."));
+    actionCollection()->setDefaultShortcuts(replaceLocation, {Qt::CTRL | Qt::Key_L, Qt::ALT | Qt::Key_D});
+    connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
 
     // setup 'Go' menu
-    KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
-    connect(backAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
-    KShortcut backShortcut = backAction->shortcut();
-    backShortcut.setAlternate(Qt::Key_Backspace);
-    backAction->setShortcut(backShortcut);
-
-    m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this);
-    m_recentTabsMenu->setIcon(KIcon("edit-undo"));
-    actionCollection()->addAction("closed_tabs", m_recentTabsMenu);
-    connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)),
-            this, SLOT(restoreClosedTab(QAction*)));
-
-    QAction* action = new QAction(i18n("Empty Recently Closed Tabs"), m_recentTabsMenu);
-    action->setIcon(KIcon("edit-clear-list"));
-    action->setData(QVariant::fromValue(true));
-    m_recentTabsMenu->addAction(action);
-    m_recentTabsMenu->addSeparator();
-    m_recentTabsMenu->setEnabled(false);
-
-    KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
-    connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
-
-    KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
-    connect(upAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
-
-    KAction* homeAction = KStandardAction::home(this, SLOT(goHome()), actionCollection());
-    connect(homeAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goHome(Qt::MouseButtons)));
+    {
+        QScopedPointer<QAction> backAction(KStandardAction::back(nullptr, nullptr, nullptr));
+        m_backAction = new KToolBarPopupAction(backAction->icon(), backAction->text(), actionCollection());
+        m_backAction->setObjectName(backAction->objectName());
+        m_backAction->setShortcuts(backAction->shortcuts());
+    }
+    m_backAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
+    connect(m_backAction, &QAction::triggered, this, &DolphinMainWindow::goBack);
+    connect(m_backAction->popupMenu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu);
+    connect(m_backAction->popupMenu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoBack);
+    actionCollection()->addAction(m_backAction->objectName(), m_backAction);
+
+    auto backShortcuts = m_backAction->shortcuts();
+    // Prepend this shortcut, to avoid being hidden by the two-slot UI (#371130)
+    backShortcuts.prepend(QKeySequence(Qt::Key_Backspace));
+    actionCollection()->setDefaultShortcuts(m_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"));
+    undoCloseTab->setWhatsThis(i18nc("@info:whatsthis undo close tab", "This returns you to the previously closed 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->setWhatsThis(xi18nc("@info:whatsthis",
+                                    "This undoes "
+                                    "the last change you made to files or folders.<nl/>"
+                                    "Such changes include <interface>creating</interface>, <interface>renaming</interface> "
+                                    "and <interface>moving</interface> them to a different location "
+                                    "or to the <filename>Trash</filename>. <nl/>Any changes that cannot be undone "
+                                    "will ask for your confirmation beforehand."));
+    undoAction->setEnabled(false); // undo should be disabled by default
+
+    {
+        QScopedPointer<QAction> forwardAction(KStandardAction::forward(nullptr, nullptr, nullptr));
+        m_forwardAction = new KToolBarPopupAction(forwardAction->icon(), forwardAction->text(), actionCollection());
+        m_forwardAction->setObjectName(forwardAction->objectName());
+        m_forwardAction->setShortcuts(forwardAction->shortcuts());
+    }
+    m_forwardAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
+    connect(m_forwardAction, &QAction::triggered, this, &DolphinMainWindow::goForward);
+    connect(m_forwardAction->popupMenu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu);
+    connect(m_forwardAction->popupMenu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoForward);
+    actionCollection()->addAction(m_forwardAction->objectName(), m_forwardAction);
+    actionCollection()->setDefaultShortcuts(m_forwardAction, m_forwardAction->shortcuts());
+
+    // enable middle-click to open in a new tab
+    auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
+    connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked);
+    m_backAction->popupMenu()->installEventFilter(middleClickEventFilter);
+    m_forwardAction->popupMenu()->installEventFilter(middleClickEventFilter);
+    KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection());
+    QAction *homeAction = KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection());
+    homeAction->setWhatsThis(xi18nc("@info:whatsthis",
+                                    "Go to your "
+                                    "<filename>Home</filename> folder.<nl/>Every user account "
+                                    "has their own <filename>Home</filename> that contains their personal files, "
+                                    "as well as hidden folders for their applications' data and configuration files."));
 
     // setup 'Tools' menu
-    KAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
-    showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
-    showFilterBar->setIcon(KIcon("view-filter"));
-    showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
-    connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
-
-    KAction* compareFiles = actionCollection()->addAction("compare_files");
+    QAction *compareFiles = actionCollection()->addAction(QStringLiteral("compare_files"));
     compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
-    compareFiles->setIcon(KIcon("kompare"));
+    compareFiles->setIcon(QIcon::fromTheme(QStringLiteral("kompare")));
     compareFiles->setEnabled(false);
-    connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
-
-    KAction* openTerminal = actionCollection()->addAction("open_terminal");
-    openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
-    openTerminal->setIcon(KIcon("utilities-terminal"));
-    openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4);
-    connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
+    connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
+
+    QAction *manageDiskSpaceUsage = actionCollection()->addAction(QStringLiteral("manage_disk_space"));
+    manageDiskSpaceUsage->setText(i18nc("@action:inmenu Tools", "Manage Disk Space Usage"));
+    manageDiskSpaceUsage->setIcon(QIcon::fromTheme(QStringLiteral("filelight")));
+    m_diskSpaceUsageMenu = new DiskSpaceUsageMenu{this};
+    manageDiskSpaceUsage->setMenu(m_diskSpaceUsageMenu);
+
+    QAction *openPreferredSearchTool = actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
+    openPreferredSearchTool->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
+    openPreferredSearchTool->setWhatsThis(xi18nc("@info:whatsthis",
+                                                 "<para>This opens a preferred search tool for the viewed location.</para>"
+                                                 "<para>Use <emphasis>More Search Tools</emphasis> menu to configure it.</para>"));
+    openPreferredSearchTool->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+    actionCollection()->setDefaultShortcut(openPreferredSearchTool, Qt::CTRL | Qt::SHIFT | Qt::Key_F);
+    connect(openPreferredSearchTool, &QAction::triggered, this, &DolphinMainWindow::openPreferredSearchTool);
+
+    if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
+        // Get icon of user default terminal emulator application
+        const KConfigGroup group(KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig), QStringLiteral("General"));
+        const QString terminalDesktopFilename = group.readEntry("TerminalService");
+        // Use utilities-terminal icon from theme if readEntry() has failed
+        const QString terminalIcon = terminalDesktopFilename.isEmpty() ? "utilities-terminal" : KDesktopFile(terminalDesktopFilename).readIcon();
+
+        QAction *openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
+        openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
+        openTerminal->setWhatsThis(xi18nc("@info:whatsthis",
+                                          "<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
+                                          "<para>To learn more about terminals use the help features in the terminal application.</para>"));
+        openTerminal->setIcon(QIcon::fromTheme(terminalIcon));
+        actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4);
+        connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
+
+        QAction *openTerminalHere = actionCollection()->addAction(QStringLiteral("open_terminal_here"));
+        // i18n: "Here" refers to the location(s) of the currently selected item(s) or the currently viewed location if nothing is selected.
+        openTerminalHere->setText(i18nc("@action:inmenu Tools", "Open Terminal Here"));
+        openTerminalHere->setWhatsThis(xi18nc("@info:whatsthis",
+                                              "<para>This opens <emphasis>terminal</emphasis> applications for the selected items' locations.</para>"
+                                              "<para>To learn more about terminals use the help features in the terminal application.</para>"));
+        openTerminalHere->setIcon(QIcon::fromTheme(terminalIcon));
+        actionCollection()->setDefaultShortcut(openTerminalHere, Qt::SHIFT | Qt::ALT | Qt::Key_F4);
+        connect(openTerminalHere, &QAction::triggered, this, &DolphinMainWindow::openTerminalHere);
+    }
+
+    // setup 'Bookmarks' menu
+    KActionMenu *bookmarkMenu = new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
+    bookmarkMenu->setIcon(QIcon::fromTheme(QStringLiteral("bookmarks")));
+    // Make the toolbar button version work properly on click
+    bookmarkMenu->setPopupMode(QToolButton::InstantPopup);
+    m_bookmarkHandler = new DolphinBookmarkHandler(this, actionCollection(), bookmarkMenu->menu(), this);
+    actionCollection()->addAction(QStringLiteral("bookmarks"), bookmarkMenu);
 
     // setup 'Settings' menu
-    KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
-    connect(showMenuBar, SIGNAL(triggered(bool)),                   // Fixes #286822
-            this, SLOT(toggleShowMenuBar()), Qt::QueuedConnection);
-    KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
+    KToggleAction *showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
+    showMenuBar->setWhatsThis(xi18nc("@info:whatsthis",
+                                     "<para>This switches between having a <emphasis>Menubar</emphasis> "
+                                     "and having an <interface>%1</interface> button. Both "
+                                     "contain mostly the same actions and configuration options.</para>"
+                                     "<para>The Menubar takes up more space but allows for fast and organized access to all "
+                                     "actions an application has to offer.</para><para>The %1 button "
+                                     "is simpler and small which makes triggering advanced actions more time consuming.</para>",
+                                     hamburgerMenuAction->text().replace('&', "")));
+    connect(showMenuBar,
+            &KToggleAction::triggered, // Fixes #286822
+            this,
+            &DolphinMainWindow::toggleShowMenuBar,
+            Qt::QueuedConnection);
+
+    KStandardAction::keyBindings(this, &DolphinMainWindow::slotKeyBindings, actionCollection());
+    KStandardAction::preferences(this, &DolphinMainWindow::editSettings, actionCollection());
 
     // not in menu actions
-    QList<QKeySequence> nextTabKeys;
-    nextTabKeys.append(KStandardShortcut::tabNext().primary());
+    QList<QKeySequence> nextTabKeys = KStandardShortcut::tabNext();
     nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab));
 
-    QList<QKeySequence> prevTabKeys;
-    prevTabKeys.append(KStandardShortcut::tabPrev().primary());
+    QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
     prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab));
 
-    KAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
-    activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
-    connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab()));
-    activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys);
+    for (int i = 0; i < MaxActivateTabShortcuts; ++i) {
+        QAction *activateTab = actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i));
+        activateTab->setText(i18nc("@action:inmenu", "Go to Tab %1", i + 1));
+        activateTab->setEnabled(false);
+        connect(activateTab, &QAction::triggered, this, [this, i]() {
+            m_tabWidget->activateTab(i);
+        });
+
+        // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
+        if (i < 9) {
+            actionCollection()->setDefaultShortcut(activateTab, QStringLiteral("Alt+%1").arg(i + 1));
+        }
+    }
+
+    QAction *activateLastTab = actionCollection()->addAction(QStringLiteral("activate_last_tab"));
+    activateLastTab->setIconText(i18nc("@action:inmenu", "Last Tab"));
+    activateLastTab->setText(i18nc("@action:inmenu", "Go to Last Tab"));
+    activateLastTab->setEnabled(false);
+    connect(activateLastTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateLastTab);
+    actionCollection()->setDefaultShortcut(activateLastTab, Qt::ALT | Qt::Key_0);
+
+    QAction *activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab"));
+    activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
+    activateNextTab->setText(i18nc("@action:inmenu", "Go to Next Tab"));
+    activateNextTab->setEnabled(false);
+    connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab);
+    actionCollection()->setDefaultShortcuts(activateNextTab, nextTabKeys);
 
-    KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
-    activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
-    connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab()));
-    activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys);
+    QAction *activatePrevTab = actionCollection()->addAction(QStringLiteral("activate_prev_tab"));
+    activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab"));
+    activatePrevTab->setText(i18nc("@action:inmenu", "Go to Previous Tab"));
+    activatePrevTab->setEnabled(false);
+    connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab);
+    actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys);
 
     // for context menu
-    KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
+    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(KIcon("tab-new"));
-    connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab()));
+    openInNewTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
+    connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
 
-    KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
+    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(KIcon("window-new"));
-    connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
+    openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
+    connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
+
+    QAction *openInSplitViewAction = actionCollection()->addAction(QStringLiteral("open_in_split_view"));
+    openInSplitViewAction->setText(i18nc("@action:inmenu", "Open in Split View"));
+    openInSplitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
+    connect(openInSplitViewAction, &QAction::triggered, this, [this]() {
+        openInSplitView(QUrl());
+    });
+
+    m_recentFiles = new KRecentFilesAction(this);
 }
 
 void DolphinMainWindow::setupDockWidgets()
 {
     const bool lock = GeneralSettings::lockPanels();
 
-    KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>("lock_panels");
+    DolphinPlacesModelSingleton::instance().placesModel()->setPanelsLocked(lock);
+
+    KDualAction *lockLayoutAction = actionCollection()->add<KDualAction>(QStringLiteral("lock_panels"));
     lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
-    lockLayoutAction->setActiveIcon(KIcon("object-unlocked"));
+    lockLayoutAction->setActiveIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
     lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
-    lockLayoutAction->setInactiveIcon(KIcon("object-locked"));
+    lockLayoutAction->setInactiveIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
+    lockLayoutAction->setWhatsThis(xi18nc("@info:whatsthis",
+                                          "This "
+                                          "switches between having panels <emphasis>locked</emphasis> or "
+                                          "<emphasis>unlocked</emphasis>.<nl/>Unlocked panels can be "
+                                          "dragged to the other side of the window and have a close "
+                                          "button.<nl/>Locked panels are embedded more cleanly."));
     lockLayoutAction->setActive(lock);
-    connect(lockLayoutAction, SIGNAL(triggered()), this, SLOT(togglePanelLockState()));
+    connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState);
 
     // Setup "Information"
-    DolphinDockWidgetinfoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
+    DolphinDockWidget *infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
     infoDock->setLocked(lock);
-    infoDock->setObjectName("infoDock");
+    infoDock->setObjectName(QStringLiteral("infoDock"));
     infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-    Panel* infoPanel = new InformationPanel(infoDock);
-    infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
-    connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
+
+#if HAVE_BALOO
+    InformationPanel *infoPanel = new InformationPanel(infoDock);
+    infoPanel->setCustomContextMenuActions({lockLayoutAction});
+    connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
     infoDock->setWidget(infoPanel);
 
-    QAction* infoAction = infoDock->toggleViewAction();
-    createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel");
+    createPanelAction(QIcon::fromTheme(QStringLiteral("documentinfo")), Qt::Key_F11, infoDock, QStringLiteral("show_information_panel"));
 
     addDockWidget(Qt::RightDockWidgetArea, infoDock);
-    connect(this, SIGNAL(urlChanged(KUrl)),
-            infoPanel, SLOT(setUrl(KUrl)));
-    connect(this, SIGNAL(selectionChanged(KFileItemList)),
-            infoPanel, SLOT(setSelection(KFileItemList)));
-    connect(this, SIGNAL(requestItemInfo(KFileItem)),
-            infoPanel, SLOT(requestDelayedItemInfo(KFileItem)));
+    connect(this, &DolphinMainWindow::urlChanged, infoPanel, &InformationPanel::setUrl);
+    connect(this, &DolphinMainWindow::selectionChanged, infoPanel, &InformationPanel::setSelection);
+    connect(this, &DolphinMainWindow::requestItemInfo, infoPanel, &InformationPanel::requestDelayedItemInfo);
+    connect(this, &DolphinMainWindow::fileItemsChanged, infoPanel, &InformationPanel::slotFilesItemChanged);
+    connect(this, &DolphinMainWindow::settingsChanged, infoPanel, &InformationPanel::readSettings);
+#endif
+
+    // i18n: This is the last paragraph for the "What's This"-texts of all four panels.
+    const QString panelWhatsThis = xi18nc("@info:whatsthis",
+                                          "<para>To show or "
+                                          "hide panels like this go to <interface>Menu|Panels</interface> "
+                                          "or <interface>View|Panels</interface>.</para>");
+#if HAVE_BALOO
+    actionCollection()
+        ->action(QStringLiteral("show_information_panel"))
+        ->setWhatsThis(xi18nc("@info:whatsthis",
+                              "<para> This toggles the "
+                              "<emphasis>information</emphasis> panel at the right side of the "
+                              "window.</para><para>The panel provides in-depth information "
+                              "about the items your mouse is hovering over or about the selected "
+                              "items. Otherwise it informs you about the currently viewed folder.<nl/>"
+                              "For single items a preview of their contents is provided.</para>"));
+#endif
+    infoDock->setWhatsThis(xi18nc("@info:whatsthis",
+                                  "<para>This panel "
+                                  "provides in-depth information about the items your mouse is "
+                                  "hovering over or about the selected items. Otherwise it informs "
+                                  "you about the currently viewed folder.<nl/>For single items a "
+                                  "preview of their contents is provided.</para><para>You can configure "
+                                  "which and how details are given here by right-clicking.</para>")
+                           + panelWhatsThis);
 
     // Setup "Folders"
-    DolphinDockWidgetfoldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
+    DolphinDockWidget *foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
     foldersDock->setLocked(lock);
-    foldersDock->setObjectName("foldersDock");
+    foldersDock->setObjectName(QStringLiteral("foldersDock"));
     foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-    FoldersPanelfoldersPanel = new FoldersPanel(foldersDock);
-    foldersPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+    FoldersPanel *foldersPanel = new FoldersPanel(foldersDock);
+    foldersPanel->setCustomContextMenuActions({lockLayoutAction});
     foldersDock->setWidget(foldersPanel);
 
-    QAction* foldersAction = foldersDock->toggleViewAction();
-    createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel");
+    createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersDock, QStringLiteral("show_folders_panel"));
 
     addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
-    connect(this, SIGNAL(urlChanged(KUrl)),
-            foldersPanel, SLOT(setUrl(KUrl)));
-    connect(foldersPanel, SIGNAL(folderActivated(KUrl)),
-            this, SLOT(changeUrl(KUrl)));
-    connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)),
-            this, SLOT(openNewActivatedTab(KUrl)));
-    connect(foldersPanel, SIGNAL(errorMessage(QString)),
-            this, SLOT(slotPanelErrorMessage(QString)));
+    connect(this, &DolphinMainWindow::urlChanged, foldersPanel, &FoldersPanel::setUrl);
+    connect(foldersPanel, &FoldersPanel::folderActivated, this, &DolphinMainWindow::changeUrl);
+    connect(foldersPanel, &FoldersPanel::folderInNewTab, this, &DolphinMainWindow::openNewTab);
+    connect(foldersPanel, &FoldersPanel::folderInNewActiveTab, this, &DolphinMainWindow::openNewTabAndActivate);
+    connect(foldersPanel, &FoldersPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage);
+
+    actionCollection()
+        ->action(QStringLiteral("show_folders_panel"))
+        ->setWhatsThis(xi18nc("@info:whatsthis",
+                              "This toggles the "
+                              "<emphasis>folders</emphasis> panel at the left side of the window."
+                              "<nl/><nl/>It shows the folders of the <emphasis>file system"
+                              "</emphasis> in a <emphasis>tree view</emphasis>."));
+    foldersDock->setWhatsThis(xi18nc("@info:whatsthis",
+                                     "<para>This panel "
+                                     "shows the folders of the <emphasis>file system</emphasis> in a "
+                                     "<emphasis>tree view</emphasis>.</para><para>Click a folder to go "
+                                     "there. Click the arrow to the left of a folder to see its subfolders. "
+                                     "This allows quick switching between any folders.</para>")
+                              + panelWhatsThis);
 
     // Setup "Terminal"
-#ifndef Q_OS_WIN
-    DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
-    terminalDock->setLocked(lock);
-    terminalDock->setObjectName("terminalDock");
-    terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
-    Panel* terminalPanel = new TerminalPanel(terminalDock);
-    terminalPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
-    terminalDock->setWidget(terminalPanel);
-
-    connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
-    connect(terminalPanel, SIGNAL(changeUrl(KUrl)), this, SLOT(slotTerminalDirectoryChanged(KUrl)));
-    connect(terminalDock, SIGNAL(visibilityChanged(bool)),
-            terminalPanel, SLOT(dockVisibilityChanged()));
-
-    QAction* terminalAction = terminalDock->toggleViewAction();
-    createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel");
-
-    addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
-    connect(this, SIGNAL(urlChanged(KUrl)),
-            terminalPanel, SLOT(setUrl(KUrl)));
-#endif
+#if HAVE_TERMINAL
+    if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
+        DolphinDockWidget *terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
+        terminalDock->setLocked(lock);
+        terminalDock->setObjectName(QStringLiteral("terminalDock"));
+        terminalDock->setContentsMargins(0, 0, 0, 0);
+        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);
+
+        createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4, terminalDock, QStringLiteral("show_terminal_panel"));
+
+        addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
+        connect(this, &DolphinMainWindow::urlChanged, m_terminalPanel, &TerminalPanel::setUrl);
+
+        if (GeneralSettings::version() < 200) {
+            terminalDock->hide();
+        }
+
+        actionCollection()
+            ->action(QStringLiteral("show_terminal_panel"))
+            ->setWhatsThis(xi18nc("@info:whatsthis",
+                                  "<para>This toggles the "
+                                  "<emphasis>terminal</emphasis> panel at the bottom of the window."
+                                  "<nl/>The location in the terminal will always match the folder "
+                                  "view so you can navigate using either.</para><para>The terminal "
+                                  "panel is not needed for basic computer usage but can be useful "
+                                  "for advanced tasks. To learn more about terminals use the help features "
+                                  "in a standalone terminal application like Konsole.</para>"));
+        terminalDock->setWhatsThis(xi18nc("@info:whatsthis",
+                                          "<para>This is "
+                                          "the <emphasis>terminal</emphasis> panel. It behaves like a "
+                                          "normal terminal but will match the location of the folder view "
+                                          "so you can navigate using either.</para><para>The terminal panel "
+                                          "is not needed for basic computer usage but can be useful for "
+                                          "advanced tasks. To learn more about terminals use the help features in a "
+                                          "standalone terminal application like Konsole.</para>")
+                                   + panelWhatsThis);
+
+        QAction *focusTerminalPanel = actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
+        focusTerminalPanel->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
+        focusTerminalPanel->setToolTip(i18nc("@info:tooltip", "Move keyboard focus to and from the Terminal panel."));
+        focusTerminalPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
+        actionCollection()->setDefaultShortcut(focusTerminalPanel, Qt::CTRL | Qt::SHIFT | Qt::Key_F4);
+        connect(focusTerminalPanel, &QAction::triggered, this, &DolphinMainWindow::toggleTerminalPanelFocus);
+    } // endif "shell_access" allowed
+#endif // HAVE_TERMINAL
 
     if (GeneralSettings::version() < 200) {
         infoDock->hide();
         foldersDock->hide();
-#ifndef Q_OS_WIN
-        terminalDock->hide();
-#endif
     }
 
     // Setup "Places"
-    DolphinDockWidgetplacesDock = new DolphinDockWidget(i18nc("@title:window", "Places"));
+    DolphinDockWidget *placesDock = new DolphinDockWidget(i18nc("@title:window", "Places"));
     placesDock->setLocked(lock);
-    placesDock->setObjectName("placesDock");
+    placesDock->setObjectName(QStringLiteral("placesDock"));
     placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+    
+    m_placesPanel = new PlacesPanel(placesDock);
+    m_placesPanel->setCustomContextMenuActions({lockLayoutAction});
+    placesDock->setWidget(m_placesPanel);
 
-    PlacesPanel* placesPanel = new PlacesPanel(placesDock);
-    placesPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
-    placesDock->setWidget(placesPanel);
-
-    QAction* placesAction = placesDock->toggleViewAction();
-    createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel");
+    createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9, placesDock, QStringLiteral("show_places_panel"));
 
     addDockWidget(Qt::LeftDockWidgetArea, placesDock);
-    connect(placesPanel, SIGNAL(placeActivated(KUrl)),
-            this, SLOT(changeUrl(KUrl)));
-    connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
-            this, SLOT(openNewActivatedTab(KUrl)));
-    connect(placesPanel, SIGNAL(errorMessage(QString)),
-            this, SLOT(slotPanelErrorMessage(QString)));
-    connect(this, SIGNAL(urlChanged(KUrl)),
-            placesPanel, SLOT(setUrl(KUrl)));
-    connect(placesDock, SIGNAL(visibilityChanged(bool)),
-            this, SLOT(slotPlacesPanelVisibilityChanged(bool)));
+    connect(m_placesPanel, &PlacesPanel::placeActivated, this, &DolphinMainWindow::slotPlaceActivated);
+    connect(m_placesPanel, &PlacesPanel::tabRequested, this, &DolphinMainWindow::openNewTab);
+    connect(m_placesPanel, &PlacesPanel::activeTabRequested, this, &DolphinMainWindow::openNewTabAndActivate);
+    connect(m_placesPanel, &PlacesPanel::newWindowRequested, this, [this](const QUrl &url) {
+        Dolphin::openNewWindow({url}, this);
+    });
+    connect(m_placesPanel, &PlacesPanel::openInSplitViewRequested, this, &DolphinMainWindow::openInSplitView);
+    connect(m_placesPanel, &PlacesPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage);
+    connect(this, &DolphinMainWindow::urlChanged, m_placesPanel, &PlacesPanel::setUrl);
+    connect(placesDock, &DolphinDockWidget::visibilityChanged, &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged);
+    connect(placesDock, &DolphinDockWidget::visibilityChanged, this, &DolphinMainWindow::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);
+    DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
+
+    auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
+    actionShowAllPlaces->setCheckable(true);
+    actionShowAllPlaces->setDisabled(true);
+    actionShowAllPlaces->setWhatsThis(i18nc("@info:whatsthis",
+                                            "This displays "
+                                            "all places in the places panel that have been hidden. They will "
+                                            "appear semi-transparent and allow you to uncheck their \"Hide\" property."));
+
+    connect(actionShowAllPlaces, &QAction::triggered, this, [this](bool checked) {
+        m_placesPanel->setShowAll(checked);
+    });
+    connect(m_placesPanel, &PlacesPanel::allPlacesShownChanged, actionShowAllPlaces, &QAction::setChecked);
+
+    actionCollection()
+        ->action(QStringLiteral("show_places_panel"))
+        ->setWhatsThis(xi18nc("@info:whatsthis",
+                              "<para>This toggles the "
+                              "<emphasis>places</emphasis> panel at the left side of the window."
+                              "</para><para>It allows you to go to locations you have "
+                              "bookmarked and to access disk or media attached to the computer "
+                              "or to the network. It also contains sections to find recently "
+                              "saved files or files of a certain type.</para>"));
+    placesDock->setWhatsThis(xi18nc("@info:whatsthis",
+                                    "<para>This is the "
+                                    "<emphasis>Places</emphasis> panel. It allows you to go to locations "
+                                    "you have bookmarked and to access disk or media attached to the "
+                                    "computer or to the network. It also contains sections to find "
+                                    "recently saved files or files of a certain type.</para><para>"
+                                    "Click on an entry to go there. Click with the right mouse button "
+                                    "instead to open any entry in a new tab or new window.</para>"
+                                    "<para>New entries can be added by dragging folders onto this panel. "
+                                    "Right-click any section or entry to hide it. Right-click an empty "
+                                    "space on this panel and select <interface>Show Hidden Places"
+                                    "</interface> to display it again.</para>")
+                             + panelWhatsThis);
+
+    QAction *focusPlacesPanel = actionCollection()->addAction(QStringLiteral("focus_places_panel"));
+    focusPlacesPanel->setText(i18nc("@action:inmenu View", "Focus Places Panel"));
+    focusPlacesPanel->setToolTip(i18nc("@info:tooltip", "Move keyboard focus to and from the Places panel."));
+    focusPlacesPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
+    actionCollection()->setDefaultShortcut(focusPlacesPanel, Qt::CTRL | Qt::Key_P);
+    connect(focusPlacesPanel, &QAction::triggered, this, &DolphinMainWindow::togglePlacesPanelFocus);
 
     // Add actions into the "Panels" menu
-    KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
-    actionCollection()->addAction("panels", panelsMenu);
-    panelsMenu->setDelayed(false);
-    const KActionCollection* ac = actionCollection();
-    panelsMenu->addAction(ac->action("show_places_panel"));
-    panelsMenu->addAction(ac->action("show_information_panel"));
-    panelsMenu->addAction(ac->action("show_folders_panel"));
-#ifndef Q_OS_WIN
-    panelsMenu->addAction(ac->action("show_terminal_panel"));
+    KActionMenu *panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Show Panels"), this);
+    actionCollection()->addAction(QStringLiteral("panels"), panelsMenu);
+    panelsMenu->setIcon(QIcon::fromTheme(QStringLiteral("view-sidetree")));
+    panelsMenu->setPopupMode(QToolButton::InstantPopup);
+    const KActionCollection *ac = actionCollection();
+    panelsMenu->addAction(ac->action(QStringLiteral("show_places_panel")));
+#if 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);
+    panelsMenu->addSeparator();
+    panelsMenu->addAction(actionShowAllPlaces);
+    panelsMenu->addAction(focusPlacesPanel);
+    panelsMenu->addAction(ac->action(QStringLiteral("focus_terminal_panel")));
+
+    connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces] {
+        actionShowAllPlaces->setEnabled(DolphinPlacesModelSingleton::instance().placesModel()->hiddenCount());
+    });
 }
 
-void DolphinMainWindow::updateEditActions()
+void DolphinMainWindow::updateFileAndEditActions()
 {
     const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+    const KActionCollection *col = actionCollection();
+    KFileItemListProperties capabilitiesSource(list);
+
+    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 *duplicateAction = col->action(QStringLiteral("duplicate")); // see DolphinViewActionHandler
+    QAction *addToPlacesAction = col->action(QStringLiteral("add_to_places"));
+    QAction *copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view"));
+    QAction *moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_split_view"));
+    QAction *copyLocation = col->action(QStringLiteral("copy_location"));
+
     if (list.isEmpty()) {
-        stateChanged("has_no_selection");
+        stateChanged(QStringLiteral("has_no_selection"));
+
+        // All actions that need a selection to function can be enabled because they should trigger selection mode.
+        renameAction->setEnabled(true);
+        moveToTrashAction->setEnabled(true);
+        deleteAction->setEnabled(true);
+        cutAction->setEnabled(true);
+        duplicateAction->setEnabled(true);
+        addToPlacesAction->setEnabled(true);
+        copyLocation->setEnabled(true);
+        // Them triggering selection mode and not directly acting on selected items is signified by adding "…" to their text.
+        m_actionTextHelper->textsWhenNothingIsSelectedEnabled(true);
+
     } else {
-        stateChanged("has_selection");
+        m_actionTextHelper->textsWhenNothingIsSelectedEnabled(false);
+        stateChanged(QStringLiteral("has_selection"));
 
-        KActionCollection* col = actionCollection();
-        QAction* renameAction      = col->action("rename");
-        QAction* moveToTrashAction = col->action("move_to_trash");
-        QAction* deleteAction      = col->action("delete");
-        QAction* cutAction         = col->action(KStandardAction::name(KStandardAction::Cut));
-        QAction* deleteWithTrashShortcut = col->action("delete_shortcut"); // see DolphinViewActionHandler
+        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();
+        if (list.length() == 1 && list.first().isDir()) {
+            addToPlacesAction->setEnabled(true);
+        } else {
+            addToPlacesAction->setEnabled(false);
+        }
 
-        renameAction->setEnabled(capabilities.supportsMoving());
-        moveToTrashAction->setEnabled(enableMoveToTrash);
-        deleteAction->setEnabled(capabilities.supportsDeleting());
-        deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
-        cutAction->setEnabled(capabilities.supportsMoving());
+        const bool enableMoveToTrash = capabilitiesSource.isLocal() && capabilitiesSource.supportsMoving();
+
+        renameAction->setEnabled(capabilitiesSource.supportsMoving());
+        m_disabledActionNotifier->setDisabledReason(renameAction, i18nc("@info", "Cannot rename: You do not have permission to rename items in this folder."));
+        deleteAction->setEnabled(capabilitiesSource.supportsDeleting());
+        m_disabledActionNotifier->setDisabledReason(deleteAction,
+                                                    i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
+        cutAction->setEnabled(capabilitiesSource.supportsMoving());
+        m_disabledActionNotifier->setDisabledReason(cutAction, i18nc("@info", "Cannot cut: You do not have permission to move items from this folder."));
+        copyLocation->setEnabled(list.length() == 1);
+        showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
+        duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
+        m_disabledActionNotifier->setDisabledReason(duplicateAction,
+                                                    i18nc("@info", "Cannot duplicate here: You do not have permission to create items in this folder."));
+
+        if (enableMoveToTrash) {
+            moveToTrashAction->setEnabled(true);
+            deleteWithTrashShortcut->setEnabled(false);
+            m_disabledActionNotifier->clearDisabledReason(deleteWithTrashShortcut);
+        } else {
+            moveToTrashAction->setEnabled(false);
+            deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting());
+            m_disabledActionNotifier->setDisabledReason(deleteWithTrashShortcut,
+                                                        i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder."));
+        }
+    }
+
+    if (!m_tabWidget->currentTabPage()->splitViewEnabled()) {
+        // No need to set the disabled reason here, as it's obvious to the user that the reason is the split view being disabled.
+        copyToOtherViewAction->setEnabled(false);
+        m_disabledActionNotifier->clearDisabledReason(copyToOtherViewAction);
+        moveToOtherViewAction->setEnabled(false);
+        m_disabledActionNotifier->clearDisabledReason(moveToOtherViewAction);
+    } else if (list.isEmpty()) {
+        copyToOtherViewAction->setEnabled(false);
+        m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, i18nc("@info", "Cannot copy to other view: No files selected."));
+        moveToOtherViewAction->setEnabled(false);
+        m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, i18nc("@info", "Cannot move to other view: No files selected."));
+    } else {
+        DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+        KFileItem capabilitiesDestination;
+
+        if (tabPage->primaryViewActive()) {
+            capabilitiesDestination = tabPage->secondaryViewContainer()->rootItem();
+        } else {
+            capabilitiesDestination = tabPage->primaryViewContainer()->rootItem();
+        }
+
+        const auto destUrl = capabilitiesDestination.url();
+        const bool allNotTargetOrigin = std::all_of(list.cbegin(), list.cend(), [destUrl](const KFileItem &item) {
+            return item.url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash) != destUrl;
+        });
+
+        if (!allNotTargetOrigin) {
+            copyToOtherViewAction->setEnabled(false);
+            m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction,
+                                                        i18nc("@info", "Cannot copy to other view: The other view already contains these items."));
+            moveToOtherViewAction->setEnabled(false);
+            m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction,
+                                                        i18nc("@info", "Cannot move to other view: The other view already contains these items."));
+        } else if (!capabilitiesDestination.isWritable()) {
+            copyToOtherViewAction->setEnabled(false);
+            m_disabledActionNotifier->setDisabledReason(
+                copyToOtherViewAction,
+                i18nc("@info", "Cannot copy to other view: You do not have permission to write into the destination folder."));
+            moveToOtherViewAction->setEnabled(false);
+            m_disabledActionNotifier->setDisabledReason(
+                moveToOtherViewAction,
+                i18nc("@info", "Cannot move to other view: You do not have permission to write into the destination folder."));
+        } else {
+            copyToOtherViewAction->setEnabled(true);
+            moveToOtherViewAction->setEnabled(capabilitiesSource.supportsMoving());
+            m_disabledActionNotifier->setDisabledReason(
+                moveToOtherViewAction,
+                i18nc("@info", "Cannot move to other view: You do not have permission to move items from this folder."));
+        }
     }
-    updatePasteAction();
 }
 
 void DolphinMainWindow::updateViewActions()
 {
     m_actionHandler->updateViewActions();
 
-    QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
-    showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
+    QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
+    toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
 
-    updateSplitAction();
-
-    QAction* editableLocactionAction = actionCollection()->action("editable_location");
-    const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
-    editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
+    updateSplitActions();
 }
 
 void DolphinMainWindow::updateGoActions()
 {
-    QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
-    const KUrl currentUrl = m_activeViewContainer->url();
-    goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
+    QAction *goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
+    const QUrl currentUrl = m_activeViewContainer->url();
+    // I think this is one of the best places to firstly be confronted
+    // with a file system and its hierarchy. Talking about the root
+    // directory might seem too much here but it is the question that
+    // naturally arises in this context.
+    goUpAction->setWhatsThis(xi18nc("@info:whatsthis",
+                                    "<para>Go to "
+                                    "the folder that contains the currently viewed one.</para>"
+                                    "<para>All files and folders are organized in a hierarchical "
+                                    "<emphasis>file system</emphasis>. At the top of this hierarchy is "
+                                    "a directory that contains all data connected to this computer"
+                                    "—the <emphasis>root directory</emphasis>.</para>"));
+    goUpAction->setEnabled(KIO::upUrl(currentUrl) != currentUrl);
 }
 
-void DolphinMainWindow::createControlButton()
+void DolphinMainWindow::refreshViews()
 {
-    if (m_controlButton) {
-        return;
-    }
-    Q_ASSERT(!m_controlButton);
-
-    m_controlButton = new QToolButton(this);
-    m_controlButton->setIcon(KIcon("applications-system"));
-    m_controlButton->setText(i18nc("@action", "Control"));
-    m_controlButton->setPopupMode(QToolButton::InstantPopup);
-    m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
-
-    KMenu* controlMenu = new KMenu(m_controlButton);
-    connect(controlMenu, SIGNAL(aboutToShow()), this, SLOT(updateControlMenu()));
+    m_tabWidget->refreshViews();
 
-    m_controlButton->setMenu(controlMenu);
+    if (GeneralSettings::modifiedStartupSettings()) {
+        updateWindowTitle();
+    }
 
-    toolBar()->addWidget(m_controlButton);
-    connect(toolBar(), SIGNAL(iconSizeChanged(QSize)),
-            m_controlButton, SLOT(setIconSize(QSize)));
-    connect(toolBar(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
-            m_controlButton, SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
+    updateSplitActions();
 
-    // 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, SIGNAL(destroyed()), this, SLOT(slotControlButtonDeleted()));
-    m_updateToolBarTimer = new QTimer(this);
-    m_updateToolBarTimer->setInterval(500);
-    connect(m_updateToolBarTimer, SIGNAL(timeout()), this, SLOT(updateToolBar()));
+    Q_EMIT settingsChanged();
 }
 
-void DolphinMainWindow::deleteControlButton()
+void DolphinMainWindow::clearStatusBar()
 {
-    delete m_controlButton;
-    m_controlButton = 0;
-
-    delete m_updateToolBarTimer;
-    m_updateToolBarTimer = 0;
+    m_activeViewContainer->statusBar()->resetToDefaultText();
 }
 
-bool DolphinMainWindow::addActionToMenu(QAction* action, KMenu* menu)
-{
-    Q_ASSERT(action);
-    Q_ASSERT(menu);
-
-    const KToolBar* toolBarWidget = toolBar();
-    foreach (const QWidget* widget, action->associatedWidgets()) {
-        if (widget == toolBarWidget) {
-            return false;
+void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container)
+{
+    connect(container, &DolphinViewContainer::showFilterBarChanged, this, &DolphinMainWindow::updateFilterBarAction);
+    connect(container, &DolphinViewContainer::writeStateChanged, this, &DolphinMainWindow::slotWriteStateChanged);
+    slotWriteStateChanged(container->view()->isFolderWritable());
+    connect(container, &DolphinViewContainer::searchBarVisibilityChanged, this, &DolphinMainWindow::updateSearchAction);
+    connect(container, &DolphinViewContainer::captionChanged, this, &DolphinMainWindow::updateWindowTitle);
+    connect(container, &DolphinViewContainer::tabRequested, this, &DolphinMainWindow::openNewTab);
+    connect(container, &DolphinViewContainer::activeTabRequested, this, &DolphinMainWindow::openNewTabAndActivate);
+
+    // Make the toggled state of the selection mode actions visually follow the selection mode state of the view.
+    auto toggleSelectionModeAction = actionCollection()->action(QStringLiteral("toggle_selection_mode"));
+    toggleSelectionModeAction->setChecked(m_activeViewContainer->isSelectionModeEnabled());
+    connect(m_activeViewContainer, &DolphinViewContainer::selectionModeChanged, toggleSelectionModeAction, &QAction::setChecked);
+
+    const DolphinView *view = container->view();
+    connect(view, &DolphinView::selectionChanged, this, &DolphinMainWindow::slotSelectionChanged);
+    connect(view, &DolphinView::requestItemInfo, this, &DolphinMainWindow::requestItemInfo);
+    connect(view, &DolphinView::fileItemsChanged, this, &DolphinMainWindow::fileItemsChanged);
+    connect(view, &DolphinView::tabRequested, this, &DolphinMainWindow::openNewTab);
+    connect(view, &DolphinView::activeTabRequested, this, &DolphinMainWindow::openNewTabAndActivate);
+    connect(view, &DolphinView::windowRequested, this, &DolphinMainWindow::openNewWindow);
+    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, &DolphinMainWindow::goBack);
+    connect(view, &DolphinView::goForwardRequested, this, &DolphinMainWindow::goForward);
+    connect(view, &DolphinView::urlActivated, this, &DolphinMainWindow::handleUrl);
+    connect(view, &DolphinView::goUpRequested, this, &DolphinMainWindow::goUp);
+    connect(view, &DolphinView::doubleClickViewBackground, this, &DolphinMainWindow::slotDoubleClickViewBackground);
+
+    connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged, this, &DolphinMainWindow::changeUrl);
+    connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged, this, &DolphinMainWindow::updateHistory);
+
+    auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators")));
+    const KUrlNavigator *navigator =
+        m_tabWidget->currentTabPage()->primaryViewActive() ? navigators->primaryUrlNavigator() : navigators->secondaryUrlNavigator();
+
+    QAction *editableLocactionAction = actionCollection()->action(QStringLiteral("editable_location"));
+    editableLocactionAction->setChecked(navigator->isUrlEditable());
+    connect(navigator, &KUrlNavigator::editableStateChanged, this, &DolphinMainWindow::slotEditableStateChanged);
+    connect(navigator, &KUrlNavigator::tabRequested, this, &DolphinMainWindow::openNewTab);
+    connect(navigator, &KUrlNavigator::activeTabRequested, this, &DolphinMainWindow::openNewTabAndActivate);
+    connect(navigator, &KUrlNavigator::newWindowRequested, this, &DolphinMainWindow::openNewWindow);
+}
+
+void DolphinMainWindow::updateSplitActions()
+{
+    QAction *popoutSplitAction = actionCollection()->action(QStringLiteral("popout_split_view"));
+
+    auto setActionPopupMode = [this](KActionMenu *action, QToolButton::ToolButtonPopupMode popupMode) {
+        action->setPopupMode(popupMode);
+        if (auto *buttonForAction = qobject_cast<QToolButton *>(toolBar()->widgetForAction(action))) {
+            buttonForAction->setPopupMode(popupMode);
         }
-    }
-
-    menu->addAction(action);
-    return true;
-}
-
-void DolphinMainWindow::rememberClosedTab(int index)
-{
-    KMenu* tabsMenu = m_recentTabsMenu->menu();
-
-    const QString primaryPath = m_viewTab[index].primaryView->url().path();
-    const QString iconName = KMimeType::iconNameForUrl(primaryPath);
-
-    QAction* action = new QAction(squeezedText(primaryPath), tabsMenu);
-
-    ClosedTab closedTab;
-    closedTab.primaryUrl = m_viewTab[index].primaryView->url();
-
-    if (m_viewTab[index].secondaryView) {
-        closedTab.secondaryUrl = m_viewTab[index].secondaryView->url();
-        closedTab.isSplit = true;
-    } else {
-        closedTab.isSplit = false;
-    }
-
-    action->setData(QVariant::fromValue(closedTab));
-    action->setIcon(KIcon(iconName));
+    };
+
+    const DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+    if (tabPage->splitViewEnabled()) {
+        if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) {
+            m_splitViewAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
+            m_splitViewAction->setToolTip(i18nc("@info", "Close left view"));
+            m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
+            m_splitViewMenuAction->setText(i18nc("@action:inmenu Close left view", "Close Left View"));
+
+            popoutSplitAction->setText(i18nc("@action:intoolbar Move left view to a new window", "Pop out Left View"));
+            popoutSplitAction->setToolTip(i18nc("@info", "Move left view to a new window"));
+        } else {
+            m_splitViewAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
+            m_splitViewAction->setToolTip(i18nc("@info", "Close right view"));
+            m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
+            m_splitViewMenuAction->setText(i18nc("@action:inmenu Close left view", "Close Right View"));
 
-    // add the closed tab menu entry after the separator and
-    // "Empty Recently Closed Tabs" entry
-    if (tabsMenu->actions().size() == 2) {
-        tabsMenu->addAction(action);
+            popoutSplitAction->setText(i18nc("@action:intoolbar Move right view to a new window", "Pop out Right View"));
+            popoutSplitAction->setToolTip(i18nc("@info", "Move right view to a new window"));
+        }
+        popoutSplitAction->setEnabled(true);
+        if (!m_splitViewAction->menu()) {
+            setActionPopupMode(m_splitViewAction, QToolButton::MenuButtonPopup);
+            m_splitViewAction->setMenu(new QMenu);
+            m_splitViewAction->addAction(popoutSplitAction);
+        }
     } else {
-        tabsMenu->insertAction(tabsMenu->actions().at(2), action);
-    }
-
-    // assure that only up to 8 closed tabs are shown in the menu
-    if (tabsMenu->actions().size() > 8) {
-        tabsMenu->removeAction(tabsMenu->actions().last());
-    }
-    actionCollection()->action("closed_tabs")->setEnabled(true);
-    KAcceleratorManager::manage(tabsMenu);
-}
-
-void DolphinMainWindow::refreshViews()
-{
-    Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
-
-    // remember the current active view, as because of
-    // the refreshing the active view might change to
-    // the secondary view
-    DolphinViewContainer* activeViewContainer = m_activeViewContainer;
-
-    const int tabCount = m_viewTab.count();
-    for (int i = 0; i < tabCount; ++i) {
-        m_viewTab[i].primaryView->readSettings();
-        if (m_viewTab[i].secondaryView) {
-            m_viewTab[i].secondaryView->readSettings();
+        m_splitViewAction->setText(i18nc("@action:intoolbar Split view", "Split"));
+        m_splitViewMenuAction->setText(m_splitViewAction->text());
+        m_splitViewAction->setToolTip(i18nc("@info", "Split view"));
+        m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
+        popoutSplitAction->setText(i18nc("@action:intoolbar Move view in focus to a new window", "Pop out"));
+        popoutSplitAction->setEnabled(false);
+        if (m_splitViewAction->menu()) {
+            m_splitViewAction->removeAction(popoutSplitAction);
+            m_splitViewAction->menu()->deleteLater();
+            m_splitViewAction->setMenu(nullptr);
+            setActionPopupMode(m_splitViewAction, QToolButton::DelayedPopup);
         }
     }
 
-    setActiveViewContainer(activeViewContainer);
-
-    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();
-        const ViewTab& activeTab = m_viewTab[m_tabIndex];
-        const bool toggle =    ( splitView && !activeTab.secondaryView)
-                            || (!splitView &&  activeTab.secondaryView);
-        if (toggle) {
-            toggleSplitView();
-        }
-    }
+    // Update state from toolbar action
+    m_splitViewMenuAction->setToolTip(m_splitViewAction->toolTip());
+    m_splitViewMenuAction->setIcon(m_splitViewAction->icon());
 }
 
-void DolphinMainWindow::clearStatusBar()
+void DolphinMainWindow::updateAllowedToolbarAreas()
 {
-    m_activeViewContainer->statusBar()->resetToDefaultText();
-}
-
-void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
-{
-    connect(container, SIGNAL(showFilterBarChanged(bool)),
-            this, SLOT(updateFilterBarAction(bool)));
-    connect(container, SIGNAL(writeStateChanged(bool)),
-            this, SLOT(slotWriteStateChanged(bool)));
-
-    DolphinView* view = container->view();
-    connect(view, SIGNAL(selectionChanged(KFileItemList)),
-            this, SLOT(slotSelectionChanged(KFileItemList)));
-    connect(view, SIGNAL(requestItemInfo(KFileItem)),
-            this, SLOT(slotRequestItemInfo(KFileItem)));
-    connect(view, SIGNAL(activated()),
-            this, SLOT(toggleActiveView()));
-    connect(view, SIGNAL(tabRequested(KUrl)),
-            this, SLOT(openNewTab(KUrl)));
-    connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
-            this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
-    connect(view, SIGNAL(directoryLoadingStarted()),
-            this, SLOT(enableStopAction()));
-    connect(view, SIGNAL(directoryLoadingCompleted()),
-            this, SLOT(disableStopAction()));
-    connect(view, SIGNAL(goBackRequested()),
-            this, SLOT(goBack()));
-    connect(view, SIGNAL(goForwardRequested()),
-            this, SLOT(goForward()));
-
-    const KUrlNavigator* navigator = container->urlNavigator();
-    connect(navigator, SIGNAL(urlChanged(KUrl)),
-            this, SLOT(changeUrl(KUrl)));
-    connect(navigator, SIGNAL(historyChanged()),
-            this, SLOT(updateHistory()));
-    connect(navigator, SIGNAL(editableStateChanged(bool)),
-            this, SLOT(slotEditableStateChanged(bool)));
-    connect(navigator, SIGNAL(tabRequested(KUrl)),
-            this, SLOT(openNewTab(KUrl)));
-}
-
-void DolphinMainWindow::updateSplitAction()
-{
-    QAction* splitAction = actionCollection()->action("split_view");
-    if (m_viewTab[m_tabIndex].secondaryView) {
-        if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
-            splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
-            splitAction->setToolTip(i18nc("@info", "Close right view"));
-            splitAction->setIcon(KIcon("view-right-close"));
-        } else {
-            splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
-            splitAction->setToolTip(i18nc("@info", "Close left view"));
-            splitAction->setIcon(KIcon("view-left-close"));
+    auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators")));
+    if (toolBar()->actions().contains(navigators)) {
+        toolBar()->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
+        if (toolBarArea(toolBar()) == Qt::LeftToolBarArea || toolBarArea(toolBar()) == Qt::RightToolBarArea) {
+            addToolBar(Qt::TopToolBarArea, toolBar());
         }
     } else {
-        splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
-        splitAction->setToolTip(i18nc("@info", "Split view"));
-        splitAction->setIcon(KIcon("view-right-new"));
+        toolBar()->setAllowedAreas(Qt::AllToolBarAreas);
     }
 }
 
-QString DolphinMainWindow::tabName(const KUrl& url) const
+void DolphinMainWindow::updateNavigatorsBackground()
 {
-    QString name;
-    if (url.equals(KUrl("file:///"))) {
-        name = '/';
-    } else {
-        name = url.fileName();
-        if (name.isEmpty()) {
-            name = url.protocol();
-        } else {
-            // Make sure that a '&' inside the directory name is displayed correctly
-            // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
-            name.replace('&', "&&");
-        }
-    }
-    return name;
+    auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators")));
+    navigators->setBackgroundEnabled(navigators->isInToolbar());
 }
 
 bool DolphinMainWindow::isKompareInstalled() const
@@ -2043,75 +2802,227 @@ bool DolphinMainWindow::isKompareInstalled() const
     if (!initialized) {
         // TODO: maybe replace this approach later by using a menu
         // plugin like kdiff3plugin.cpp
-        installed = !KGlobal::dirs()->findExe("kompare").isEmpty();
+        installed = !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
         initialized = true;
     }
     return installed;
 }
 
-void DolphinMainWindow::createSecondaryView(int tabIndex)
-{
-    ViewTab& viewTab = m_viewTab[tabIndex];
-
-    QSplitter* splitter = viewTab.splitter;
-    const int newWidth = (viewTab.primaryView->width() - splitter->handleWidth()) / 2;
-
-    const DolphinView* view = viewTab.primaryView->view();
-    viewTab.secondaryView = createViewContainer(view->url(), 0);
-    splitter->addWidget(viewTab.secondaryView);
-    splitter->setSizes(QList<int>() << newWidth << newWidth);
+void DolphinMainWindow::createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QDockWidget *dockWidget, const QString &actionName)
+{
+    auto dockAction = dockWidget->toggleViewAction();
+    dockAction->setIcon(icon);
+    dockAction->setEnabled(true);
+
+    QAction *panelAction = actionCollection()->addAction(actionName, dockAction);
+    actionCollection()->setDefaultShortcut(panelAction, shortcut);
+}
+// clang-format off
+void DolphinMainWindow::setupWhatsThis()
+{
+    // main widgets
+    menuBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
+        "<emphasis>Menubar</emphasis>. It provides access to commands and "
+        "configuration options. Left-click on any of the menus on this "
+        "bar to see its contents.</para><para>The Menubar can be hidden "
+        "by unchecking <interface>Settings|Show Menubar</interface>. Then "
+        "most of its contents become available through a <interface>Menu"
+        "</interface> button on the <emphasis>Toolbar</emphasis>.</para>"));
+    toolBar()->setWhatsThis(xi18nc("@info:whatsthis", "<para>This is the "
+        "<emphasis>Toolbar</emphasis>. It allows quick access to "
+        "frequently used actions.</para><para>It is highly customizable. "
+        "All items you see in the <interface>Menu</interface> or "
+        "in the <interface>Menubar</interface> can be placed on the "
+        "Toolbar. Just right-click on it and select <interface>Configure "
+        "Toolbars…</interface> or find this action within the <interface>"
+        "menu</interface>."
+        "</para><para>The location of the bar and the style of its "
+        "buttons can also be changed in the right-click menu. Right-click "
+        "a button if you want to show or hide its text.</para>"));
+    m_tabWidget->setWhatsThis(xi18nc("@info:whatsthis main view",
+        "<para>Here you can see the <emphasis>folders</emphasis> and "
+        "<emphasis>files</emphasis> that are at the location described in "
+        "the <interface>Location Bar</interface> above. This area is the "
+        "central part of this application where you navigate to the files "
+        "you want to use.</para><para>For an elaborate and general "
+        "introduction to this application <link "
+        "url='https://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin'>"
+        "click here</link>. This will open an introductory article from "
+        "the <emphasis>KDE UserBase Wiki</emphasis>.</para><para>For brief "
+        "explanations of all the features of this <emphasis>view</emphasis> "
+        "<link url='help:/dolphin/dolphin-view.html'>click here</link> "
+        "instead. This will open a page from the <emphasis>Handbook"
+        "</emphasis> that covers the basics.</para>"));
+
+    // Settings menu
+    actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings))
+        ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window "
+        "that lists the <emphasis>keyboard shortcuts</emphasis>.<nl/>"
+        "There you can set up key combinations to trigger an action when "
+        "they are pressed simultaneously. All commands in this application can "
+        "be triggered this way.</para>"));
+    actionCollection()->action(KStandardAction::name(KStandardAction::ConfigureToolbars))
+        ->setWhatsThis(xi18nc("@info:whatsthis","<para>This opens a window in which "
+        "you can change which buttons appear on the <emphasis>Toolbar</emphasis>.</para>"
+        "<para>All items you see in the <interface>Menu</interface> can also be placed on the Toolbar.</para>"));
+    actionCollection()->action(KStandardAction::name(KStandardAction::Preferences))
+        ->setWhatsThis(xi18nc("@info:whatsthis","This opens a window where you can "
+        "change a multitude of settings for this application. For an explanation "
+        "of the various settings go to the chapter <emphasis>Configuring Dolphin"
+        "</emphasis> in <interface>Help|Dolphin Handbook</interface>."));
+
+    // Help menu
+
+    auto setStandardActionWhatsThis = [this](KStandardAction::StandardAction actionId,
+                                             const QString &whatsThis) {
+        // Check for the existence of an action since it can be restricted through the Kiosk system
+        if (auto *action = actionCollection()->action(KStandardAction::name(actionId))) {
+            action->setWhatsThis(whatsThis);
+        }
+    };
+
+    // i18n: If the external link isn't available in your language it might make
+    // sense to state the external link's language in brackets to not
+    // frustrate the user. If there are multiple languages that the user might
+    // know with a reasonable chance you might want to have 2 external links.
+    // The same might be true for any external link you translate.
+    setStandardActionWhatsThis(KStandardAction::HelpContents, xi18nc("@info:whatsthis handbook", "<para>This opens the Handbook for this application. It provides explanations for every part of <emphasis>Dolphin</emphasis>.</para><para>If you want more elaborate introductions to the different features of <emphasis>Dolphin</emphasis> <link url='https://userbase.kde.org/Dolphin/File_Management'>click here</link>. It will open the dedicated page in the KDE UserBase Wiki.</para>"));
+    // (The i18n call should be completely in the line following the i18n: comment without any line breaks within the i18n call or the comment might not be correctly extracted. See: https://commits.kde.org/kxmlgui/a31135046e1b3335b5d7bbbe6aa9a883ce3284c1 )
+
+    setStandardActionWhatsThis(KStandardAction::WhatsThis,
+        xi18nc("@info:whatsthis whatsthis button",
+        "<para>This is the button that invokes the help feature you are "
+        "using right now! Click it, then click any component of this "
+        "application to ask \"What's this?\" about it. The mouse cursor "
+        "will change appearance if no help is available for a spot.</para>"
+        "<para>There are two other ways to get help: "
+        "The <link url='help:/dolphin/index.html'>Dolphin Handbook</link> and "
+        "the <link url='https://userbase.kde.org/Dolphin/File_Management'>KDE "
+        "UserBase Wiki</link>.</para><para>The \"What's this?\" help is "
+        "missing in most other windows so don't get too used to this.</para>"));
+
+    setStandardActionWhatsThis(KStandardAction::ReportBug,
+        xi18nc("@info:whatsthis","<para>This opens a "
+        "window that will guide you through reporting errors or flaws "
+        "in this application or in other KDE software.</para>"
+        "<para>High-quality bug reports are much appreciated. To learn "
+        "how to make your bug report as effective as possible "
+        "<link url='https://community.kde.org/Get_Involved/Bug_Reporting'>"
+        "click here</link>.</para>"));
+
+    setStandardActionWhatsThis(KStandardAction::Donate,
+        xi18nc("@info:whatsthis", "<para>This opens a "
+        "<emphasis>web page</emphasis> where you can donate to "
+        "support the continued work on this application and many "
+        "other projects by the <emphasis>KDE</emphasis> community.</para>"
+        "<para>Donating is the easiest and fastest way to efficiently "
+        "support KDE and its projects. KDE projects are available for "
+        "free therefore your donation is needed to cover things that "
+        "require money like servers, contributor meetings, etc.</para>"
+        "<para><emphasis>KDE e.V.</emphasis> is the non-profit "
+        "organization behind the KDE community.</para>"));
+
+    setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage,
+        xi18nc("@info:whatsthis",
+        "With this you can change the language this application uses."
+        "<nl/>You can even set secondary languages which will be used "
+        "if texts are not available in your preferred language."));
+
+    setStandardActionWhatsThis(KStandardAction::AboutApp,
+        xi18nc("@info:whatsthis","This opens a "
+        "window that informs you about the version, license, "
+        "used libraries and maintainers of this application."));
+
+    setStandardActionWhatsThis(KStandardAction::AboutKDE,
+        xi18nc("@info:whatsthis","This opens a "
+        "window with information about <emphasis>KDE</emphasis>. "
+        "The KDE community are the people behind this free software."
+        "<nl/>If you like using this application but don't know "
+        "about KDE or want to see a cute dragon have a look!"));
+}
+// clang-format on
+
+bool DolphinMainWindow::addHamburgerMenuToToolbar()
+{
+    QDomDocument domDocument = KXMLGUIClient::domDocument();
+    if (domDocument.isNull()) {
+        return false;
+    }
+    QDomNode toolbar = domDocument.elementsByTagName(QStringLiteral("ToolBar")).at(0);
+    if (toolbar.isNull()) {
+        return false;
+    }
+
+    QDomElement hamburgerMenuElement = domDocument.createElement(QStringLiteral("Action"));
+    hamburgerMenuElement.setAttribute(QStringLiteral("name"), QStringLiteral("hamburger_menu"));
+    toolbar.appendChild(hamburgerMenuElement);
+
+    KXMLGUIFactory::saveConfigFile(domDocument, xmlFile());
+    reloadXML();
+    createGUI();
+    return true;
+    // Make sure to also remove the <KXMLGUIFactory> and <QDomDocument> include
+    // whenever this method is removed (maybe in the year ~2026).
+}
 
-    connectViewSignals(viewTab.secondaryView);
-    viewTab.secondaryView->setActive(false);
-    viewTab.secondaryView->resize(newWidth, viewTab.primaryView->height());
-    viewTab.secondaryView->show();
+// Set a sane initial window size
+QSize DolphinMainWindow::sizeHint() const
+{
+    return KXmlGuiWindow::sizeHint().expandedTo(QSize(760, 550));
 }
 
-QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) const
+void DolphinMainWindow::saveNewToolbarConfig()
 {
-    return "Tab " + QString::number(tabIndex) + ' ' + property;
+    KXmlGuiWindow::saveNewToolbarConfig(); // Applies the new config. This has to be called first
+                                           // because the rest of this method decides things
+                                           // based on the new config.
+    auto navigators = static_cast<DolphinNavigatorsWidgetAction *>(actionCollection()->action(QStringLiteral("url_navigators")));
+    if (!toolBar()->actions().contains(navigators)) {
+        m_tabWidget->currentTabPage()->insertNavigatorsWidget(navigators);
+    }
+    updateAllowedToolbarAreas();
+    updateNavigatorsBackground();
+    (static_cast<KHamburgerMenu *>(actionCollection()->action(KStandardAction::name(KStandardAction::HamburgerMenu))))->hideActionsOf(toolBar());
 }
 
-void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
+void DolphinMainWindow::toggleTerminalPanelFocus()
 {
-    QString caption;
-    if (!url.isLocalFile()) {
-        caption.append(url.protocol() + " - ");
-        if (url.hasHost()) {
-            caption.append(url.host() + " - ");
-        }
+    if (!m_terminalPanel->isVisible()) {
+        actionCollection()->action(QStringLiteral("show_terminal_panel"))->trigger(); // Also moves focus to the panel.
+        actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
+        return;
     }
 
-    const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
-    caption.append(fileName);
+    if (m_terminalPanel->terminalHasFocus()) {
+        m_activeViewContainer->view()->setFocus(Qt::FocusReason::ShortcutFocusReason);
+        actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
+        return;
+    }
 
-    setCaption(caption);
+    m_terminalPanel->setFocus(Qt::FocusReason::ShortcutFocusReason);
+    actionCollection()->action(QStringLiteral("focus_terminal_panel"))->setText(i18nc("@action:inmenu Tools", "Defocus Terminal Panel"));
 }
 
-QString DolphinMainWindow::squeezedText(const QString& text) const
+void DolphinMainWindow::togglePlacesPanelFocus()
 {
-    const QFontMetrics fm = fontMetrics();
-    return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10);
-}
+    if (!m_placesPanel->isVisible()) {
+        actionCollection()->action(QStringLiteral("show_places_panel"))->trigger(); // Also moves focus to the panel.
+        actionCollection()->action(QStringLiteral("focus_places_panel"))->setText(i18nc("@action:inmenu View", "Defocus Terminal Panel"));
+        return;
+    }
 
-void DolphinMainWindow::createPanelAction(const KIcon& icon,
-                                          const QKeySequence& shortcut,
-                                          QAction* dockAction,
-                                          const QString& actionName)
-{
-    KAction* panelAction = actionCollection()->addAction(actionName);
-    panelAction->setCheckable(true);
-    panelAction->setChecked(dockAction->isChecked());
-    panelAction->setText(dockAction->text());
-    panelAction->setIcon(icon);
-    panelAction->setShortcut(shortcut);
+    if (m_placesPanel->hasFocus()) {
+        m_activeViewContainer->view()->setFocus(Qt::FocusReason::ShortcutFocusReason);
+        actionCollection()->action(QStringLiteral("focus_places_panel"))->setText(i18nc("@action:inmenu View", "Focus Places Panel"));
+        return;
+    }
 
-    connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger()));
-    connect(dockAction, SIGNAL(toggled(bool)), panelAction, SLOT(setChecked(bool)));
+    m_placesPanel->setFocus(Qt::FocusReason::ShortcutFocusReason);
+    actionCollection()->action(QStringLiteral("focus_places_panel"))->setText(i18nc("@action:inmenu View", "Defocus Places Panel"));
 }
 
-DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
-    KIO::FileUndoManager::UiInterface()
+DolphinMainWindow::UndoUiInterface::UndoUiInterface()
+    KIO::FileUndoManager::UiInterface()
 {
 }
 
@@ -2119,15 +3030,62 @@ DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
 {
 }
 
-void DolphinMainWindow::UndoUiInterface::jobError(KIO::Jobjob)
+void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job *job)
 {
-    DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
+    DolphinMainWindow *mainWin = qobject_cast<DolphinMainWindow *>(parentWidget());
     if (mainWin) {
-        DolphinViewContainercontainer = mainWin->activeViewContainer();
-        container->showMessage(job->errorString(), DolphinViewContainer::Error);
+        DolphinViewContainer *container = mainWin->activeViewContainer();
+        container->showMessage(job->errorString(), KMessageWidget::Error);
     } else {
         KIO::FileUndoManager::UiInterface::jobError(job);
     }
 }
 
-#include "dolphinmainwindow.moc"
+bool DolphinMainWindow::isUrlOpen(const QString &url)
+{
+    return m_tabWidget->isUrlOpen(QUrl::fromUserInput(url));
+}
+
+bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem)
+{
+    return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem));
+}
+
+void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button)
+{
+    if (button != Qt::MouseButton::LeftButton) {
+        // only handle left mouse button for now
+        return;
+    }
+
+    GeneralSettings *settings = GeneralSettings::self();
+    QString clickAction = settings->doubleClickViewAction();
+
+    DolphinView *view = activeViewContainer()->view();
+    if (view == nullptr || clickAction == "none") {
+        return;
+    }
+
+    if (clickAction == customCommand) {
+        // run custom command set by the user
+        QString path = view->url().toLocalFile();
+        QString clickCustomAction = settings->doubleClickViewCustomAction();
+        clickCustomAction.replace("{path}", path.prepend('"').append('"'));
+
+        m_job = new KIO::CommandLauncherJob(clickCustomAction);
+        m_job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+        m_job->start();
+
+    } else {
+        // get the action set by the user and trigger it
+        const KActionCollection *actions = actionCollection();
+        QAction *action = actions->action(clickAction);
+        if (action == nullptr) {
+            qCWarning(DolphinDebug) << QStringLiteral("Double-click view: action `%1` was not found").arg(clickAction);
+            return;
+        }
+        action->trigger();
+    }
+}
+
+#include "moc_dolphinmainwindow.cpp"