yast / yast-installation Public
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
Improve the role selection dialog #827
Conversation
7238dbb
to
edafd7e
Compare
Technically, LGTM. Just the one typo in the comment. |
Thanks so much for the review!
The thing is that some role description also force the horizontal scroll in Qt. I'll take an screenshot as soon as possible.
Perfect! |
Because the SingleItemSelector widget (fixed to not enforce an initial selection) is now used to build the role selection dialog.
|
17537ec
to
a35dd2a
Compare
As suggested in the code review, now the max line length is longer when not running in text mode.
Likely forgotten in f1b4e40
def adjust_text(text) | ||
max_line_length = Yast::UI.TextMode ? TEXT_MODE_MAX_LINE_LENGTH : MAX_LINE_LENGTH | ||
|
||
text.strip.scan(/(.{1,#{max_line_length}})(?:\s|$)/).join("\n") |
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.
JFYI, I also tried
text.strip.gsub(/(.{1,#{max_line_length}})(?:\s|$)/, "\\1\n").chomp
but a benchmark reveal that scan
and join
allocates less memory than gsub
and chomp
. Exactly 1.11x
less, although it will almost priceless for this use case...
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.
hint, you can use existing code https://github.com/yast/yast-yast2/blob/66bc64d08c6ff017b88e3cff63fd02d78bbcf7f1/library/general/src/lib/ui/text_helpers.rb#L31
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 just noticed that this does not work well if a word is longer than the max. line length:
max_line_length = 10
text = "123456789012 123456789012 123456789012 123456789012"
puts text.strip.scan(/(.{1,#{max_line_length}})(?:\s|$)/).join("\n")
results in
3456789012
3456789012
3456789012
3456789012
i.e. some part is lost. But as using a word longer than at least 70 characters is not very likely we can live with that. But maybe it's worth adding a comment about this...
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.
hint, you can use existing code https://github.com/yast/yast-yast2/blob/66bc64d08c6ff017b88e3cff63fd02d78bbcf7f1/library/general/src/lib/ui/text_helpers.rb#L31
Ops! I didn't know about it. And... I didn't took a look around
Thanks!
I re-tested it with the new changes (basically different max line lengths for textmode) and updated the most relevant screenshots in the PR description. So, It's ready for a re-review, please. |
Still LGTM from my side. @lslezak ? |
LGTM.
But as this is mainly about the UI it would be nice to see some screenshots here...
def adjust_text(text) | ||
max_line_length = Yast::UI.TextMode ? TEXT_MODE_MAX_LINE_LENGTH : MAX_LINE_LENGTH | ||
|
||
text.strip.scan(/(.{1,#{max_line_length}})(?:\s|$)/).join("\n") |
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 just noticed that this does not work well if a word is longer than the max. line length:
max_line_length = 10
text = "123456789012 123456789012 123456789012 123456789012"
puts text.strip.scan(/(.{1,#{max_line_length}})(?:\s|$)/).join("\n")
results in
3456789012
3456789012
3456789012
3456789012
i.e. some part is lost. But as using a word longer than at least 70 characters is not very likely we can live with that. But maybe it's worth adding a comment about this...
Oops, the screenshots are already there... |
Yep, I was trying to solve this problem in different ways, but as you said
reason why I decided to not invest much time on it. And, for the same reason, I don't want to solve this with a loop... |
That said, I didn't know (my fault, for not asking or taken a look) about the helper pointed out by Josef (see his comment) So, I'm going to update the code to use it. |
|
|
|
Context
Some time ago, the list of available roles grown enough to start not fitting in the role selection dialog. To fix it, the list was embedded in a scrollable
RichText
widget since libyui didn't offer a better option (see #671, bsc#1084674, bsc#1086187).Trello card: https://trello.com/c/QjRVileZ
Current status
As part of a YaST UI improvements a new
SingleItemSelector
(see https://github.com/libyui/libyui/pull/148) has been added, which is a much better solution to display the roles list.Changes
To update the role selection dialog using the new widget and removing the old code.
Tests
Screenshots
Click to show/hide
Before
After