make GUIUtil::ThemedLabel UI form friendly#358
Conversation
This makes the GUIUtil::ThemedLabel class able to be used in UI form files. This is accomplished by introducing a form file friendly constructor which only takes in a `QWidget* parent`. You cannot pass in the `platform_style` when initializing a GUIUtil::ThemedLabel in a UI form file. This introduces a `setPlatformStyle` function to be able to pass in the `platform_style` at a later point. Additionally; because we are not initializing the class with a `platform_style`, we need to implement a check in `updateThemedPixmap` to only occur when the `m_platform_style` has been set. A segfault would occur without this conditional as a `ChangeEvent` occurs on application start
|
|
||
| private: | ||
| const PlatformStyle* m_platform_style; | ||
| const PlatformStyle* m_platform_style = nullptr; |
hebasto
left a comment
There was a problem hiding this comment.
I think we should adopt your suggestion on IRC to move the ThemedLabel into its own module for the following reasons:
- all of so called "promoted widgets" in our repo have their own modules
- see https://github.com/bitcoin-core/gui/pull/330/files#r650460316
Also, it seams reasonable to me to drop this pr, and review both commits in #330, because without actual usage of a promoted widget in a *.ui file it is not easy to test it.
| { | ||
| QLabel{parent}; | ||
| } | ||
|
|
There was a problem hiding this comment.
| { | |
| QLabel{parent}; | |
| } | |
| : QLabel{parent} {} |
| } | ||
| void ThemedLabel::changeEvent(QEvent* e) |
There was a problem hiding this comment.
style nit: Add an empty line as a separator?
|
This was meant to be a part of #330. A simpler approach was chosen for that PR and this is no longer worth the effort as the issue has been fixed. Note: If there is ever a reason to make the |
This allows the
GUIUtil::ThemedLabelclass able to be used in UI form files. This is accomplished by introducing a form file friendly constructor which only takes in aQWidget* parent.You cannot pass in the
platform_stylewhen initializing aGUIUtil::ThemedLabelin a UI form file. This introduces asetPlatformStylefunction to be able to pass in theplatform_styleat a later point.Additionally; because we are not initializing the class with a
platform_style, we need to implement a check inupdateThemedPixmapso that it only executes when them_platform_stylehas been set. A segfault would occur without this conditional as aChangeEventoccurs on application startThis allows this class to be used in the form file for #330 for an elegant solution.