-
Notifications
You must be signed in to change notification settings - Fork 90
Theme: C++ implementation based on propagated attached property #19316
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
base: master
Are you sure you want to change the base?
Conversation
71355b5 to
d6a2153
Compare
Jenkins BuildsClick to see older builds (67)
|
c1b54b0 to
6cf7b25
Compare
alexjba
left a comment
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.
Awesome work! I love it :beers
Let's get it merged quickly now that we have the release branch. It's probably a burden to maintain.
| return s_asideTextFontBaseSize + m_fontSizeOffset; | ||
| } | ||
|
|
||
| QJSValue Theme::fontSize() const |
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.
Beautiful! Never crossed my mind to try this approach!
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.
it's probably a good approach to use on all the hardcoded dimensions we have in the app and ultimately to replace the scaling.
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.
Hehe that's my idea! 😆
cf4e110 to
5309fdb
Compare
caybro
left a comment
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.
Awesome work! Just some suggestions and minor things
| { | ||
| QColor c = color; | ||
| if (alpha > 0.0 && alpha <= 1.0) | ||
| c.setAlphaF(alpha); |
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.
Not sure this is going to work as expected... you usually want to switch to a HSL/HSV color space first
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.
Old code:
function setColorAlpha(color, alpha) {
return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha)
}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.
This code is replacement for:
function alphaColor(color, alpha) {
let actualColor = Qt.darker(color, 1)
actualColor.a = alpha
return actualColor
}where the first line let actualColor = Qt.darker(color, 1) is just tricky conversion in case e.g. "red" color literal is provided. The version you quoted is from Utils, and it's not related with this code.
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.
Yeah but that's why it does the darker first, it probably converts to HSL behind the scene
|
|
||
| Q_PROPERTY(Style style READ style WRITE setStyle RESET resetStyle | ||
| NOTIFY styleChanged) | ||
| Q_PROPERTY(const ThemePalette* palette READ palette |
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.
Perhaps we could also expose other old properties (like fonts) in order to minimize the QML diff, wdyt?
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.
I found it cleaner to keep things like Fonts as a separate, dedicated component responsible only for fonts. Especially that there is that FontLoader loading logic inside.
It creates bigger diff indeed, but it's just fully automatic replacement.
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.
Yup, bigger diff but also... it will be very hard to backport fixes now, e.g. to 2.36 branch but I agree that's just a temporary problem
| readonly property alias monoFont: monoFont.font | ||
| readonly property alias codeFont: codeFont.font | ||
|
|
||
| FontLoader { |
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 could (pre)load all these fonts from C++ too, and it would be faster imo :) And just expose the three baseFont/monoFont/codeFont properties
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.
I meant https://doc.qt.io/qt-6/qfontdatabase.html#addApplicationFont
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.
The idea was to keep the attached type as small/simple as possible. Ideally only stuff that can benefit from propagation should be there. I found it more modular when keeping things like that separated.
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.
Yup, this wouldn't be part of the propagation, just initialized and setup somewhere else, not in QML
5309fdb to
85e5f55
Compare
What does the PR do
Reimplements Theme from stateful singleton to attached property, dynamically propagated through the components tree.
[TODO[
Affected areas
Architecture compliance
My PR is consistent with this document: QML Architecture Guidelines
Screencapture of the functionality
Impact on end user
How to test
Risk