Bug 363473 - KDevelop should use a different tab bar widget for tabbed documents
Summary: KDevelop should use a different tab bar widget for tabbed documents
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Documentview (show other bugs)
Version: git master
Platform: Compiled Sources macOS
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-24 16:18 UTC by RJVB
Modified: 2016-10-18 16:26 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.3


Attachments
KDevelop5 (background) and Kate5 (foreground) showing "wrong" and "right" tab bar types when using the native Mac OS X qpa & theme (41.86 KB, image/png)
2016-05-24 16:20 UTC, RJVB
Details
OS X Terminal.app preferences dialog showing appropriate use of the tabbar widget (108.63 KB, image/png)
2016-05-24 16:20 UTC, RJVB
Details
Xcode preferences window showing the modern tab bar style (102.96 KB, image/png)
2016-05-24 16:21 UTC, RJVB
Details
KDevelop5's tabbed document bar using the "wrong" tabbar widget and "lots" of files open. Who's who? (8.31 KB, image/png)
2016-05-24 16:22 UTC, RJVB
Details
OS X native tab widgets; docmode vs. standard (75.98 KB, image/png)
2016-09-08 20:36 UTC, RJVB
Details
lots of native tab widgets in document mode (39.92 KB, image/png)
2016-09-09 14:42 UTC, RJVB
Details
this is how document mode tabwidgets look when they can take their full width (40.44 KB, image/png)
2016-09-09 14:43 UTC, RJVB
Details
standard mode tab widgets in full width, for comparison (49.43 KB, image/png)
2016-09-09 14:46 UTC, RJVB
Details
native Macintosh style, document mode, with scroll buttons (40.40 KB, image/png)
2016-09-09 15:43 UTC, RJVB
Details
idem, but with elideMode == Qt::ElideNone (43.86 KB, image/png)
2016-09-09 15:50 UTC, RJVB
Details
Many tabs with the native Macintosh theme but the Fusion style for the QTabBar widget (42.75 KB, image/png)
2016-09-10 15:02 UTC, RJVB
Details
Many tabs, Breeze with a Fusion QTabBar (42.49 KB, image/png)
2016-09-10 15:03 UTC, RJVB
Details
many tabs, QtCurve with a Fusion QTabBar (44.89 KB, image/png)
2016-09-10 15:03 UTC, RJVB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description RJVB 2016-05-24 16:18:07 UTC
KDevelop currently (still) uses a tab bar style which on OS X is rendered using an inappropriate widget. This widget is intended only for use in dialogs where the number of tabs is fixed and limited, like in the screenshot of Terminal.app's preferences dialog. Even Apple themselves use the widget type less and less (cf. the screenshot of the Xcode preferences, v6.2, not even the latest).

Not only is this style choice inappropriate when the goal is to follow Apple's HIG and blend in as well as possible, it's also inefficient as the tabs will quickly start truncating their text (= the filename) when the bar runs out of horizontal space. And for some reason the scroll widget which usually appears when the tab bar becomes too wide doesn't appear, presumably because the bar width never exceeds the available space.

Reproducible: Always


Actual Results:  
See screenshots

Expected Results:  
As Kate5 does; see the screenshot containing Kate's tab bar.
Comment 1 RJVB 2016-05-24 16:20:06 UTC
Created attachment 99157 [details]
KDevelop5 (background) and Kate5 (foreground) showing "wrong" and "right" tab bar types when using the native Mac OS X qpa & theme
Comment 2 RJVB 2016-05-24 16:20:49 UTC
Created attachment 99158 [details]
OS X Terminal.app preferences dialog showing appropriate use of the tabbar widget
Comment 3 RJVB 2016-05-24 16:21:35 UTC
Created attachment 99159 [details]
Xcode preferences window showing the modern tab bar style
Comment 4 RJVB 2016-05-24 16:22:32 UTC
Created attachment 99160 [details]
KDevelop5's tabbed document bar using the "wrong" tabbar widget and "lots" of files open. Who's who?
Comment 5 Kevin Funk 2016-09-08 19:26:26 UTC
Does this patch do anything?

diff --git a/sublime/container.cpp b/sublime/container.cpp
index a51c12b..23c89ed 100644
--- a/sublime/container.cpp
+++ b/sublime/container.cpp
@@ -54,6 +54,8 @@ public:
     ContainerTabBar(Container* container)
         : QTabBar(container), m_container(container)
     {
+        setDocumentMode(true);
+
         installEventFilter(this);
     }


Patches welcome!
Comment 6 RJVB 2016-09-08 20:36:24 UTC
Created attachment 100990 [details]
OS X native tab widgets; docmode vs. standard

Switching the tab widget to document mode could be an improvement (that doesn't look that nice, IMHO) as shown here in the demo app from the Oxygen theme.

I've tried this mode in KDevelop a while ago, and from what I remember it actually made things worse, probably because KDevelop does its own things on top of the widget that don't play well with document mode.

I'll try to find some time to test your suggestion, which is surely a different implementation that what I did. Did you check what effect it has under X11?
Comment 7 Kevin Funk 2016-09-08 21:34:08 UTC
Has no effect under X11/Breeze afaics.
Comment 8 RJVB 2016-09-09 08:18:58 UTC
I you use just the oxygen-demo thingy you'll see that there are some subtle changes to the framing of the documents themselves. The tabs don't change, indeed.
Comment 9 RJVB 2016-09-09 14:42:36 UTC
Created attachment 100996 [details]
lots of native tab widgets in document mode

This is KDevelop using document-mode tab widgets with the proposed patch above, but also using the OS X Integration platform theme plugin which allows to use the fonts, colours and icon theme defined in ~/.config/kdeglobals .

The look is slightly more "normal" for a tabbed document interface (if we ignore the dark colour and the inverted aspect). However, just as with non document mode, the tab bar doesn't get the slider buttons but keeps narrowing the tabs. 
In addition, both modes have an additional IMHO unwanted behaviour: they *increase* the window width (rightward growth) when the text starts getting truncated to less than 2 letters. That's what just started happening in this screenshot.

I'm not sure if I mentioned this in my initial report?
Comment 10 RJVB 2016-09-09 14:43:30 UTC
Created attachment 100997 [details]
this is how document mode tabwidgets look when they can take their full width

This is without the integration platform plugin, i.e. a pure stock interface.
Comment 11 RJVB 2016-09-09 14:46:18 UTC
Created attachment 100998 [details]
standard mode tab widgets in full width, for comparison

Note what looks like a backdrop widget in both modes. Could this be the widget that receives the scroll buttons when using other widget styles, and that gets misaligned?
Comment 12 RJVB 2016-09-09 15:02:43 UTC
It wouldn't be possible to force a specific widget style on one particular widget class, perchance? Something like "QTabBar { style : Fusion }" ?
Comment 13 RJVB 2016-09-09 15:43:29 UTC
Created attachment 100999 [details]
native Macintosh style, document mode, with scroll buttons

diff --git a/sublime/container.cpp b/sublime/container.cpp
index b04f6c3..5ce5f4d 100644
--- a/sublime/container.cpp
+++ b/sublime/container.cpp
@@ -54,6 +54,8 @@ public:
     ContainerTabBar(Container* container)
         : QTabBar(container), m_container(container)
     {
+       setDocumentMode(true);
+       setUsesScrollButtons(true);
         installEventFilter(this);
     }
Comment 14 RJVB 2016-09-09 15:50:26 UTC
Created attachment 101000 [details]
idem, but with elideMode == Qt::ElideNone

diff --git a/sublime/container.cpp b/sublime/container.cpp
index b04f6c3..9fbf931 100644
--- a/sublime/container.cpp
+++ b/sublime/container.cpp
@@ -42,6 +42,8 @@
 #include "document.h"
 #include <ksqueezedtextlabel.h>
 
+#include <QDebug>
+
 namespace Sublime {
 
 // struct ContainerPrivate
@@ -54,6 +56,9 @@ public:
     ContainerTabBar(Container* container)
         : QTabBar(container), m_container(container)
     {
+        setDocumentMode(true);
+        setUsesScrollButtons(true);
+        setElideMode(Qt::ElideNone);
         installEventFilter(this);
     }
Comment 15 RJVB 2016-09-09 15:53:35 UTC
All the usual widget styles available under X11 and also Fusion default to Qt::ElideNone . Forcing that default causes the scroll buttons to appear earlier because the tab text isn't truncated.
Comment 16 RJVB 2016-09-10 15:00:03 UTC
(In reply to RJVB from comment #12)
> It wouldn't be possible to force a specific widget style on one particular
> widget class, perchance? Something like "QTabBar { style : Fusion }" ?

In fact it is:

```
diff --git a/sublime/container.cpp b/sublime/container.cpp
index b04f6c3..3deb21f 100644
--- a/sublime/container.cpp
+++ b/sublime/container.cpp
@@ -27,6 +27,7 @@
 #include <QMouseEvent>
 #include <QPointer>
 #include <QStackedWidget>
+#include <QStyleFactory>
 #include <QStyleOptionTabBarBase>
 #include <QStylePainter>
 #include <QTabBar>
@@ -54,6 +55,7 @@ public:
     ContainerTabBar(Container* container)
         : QTabBar(container), m_container(container)
     {
+        setStyle(QStyleFactory::create("fusion"));
         installEventFilter(this);
     }
 
```
Comment 17 RJVB 2016-09-10 15:02:37 UTC
Created attachment 101015 [details]
Many tabs with the native Macintosh theme but the Fusion style for the QTabBar widget

I think this may yet be the best solution: just setting the QTabBar style to Fusion for tabbed Sublime documents.

See also the screenshots combining this approach with Breeze and QtCurve.
Comment 18 RJVB 2016-09-10 15:03:06 UTC
Created attachment 101016 [details]
Many tabs, Breeze with a Fusion QTabBar
Comment 19 RJVB 2016-09-10 15:03:38 UTC
Created attachment 101017 [details]
many tabs, QtCurve with a Fusion QTabBar
Comment 20 RJVB 2016-09-10 17:31:32 UTC
I've elaborated the patch a bit and submitted it for review: https://git.reviewboard.kde.org/r/128880/
Comment 21 Kevin Funk 2016-10-18 16:24:20 UTC
Git commit 816721d60711b1754053e63e290dba0b205a02eb by Kevin Funk, on behalf of René J.V. Bertin.
Committed on 18/10/2016 at 16:21.
Pushed by kfunk into branch '5.0'.

use a different tab bar widget for tabbed documents

This is a potential fix for an issue raised on BKO: https://bugs.kde.org/show_bug.cgi?id=363473

It's also the most complete/implementation:
- applies only when the Macintosh widget style is being used
- if so, creates a QStyle object for the Fusion widget style
- when successful, sets the `Sublime::ContainerTabBar` to use that style

This solves all issues stemming from Qt's use of a "native" widget that is intended only for use in dialogs and not in tabbed document interfaces.

In my testing, the `ContainerTabBar` ctor is called only rarely, apparently only when changing views (e.g. code -> patch review and back again, or code -> debug). If that observation is correct, use of a global `qTabBarStyle` variable is justified (but more elegant solutions might exist). This observation also justifies (IMHO) the check for the active application style rather than using an `#ifdef Q_OS_OSX` or even applying the fix across all platforms and application styles. That is certainly a possibility that doesn't lead to any shocking style mismatches in my eyes. It does cause some loss of compactness when using my QtCurve settings, which is why I added the style check; a small cost as a gesture to users of a highly configurable style.

There is still some weirdness behind the tabs which looks like a misaligned well or frame. I'd love to get that right too.

REVIEW: 128880

M  +19   -0    sublime/container.cpp

http://commits.kde.org/kdevplatform/816721d60711b1754053e63e290dba0b205a02eb