]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix: closing split view doesn't update tab name
authorJin Liu <m.liu.jin@gmail.com>
Fri, 12 Jan 2024 04:56:43 +0000 (12:56 +0800)
committerJin Liu <m.liu.jin@gmail.com>
Sat, 13 Jan 2024 01:47:15 +0000 (01:47 +0000)
BUG: 469316

src/dolphinmainwindow.cpp
src/dolphintabwidget.cpp
src/dolphintabwidget.h

index 67a62eaac7914f2095e0d612d29a79c26f1b5072..745fa97cc8ddd1f5e9691a65f7267cf8974ce3d5 100644 (file)
@@ -920,6 +920,7 @@ void DolphinMainWindow::toggleSplitView()
 {
     DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
     tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled(), WithAnimation);
+    m_tabWidget->updateTabName(m_tabWidget->indexOf(tabPage));
     updateViewActions();
 }
 
index 11a720d20cf069477e13407fc38576aa1f520baf..35921647ed243e1a3234ef9f8b08076bb930ecc1 100644 (file)
@@ -104,11 +104,17 @@ void DolphinTabWidget::refreshViews()
 
     const int tabCount = count();
     for (int i = 0; i < tabCount; ++i) {
-        tabBar()->setTabText(i, tabName(tabPageAt(i)));
+        updateTabName(i);
         tabPageAt(i)->refreshViews();
     }
 }
 
+void DolphinTabWidget::updateTabName(int index)
+{
+    Q_ASSERT(index >= 0);
+    tabBar()->setTabText(index, tabName(tabPageAt(index)));
+}
+
 bool DolphinTabWidget::isUrlOpen(const QUrl &url) const
 {
     return viewOpenAtDirectory(url).has_value();
@@ -163,9 +169,7 @@ void DolphinTabWidget::openNewTab(const QUrl &primaryUrl, const QUrl &secondaryU
     connect(tabPage, &DolphinTabPage::activeViewChanged, this, &DolphinTabWidget::activeViewChanged);
     connect(tabPage, &DolphinTabPage::activeViewUrlChanged, this, &DolphinTabWidget::tabUrlChanged);
     connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() {
-        const int tabIndex = indexOf(tabPage);
-        Q_ASSERT(tabIndex >= 0);
-        tabBar()->setTabText(tabIndex, tabName(tabPage));
+        updateTabName(indexOf(tabPage));
     });
 
     if (position == NewTabPosition::FollowSetting) {
@@ -407,7 +411,7 @@ void DolphinTabWidget::tabUrlChanged(const QUrl &url)
 {
     const int index = indexOf(qobject_cast<QWidget *>(sender()));
     if (index >= 0) {
-        tabBar()->setTabText(index, tabName(tabPageAt(index)));
+        updateTabName(index);
         tabBar()->setTabToolTip(index, url.toDisplayString(QUrl::PreferLocalFile));
         if (tabBar()->isVisible()) {
             // ensure the path url ends with a slash to have proper folder icon for remote folders
index 5bc708b380b1024544202a1aba90cd5427794180..1bdb6c9a187f3daee8dcc7fd0cf72e143d908387 100644 (file)
@@ -69,6 +69,11 @@ public:
      */
     void refreshViews();
 
+    /**
+     * Update the name of the tab with the index \a index.
+     */
+    void updateTabName(int index);
+
     /**
      * @return Whether any of the tab pages has @p url opened
      * in their primary or secondary view.