Class: Syskit::GUI::AppStartDialog
- Defined in:
- lib/syskit/gui/app_start_dialog.rb
Overview
A dialog that allows to get the parameters to start an app
Constant Summary collapse
- NO_ROBOT =
Text used to allow the user to not load any robot configuration
" -- None -- "
Instance Attribute Summary collapse
-
#robot_names ⇒ Qt::ComboBox
readonly
The combo box to choose the robot name.
-
#start_controller ⇒ Qt::CheckBox
readonly
The checkbox allowing to choose whether the controller blocks should be executed or not.
Class Method Summary collapse
-
.exec(names, parent = nil, default_robot_name: 'default') ⇒ nil, (String,Boolean)
Executes a AppStartDialog in a modal way and returns the result.
Instance Method Summary collapse
-
#initialize(names, parent = nil, default_robot_name: 'default') ⇒ AppStartDialog
constructor
A new instance of AppStartDialog.
-
#selected_name ⇒ String
The name of the selected robot.
-
#start_controller? ⇒ Boolean
Whether the controller should be started.
Constructor Details
#initialize(names, parent = nil, default_robot_name: 'default') ⇒ AppStartDialog
Returns a new instance of AppStartDialog
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/syskit/gui/app_start_dialog.rb', line 19 def initialize(names, parent = nil, default_robot_name: 'default') super(parent) self.window_title = "Start App" layout = Qt::VBoxLayout.new(self) layout.(Qt::Label.new("Robot configuration to load:")) layout.(@robot_names = Qt::ComboBox.new) robot_names.add_item NO_ROBOT names.sort.each_with_index do |n, i| robot_names.add_item(n) if n == default_robot_name robot_names.current_index = i + 1 end end layout.(@start_controller = Qt::CheckBox.new("Start controller")) start_controller.checked = true = Qt::DialogButtonBox.new( Qt::DialogButtonBox::Ok | Qt::DialogButtonBox::Cancel) connect(, SIGNAL('accepted()'), self, SLOT('accept()')); connect(, SIGNAL('rejected()'), self, SLOT('reject()')); layout.() end |
Instance Attribute Details
#robot_names ⇒ Qt::ComboBox (readonly)
The combo box to choose the robot name
8 9 10 |
# File 'lib/syskit/gui/app_start_dialog.rb', line 8 def robot_names @robot_names end |
#start_controller ⇒ Qt::CheckBox (readonly)
The checkbox allowing to choose whether the controller blocks should be executed or not
14 15 16 |
# File 'lib/syskit/gui/app_start_dialog.rb', line 14 def start_controller @start_controller end |
Class Method Details
.exec(names, parent = nil, default_robot_name: 'default') ⇒ nil, (String,Boolean)
Executes a Syskit::GUI::AppStartDialog in a modal way and returns the result
71 72 73 74 75 76 |
# File 'lib/syskit/gui/app_start_dialog.rb', line 71 def self.exec(names, parent = nil, default_robot_name: 'default') dialog = new(names, parent, default_robot_name: default_robot_name) if Qt::Dialog::Accepted == dialog.exec return dialog.selected_name, dialog.start_controller? end end |
Instance Method Details
#selected_name ⇒ String
The name of the selected robot
49 50 51 52 53 54 55 |
# File 'lib/syskit/gui/app_start_dialog.rb', line 49 def selected_name txt = robot_names.current_text if txt != NO_ROBOT txt else "" end end |
#start_controller? ⇒ Boolean
Whether the controller should be started
60 61 62 |
# File 'lib/syskit/gui/app_start_dialog.rb', line 60 def start_controller? start_controller.checked? end |