enh(ui): apply SParameters stylesheet globally
Description
The MR !795 (merged) will add a new stylesheet to improve touch friendliness in the SParameters module. It is therefore only applied to SParameters. An application could benefit from applying this stylesheet globally. In Sight, there is already a style which is applied globally (darkstyle.qss and flatdark.qss, applied during configuration via the stylesheet
application parameter). Therefore, this issue has two main points:
- How to apply both the current style and the new touch-friendly style?
- Is there any modification from the new style which is unwelcome when applied globally?
Proposal
There are several ways to apply both the current style and the new touch-friendly style:
- Directly modify the existing style to include the modification of the new style
- Upside: There is no other modifications to be done for application already using the existing style
- Downside: The applications which don't use these styles won't have the touch-friendly style. The style will be copied in at least the stylesheet shipped with Sight, darkstyle.qss and flatdark.qss, and possibly others, which introduce a redundancy in the stylesheets. There is no way to opt out of these touch-friendly style if we use one of these styles.
- Hardcode the touch-friendly style, and concatenate it with the existing stylesheet if it exists. Might be disabled with a application parameter as well.
- Upside: There is no other modifications to be done for the applications
- Downside: Most developers hate the word "hardcode". If the style must be changed, it might be harder to find than if it were a file.
- Same as above, but the touch-friendly style is a new separate stylesheet file instead of hardcoded
- Upside: The style is easier to find if one wants to change it.
- Downside: It seems that modification related to stylesheets are poorly documented, do you know that darkstyle.qss isn't used anymore by any of the applications shipped in Sight?
- Put the touch-friendly style in a new separate stylesheet file and specify it in the
stylesheet
application parameter. This parameter must therefore be modified to accept a list of stylesheets (it currently accepts only one), the stylesheets will be concatenated at runtime.- Upside: Aside from the touch-friendly style, the capability to specify multiple stylesheets can be useful in the long run to make the usage of style modular.
- Downside: This modification might be hard, it is at least harder than the other options above. For each of the applications who want to apply the touch-friendly style, this parameter must be changed.
Functional specifications
I decided to apply the third solution: Put the touch-friendly style in a separate stylesheet file, and concatenate it with the existing stylesheet if it exists. The touch-friendly style can be enabled or disabled with a parameter.
Technical specifications
The style which was hardcoded in SParameters.cpp is copied in a new file touch-friendly.qss, in the same folder as darkstyle.qss and flatdark.qss. In modules/ui/qt/Plugin.cpp, where the stylesheet is loaded, the touch-friendly stylesheet is loaded as well, and the two stylesheets are concatenated. If the parameter touch_friendly
is set and the its value is "false"
, the touch-friendly style won't be loaded.
Test plan
Make sure the touch-friendly style is applied when the parameter touch_friendly
isn't set or set to "true"
, make sure the touch-friendly style isn't applied when the parameter touch_friendly
is set to "false'
. Make sure all the applications still look good when the parameter is applied.