]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabpage.cpp
Update window title after closing split view
[dolphin.git] / src / dolphintabpage.cpp
index e6440af5e22b0249f1ff61cdebcc40bcb826238c..a96c8b6a32dc6706c6aae1abb90dd465ea2703fb 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);
@@ -71,17 +72,13 @@ bool DolphinTabPage::splitViewEnabled() const
     return m_splitViewEnabled;
 }
 
-void DolphinTabPage::setSplitViewEnabled(bool enabled, bool stash /*= false*/)
+void DolphinTabPage::setSplitViewEnabled(bool enabled, const QUrl &secondaryUrl)
 {
     if (m_splitViewEnabled != enabled) {
         m_splitViewEnabled = enabled;
-        QUrl url;
+
         if (enabled) {
-            if (stash) {
-                url = QUrl("stash:/");
-            } else {
-                url = m_primaryViewContainer->url();
-            }
+            const QUrl& url = (secondaryUrl.isEmpty()) ? m_primaryViewContainer->url() : secondaryUrl;
             m_secondaryViewContainer = createViewContainer(url);
 
             const bool placesSelectorVisible = m_primaryViewContainer->urlNavigator()->isPlacesSelectorVisible();
@@ -97,6 +94,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, bool stash /*= false*/)
                 // 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();
@@ -290,17 +288,31 @@ 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;
+        }
     }
 
     const DolphinView* newActiveView = activeViewContainer()->view();