]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabwidget.cpp
prevent excessive tab opening
[dolphin.git] / src / dolphintabwidget.cpp
index 0e7012d3b687316be7097b249ea023b79f404d72..5586c9df26ad8887e6c159bdb5bb8646e719fbc0 100644 (file)
@@ -162,10 +162,17 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
             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));
+    });
+
     int newTabIndex = -1;
     if (!GeneralSettings::openNewTabAfterLastTab()) {
         newTabIndex = currentIndex() + 1;
     }
+
     insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
 
     if (focusWidget) {
@@ -229,7 +236,7 @@ void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
     // directories are shown inside one tab (see openDirectories()).
     QList<QUrl> dirs;
     for (const QUrl& url : files) {
-        const QUrl dir(url.adjusted(QUrl::RemoveFilename));
+        const QUrl dir(url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash));
         if (!dirs.contains(dir)) {
             dirs.append(dir);
         }