┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorElvis Angelaccio <[email protected]>2018-04-25 13:42:18 +0200
committerElvis Angelaccio <[email protected]>2018-04-25 13:42:18 +0200
commit362244ccbe694442b9145bbcea975f91b4c44af1 (patch)
treedccb352b8f5bfd9e2a18b942fcc2c6b5bbf3837a /src
parent9ec813597430db05326c24a8e0e07c5539387e27 (diff)
DolphinTabPage: deactivate secondary view after closing split view
We deactivate the previously active view container whenever we change the active split view, but we never do the same when we close the split view. Long term we should probably even delete the secondary view after closing the split view, because it will never be used again and the pointer will be overwritten the next time the user opens the split view.
Diffstat (limited to 'src')
-rw-r--r--src/dolphintabpage.cpp3
-rw-r--r--src/tests/dolphinmainwindowtest.cpp55
2 files changed, 58 insertions, 0 deletions
diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp
index a96c8b6a3..b2bb5c896 100644
--- a/src/dolphintabpage.cpp
+++ b/src/dolphintabpage.cpp
@@ -312,6 +312,9 @@ void DolphinTabPage::slotViewActivated()
m_primaryViewActive = !m_primaryViewActive;
} else {
m_primaryViewActive = true;
+ if (m_secondaryViewContainer) {
+ m_secondaryViewContainer->setActive(false);
+ }
}
}
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp
index a31237f3c..70ec8dba0 100644
--- a/src/tests/dolphinmainwindowtest.cpp
+++ b/src/tests/dolphinmainwindowtest.cpp
@@ -34,6 +34,8 @@ class DolphinMainWindowTest : public QObject
private slots:
void init();
void testClosingTabsWithSearchBoxVisible();
+ void testActiveViewAfterClosingSplitView_data();
+ void testActiveViewAfterClosingSplitView();
void testUpdateWindowTitleAfterClosingSplitView();
private:
@@ -68,6 +70,58 @@ void DolphinMainWindowTest::testClosingTabsWithSearchBoxVisible()
QCOMPARE(tabWidget->count(), 1);
}
+void DolphinMainWindowTest::testActiveViewAfterClosingSplitView_data()
+{
+ QTest::addColumn<bool>("closeLeftView");
+
+ QTest::newRow("close left view") << true;
+ QTest::newRow("close right view") << false;
+}
+
+void DolphinMainWindowTest::testActiveViewAfterClosingSplitView()
+{
+ m_mainWindow->openDirectories({ QUrl::fromLocalFile(QDir::homePath()) }, false);
+ m_mainWindow->show();
+ QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
+ QVERIFY(m_mainWindow->isVisible());
+
+ auto tabWidget = m_mainWindow->findChild<DolphinTabWidget*>("tabWidget");
+ QVERIFY(tabWidget);
+ QVERIFY(tabWidget->currentTabPage()->primaryViewContainer());
+ QVERIFY(!tabWidget->currentTabPage()->secondaryViewContainer());
+
+ // Open split view.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
+ QVERIFY(tabWidget->currentTabPage()->secondaryViewContainer());
+
+ // Make sure the right view is the active one.
+ auto leftViewContainer = tabWidget->currentTabPage()->primaryViewContainer();
+ auto rightViewContainer = tabWidget->currentTabPage()->secondaryViewContainer();
+ QVERIFY(!leftViewContainer->isActive());
+ QVERIFY(rightViewContainer->isActive());
+
+ QFETCH(bool, closeLeftView);
+ if (closeLeftView) {
+ // Activate left view.
+ leftViewContainer->setActive(true);
+ QVERIFY(leftViewContainer->isActive());
+ QVERIFY(!rightViewContainer->isActive());
+
+ // Close left view. The secondary view (which was on the right) will become the primary one and must be active.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(!leftViewContainer->isActive());
+ QVERIFY(rightViewContainer->isActive());
+ QCOMPARE(rightViewContainer, tabWidget->currentTabPage()->activeViewContainer());
+ } else {
+ // Close right view. The left view will become active.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(leftViewContainer->isActive());
+ QVERIFY(!rightViewContainer->isActive());
+ QCOMPARE(leftViewContainer, tabWidget->currentTabPage()->activeViewContainer());
+ }
+}
+
// Test case for bug #385111
void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
{
@@ -99,6 +153,7 @@ void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
// Close split view. The secondary view (which was on the right) will become the primary one and must be active.
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(!leftViewContainer->isActive());
QVERIFY(rightViewContainer->isActive());
QCOMPARE(rightViewContainer, tabWidget->currentTabPage()->activeViewContainer());