]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabpage.cpp
Merge branch 'Applications/18.04'
[dolphin.git] / src / dolphintabpage.cpp
index 5c42d41ec7c2e97236542a7923e55b919813bbbb..b2bb5c896d95d720c4cab58a8f4d268c6c46214a 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "dolphintabpage.h"
 
-#include "dolphinviewcontainer.h"
 #include "dolphin_generalsettings.h"
+#include "dolphinviewcontainer.h"
 
 #include <QSplitter>
 #include <QVBoxLayout>
@@ -28,7 +28,8 @@
 DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
     QWidget(parent),
     m_primaryViewActive(true),
-    m_splitViewEnabled(false)
+    m_splitViewEnabled(false),
+    m_active(true)
 {
     QVBoxLayout* layout = new QVBoxLayout(this);
     layout->setSpacing(0);
@@ -93,6 +94,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, const QUrl &secondaryUrl)
                 // 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;
             }
             m_primaryViewContainer->setActive(true);
             view->close();
@@ -286,17 +288,34 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
     m_splitter->restoreState(splitterState);
 }
 
+void DolphinTabPage::setActive(bool active)
+{
+    if (active) {
+        m_active = active;
+    } else {
+        // we should bypass changing active view in split mode
+        m_active = !m_splitViewEnabled;
+    }
+    // we want view to fire activated when goes from false to true
+    activeViewContainer()->setActive(active);
+}
+
 void DolphinTabPage::slotViewActivated()
 {
     const DolphinView* oldActiveView = activeViewContainer()->view();
 
     // Set the view, which was active before, to inactive
-    // and update the active view type.
-    if (m_splitViewEnabled) {
-        activeViewContainer()->setActive(false);
-        m_primaryViewActive = !m_primaryViewActive;
-    } else {
-        m_primaryViewActive = true;
+    // and update the active view type, if tab is active
+    if (m_active) {
+        if (m_splitViewEnabled) {
+            activeViewContainer()->setActive(false);
+            m_primaryViewActive = !m_primaryViewActive;
+        } else {
+            m_primaryViewActive = true;
+            if (m_secondaryViewContainer) {
+                m_secondaryViewContainer->setActive(false);
+            }
+        }
     }
 
     const DolphinView* newActiveView = activeViewContainer()->view();