]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add option to choose which view to close
authorAngelo Oliveira Jr <angelojr.oliveira@gmail.com>
Sat, 16 Feb 2019 15:08:12 +0000 (16:08 +0100)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 16 Feb 2019 15:09:27 +0000 (16:09 +0100)
Summary:
This Diff make configurable which view will close when toggling off
the split view mode, if it's the active one or the inactive one.

A new checkbox was added to the Dolphin configuration window,
and defaults to the original behavior.

FEATURE: 312834
FIXED-IN: 19.03.80

Test Plan: {F6535432}

Reviewers: ngraham, #dolphin, elvisangelaccio

Reviewed By: ngraham, #dolphin

Subscribers: elvisangelaccio, cfeck, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D18040

src/dolphinmainwindow.cpp
src/dolphintabpage.cpp
src/settings/dolphin_generalsettings.kcfg
src/settings/general/behaviorsettingspage.cpp
src/settings/general/behaviorsettingspage.h

index 076869c1ac0bea75365e03745582b9e53708f580..8be788eaea6cbd2b3d7d551ccbd638b49290abe7 100644 (file)
@@ -1606,7 +1606,7 @@ void DolphinMainWindow::updateSplitAction()
     QAction* splitAction = actionCollection()->action(QStringLiteral("split_view"));
     const DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
     if (tabPage->splitViewEnabled()) {
-        if (tabPage->primaryViewActive()) {
+        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")));
index 0193aaad0a714164f9650a1688e3963e97a40fa3..e0e9bf4bdbcb50faffd0dfbb265bb0dc0e3345e1 100644 (file)
@@ -88,13 +88,23 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, const QUrl &secondaryUrl)
             m_secondaryViewContainer->show();
             m_secondaryViewContainer->setActive(true);
         } else {
-            // Close the view which is active.
-            DolphinViewContainer* view = activeViewContainer();
-            if (m_primaryViewActive) {
-                // If the primary view is active, we have to swap the pointers
-                // because the secondary view will be the new primary view.
-                qSwap(m_primaryViewContainer, m_secondaryViewContainer);
-                m_primaryViewActive = false;
+            DolphinViewContainer* view;
+            if (GeneralSettings::closeActiveSplitView()) {
+                view = activeViewContainer();
+                if (m_primaryViewActive) {
+                    // If the primary view is active, we have to swap the pointers
+                    // because the secondary view will be the new primary view.
+                    qSwap(m_primaryViewContainer, m_secondaryViewContainer);
+                    m_primaryViewActive = false;
+                }
+            } else {
+                view = m_primaryViewActive ? m_secondaryViewContainer : m_primaryViewContainer;
+                if (!m_primaryViewActive) {
+                    // If the secondary view is active, we have to swap the pointers
+                    // because the secondary view will be the new primary view.
+                    qSwap(m_primaryViewContainer, m_secondaryViewContainer);
+                    m_primaryViewActive = true;
+                }
             }
             m_primaryViewContainer->setActive(true);
             view->close();
index b06b3a1f3dc11dd494ab11aaf04c356ae342584d..e76103c5e6f1b774d9ff18bf43737ef6467b5349 100644 (file)
             <label>Use tab for switching between right and left split</label>
             <default>false</default>
         </entry>
+        <entry name="CloseActiveSplitView" type="Bool">
+            <label>Close active view when toggling off</label>
+            <default>true</default>
+        </entry>
         <entry name="ShowToolTips" type="Bool">
             <label>Show tooltips</label>
             <default>false</default>
index add9acad58e6a41e2b17e11a85680a0ee39dcce1..0b5cee7aaf38c9946417217679bcfb7475199d4f 100644 (file)
@@ -100,6 +100,11 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
     m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check", "Switch between split views with tab key"));
     topLayout->addRow(QString(), m_useTabForSplitViewSwitch);
 
+    // 'Close active view when turning off split view'
+    m_closeActiveSplitView = new QCheckBox(i18nc("option:check", "Turning off split view closes active pane"));
+    topLayout->addRow(QString(), m_closeActiveSplitView);
+    m_closeActiveSplitView->setToolTip(i18n("When deactivated, turning off split view will close the inactive pane"));
+
     loadSettings();
 
     connect(m_localViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
@@ -113,6 +118,7 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
     connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_useTabForSplitViewSwitch, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+    connect(m_closeActiveSplitView, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
 }
 
 BehaviorSettingsPage::~BehaviorSettingsPage()
@@ -133,6 +139,7 @@ void BehaviorSettingsPage::applySettings()
     setSortingChoiceValue(settings);
     settings->setRenameInline(m_renameInline->isChecked());
     settings->setUseTabForSwitchingSplitView(m_useTabForSplitViewSwitch->isChecked());
+    settings->setCloseActiveSplitView(m_closeActiveSplitView->isChecked());
     settings->save();
 
     if (useGlobalViewProps) {
@@ -165,6 +172,7 @@ void BehaviorSettingsPage::loadSettings()
     m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
     m_renameInline->setChecked(GeneralSettings::renameInline());
     m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView());
+    m_closeActiveSplitView->setChecked(GeneralSettings::closeActiveSplitView());
 
     loadSortingChoiceSettings();
 }
index 779fae3770de48dff19ff111d67b59f9f7e4cd4c..d26a709d3df864ec8d8244bc5afc5704286d875b 100644 (file)
@@ -67,6 +67,7 @@ private:
 
     QCheckBox* m_renameInline;
     QCheckBox* m_useTabForSplitViewSwitch;
+    QCheckBox* m_closeActiveSplitView;
 };
 
 #endif