]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Set Maximum Tab Width for folders to Tab bar
authorK. Cottonears <k_cottonears@pm.me>
Thu, 17 Aug 2023 07:22:49 +0000 (07:22 +0000)
committerMéven Car <meven.car@kdemail.net>
Thu, 17 Aug 2023 07:22:49 +0000 (07:22 +0000)
There is no limit to the width of tabs with the tab bar of the main window. If the directory name is too long, tabs can take up a lot of space and can lead to inconsistent tab widths.

To alleviate this, set a maximum tab bar text width of 40 characters for each folder.

BUG: 420870

src/dolphintabwidget.cpp

index 03f09ca86810378cad5cc52abb395fab54f1eb11..89dd9feba544bf598a77b270f8e01e0eb501934d 100644 (file)
@@ -15,6 +15,7 @@
 #include <KIO/CommandLauncherJob>
 #include <KLocalizedString>
 #include <KShell>
+#include <KStringHandler>
 #include <kio/global.h>
 
 #include <QApplication>
@@ -507,7 +508,7 @@ QString DolphinTabWidget::tabName(DolphinTabPage *tabPage) const
 
     // Make sure that a '&' inside the directory name is displayed correctly
     // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
-    return name.replace('&', QLatin1String("&&"));
+    return KStringHandler::rsqueeze(name.replace('&', QLatin1String("&&")), 40 /* default maximum visible folder name visible */);
 }
 
 DolphinViewContainer *DolphinTabWidget::viewContainerAt(DolphinTabWidget::ViewIndex viewIndex) const