Bug 340150 - Contents of QHeaderView sections clipped with Breeze style
Summary: Contents of QHeaderView sections clipped with Breeze style
Status: CLOSED FIXED
Alias: None
Product: Breeze
Classification: Plasma
Component: QStyle (other bugs)
Version First Reported In: 5.0.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-20 11:00 UTC by Jarosław Staniek
Modified: 2014-11-24 23:50 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screenshot of the bug in Kexi and JuK (11.40 KB, image/png)
2014-10-20 11:01 UTC, Jarosław Staniek
Details
.ui test that shows the bug in QTableWidget (1.59 KB, application/x-designer)
2014-10-20 11:41 UTC, Jarosław Staniek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jarosław Staniek 2014-10-20 11:00:14 UTC
Contents of QHeaderView sections clipped with Breeze style.

Popped up in Kexi first, where I put icons in header sections of table views (by returning a KDE icon for Qt::DecorationRole in implementation of QAbstractItemModel::headerData()). 

See upper part of the first attached screenshot.

Also found it in the JuK music player (here, the text is clipped).

See lower part of the first attached screenshot.

Reproducing: just run JuK and look at the headers of the main list. I have not inspected JuK's code so I don't know if QHeaderView is used explicitly.

If you want to try Kexi, you'd have to build it with my patch (let me know), the code using QHeaderView isn't packaged.

Reproducible: Always


Actual Results:  
Cropped content.

Expected Results:  
Entire content is displayed.
Comment 1 Jarosław Staniek 2014-10-20 11:01:00 UTC
Created attachment 89210 [details]
Screenshot of the bug in Kexi and JuK
Comment 2 Jarosław Staniek 2014-10-20 11:40:31 UTC
Kexi uses Qt4's QAbstractScrollArea, to be strict, and QHeaderView.

Height of the row in Kexi is based on QFontMetrics::height() of the used font. It is 19 on the screenshot. Small height (or width) isn't something unusual in large data sheets of db or in spreadsheets.

Attaching a test .ui file below that uses QTableWidget, which is based on the same technology.
I set verticalHeaderDefaultSectionSize to 19 there.

Expected fix would be to avoid adding so large margins.
Comment 3 Jarosław Staniek 2014-10-20 11:41:10 UTC
Created attachment 89211 [details]
.ui test that shows the bug in QTableWidget
Comment 4 Hugo Pereira Da Costa 2014-10-20 13:15:59 UTC
(In reply to Jarosław Staniek from comment #2)
> Kexi uses Qt4's QAbstractScrollArea, to be strict, and QHeaderView.
> 
> Height of the row in Kexi is based on QFontMetrics::height() of the used
> font. It is 19 on the screenshot. Small height (or width) isn't something
> unusual in large data sheets of db or in spreadsheets.
> 

That is likely what creates the issue. Breeze, per design, adds margins around the content. 
You are supposed to call QStyle::sizeForContents( CT_HeaderView, ...) to get the size of the header for a given contents size. 

Fixing it to anything smaller like this is bound to break on one style or the other ... 

This can probably be worked-around in breeze (by unclipping the text, that is, allow drawing on the margins) but the real fix would be really not to fix the size of the header line.
Fixing sizes at the application level just brings inconsistencies from one app to the other, which is precisely what the style aims at preventing ...
Comment 5 Jarosław Staniek 2014-10-20 13:21:38 UTC
I understand but in my optics the higher priority is to adhere to what's defined in file format. E.g. if a spreadsheet in given zoom level takes 19 physical pixels, we have to paint 19 pixels whatever toolkit or style is used. I am not sure why only breeze reproduces the issue.

Think about the header as a part of document's content rather than the GUI itself. Like a table header in a wordprocessor: it should be able to even take 2 pixels if this is what the document says :)
Comment 6 Hugo Pereira Da Costa 2014-10-20 13:25:11 UTC
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -1475,7 +1475,8 @@ namespace Breeze
         if( !headerOption ) return option->rect;
 
         // check if arrow is necessary
-        QRect labelRect( insideMargin( option->rect, Metrics::Header_MarginWidth ) );
+        // QRect labelRect( insideMargin( option->rect, Metrics::Header_MarginWidth ) );
+        QRect labelRect( insideMargin( option->rect, Metrics::Header_MarginWidth, 0 ) );
         if( headerOption->sortIndicator == QStyleOptionHeader::None ) return labelRect;
 
         labelRect.adjust( 0, 0, -Metrics::Header_ArrowSize-Metrics::Header_ItemSpacing, 0 );

Can you test ? 
If fixes I'll push
Comment 7 Hugo Pereira Da Costa 2014-10-20 13:26:18 UTC
(In reply to Jarosław Staniek from comment #5)
> I understand but in my optics the higher priority is to adhere to what's
> defined in file format. E.g. if a spreadsheet in given zoom level takes 19
> physical pixels, we have to paint 19 pixels whatever toolkit or style is
> used. I am not sure why only breeze reproduces the issue.
> 
Because its the only style I know of that adds the margins and actually enforces respecting it.
Comment 8 Jarosław Staniek 2014-10-20 13:36:05 UTC
Thanks, I'll try tonight.

On 20 October 2014 15:25, Hugo Pereira Da Costa <hugo.pereira@free.fr> wrote:
> Comment # 6 on bug 340150 from Hugo Pereira Da Costa
>
> --- a/kstyle/breezestyle.cpp
> +++ b/kstyle/breezestyle.cpp
> @@ -1475,7 +1475,8 @@ namespace Breeze
>          if( !headerOption ) return option->rect;
>
>          // check if arrow is necessary
> -        QRect labelRect( insideMargin( option->rect,
> Metrics::Header_MarginWidth ) );
> +        // QRect labelRect( insideMargin( option->rect,
> Metrics::Header_MarginWidth ) );
> +        QRect labelRect( insideMargin( option->rect,
> Metrics::Header_MarginWidth, 0 ) );
>          if( headerOption->sortIndicator == QStyleOptionHeader::None )
> return
> labelRect;
>
>          labelRect.adjust( 0, 0,
> -Metrics::Header_ArrowSize-Metrics::Header_ItemSpacing, 0 );
>
> Can you test ?
> If fixes I'll push
>
> ________________________________
> You are receiving this mail because:
>
> You reported the bug.
Comment 9 Hugo Pereira Da Costa 2014-10-20 21:54:38 UTC
Git commit 70af858a6d1afe9899fb76fd64a83585618c3fb0 by Hugo Pereira Da Costa.
Committed on 20/10/2014 at 13:23.
Pushed by hpereiradacosta into branch 'master'.

Do not clip away vertical margins for headers to accomodate custom widgets that set a two small vertical size for those.

M  +2    -1    kstyle/breezestyle.cpp

http://commits.kde.org/breeze/70af858a6d1afe9899fb76fd64a83585618c3fb0
Comment 10 Hugo Pereira Da Costa 2014-10-20 22:04:36 UTC
Git commit 5542c48d9c3b07559ee5c600a14a192518e5e4e0 by Hugo Pereira Da Costa.
Committed on 20/10/2014 at 13:23.
Pushed by hpereiradacosta into branch 'Plasma/5.1'.

Do not clip away vertical margins for headers to accomodate custom widgets that set a two small vertical size for those.

M  +2    -1    kstyle/breezestyle.cpp

http://commits.kde.org/breeze/5542c48d9c3b07559ee5c600a14a192518e5e4e0
Comment 11 Hugo Pereira Da Costa 2014-10-20 22:11:27 UTC
Git commit 2100ca125c961d68e566b53bc63ec3885260b669 by Hugo Pereira Da Costa.
Committed on 20/10/2014 at 22:09.
Pushed by hpereiradacosta into branch 'master'.

properly handle RTL for corner rects and tabbar
Do not clip away vertical margins for headers to accomodate custom widgets that set a two small vertical size for those.
Related: bug 340155

M  +12   -25   kstyle/oxygenstyle.cpp

http://commits.kde.org/oxygen/2100ca125c961d68e566b53bc63ec3885260b669
Comment 12 Hugo Pereira Da Costa 2014-10-20 22:11:53 UTC
Git commit 17e1053bc03ace87502999776294d4be29b2b8f0 by Hugo Pereira Da Costa.
Committed on 20/10/2014 at 22:09.
Pushed by hpereiradacosta into branch 'Plasma/5.1'.

properly handle RTL for corner rects and tabbar
Do not clip away vertical margins for headers to accomodate custom widgets that set a two small vertical size for those.
Related: bug 340155

M  +12   -25   kstyle/oxygenstyle.cpp

http://commits.kde.org/oxygen/17e1053bc03ace87502999776294d4be29b2b8f0
Comment 13 Jarosław Staniek 2014-10-20 23:50:42 UTC
Looks much better, thanks Hugo!
I'll let you know if there's another glitch.