]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Allow popping out a split view
authorLoren Burkholder <computersemiexpert@outlook.com>
Fri, 7 Apr 2023 00:05:48 +0000 (20:05 -0400)
committerLoren Burkholder <computersemiexpert@outlook.com>
Thu, 18 Jan 2024 23:29:23 +0000 (23:29 +0000)
If you have a split view open, you can now pop the active half out into a new window by clicking the "Pop out" button in the toolbar or by activating "View > Pop out".

BUG: 270604

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinui.rc

index d73cc4866d9472964df0693b84ed71f756a3877c..308cd166f8c4228598ba7fb66609a2e0a7750e62 100644 (file)
@@ -469,7 +469,7 @@ void DolphinMainWindow::openNewWindow(const QUrl &url)
 void DolphinMainWindow::slotSplitViewChanged()
 {
     m_tabWidget->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation);
-    updateSplitAction();
+    updateSplitActions();
 }
 
 void DolphinMainWindow::openInNewTab()
@@ -984,6 +984,15 @@ void DolphinMainWindow::toggleSplitView()
     updateViewActions();
 }
 
+void DolphinMainWindow::popoutSplitView()
+{
+    DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+    if (!tabPage->splitViewEnabled())
+        return;
+    openNewWindow(tabPage->activeViewContainer()->url());
+    tabPage->setSplitViewEnabled(false, WithAnimation);
+}
+
 void DolphinMainWindow::toggleSplitStash()
 {
     DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
@@ -1829,6 +1838,14 @@ void DolphinMainWindow::setupActions()
     actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
     connect(split, &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);
+    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"));
@@ -2417,7 +2434,7 @@ void DolphinMainWindow::updateViewActions()
     QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
     toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
 
-    updateSplitAction();
+    updateSplitActions();
 }
 
 void DolphinMainWindow::updateGoActions()
@@ -2446,7 +2463,7 @@ void DolphinMainWindow::refreshViews()
         updateWindowTitle();
     }
 
-    updateSplitAction();
+    updateSplitActions();
 
     Q_EMIT settingsChanged();
 }
@@ -2505,24 +2522,31 @@ 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")));
+            popoutSplitAction->setText(i18nc("@action:intoolbar Pop out left view", "Pop out"));
+            popoutSplitAction->setToolTip(i18nc("@info", "Pop out left view"));
         } 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")));
+            popoutSplitAction->setText(i18nc("@action:intoolbar Pop out right view", "Pop out"));
+            popoutSplitAction->setToolTip(i18nc("@info", "Pop out right view"));
         }
+        popoutSplitAction->setVisible(true);
     } else {
         splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
         splitAction->setToolTip(i18nc("@info", "Split view"));
         splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
+        popoutSplitAction->setVisible(false);
     }
 }
 
index bff0ef4de8cac5d60908bc07ef80036832db98c7..844360aaaa446285488b73e51f00ae708149ef3b 100644 (file)
@@ -343,6 +343,13 @@ private Q_SLOTS:
      */
     void toggleSplitView();
 
+    /**
+     * Pops out a split view.
+     * The active view will be popped out, unless the view is not split,
+     * in which case nothing will happen.
+     */
+    void popoutSplitView();
+
     /** Dedicated action to open the stash:/ ioslave in split view. */
     void toggleSplitStash();
 
@@ -662,7 +669,7 @@ private:
      * otherwise the text is set to "Join". The icon
      * is updated to match with the text and the currently active view.
      */
-    void updateSplitAction();
+    void updateSplitActions();
 
     /**
      * Sets the window sides the toolbar may be moved to based on toolbar contents.
index 0eca6b8fe3fb46312ea3c2a9cca008f64081cee7..7d35ed3037e7bc4808562e77581bf30ee30624b8 100644 (file)
@@ -50,6 +50,7 @@
             <Action name="show_hidden_files" />
             <Separator/>
             <Action name="split_view" />
+            <Action name="popout_split_view" />
             <Action name="split_stash" />
             <Action name="redisplay" />
             <Action name="stop" />
         <Action name="details" />
         <Action name="url_navigators" />
         <Action name="split_view" />
+        <Action name="popout_split_view" />
         <Action name="split_stash" />
         <Action name="toggle_search" />
         <Action name="hamburger_menu" />