Class: Syskit::GUI::AppStartDialog

Inherits:
Qt::Dialog
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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.add_widget(Qt::Label.new("Robot configuration to load:"))
    layout.add_widget(@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.add_widget(@start_controller = Qt::CheckBox.new("Start controller"))
    start_controller.checked = true

    button_box = Qt::DialogButtonBox.new(
        Qt::DialogButtonBox::Ok | Qt::DialogButtonBox::Cancel)
    connect(button_box, SIGNAL('accepted()'), self, SLOT('accept()'));
    connect(button_box, SIGNAL('rejected()'), self, SLOT('reject()'));
    layout.add_widget(button_box)
end

Instance Attribute Details

#robot_namesQt::ComboBox (readonly)

The combo box to choose the robot name

Returns:

  • (Qt::ComboBox)


8
9
10
# File 'lib/syskit/gui/app_start_dialog.rb', line 8

def robot_names
  @robot_names
end

#start_controllerQt::CheckBox (readonly)

The checkbox allowing to choose whether the controller blocks should be executed or not

Returns:

  • (Qt::CheckBox)


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

Returns:

  • (nil, (String,Boolean))

    either nil if the dialog was rejected, or a robot name and a boolean indicating whether the controller blocks should be executed. The robot name can be empty to indicate that the dialog was accepted but no robot configuration should be loaded



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_nameString

The name of the selected robot

Returns:

  • (String)

    the robot name, or an empty string if no robot configuration should be loaded



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

Returns:

  • (Boolean)


60
61
62
# File 'lib/syskit/gui/app_start_dialog.rb', line 60

def start_controller?
    start_controller.checked?
end