Stellarium  0.17.0
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...


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)


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...


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.

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

bool StelAction::isCheckable ( ) const
See also
bool StelAction::isChecked ( ) const
See also
void StelAction::setChecked ( bool  )
See also
If used on a non-checkable action, the program may crash.
void StelAction::toggle ( )
If used on a non-checkable action, the program may crash.
void StelAction::toggled ( bool  )

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)

void StelAction::trigger ( )

Otherwise, the connected slot is invoked.

Property Documentation

bool StelAction::checkable

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.

bool StelAction::checked

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

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