Skip to content

Commit

Permalink
Merge pull request #675 from yast/infinite-roles-images
Browse files Browse the repository at this point in the history
System roles: make the radio buttons match other dialogs, using images
  • Loading branch information
mvidner committed Mar 23, 2018
2 parents 987d927 + 849923c commit 3853557
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Mar 23 09:57:56 UTC 2018 - mvidner@suse.com

- System roles: make the radio buttons match other dialogs,
using images (bsc#1084674)
- 4.0.42

-------------------------------------------------------------------
Tue Mar 20 16:10:24 UTC 2018 - mvidner@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.0.41
Version: 4.0.42
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
18 changes: 13 additions & 5 deletions src/lib/installation/select_system_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# To contact SUSE about this file by physical or electronic mail,
# you may find current contact information at www.suse.com

require "cgi"
require "yast"
require "ui/installation_dialog"
require "installation/services"
Expand Down Expand Up @@ -75,7 +76,7 @@ def dialog_content
@selected_role_id = self.class.original_role_id
@selected_role_id ||= roles.first && roles.first.id if SystemRole.default?

HSquash(ReplacePoint(Id(:rp), role_buttons(selected_role_id: @selected_role_id)))
HCenter(ReplacePoint(Id(:rp), role_buttons(selected_role_id: @selected_role_id)))
end

def create_dialog
Expand Down Expand Up @@ -229,7 +230,7 @@ def role_buttons(selected_role_id:)
label: role.label,
selected: role.id == selected_role_id)

description = description.gsub("\n", "<br>\n")
description = CGI.escape_html(description).gsub("\n", "<br>\n")
# extra empty paragraphs for better spacing
"<p></p>#{rb}<p></p><ul>#{description}</ul>"
end
Expand All @@ -252,19 +253,26 @@ def richtext_radiobutton(id:, label:, selected:)

def richtext_radiobutton_tui(id:, label:, selected:)
check = selected ? "(x)" : "( )"
widget = "#{check} #{label}"
widget = "#{check} #{CGI.escape_html(label)}"
enabled_widget = "<a href=\"#{id}\">#{widget}</a>"
"#{enabled_widget}<br>"
end

IMAGE_DIR = "/usr/share/YaST2/theme/current/wizard".freeze

BUTTON_ON = "◉".freeze # U+25C9 Fisheye
BUTTON_OFF = "○".freeze # U+25CB White Circle

def richtext_radiobutton_gui(id:, label:, selected:)
check = selected ? BUTTON_ON : BUTTON_OFF
widget = "#{check} #{label}"
# check for installation style, which is dark, FIXME: find better way
installation = ENV["Y2STYLE"] == "installation.qss"
if installation
image = selected ? "inst_radio-button-checked.png" : "inst_radio-button-unchecked.png"
bullet = "<img src=\"#{IMAGE_DIR}/#{image}\"></img>"
else
bullet = selected ? BUTTON_ON : BUTTON_OFF
end
widget = "#{bullet} #{CGI.escape_html(label)}"
color = installation ? "white" : "black"
enabled_widget = "<a style='text-decoration:none; color:#{color}' href=\"#{id}\">#{widget}</a>"
"<p>#{enabled_widget}</p>"
Expand Down

0 comments on commit 3853557

Please sign in to comment.