-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #358 - fade-out instead elide text (trim with...) in tabs #538
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asashnov Thank you for this promising PR but:
- It applies to any title, even if very smal ("Bird" for example) and in fact there should be not fading because there is a lot of space.
- I wonder if it would not be better practive to have the CSS in the stylesheet file, instead of having it mixed with the C++ code in
setStyleSheet()
.
@asashnov Is that ready to review again? |
@kelson42 No, this PR is not ready yet. I moved the style to .css file, but didn't found a way to use separate styles in QTabBar for each tab. Seems it should involve to create our own implementation. Also, I'll think about implementing ::paint() method to render kind of fade-out effect on top of standard rendering. |
You've arrived to the same conclusion than me. The css rule you apply is nice but it applies to all texts, even if they are not too long. |
And this is not possible to have the width of the widget and do the math to apply the CSS only if necessary (width big enough)? |
This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
@kelson42 I found a way to get QRect for text in the tab. Instead, we can fillRect() in In this screenshot the background color for the active tab is wrong, and no alpha channel gradient, but the position of QRect is right. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
Unfortunately, there is NO an easy way to get the background color of selected tab like: QColor c0;
c0 = tab.palette.color(QPalette::Active, QPalette::Button);
c0 = QApplication::style().standardPalette().color(QPalette::Active, QPalette::Button);
c0 = palette().color(QPalette::Active, QPalette::Button); (I tried many variants also) Since we install our own custom style from 'style.css' This class is a private part of Qt (no public header for it). Moreover, in its implementation (see Qt/5.12.6/Src/qtbase/src/widgets/styles/qstylesheetstyle.cpp) Also, I saw in the sources there is really no way to specify tab by tab number. For more details see: void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
...
case CE_TabBarTabShape:
...
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
`QStyle` and its derived classes have no interface for getting colors back.
They can only draw a control or its part on some `QPaintDevice`.
So we have no easy way here to get back our 'white' color we set our style.css file:
```css
QTabBar::tab:selected {
background-color: white;
border-bottom: 2px solid white;
} So I decided to just hardcode it in the code and write comments that it should be in sync in both places. An alternative solution may involve 'picking' this active tab background color from the widget This is how it looks now: |
@mgautierfr Please review |
7c4e08c
to
7e0c903
Compare
@asashnov I have rebased on git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the user side looks good. Waiting @mgautierfr review for the code.
This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
7e0c903
to
474c758
Compare
Rebased, squashed, long commentary removed (it still here in this 'Conversation'). |
474c758
to
a1e00e9
Compare
a1e00e9
to
c621079
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are definitively on the good way but it seems there is a small issue with RightToLeft text.
b4cc704
to
8759c81
Compare
Qt::LayoutDirection - Specifies the direction of Qt's layouts and text handling (https://doc.qt.io/qt-5/qt.html#LayoutDirection-enum) When we open arabic wiki, and see arabic in tab's title, we change just 'text layout'. But my code checked 'widget layout' of the application- that was a problem. Fixed: In the current implementation the text layout direction is given, not application widgets layout. |
8759c81
to
c060776
Compare
c060776
to
7252b1b
Compare
Fixed in 7252b1b (Feb 15, 2021) |
Fixes #358 - fade-out instead elide text (trim with...) in tabs
This is how it looks like with the change: