Class: Syskit::GUI::GlobalStateLabel
- Inherits:
-
StateLabel
- Object
- Qt::Label
- StateLabel
- Syskit::GUI::GlobalStateLabel
- Defined in:
- lib/syskit/gui/global_state_label.rb
Overview
Representation of the state of the connected Roby instance
Constant Summary
Constants inherited from StateLabel
StateLabel::COLORS, StateLabel::STYLE, StateLabel::TEXT_WITHOUT_NAME, StateLabel::TEXT_WITH_NAME
Instance Attribute Summary collapse
-
#actions ⇒ Array<Qt::Action>
readonly
Actions that are shown when the context menu is activated.
Attributes inherited from StateLabel
#current_color, #current_state, #current_text, #default_color, #extra_style, #name, #states
Instance Method Summary collapse
-
#app_state_menu(global_pos) ⇒ Object
Execute the app state menu.
-
#contextMenuEvent(event) ⇒ Object
private
Qt handler called when the context menu is activated.
-
#initialize(actions: Array.new, **options) ⇒ GlobalStateLabel
constructor
A new instance of GlobalStateLabel.
-
#mousePressEvent(event) ⇒ Object
private
Qt handler called when the mouse is pressed.
-
#mouseReleaseEvent(event) ⇒ Object
private
Qt handler called when the mouse is released.
Methods inherited from StateLabel
#color_from_state, #declare_default_color, #declare_state, #handle_color_argument, #ignore_state, #rate_limited?, #update_state, #update_style, #update_text
Constructor Details
#initialize(actions: Array.new, **options) ⇒ GlobalStateLabel
Returns a new instance of GlobalStateLabel
13 14 15 16 17 18 19 20 21 |
# File 'lib/syskit/gui/global_state_label.rb', line 13 def initialize(actions: Array.new, **) super(extra_style: 'margin-left: 2px; margin-top: 2px; font-size: 10pt;', rate_limited: true, **) @actions = actions declare_state 'STARTING', :blue declare_state 'RESTARTING', :blue declare_state 'CONNECTED', :green declare_state 'UNREACHABLE', :red end |
Instance Attribute Details
#actions ⇒ Array<Qt::Action> (readonly)
Actions that are shown when the context menu is activated
9 10 11 |
# File 'lib/syskit/gui/global_state_label.rb', line 9 def actions @actions end |
Instance Method Details
#app_state_menu(global_pos) ⇒ Object
Execute the app state menu
34 35 36 37 38 39 40 41 |
# File 'lib/syskit/gui/global_state_label.rb', line 34 def (global_pos) if !actions.empty? = Qt::Menu.new(self) actions.each { |act| .add_action(act) } .exec(global_pos) true end end |
#contextMenuEvent(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Qt handler called when the context menu is activated
26 27 28 29 30 31 |
# File 'lib/syskit/gui/global_state_label.rb', line 26 def contextMenuEvent(event) if !actions.empty? (event.global_pos) event.accept end end |
#mousePressEvent(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Qt handler called when the mouse is pressed
46 47 48 |
# File 'lib/syskit/gui/global_state_label.rb', line 46 def mousePressEvent(event) event.accept end |
#mouseReleaseEvent(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Qt handler called when the mouse is released
It emits the 'clicked' signal
55 56 57 58 |
# File 'lib/syskit/gui/global_state_label.rb', line 55 def mouseReleaseEvent(event) emit clicked(event.global_pos) event.accept end |