]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabwidget.cpp
Set the focus to the active view if the current tab has been changed.
[dolphin.git] / src / dolphintabwidget.cpp
index 4bb70b4eab62a75151b1f07a9b509113583cd9f6..c6607e52933c988fbf6cf06dc2d2c3a265e0d60c 100644 (file)
@@ -72,7 +72,7 @@ void DolphinTabWidget::saveProperties(KConfigGroup& group) const
 
     for (int i = 0; i < tabCount; ++i) {
         const DolphinTabPage* tabPage = tabPageAt(i);
-        group.writeEntry("Tab " % QString::number(i), tabPage->saveState());
+        group.writeEntry("Tab Data " % QString::number(i), tabPage->saveState());
     }
 }
 
@@ -83,8 +83,15 @@ void DolphinTabWidget::readProperties(const KConfigGroup& group)
         if (i >= count()) {
             openNewActivatedTab();
         }
-        const QByteArray state = group.readEntry("Tab " % QString::number(i), QByteArray());
-        tabPageAt(i)->restoreState(state);
+        if (group.hasKey("Tab Data " % QString::number(i))) {
+            // Tab state created with Dolphin > 4.14.x
+            const QByteArray state = group.readEntry("Tab Data " % QString::number(i), QByteArray());
+            tabPageAt(i)->restoreState(state);
+        } else {
+            // Tab state created with Dolphin <= 4.14.x
+            const QByteArray state = group.readEntry("Tab " % QString::number(i), QByteArray());
+            tabPageAt(i)->restoreStateV1(state);
+        }
     }
 
     const int index = group.readEntry("Active Tab Index", 0);
@@ -213,12 +220,7 @@ void DolphinTabWidget::closeTab(const int index)
     }
 
     DolphinTabPage* tabPage = tabPageAt(index);
-    if (tabPage->splitViewEnabled()) {
-        emit rememberClosedTab(tabPage->primaryViewContainer()->url(),
-                               tabPage->secondaryViewContainer()->url());
-    } else {
-        emit rememberClosedTab(tabPage->primaryViewContainer()->url(), KUrl());
-    }
+    emit rememberClosedTab(tabPage->activeViewContainer()->url(), tabPage->saveState());
 
     removeTab(index);
     tabPage->deleteLater();
@@ -249,6 +251,12 @@ void DolphinTabWidget::slotPlacesPanelVisibilityChanged(bool visible)
     }
 }
 
+void DolphinTabWidget::restoreClosedTab(const QByteArray& state)
+{
+    openNewActivatedTab();
+    currentTabPage()->restoreState(state);
+}
+
 void DolphinTabWidget::detachTab(int index)
 {
     Q_ASSERT(index >= 0);
@@ -294,12 +302,20 @@ void DolphinTabWidget::tabUrlChanged(const KUrl& url)
     if (index >= 0) {
         tabBar()->setTabText(index, tabName(url));
         tabBar()->setTabIcon(index, KIcon(KMimeType::iconNameForUrl(url)));
+
+        // Emit the currentUrlChanged signal if the url of the current tab has been changed.
+        if (index == currentIndex()) {
+            emit currentUrlChanged(url);
+        }
     }
 }
 
 void DolphinTabWidget::currentTabChanged(int index)
 {
-    emit activeViewChanged(tabPageAt(index)->activeViewContainer());
+    DolphinViewContainer* viewContainer = tabPageAt(index)->activeViewContainer();
+    emit activeViewChanged(viewContainer);
+    emit currentUrlChanged(viewContainer->url());
+    viewContainer->view()->setFocus();
 }
 
 void DolphinTabWidget::tabInserted(int index)