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
Makes the addon selector more "themeable" #566
Conversation
As asked by @kobliha in IRC, a grep of
|
Ok, so only |
Thanks @dgdavid for this great summay! And thanks for clarfiying me why it is not possible to specify different checkbox images for each stylesheet. Let me write it here just in case anyone else has the same doubts:
So, as David already exposed before, the best solution could be to replace these fake checkboxes for a real widget provided by libyui. A less disruptive approach could be to extend the criteria of selecting the checkbox images and start considering the currently selected theme too. |
This requires changes in the corresponding theme richtext.css file, but allows designers to choose the desired addon text color avoiding usability/visibility problems in certain themes. Read #566 to understand why.
55262e2
to
ce70264
Compare
This requires changes in the corresponding theme richtext.css file, but allows designers to choose the desired addon text color avoiding usability/visibility problems in certain themes. Read #566 to understand why.
ce70264
to
50076ec
Compare
Just for completeness: I asked in IRC if this was tested with NCurses, but that part of the code is only executed for the Qt UI. |
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.
LGTM
Which helps (slightly and) easily adapt the style of the addons selector. See yast/yast-registration#566 for more context and details.
To make the emulated not selected checkbox visible in both, a dark and a light theme. Check yast/yast-registration#566 for more context and details. The SVG has been optimized too, making use of the online https://jakearchibald.github.io/svgomg/ tool.
50076ec
to
241c3dd
Compare
✔️ Internal Jenkins job #105 successfully finished |
✔️ Public Jenkins job #142 successfully finished |
TL;DR
Read #566 (comment)
The Long Story
While working on a light theme, @jhmarina couldn't style the "Extension and Module Selection" dialog for a registered system, ending up with an almost empty (and not usable at all) screen.
Why?
Because the styles for the checkboxes are neither, in the .qss nor the richtext.css file. Instead, they are hard-coded in the HTML built for simulating them.
Wait, HTML?
Yes, HTML. Contrary to the dialog used for displaying the extensions/modules for a no registered system, which uses a MultiSelectionBox, when the system is registered the dialog uses a RichText to simulate the multi selection with more than two (on/off) statuses. Interesting and clever idea, isn't it? For reading more details about the reasoning behind it, read following links:
Solution
At first sight, the fix looks simple: just move those hard-coded styles to the corresponding (installation_)richtext.css file, which is read by the Y2Styler and set as a default CSS document for the RichText before adding its content.
Unfortunately, the Qt's rich text engine only supports a limited HTML and CSS subset, which basically means that this solution will work only partially.
Text color and decoration
Since
color
andtext-decoration
CSS properties are supported, the styles for the checkbox caption can be safely moved to the mentioned CSS file, no matter if it is surrounded by ana
orspan
element. In fact, this is exactly the change that this PR proposes: replacing thestyle='text-decoration:none; color:#{color}'
andstyle='color:grey'
byclass='enabled-item'
andclass='disabled-item'
respectively. Better class names are welcome, of course.It should work as long as https://github.com/yast/yast-theme/ and https://github.com/openSUSE got the needed CSS (PRs not created yet).
Checkbox image
Due to mentioned limitations, the checkbox image cannot be moved to the CSS file (read, @dgdavid was not able to do it). Let's recap tests done:
Using a
span
ordiv
elementIt will not work because
display
,width
, andheight
CSS properties are not supportedStill using the
img
without thesrc
attribute but with aclass
insteadDoes not work, because Qt renders a file icon somehow meaning "missing file" or so when the
src
is not present, wrong, or empty.Ok, use a transparent pixel as
src
Good try, but remember:
width
andheight
CSS properties are not supported.Then, use the supported
width
andheight
img attributes.Great! It even opens the door to use them for setting a reasonable big value (18x18, maybe?) and leave the checkbox size up to the designers (14x14? 15x15? 12x12?). Unluckily,
background-position
andbackground-repeat
CSS properties aren't supported either.Never mind, tell them a fixed size
It does not work. Looks like Qt places the center of the image as the origin (??), repeating it until filling the placeholder reserved for it.
See the screenshot for a visual summary
Anyway, there are other extra disadvantages with the
background-image
approachCheckbox image, the workaround
Fortunately, there is a quick workaround for making those checkboxes visible in a light theme too: changing the border of inst_checkbox-off.svg from white to gray. It will work unless the theme uses a gray background, obviously.
See the screenshots below
However, still being not perfect (that's why is called workaround): designers cannot change/adapt the checkbox color to the theme. Imagine a dark theme with green checkboxes and a light theme using orange ones instead.
Unless we can provide a solution for loading the icons per theme. E.g.,
/usr/share/YaST2/theme/sle/dark-installation/icons
or/usr/share/YaST2/theme/sle/light-installation/icons
or so. Even falling back to a default one in case of file missing (?)/usr/share/YaST2/theme/sle/installation/icons
For this, themes need a name or identifier, of course. Perhaps something to have in consideration in the context of https://trello.com/c/joXRejJi (internal link).
Additional information
This is not the first time we have issues with those dialogs/selectors. Read #483 (specially "The Long Story" chapter), #484, and #487 to know more.
More additional information (2022-02-23)
DISCLAIMER: I (@dgdavid) do not like the trick of using the transparent pixel. I was just exploring the ways for moving the hard-coded styles to a CSS file. Moreover, although I strongly admire the work and effort done back in the time for providing solutions with the tools at hand, I don't like the emulated multi selector either. IMHO, a native libyui solution is the right way to definitely improve these dialogs.