Stellarium  0.22.2
Public Slots | Signals | Public Member Functions | Properties | Friends
StelAction Class Reference

Wrapper around an argumentless QObject slot or a bool Q_PROPERTY with WRITE method, allowing the slot to be called/property to be toggled using this action object. More...

#include <StelActionMgr.hpp>

Public Slots

void setChecked (bool)
 
void trigger ()
 If the action is checkable, toggle() is called. More...
 
void toggle ()
 If the action is checkable, this toggles the value of the connected boolean property. More...
 

Signals

void toggled (bool)
 Emitted when the boolean state of this StelAction changes. More...
 
void triggered ()
 Emitted after an argumentless slot has been called.
 
void changed ()
 Emitted when additional data associated with this action changed (i.e. shortcuts, text,...)
 

Public Member Functions

bool isCheckable () const
 
bool isChecked () const
 
bool isGlobal () const
 
void setShortcut (const QString &key)
 Defines the key-combination used to call this action.
 
void setAltShortcut (const QString &key)
 Defines an alternative key-combination.
 
QKeySequence::SequenceMatch matches (const QKeySequence &seq) const
 
QString getId () const
 The ID of this action. Must be unique.
 
QString getGroup () const
 
const QKeySequence getShortcut () const
 
const QKeySequence getAltShortcut () const
 
QString getText () const
 
void setText (const QString &value)
 

Properties

bool checked
 When the StelAction is checkable, this may be used to get/set the current value. More...
 
bool checkable
 If this is true, this StelAction can be toggled. More...
 

Friends

class StelActionMgr
 

Detailed Description

The action object can be identified by a unique string, and found through StelActionMgr::findAction. Use StelActionMgr::addAction to define a new action. In StelModule subclasses, one can also use StelModule::addAction for convenience.

StelAction objects are intended for user interaction. They automatically show up in the hotkey configuration dialog (ShortcutsDialog), and can be bound to interface buttons (StelButton).

StelAction internally uses a StelProperty, if connected to a property. A new StelProperty with the name of the action is registered automatically in this case. A NOTIFY signal should be provided, though not strictly necessary, it is really recommended.

Note
If you want to have a globally accessible reference to arbitrary Q_PROPERTY instances (not just bool), or don't want to expose the property to the user you could use a StelProperty directly registered through the StelPropertyMgr instead.
See also
StelActionMgr, StelProperty

Member Function Documentation

◆ isCheckable()

bool StelAction::isCheckable ( ) const
inline
See also
checkable

◆ isChecked()

bool StelAction::isChecked ( ) const
inline
See also
checked

◆ setChecked

void StelAction::setChecked ( bool  )
slot
See also
checked
Warning
If used on a non-checkable action, the program may crash.

◆ toggle

void StelAction::toggle ( )
slot
Warning
If used on a non-checkable action, the program may crash.

◆ toggled

void StelAction::toggled ( bool  )
signal

When the action is connected to a StelProperty, this is equivalent to the StelProperty::valueChanged signal. In the other cases, this state may not always be emitted correctly (i.e. when the state changes through other mechanisms than StelAction)

◆ trigger

void StelAction::trigger ( )
slot

Otherwise, the connected slot is invoked.

Property Documentation

◆ checkable

bool StelAction::checkable
read

This is the case when connected to a boolean Q_PROPERTY. This means the checked property as well as the toggle() function may be used If false, the StelAction represents a simple argumentless slot call. Using checked or toggle() may result in an error.

◆ checked

bool StelAction::checked
readwrite

Note that the toggled signal may not be emitted on all changes of the connected property

Warning
If used on a non-checkable action, the program may crash.