class Syskit::GUI::GlobalStateLabel

Representation of the state of the connected Roby instance

Attributes

actions[R]

Actions that are shown when the context menu is activated

@return [Array<Qt::Action>] the list of actions that can be

performed on the remote Roby instance (e.g. start/stop ...)

Public Class Methods

new(actions: Array.new, **options) click to toggle source

@param [Array<Qt::Action>] the list of actions that can be

performed on the remote Roby instance
Calls superclass method
# File lib/syskit/gui/global_state_label.rb, line 13
def initialize(actions: Array.new, **options)
    super(extra_style: 'margin-left: 2px; margin-top: 2px; font-size: 10pt;',
          rate_limited: true, **options)
    @actions = actions
    declare_state 'STARTING', :blue
    declare_state 'RESTARTING', :blue
    declare_state 'CONNECTED', :green
    declare_state 'UNREACHABLE', :red
end

Public Instance Methods

app_state_menu(global_pos) click to toggle source

Execute the app state menu

# File lib/syskit/gui/global_state_label.rb, line 34
def app_state_menu(global_pos)
    if !actions.empty?
        menu = Qt::Menu.new(self)
        actions.each { |act| menu.add_action(act) }
        menu.exec(global_pos)
        true
    end
end
contextMenuEvent(event) click to toggle source

@api private

Qt handler called when the context menu is activated

# File lib/syskit/gui/global_state_label.rb, line 26
def contextMenuEvent(event)
    if !actions.empty?
        app_state_menu(event.global_pos)
        event.accept
    end
end
mousePressEvent(event) click to toggle source

@api private

Qt handler called when the mouse is pressed

# File lib/syskit/gui/global_state_label.rb, line 46
def mousePressEvent(event)
    event.accept
end
mouseReleaseEvent(event) click to toggle source

@api private

Qt handler called when the mouse is released

It emits the 'clicked' signal

# File lib/syskit/gui/global_state_label.rb, line 55
def mouseReleaseEvent(event)
    emit clicked(event.global_pos)
    event.accept
end