Bug 166573

Summary: minimum tab width is too wide
Product: [Applications] konsole Reporter: Felix Miata <mrmazda>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: wishlist CC: alex, chemobejk, des, lecha, michalm, petr, rastos_kdebugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: make the QTabBar not expanding

Description Felix Miata 2008-07-14 21:34:10 UTC
Version:            (using Devel)
Installed from:    Compiled sources
OS:                Linux

In KDE3, tabs are only as wide as required to contain the name of whatever is running in them, e.g. shell, root shell, or root midnight commander. In KDE4, with only two tabs open, each tab is about 41 characters wide, and yet, the two tabs only use about 2/3 of the available (120 character) window width devoted to tab space. If I open a 3rd tab, the used space is about 75% of the available width. Even with 4 tabs, all the available width is not used, leaving roughly 20% unused. Instead of what happens now, either all the available width should be used; or only enough for each tab as its content requires, with a minimum of 6-8 or 10 characters.
Comment 1 Felix Miata 2008-07-14 21:47:55 UTC
I'm using Mandriva Cooker (devel) RPMs, not compiling myself.
Comment 2 Drew Fisher 2008-07-15 01:07:36 UTC
For the record, I think that the empty tab-space unit is left so one can double-click in the open space to open a new tab.  I personally wouldn't mind minimum-width tabs, though.
Comment 3 Rasto Stanik 2009-05-16 13:10:02 UTC
I figured how to do it. With Qt 4.5 there is a new property for QTabBar widget which has name "expanding" and defaults to "true". If set to "false" (for example in TabbedViewContainer constructor) you can specify the new width by changing ViewContainerTabBar::tabSizeHint(). All that in in apps/konsole/src/ViewContainer.cpp in kdebase.

Now the question is - what is the desired width? Do we want 
- a fixed width
- to fit the text of tab name 
- to fit the text of tab name with upper limit (perhaps with a tooltip?)
- something else
The 1st option is easiest - just say the number of pixels. For 2nd and 3rd - I would need to figure out the length of string in pixels based on font ... no idea how difficult is that.
Comment 4 Felix Miata 2009-05-16 13:54:26 UTC
(In reply to comment #3)
> Now the question is - what is the desired width? Do we want 
> - a fixed width
> - to fit the text of tab name 
> - to fit the text of tab name with upper limit (perhaps with a tooltip?)
> - something else
> The 1st option is easiest - just say the number of pixels. For 2nd and 3rd - I
> would need to figure out the length of string in pixels based on font ... no
> idea how difficult is that.

Width in px is not acceptable unless the width in px is derived from the width of the font to be used. How many px are required is double if your desktop DPI is 140 instead of 70. Fit the text with upper limit makes most sense to me.
Comment 5 Rasto Stanik 2009-05-16 20:33:27 UTC
Created attachment 33733 [details]
make the QTabBar not expanding

In the attachment is a single-line patch that says that the QTabBar used in Konsole is not expanding to fill available space. The patch was created using Slackware-current source code package ftp://ftp.slackware.at/slackware-current/source/kde/src/kdebase-4.2.3.tar.xz

Note: there is already a hardcoded limit of 20 characters on the tab's text in TabbedViewContainer::updateTitle(), so it is not necessary to limit the size of the tab width in ViewContainerTabBar::tabSizeHint().
Comment 6 Matthew Woehlke 2009-06-02 20:31:44 UTC
> I would need to figure out the length of string in pixels based on font ... no
> idea how difficult is that.

It's not difficult (although the answer you get is a "guess", you can only get actual width by rendering the text, but the guess is good enough 90% of the time).

I could provide sample code if you like.

That said, I prefer the current behavior when things "aren't crowded", but this relates closely to bug 192079 (which I believe is a duplicate, but I don't have an older bug number handy).
Comment 7 Petr Morávek 2009-12-13 17:32:28 UTC
*** This bug has been confirmed by popular vote. ***
Comment 8 Alex 2010-09-03 23:54:56 UTC
In KDE 4.5.x the situation is much worse. So worse in fact that I had to quit using konsole and start using terminate.

The problem in current version (konsole 4:4.5.1-0ubuntu1) is that the minimum tab width on the tab bar is so large that I can't open more than 4 or 5 tabs before the tabs have to "scroll". I.e.: they are not visible all together as before.

Since I need at least 20 open tabs to work I forcefully had to dump konsole and find an alternative :(

Please, pretty please revert to the old behavior on the tab bar!
Comment 9 Marco Aicardi 2010-09-04 14:20:16 UTC
Agree with Alex; having many tabs makes konsole unusable! :-(
Comment 10 Stefan Becker 2010-09-05 19:29:51 UTC
Me too. Minimum tab width should be reduced at least to what it was in KDE 4.4.

Or make it configurable for those of us that use a lot of tabs!
Comment 11 Kurt Hindenburg 2010-09-06 03:09:55 UTC
#9, #10 - at the time I had to put in a minimum otherwise no scrollbar would appear.  It does appear 150 was a bit much.  I'll look at it again.  Ideally, the tab text should be used to calculate the width.

What Konsole version were you getting 20 tabs w/o a scroll bar?  What was your tab format?
Comment 12 Stefan Becker 2010-09-06 04:45:09 UTC
It has worked OK with every konsole version before 4.5. For those tabs I talk about I have replaced the tab format with a fixed (mnemonic) text. I use "Lucida Typewriter 9" (mapped to a bitmap font of 12 pixels @ 75dpi) and a terminal size of 80x25, which leads to a size of 583x380 pixels, at least on the machine I'm typing this.

On my Fedora 14 test machine, which is the first one with KDE 4.5, I had been using the same size of konsole previously with 5 tabs and no scrolling. Now 4 tabs already cause tab scrolling.
Comment 13 Alex 2010-09-06 08:57:22 UTC
As Stefan: everything worked fine until pre 4.5 release: I renamed my tabs to have a single char so that I could fill the bar with lot of them.

This is now not possible anymore so I had to stop using it and thats bothers me very much :(
Comment 14 Kurt Hindenburg 2010-09-09 05:05:22 UTC
I've changed trunk to have a minimum and max width using stylesheets.  


setStyleSheet("QTabBar::tab { min-width: 2em; max-width: 25em }");

Comments welcomed.
Comment 15 Stefan Becker 2010-09-09 14:46:55 UTC
(In reply to comment #14)
> I've changed trunk to have a minimum and max width using stylesheets.

This seems to work nicely. Tab width is dynamic again and I was able to fit 10 one-letter tabs into my standard konsole window before the scrolling buttons appeared.
Comment 16 Alex 2010-09-09 16:28:41 UTC
I'm sorry I've to ask a stupid question since I've no knowledge of QT and stylesheets: do I have to wait for the next point release of KDE or is there a way to fix my current installation?

I'm running KDE 4.5.1 under Kubuntu 10.04.

Thanks,
Alex
Comment 17 Stefan Becker 2010-09-09 17:01:26 UTC
It's a code change, so you'll have to recompile the kdebase package. The patch can be extracted from SVN revision 1172362:

<http://websvn.kde.org/?view=revision&revision=1172362>
Comment 18 Kurt Hindenburg 2010-09-10 04:24:28 UTC
SVN commit 1173668 by hindenburg:

Change the way tab width is determined by using min/max stylesheet.

BUG: 166573
BUG: 189847
BUG: 157201


 M  +3 -21     ViewContainer.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1173668
Comment 19 Kurt Hindenburg 2010-09-15 15:01:33 UTC
*** Bug 251295 has been marked as a duplicate of this bug. ***