]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Use a separate menu action for split view action
[dolphin.git] / src / dolphinmainwindow.cpp
index 76b8ded6f5a7045f0f4f4464811c8ac0a34a539b..e3591bcaf2d917e5d6e3d5626a284572a75416b0 100644 (file)
 #include <KDualAction>
 #include <KFileItemListProperties>
 #include <KIO/CommandLauncherJob>
-#include <kio_version.h>
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
 #include <KIO/JobUiDelegateFactory>
-#else
-#include <KIO/JobUiDelegate>
-#endif
 #include <KIO/OpenFileManagerWindowJob>
 #include <KIO/OpenUrlJob>
 #include <KJobWidgets>
 #include <KLocalizedString>
 #include <KMessageBox>
-#include <KMoreToolsMenuFactory>
 #include <KProtocolInfo>
 #include <KProtocolManager>
 #include <KShell>
 #include <KShortcutsDialog>
 #include <KStandardAction>
-#include <KStartupInfo>
 #include <KSycoca>
 #include <KTerminalLauncherJob>
 #include <KToggleAction>
@@ -70,7 +63,6 @@
 #include <KWindowSystem>
 #include <KXMLGUIFactory>
 
-#include <kio_version.h>
 #include <kwidgetsaddons_version.h>
 
 #include <QApplication>
 #include <QStandardPaths>
 #include <QTimer>
 #include <QToolButton>
+#include <QtConcurrentRun>
 
 #include <algorithm>
 
+#if HAVE_X11
+#include <KStartupInfo>
+#endif
+
 namespace
 {
 // Used for GeneralSettings::version() to determine whether
@@ -118,6 +115,11 @@ DolphinMainWindow::DolphinMainWindow()
     , m_tearDownFromPlacesRequested(false)
     , m_backAction(nullptr)
     , m_forwardAction(nullptr)
+    , m_sessionSaveTimer(nullptr)
+    , m_sessionSaveWatcher(nullptr)
+    , m_sessionSaveScheduled(false)
+    , m_splitViewAction(nullptr)
+    , m_splitViewMenuAction(nullptr)
 {
     Q_INIT_RESOURCE(dolphin);
 
@@ -165,6 +167,9 @@ DolphinMainWindow::DolphinMainWindow()
     connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory);
     connect(m_actionHandler, &DolphinViewActionHandler::selectionModeChangeTriggered, this, &DolphinMainWindow::slotSetSelectionMode);
 
+    Q_CHECK_PTR(actionCollection()->action(QStringLiteral("create_dir")));
+    m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action(QStringLiteral("create_dir")));
+
     m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
     connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
 
@@ -277,39 +282,16 @@ void DolphinMainWindow::openFiles(const QStringList &files, bool splitView)
     openFiles(QUrl::fromStringList(files), splitView);
 }
 
-bool DolphinMainWindow::isOnCurrentDesktop() const
-{
-#if HAVE_X11
-    if (KWindowSystem::isPlatformX11()) {
-        const NET::Properties properties = NET::WMDesktop;
-        KWindowInfo info(this->winId(), properties);
-        return info.isOnCurrentDesktop();
-    }
-#endif
-    return true;
-}
-
-bool DolphinMainWindow::isOnActivity(const QString &activityId) const
-{
-#if HAVE_X11 && HAVE_KACTIVITIES
-    if (KWindowSystem::isPlatformX11()) {
-        const NET::Properties properties = NET::Supported;
-        const NET::Properties2 properties2 = NET::WM2Activities;
-        KWindowInfo info(this->winId(), properties, properties2);
-        return info.activities().contains(activityId);
-    }
-#endif
-    return true;
-}
-
 void DolphinMainWindow::activateWindow(const QString &activationToken)
 {
     window()->setAttribute(Qt::WA_NativeWindow, true);
 
     if (KWindowSystem::isPlatformWayland()) {
         KWindowSystem::setCurrentXdgActivationToken(activationToken);
-    } else {
+    } else if (KWindowSystem::isPlatformX11()) {
+#if HAVE_X11
         KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken.toUtf8());
+#endif
     }
 
     KWindowSystem::activateWindow(window()->windowHandle());
@@ -489,7 +471,7 @@ void DolphinMainWindow::openNewWindow(const QUrl &url)
 void DolphinMainWindow::slotSplitViewChanged()
 {
     m_tabWidget->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation);
-    updateSplitAction();
+    updateSplitActions();
 }
 
 void DolphinMainWindow::openInNewTab()
@@ -529,12 +511,38 @@ void DolphinMainWindow::openInNewWindow()
     }
 }
 
+void DolphinMainWindow::openInSplitView(const QUrl &url)
+{
+    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;
+    }
+
+    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::statDetails(destinationUrl, KIO::StatJob::SourceSide, KIO::StatNoDetails);
+    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);
@@ -547,6 +555,19 @@ void DolphinMainWindow::showTarget()
     });
 }
 
+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;
+        }
+    }
+
+    return KXmlGuiWindow::event(event);
+}
+
 void DolphinMainWindow::showEvent(QShowEvent *event)
 {
     KXmlGuiWindow::showEvent(event);
@@ -641,7 +662,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent *event)
             QStringList(),
             i18n("Do not ask again"),
             &doNotAskAgainCheckboxResult,
-            KMessageBox::Dangerous);
+            KMessageBox::Notify | KMessageBox::Dangerous);
 
         if (doNotAskAgainCheckboxResult) {
             GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
@@ -661,18 +682,74 @@ void DolphinMainWindow::closeEvent(QCloseEvent *event)
         }
     }
 
-    if (GeneralSettings::rememberOpenedTabs()) {
+    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()->save();
+
+    KXmlGuiWindow::closeEvent(event);
+}
+
+void DolphinMainWindow::slotSaveSession()
+{
+    m_sessionSaveScheduled = false;
+
+    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);
-        config->sync();
+
+        auto future = QtConcurrent::run([config]() {
+            config->sync();
+        });
+        m_sessionSaveWatcher->setFuture(future);
     }
+}
 
-    GeneralSettings::setVersion(CurrentDolphinVersion);
-    GeneralSettings::self()->save();
+void DolphinMainWindow::setSessionAutoSaveEnabled(bool enable)
+{
+    if (enable) {
+        if (!m_sessionSaveTimer) {
+            m_sessionSaveTimer = new QTimer(this);
+            m_sessionSaveWatcher = new QFutureWatcher<void>(this);
+            m_sessionSaveTimer->setSingleShot(true);
+            m_sessionSaveTimer->setInterval(22000);
 
-    KXmlGuiWindow::closeEvent(event);
+            connect(m_sessionSaveTimer, &QTimer::timeout, this, &DolphinMainWindow::slotSaveSession);
+        }
+
+        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;
+
+        m_sessionSaveWatcher->waitForFinished();
+
+        m_sessionSaveTimer->deleteLater();
+        m_sessionSaveWatcher->deleteLater();
+        m_sessionSaveTimer = nullptr;
+        m_sessionSaveWatcher = nullptr;
+    }
 }
 
 void DolphinMainWindow::saveProperties(KConfigGroup &group)
@@ -688,20 +765,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup &group)
 void DolphinMainWindow::updateNewMenu()
 {
     m_newFileMenu->checkUpToDate();
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
     m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
-#else
-    m_newFileMenu->setPopupFiles(QList<QUrl>() << activeViewContainer()->url());
-#endif
 }
 
 void DolphinMainWindow::createDirectory()
 {
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
     m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
-#else
-    m_newFileMenu->setPopupFiles(QList<QUrl>() << activeViewContainer()->url());
-#endif
     m_newFileMenu->createDirectory();
 }
 
@@ -836,10 +905,11 @@ void DolphinMainWindow::slotAboutToShowBackPopupMenu()
 {
     const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
     int entries = 0;
-    m_backAction->menu()->clear();
+    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, m_backAction->menu());
-        m_backAction->menu()->addAction(action);
+        QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu);
+        menu->addAction(action);
     }
 }
 
@@ -864,10 +934,10 @@ void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
 {
     const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
     int entries = 0;
-    m_forwardAction->menu()->clear();
+    QMenu *menu = m_forwardAction->popupMenu();
     for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) {
-        QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_forwardAction->menu());
-        m_forwardAction->menu()->addAction(action);
+        QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu);
+        menu->addAction(action);
     }
 }
 
@@ -912,10 +982,20 @@ void DolphinMainWindow::toggleSplitView()
 {
     DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
     tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled(), WithAnimation);
-
+    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();
@@ -1119,15 +1199,20 @@ void DolphinMainWindow::toggleShowMenuBar()
 QPointer<QAction> DolphinMainWindow::preferredSearchTool()
 {
     m_searchTools.clear();
-    KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&m_searchTools, {"files-find"}, m_activeViewContainer->url());
-    QList<QAction *> actions = m_searchTools.actions();
-    if (actions.isEmpty()) {
-        return nullptr;
-    }
-    QAction *action = actions.first();
-    if (action->isSeparator()) {
+
+    KService::Ptr kfind = KService::serviceByDesktopName(QStringLiteral("org.kde.kfind"));
+
+    if (!kfind) {
         return nullptr;
     }
+
+    auto *action = new QAction(QIcon::fromTheme(kfind->icon()), kfind->name(), this);
+
+    connect(action, &QAction::triggered, this, [kfind] {
+        auto *job = new KIO::ApplicationLauncherJob(kfind);
+        job->start();
+    });
+
     return action;
 }
 
@@ -1171,7 +1256,8 @@ void DolphinMainWindow::openTerminalHere()
 {
     QList<QUrl> urls = {};
 
-    for (const KFileItem &item : m_activeViewContainer->view()->selectedItems()) {
+    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());
@@ -1189,29 +1275,19 @@ void DolphinMainWindow::openTerminalHere()
 
     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());
-#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
-        const int answer = KMessageBox::warningTwoActions(
-            this,
-            question,
-            {},
-#else
-        const int answer = KMessageBox::warningYesNo(
+        const int answer = KMessageBox::warningContinueCancel(
             this,
             question,
             {},
-#endif
             KGuiItem(i18ncp("@action:button", "Open %1 Terminal", "Open %1 Terminals", urls.count()), QStringLiteral("utilities-terminal")),
-            KStandardGuiItem::cancel());
-#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
-        if (answer != KMessageBox::PrimaryAction) {
-#else
-        if (answer != KMessageBox::Yes) {
-#endif
+            KStandardGuiItem::cancel(),
+            QStringLiteral("ConfirmOpenManyTerminals"));
+        if (answer != KMessageBox::PrimaryAction && answer != KMessageBox::Continue) {
             return;
         }
     }
 
-    for (const QUrl &url : urls) {
+    for (const QUrl &url : std::as_const(urls)) {
         openTerminalJob(url);
     }
 }
@@ -1276,11 +1352,7 @@ void DolphinMainWindow::handleUrl(const QUrl &url)
         activeViewContainer()->setUrl(url);
     } else {
         m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url);
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
         m_lastHandleUrlOpenJob->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
-#else
-        m_lastHandleUrlOpenJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
-#endif
         m_lastHandleUrlOpenJob->setShowOpenOrExecuteDialog(true);
 
         connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this, [this, url](const QString &mimetype) {
@@ -1310,7 +1382,7 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
 void DolphinMainWindow::openContextMenu(const QPoint &pos, const KFileItem &item, const KFileItemList &selectedItems, const QUrl &url)
 {
     QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, item, selectedItems, url, &m_fileItemActions);
-    contextMenu.data()->exec(pos);
+    contextMenu->exec(pos);
 
     // Delete the menu, unless it has been deleted in its own nested event loop already.
     if (contextMenu) {
@@ -1504,7 +1576,7 @@ void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString &mo
         setViewsToHomeIfMountPathOpen(mountPath);
     });
 
-    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsChildOf(mountPath)) {
         m_tearDownFromPlacesRequested = true;
         m_terminalPanel->goHome();
         // m_placesPanel->proceedWithTearDown() will be called in slotTerminalDirectoryChanged
@@ -1519,7 +1591,7 @@ void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString &mo
         setViewsToHomeIfMountPathOpen(mountPath);
     });
 
-    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
+    if (m_terminalPanel && m_terminalPanel->currentWorkingDirectoryIsChildOf(mountPath)) {
         m_tearDownFromPlacesRequested = false;
         m_terminalPanel->goHome();
     }
@@ -1554,7 +1626,8 @@ void DolphinMainWindow::setupActions()
     auto hamburgerMenuAction = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
 
     // setup 'File' menu
-    m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
+    m_newFileMenu = new DolphinNewFileMenu(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(QIcon::fromTheme(QStringLiteral("list-add")));
@@ -1578,7 +1651,7 @@ void DolphinMainWindow::setupActions()
                                 "<emphasis>Tab</emphasis> with the current location and view.<nl/>"
                                 "A tab is an additional view within this window. "
                                 "You can drag and drop items between tabs."));
-    actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N});
+    actionCollection()->setDefaultShortcut(newTab, Qt::CTRL | Qt::Key_T);
     connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab);
 
     QAction *addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places"));
@@ -1663,7 +1736,7 @@ void DolphinMainWindow::setupActions()
     connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToInactiveSplitView);
 
     QAction *showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
-    showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter..."));
+    showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter"));
     showFilterBar->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
     showFilterBar->setWhatsThis(xi18nc("@info:whatsthis",
                                        "This opens the "
@@ -1687,7 +1760,7 @@ void DolphinMainWindow::setupActions()
     connect(toggleFilter, &QAction::triggered, this, &DolphinMainWindow::toggleFilterBar);
 
     QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
-    searchAction->setText(i18n("Search..."));
+    searchAction->setText(i18n("Search"));
     searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
     searchAction->setWhatsThis(xi18nc("@info:whatsthis find",
                                       "<para>This helps you "
@@ -1722,6 +1795,7 @@ void DolphinMainWindow::setupActions()
         "</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
@@ -1732,7 +1806,7 @@ void DolphinMainWindow::setupActions()
     toggleSelectionModeToolBarAction->setWhatsThis(toggleSelectionModeAction->whatsThis());
     actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction);
     toggleSelectionModeToolBarAction->setCheckable(true);
-    toggleSelectionModeToolBarAction->setPopupMode(QToolButton::DelayedPopup);
+    toggleSelectionModeToolBarAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
     connect(toggleSelectionModeToolBarAction, &QAction::triggered, toggleSelectionModeAction, &QAction::trigger);
     connect(toggleSelectionModeAction, &QAction::toggled, toggleSelectionModeToolBarAction, &QAction::setChecked);
 
@@ -1758,14 +1832,31 @@ void DolphinMainWindow::setupActions()
     // setup 'View' menu
     // (note that most of it is set up in DolphinViewActionHandler)
 
-    QAction *split = actionCollection()->addAction(QStringLiteral("split_view"));
-    split->setWhatsThis(xi18nc("@info:whatsthis find",
-                               "<para>This splits "
-                               "the folder view below into two autonomous views.</para><para>This "
-                               "way you can see two locations at once and move items between them "
-                               "quickly.</para>Click this again afterwards to recombine the views."));
-    actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
-    connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
+    m_splitViewAction = actionCollection()->add<KActionMenu>(QStringLiteral("split_view"));
+    m_splitViewMenuAction = actionCollection()->addAction(QStringLiteral("split_view_menu"));
+
+    m_splitViewAction->setWhatsThis(xi18nc("@info:whatsthis find",
+                                           "<para>This splits "
+                                           "the folder view below into two autonomous views.</para><para>This "
+                                           "way you can see two locations at once and move items between them "
+                                           "quickly.</para>Click this again afterwards to recombine the views."));
+    m_splitViewMenuAction->setWhatsThis(m_splitViewAction->whatsThis());
+
+    // only set it for the menu version
+    actionCollection()->setDefaultShortcut(m_splitViewMenuAction, Qt::Key_F3);
+
+    m_splitViewAction->setPopupMode(QToolButton::MenuButtonPopup);
+    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 folder view has been split, this will pop the active folder "
+                                     "view out into a new window."));
+    popoutSplit->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
+    actionCollection()->setDefaultShortcut(popoutSplit, Qt::SHIFT | Qt::Key_F3);
+    m_splitViewAction->addAction(popoutSplit);
+    connect(popoutSplit, &QAction::triggered, this, &DolphinMainWindow::popoutSplitView);
 
     QAction *stashSplit = actionCollection()->addAction(QStringLiteral("split_stash"));
     actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL | Qt::Key_S);
@@ -1777,7 +1868,14 @@ void DolphinMainWindow::setupActions()
     stashSplit->setVisible(sessionInterface && sessionInterface->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
     connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
 
-    KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
+    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"));
@@ -1804,7 +1902,7 @@ void DolphinMainWindow::setupActions()
     replaceLocation->setWhatsThis(xi18nc("@info:whatsthis",
                                          "This switches to editing the location and selects it "
                                          "so you can quickly enter a different location."));
-    actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL | Qt::Key_L);
+    actionCollection()->setDefaultShortcuts(replaceLocation, {Qt::CTRL | Qt::Key_L, Qt::ALT | Qt::Key_D});
     connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
 
     // setup 'Go' menu
@@ -1814,10 +1912,10 @@ void DolphinMainWindow::setupActions()
         m_backAction->setObjectName(backAction->objectName());
         m_backAction->setShortcuts(backAction->shortcuts());
     }
-    m_backAction->setPopupMode(QToolButton::DelayedPopup);
+    m_backAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
     connect(m_backAction, &QAction::triggered, this, &DolphinMainWindow::goBack);
-    connect(m_backAction->menu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu);
-    connect(m_backAction->menu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoBack);
+    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();
@@ -1855,18 +1953,18 @@ void DolphinMainWindow::setupActions()
         m_forwardAction->setObjectName(forwardAction->objectName());
         m_forwardAction->setShortcuts(forwardAction->shortcuts());
     }
-    m_forwardAction->setPopupMode(QToolButton::DelayedPopup);
+    m_forwardAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
     connect(m_forwardAction, &QAction::triggered, this, &DolphinMainWindow::goForward);
-    connect(m_forwardAction->menu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu);
-    connect(m_forwardAction->menu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoForward);
+    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->menu()->installEventFilter(middleClickEventFilter);
-    m_forwardAction->menu()->installEventFilter(middleClickEventFilter);
+    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",
@@ -2017,6 +2115,13 @@ void DolphinMainWindow::setupActions()
     openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
     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-right-new")));
+    connect(openInSplitViewAction, &QAction::triggered, this, [this]() {
+        openInSplitView(QUrl());
+    });
 }
 
 void DolphinMainWindow::setupDockWidgets()
@@ -2051,8 +2156,7 @@ void DolphinMainWindow::setupDockWidgets()
     connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
     infoDock->setWidget(infoPanel);
 
-    QAction *infoAction = infoDock->toggleViewAction();
-    createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoAction, QStringLiteral("show_information_panel"));
+    createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoDock, QStringLiteral("show_information_panel"));
 
     addDockWidget(Qt::RightDockWidgetArea, infoDock);
     connect(this, &DolphinMainWindow::urlChanged, infoPanel, &InformationPanel::setUrl);
@@ -2095,8 +2199,7 @@ void DolphinMainWindow::setupDockWidgets()
     foldersPanel->setCustomContextMenuActions({lockLayoutAction});
     foldersDock->setWidget(foldersPanel);
 
-    QAction *foldersAction = foldersDock->toggleViewAction();
-    createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersAction, QStringLiteral("show_folders_panel"));
+    createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersDock, QStringLiteral("show_folders_panel"));
 
     addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
     connect(this, &DolphinMainWindow::urlChanged, foldersPanel, &FoldersPanel::setUrl);
@@ -2126,6 +2229,7 @@ void DolphinMainWindow::setupDockWidgets()
         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);
@@ -2135,8 +2239,7 @@ void DolphinMainWindow::setupDockWidgets()
         connect(terminalDock, &DolphinDockWidget::visibilityChanged, m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
         connect(terminalDock, &DolphinDockWidget::visibilityChanged, this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
 
-        QAction *terminalAction = terminalDock->toggleViewAction();
-        createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
+        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);
@@ -2182,8 +2285,7 @@ void DolphinMainWindow::setupDockWidgets()
     m_placesPanel->setCustomContextMenuActions({lockLayoutAction});
     placesDock->setWidget(m_placesPanel);
 
-    QAction *placesAction = placesDock->toggleViewAction();
-    createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel"));
+    createPanelAction(QIcon::fromTheme(QStringLiteral("compass")), Qt::Key_F9, placesDock, QStringLiteral("show_places_panel"));
 
     addDockWidget(Qt::LeftDockWidgetArea, placesDock);
     connect(m_placesPanel, &PlacesPanel::placeActivated, this, &DolphinMainWindow::slotPlaceActivated);
@@ -2192,6 +2294,7 @@ void DolphinMainWindow::setupDockWidgets()
     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);
@@ -2208,7 +2311,7 @@ void DolphinMainWindow::setupDockWidgets()
                                             "all places in the places panel that have been hidden. They will "
                                             "appear semi-transparent unless you uncheck their hide property."));
 
-    connect(actionShowAllPlaces, &QAction::triggered, this, [actionShowAllPlaces, this](bool checked) {
+    connect(actionShowAllPlaces, &QAction::triggered, this, [this](bool checked) {
         m_placesPanel->setShowAll(checked);
     });
     connect(m_placesPanel, &PlacesPanel::allPlacesShownChanged, actionShowAllPlaces, &QAction::setChecked);
@@ -2252,7 +2355,7 @@ void DolphinMainWindow::setupDockWidgets()
     panelsMenu->addAction(actionShowAllPlaces);
     panelsMenu->addAction(lockLayoutAction);
 
-    connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this] {
+    connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces] {
         actionShowAllPlaces->setEnabled(DolphinPlacesModelSingleton::instance().placesModel()->hiddenCount());
     });
 }
@@ -2343,7 +2446,7 @@ void DolphinMainWindow::updateViewActions()
     QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
     toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
 
-    updateSplitAction();
+    updateSplitActions();
 }
 
 void DolphinMainWindow::updateGoActions()
@@ -2372,7 +2475,7 @@ void DolphinMainWindow::refreshViews()
         updateWindowTitle();
     }
 
-    updateSplitAction();
+    updateSplitActions();
 
     Q_EMIT settingsChanged();
 }
@@ -2386,6 +2489,7 @@ 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::searchModeEnabledChanged, this, &DolphinMainWindow::updateSearchAction);
     connect(container, &DolphinViewContainer::captionChanged, this, &DolphinMainWindow::updateWindowTitle);
     connect(container, &DolphinViewContainer::tabRequested, this, &DolphinMainWindow::openNewTab);
@@ -2430,25 +2534,37 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container)
     connect(navigator, &KUrlNavigator::newWindowRequested, this, &DolphinMainWindow::openNewWindow);
 }
 
-void DolphinMainWindow::updateSplitAction()
+void DolphinMainWindow::updateSplitActions()
 {
-    QAction *splitAction = actionCollection()->action(QStringLiteral("split_view"));
+    QAction *popoutSplitAction = actionCollection()->action(QStringLiteral("popout_split_view"));
     const DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
     if (tabPage->splitViewEnabled()) {
         if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) {
-            splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
-            splitAction->setToolTip(i18nc("@info", "Close left view"));
-            splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
+            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")));
+            popoutSplitAction->setText(i18nc("@action:intoolbar Move left split view to a new window", "Pop out"));
+            popoutSplitAction->setToolTip(i18nc("@info", "Move left split view to a new window"));
         } else {
-            splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
-            splitAction->setToolTip(i18nc("@info", "Close right view"));
-            splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
+            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")));
+            popoutSplitAction->setText(i18nc("@action:intoolbar Move right split view to a new window", "Pop out"));
+            popoutSplitAction->setToolTip(i18nc("@info", "Move right split view to a new window"));
         }
+        popoutSplitAction->setEnabled(true);
     } else {
-        splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
-        splitAction->setToolTip(i18nc("@info", "Split view"));
-        splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
+        m_splitViewAction->setText(i18nc("@action:intoolbar Split view", "Split"));
+        m_splitViewAction->setToolTip(i18nc("@info", "Split view"));
+        m_splitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
+        popoutSplitAction->setText(i18nc("@action:intoolbar Move active split view to a new window", "Pop out"));
+        popoutSplitAction->setEnabled(false);
     }
+
+    // Update state from toolbar action
+    m_splitViewMenuAction->setText(m_splitViewAction->text());
+    m_splitViewMenuAction->setToolTip(m_splitViewAction->toolTip());
+    m_splitViewMenuAction->setIcon(m_splitViewAction->icon());
 }
 
 void DolphinMainWindow::updateAllowedToolbarAreas()
@@ -2477,18 +2593,16 @@ bool DolphinMainWindow::isKompareInstalled() const
     return installed;
 }
 
-void DolphinMainWindow::createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QAction *dockAction, const QString &actionName)
+void DolphinMainWindow::createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QDockWidget *dockWidget, const QString &actionName)
 {
-    QAction *panelAction = actionCollection()->addAction(actionName);
-    panelAction->setCheckable(true);
-    panelAction->setChecked(dockAction->isChecked());
-    panelAction->setText(dockAction->text());
-    panelAction->setIcon(icon);
+    auto dockAction = dockWidget->toggleViewAction();
     dockAction->setIcon(icon);
+    dockAction->setEnabled(true);
+
+    QAction *panelAction = actionCollection()->addAction(actionName, dockAction);
     actionCollection()->setDefaultShortcut(panelAction, shortcut);
 
-    connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
-    connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked);
+    connect(panelAction, &QAction::toggled, dockWidget, &QWidget::setVisible);
 }
 // clang-format off
 void DolphinMainWindow::setupWhatsThis()
@@ -2702,3 +2816,5 @@ bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem)
 {
     return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem));
 }
+
+#include "moc_dolphinmainwindow.cpp"