Bug 59350

Summary: Need a minimum tab width
Product: [Applications] konqueror Reporter: Jason Keirstead <jason>
Component: tabbingAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Jason Keirstead 2003-06-04 22:10:34 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

WIth the new close button on tabs in Konqueror, there is a renewed need for the feature requested in bug 48957, a minimum width setting for Konqueror tabs. If you make either a 1) new, blank tab or 2) a tab to a KURL with a very short title, the close button takes up nearly the entire width of the tab. It is difficult in general to select the tab, you have to carefully navigate around the close button to avoid closing it. 

While I much like the close buttons it would be helpful if there was a minimum width for tabs of say 75 or 100 pixels, so that you always have adequate room to click the tab without closing it.
Comment 1 Stephan Binner 2003-06-05 09:23:33 UTC
The close buttons doesn't occupies space at all, they take the space of the 
site icon. If no site icon, no close button. 
Comment 2 Jason Keirstead 2003-06-05 13:08:26 UTC
Exactly. And if you open a new, empty  tab in the background, or open a new one and 
click away for a second, or visit a site whose page title is ".", the icon takes up nearly 
100% of the tab width.  
Comment 3 Stephan Binner 2003-06-07 12:30:15 UTC
Close buttons could be disabled for tabs with no/small labels. Or delay before 
they show doubled? Not sure what is better. 
Comment 4 Unai Garro 2003-06-19 11:54:50 UTC
Statistics for today (after 1-2 weeks of use): During 3 hours I closed 5 pages by 
mistake.  It's just too easy to click on the "hidden" close button instead of switching 
tabs, no matter the size. Obviously, the smaller the tab, the greater the chances are. 
 
I wish these buttons are made optional, otherwise people will really complain when 
released. 
 
 
Comment 5 Jason Keirstead 2003-06-19 13:06:26 UTC
Subject: Re:  Need a minimum tab width

On June 19, 2003 06:54 am, you wrote:
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> http://bugs.kde.org/show_bug.cgi?id=59350
>
>
>
>
> ------- Additional Comments From Unai.Garro@ee.ed.ac.uk  2003-06-19 11:54
> ------- Statistics for today (after 1-2 weeks of use): During 3 hours I
> closed 5 pages by mistake.  It's just too easy to click on the "hidden"
> close button instead of switching tabs, no matter the size. Obviously, the
> smaller the tab, the greater the chances are.
>
> I wish these buttons are made optional, otherwise people will really
> complain when released.

They are optional. You can disable them with HoverCloseButtons=false or
something liek that in your config file. The preference is just not in CVS
yet. Thats why it's called development.

I in NO WAY want the buttons removed, I just want a minimum tab width so that
sometimes the button isn't nearly the *only* thing on the tab, making it impossible
to select



Comment 6 Yves Glodt 2004-03-13 12:42:17 UTC
IMHO the tabs should simply have a fixed width, and shrink equally as soon
as the tabbar is getting full.

This would also remove some flicker that occurs when the title
of the tab changes. This happens frequently when you open a new tab
with the MMB. If your tabbar is full, *all* the tabs get reiszed just because
of *one* changing tab-title.
Comment 7 Stephan Binner 2004-05-14 11:37:28 UTC
CVS commit by binner: 

Two more hidden tab options: MaximumTabLength and MinimumTabLength (in chars)
Latter defaults to 3 which implements the wish "Need a minimum tab width"
CCMAIL:59350-done@bugs.kde.org


  M +32 -13    konq_tabs.cc   1.49
  M +3 -1      konq_tabs.h   1.17


--- kdebase/konqueror/konq_tabs.cc  #1.48:1.49
@@ -53,5 +53,5 @@
 KonqFrameTabs::KonqFrameTabs(QWidget* parent, KonqFrameContainerBase* parentContainer,
                              KonqViewManager* viewManager, const char * name)
-  : KTabWidget(parent, name), m_CurrentMaxLength(30), m_rightWidget(0)
+  : KTabWidget(parent, name), m_rightWidget(0)
 {
   //kdDebug(1202) << "KonqFrameTabs::KonqFrameTabs()" << endl;
@@ -119,4 +119,11 @@ KonqFrameTabs::KonqFrameTabs(QWidget* pa
   KConfig *config = KGlobal::config();
   KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
+
+  m_maxLength = config->readNumEntry("MaximumTabLength", 30);
+  m_minLength = config->readNumEntry("MinimumTabLength", 3);
+  if (m_minLength>m_maxLength)
+    m_maxLength=m_minLength;
+  m_CurrentMaxLength = m_maxLength;
+
   m_permanentCloseButtons = config->readBoolEntry( "PermanentCloseButton", false );
   if (m_permanentCloseButtons) {
@@ -263,6 +270,5 @@ uint KonqFrameTabs::tabBarWidthForMaxCha
     }
 
-    if ( newTitle.length() > maxLength )
-      newTitle = newTitle.left( maxLength-3 ) + "...";
+    newTitle = constrainedTitle( newTitle, maxLength );
 
     QTab* tab = tabBar()->tabAt( i );
@@ -278,4 +284,17 @@ uint KonqFrameTabs::tabBarWidthForMaxCha
 }
 
+QString KonqFrameTabs::constrainedTitle( QString title, int maxLength )
+{
+    if ( title.length() > maxLength )
+      title = title.left( maxLength-3 ) + "...";
+
+    if ( title.length() < m_minLength && m_minLength <= maxLength ) {
+      QString tail;
+      tail.fill(' ', m_minLength - title.length());
+      title = title + tail;
+    }
+    return title;
+}
+
 void KonqFrameTabs::setTitle( const QString &title , QWidget* sender)
 {
@@ -284,5 +303,5 @@ void KonqFrameTabs::setTitle( const QStr
 
   uint lcw=0, rcw=0;
-#if QT_VERSION >= 0x030200
+
   int tabBarHeight = tabBar()->sizeHint().height();
   if ( cornerWidget( TopLeft ) && cornerWidget( TopLeft )->isVisible() )
@@ -290,10 +309,10 @@ void KonqFrameTabs::setTitle( const QStr
   if ( cornerWidget( TopRight ) && cornerWidget( TopRight )->isVisible() )
     rcw = QMAX( cornerWidget( TopRight )->width(), tabBarHeight );
-#endif
+
   uint maxTabBarWidth = width() - lcw - rcw;
   // kdDebug(1202) << "maxTabBarWidth=" << maxTabBarWidth << endl;
 
-  uint newMaxLength=30;
-  for ( ; newMaxLength > 3; newMaxLength-- ) {
+  uint newMaxLength=m_maxLength;
+  for ( ; newMaxLength > m_minLength; newMaxLength-- ) {
     // kdDebug(1202) << "tabBarWidthForMaxChars(" << newMaxLength
     //               << ")=" << tabBarWidthForMaxChars( newMaxLength ) << endl;
@@ -305,8 +324,8 @@ void KonqFrameTabs::setTitle( const QStr
   QString newTitle = title;
   if ( newTitle.length() > newMaxLength )
-    {
       setTabToolTip( sender, newTitle );
-      newTitle = newTitle.left( newMaxLength-3 ) + "...";
-    }
+
+  newTitle = constrainedTitle( newTitle, newMaxLength );
+
   newTitle.replace( '&', "&&" );
   if ( tabLabel( sender ) != newTitle )
@@ -328,8 +347,8 @@ void KonqFrameTabs::setTitle( const QStr
           removeTabToolTip( page( i ) );
           if ( newTitle.length() > newMaxLength )
-            {
               setTabToolTip( page( i ), newTitle );
-              newTitle = newTitle.left( newMaxLength-3 ) + "...";
-            }
+
+          newTitle = constrainedTitle( newTitle, newMaxLength );
+
           newTitle.replace( '&', "&&" );
           if ( newTitle != tabLabel( page( i ) ) )

--- kdebase/konqueror/konq_tabs.h  #1.16:1.17
@@ -116,8 +116,10 @@ private slots:
     void slotSubPopupMenuTabActivated( int);
 private:
+  QString constrainedTitle( QString title, int maxLength );
+
   KonqViewManager* m_pViewManager;
   QPopupMenu* m_pPopupMenu;
     QPopupMenu * m_pSubPopupMenuTab;
-  uint m_CurrentMaxLength;
+  uint m_CurrentMaxLength, m_maxLength, m_minLength;
   QToolButton* m_rightWidget;
   bool m_permanentCloseButtons;