Kross::Action
#include <action.h>

Signals | |
void | dataChanged (Action *) |
void | finalized (Kross::Action *) |
void | finished (Kross::Action *) |
void | started (Kross::Action *) |
void | updated () |
Public Slots | |
void | addQObject (QObject *obj, const QString &name=QString()) |
QVariant | callFunction (const QString &name, const QVariantList &args=QVariantList()) |
QByteArray | code () const |
QString | currentPath () const |
QString | description () const |
QVariant | evaluate (const QByteArray &code) |
QString | file () const |
QStringList | functionNames () |
QString | iconName () const |
QString | interpreter () const |
bool | isEnabled () const |
QString | name () const |
QVariant | option (const QString &name, const QVariant &defaultvalue=QVariant()) |
QVariantMap | options () const |
QObject * | qobject (const QString &name) const |
QStringList | qobjectNames () const |
void | setCode (const QByteArray &code) |
void | setDescription (const QString &description) |
void | setEnabled (bool enabled) |
bool | setFile (const QString &scriptfile) |
void | setIconName (const QString &iconname) |
void | setInterpreter (const QString &interpretername) |
bool | setOption (const QString &name, const QVariant &value) |
int | version () const |
Public Member Functions | |
Action (QObject *parent, const QString &name, const QDir &packagepath=QDir()) | |
Action (QObject *parent, const QUrl &url) | |
~Action () override | |
void | finalize () |
void | fromDomElement (const QDomElement &element) |
void | fromDomElement (const QDomElement &element, const QStringList &searchPath) |
bool | initialize () |
bool | isFinalized () const |
Script * | script () const |
QDomElement | toDomElement () const |
QDomElement | toDomElement (const QStringList &searchPath) const |
![]() | |
QAction (const QIcon &icon, const QString &text, QObject *parent) | |
QAction (const QString &text, QObject *parent) | |
QAction (QObject *parent) | |
QActionGroup * | actionGroup () const const |
void | activate (QAction::ActionEvent event) |
QList< QGraphicsWidget * > | associatedGraphicsWidgets () const const |
QList< QWidget * > | associatedWidgets () const const |
bool | autoRepeat () const const |
void | changed () |
QVariant | data () const const |
QFont | font () const const |
void | hover () |
void | hovered () |
QIcon | icon () const const |
QString | iconText () const const |
bool | isCheckable () const const |
bool | isChecked () const const |
bool | isEnabled () const const |
bool | isIconVisibleInMenu () const const |
bool | isSeparator () const const |
bool | isShortcutVisibleInContextMenu () const const |
bool | isVisible () const const |
QMenu * | menu () const const |
QAction::MenuRole | menuRole () const const |
QWidget * | parentWidget () const const |
QAction::Priority | priority () const const |
void | setActionGroup (QActionGroup *group) |
void | setAutoRepeat (bool) |
void | setCheckable (bool) |
void | setChecked (bool) |
void | setData (const QVariant &userData) |
void | setDisabled (bool b) |
void | setEnabled (bool) |
void | setFont (const QFont &font) |
void | setIcon (const QIcon &icon) |
void | setIconText (const QString &text) |
void | setIconVisibleInMenu (bool visible) |
void | setMenu (QMenu *menu) |
void | setMenuRole (QAction::MenuRole menuRole) |
void | setPriority (QAction::Priority priority) |
void | setSeparator (bool b) |
void | setShortcut (const QKeySequence &shortcut) |
void | setShortcutContext (Qt::ShortcutContext context) |
void | setShortcuts (const QList< QKeySequence > &shortcuts) |
void | setShortcuts (QKeySequence::StandardKey key) |
void | setShortcutVisibleInContextMenu (bool show) |
void | setStatusTip (const QString &statusTip) |
void | setText (const QString &text) |
void | setToolTip (const QString &tip) |
void | setVisible (bool) |
void | setWhatsThis (const QString &what) |
QKeySequence | shortcut () const const |
Qt::ShortcutContext | shortcutContext () const const |
QList< QKeySequence > | shortcuts () const const |
bool | showStatusText (QWidget *widget) |
QString | statusTip () const const |
QString | text () const const |
void | toggle () |
void | toggled (bool checked) |
QString | toolTip () const const |
void | trigger () |
void | triggered (bool checked) |
QString | whatsThis () const const |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
![]() | |
void | addObject (QObject *object, const QString &name=QString(), Options options=NoOption) |
bool | hasObject (const QString &name) const |
QObject * | object (const QString &name) const |
Options | objectOption (const QString &name) const |
QHash< QString, Options > | objectOptions () const |
QHash< QString, QObject * > | objects () const |
![]() | |
ErrorInterface () | |
void | clearError () |
long | errorLineNo () const |
const QString | errorMessage () const |
const QString | errorTrace () const |
bool | hadError () const |
void | setError (const QString &errormessage, const QString &tracemessage=QString(), long lineno=-1) |
void | setError (ErrorInterface *error) |
Additional Inherited Members | |
![]() | |
enum | ActionEvent |
enum | MenuRole |
enum | Priority |
![]() | |
enum | Options { NoOption = 0x00, AutoConnectSignals = 0x01, LastOption = 0x1000000 } |
![]() | |
autoRepeat | |
checkable | |
checked | |
enabled | |
font | |
icon | |
iconText | |
iconVisibleInMenu | |
menuRole | |
priority | |
shortcut | |
shortcutContext | |
shortcutVisibleInContextMenu | |
statusTip | |
text | |
toolTip | |
visible | |
whatsThis | |
![]() | |
objectName | |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
AboutQtRole | |
AboutRole | |
ApplicationSpecificRole | |
HighPriority | |
Hover | |
LowPriority | |
NormalPriority | |
NoRole | |
PreferencesRole | |
QuitRole | |
TextHeuristicRole | |
Trigger | |
![]() | |
typedef | QObjectList |
![]() | |
virtual bool | event (QEvent *e) override |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
The Action class is an abstract container to deal with scripts like a single standalone script file.
Each action holds a reference to the matching Kross::Interpreter created Kross::Script instance.
The Manager takes care of handling the Action instances application by providing access to ActionCollection containers for those Action instances.
Once you've such a Action instance you're able to perform actions with it like executing scripting code.
Following sample shows "Hello World." executed with the python interpreter:
Following sample demonstrates how to execute an external python script file. The script file itself is named "mytest.py" and contains:
Then you are able to load the script file, publish QObject instances and let the script do whatever it likes to do:
Constructor & Destructor Documentation
◆ Action() [1/2]
Constructor.
- Parameters
-
parent The parent QObject this Action is a child of. name The unique name this Action has. It's used e.g. at the Manager to identify the Action. The name is accessible via QObject::objectName .
- Deprecated:
- since 4.3: pass search path to fromDomElement() and toDomElement()
Definition at line 116 of file action.cpp.
◆ Action() [2/2]
Constructor.
- Parameters
-
parent The parent QObject this Action is a child of. url The URL should point to a valid scripting file. This Action will be filled with the content of the file (e.g. the file is read and code should return its content and it's also tried to determine the interpreter ). Remember to use QUrl c'tor explicitly. The name will be set to url.path()
Definition at line 127 of file action.cpp.
◆ ~Action()
|
override |
Destructor.
Definition at line 141 of file action.cpp.
Member Function Documentation
◆ addQObject
Add a QObject instance to the action.
This instance will be published to scripts.
Definition at line 402 of file action.cpp.
◆ callFunction
|
slot |
Call a function in the script.
- Parameters
-
name The name of the function which should be called. args The optional list of arguments.
Definition at line 454 of file action.cpp.
◆ code
|
slot |
- Returns
- the scriptcode this Action holds.
Definition at line 332 of file action.cpp.
◆ currentPath
|
slot |
- Returns
- the current path the script is running in or an empty string if there is no current path defined.
Definition at line 392 of file action.cpp.
◆ dataChanged
|
signal |
This signal is emitted when the data of the Action is changed.
◆ description
|
slot |
- Returns
- the optional description for this Action.
Definition at line 295 of file action.cpp.
◆ evaluate
|
slot |
Evaluate some scripting code.
Example how this can be used:
- Parameters
-
code The scripting code to evaluate.
- Returns
- The return value of the evaluation.
Definition at line 464 of file action.cpp.
◆ file
|
slot |
- Returns
- the script file that should be executed.
Definition at line 366 of file action.cpp.
◆ finalize()
void Action::finalize | ( | ) |
Finalize the Script instance and frees any cached or still running executions.
Normally there is no need to call this function directly because the Action will take care of calling it if needed.
Definition at line 523 of file action.cpp.
◆ finalized
|
signal |
This signal is emitted once a script finalized.
◆ finished
|
signal |
This signal is emitted after the script got executed.
◆ fromDomElement() [1/2]
void Action::fromDomElement | ( | const QDomElement & | element | ) |
Method to read settings from the QDomElement element
that contains details about e.g.
the displayed text, the file to execute or the used interpreter.
- Todo:
- BIC merge
Definition at line 154 of file action.cpp.
◆ fromDomElement() [2/2]
void Action::fromDomElement | ( | const QDomElement & | element, |
const QStringList & | searchPath | ||
) |
Method to read settings from the QDomElement element
that contains details about e.g.
the displayed text, the file to execute or the used interpreter.
- Parameters
-
searchPath List of directories where to search the script if its path is relative First item is given the highest priority.
Definition at line 159 of file action.cpp.
◆ functionNames
|
slot |
- Returns
- the list of functionnames.
Definition at line 444 of file action.cpp.
◆ iconName
|
slot |
Return the name of the icon.
Definition at line 307 of file action.cpp.
◆ initialize()
bool Action::initialize | ( | ) |
Initialize the Script instance.
Normally there is no need to call this function directly because if will be called internally if needed (e.g. on execute ).
- Returns
- true if the initialization was successful else false is returned.
Definition at line 474 of file action.cpp.
◆ interpreter
|
slot |
- Returns
- the name of the interpreter. Could be for example "python" or "ruby".
Definition at line 347 of file action.cpp.
◆ isEnabled
|
slot |
Return true if this Action is enabled else false is returned.
Definition at line 320 of file action.cpp.
◆ isFinalized()
bool Action::isFinalized | ( | ) | const |
- Returns
- true if the action is finalized, which means the action is currently not running.
Definition at line 532 of file action.cpp.
◆ name
|
slot |
- Returns
- the objectName for this Action.
Definition at line 285 of file action.cpp.
◆ option
- Returns
- the value of the option defined with
name
. If there doesn't exist an option with such a name, thedefaultvalue
is returned.
Definition at line 417 of file action.cpp.
◆ options
|
slot |
- Returns
- a map of options this Action defines. The options are returned call-by-ref, so you are able to manipulate them.
Definition at line 397 of file action.cpp.
◆ qobject
- Returns
- the QObject with the object name
name
.
Definition at line 407 of file action.cpp.
◆ qobjectNames
|
slot |
- Returns
- a list of QObject object names.
Definition at line 412 of file action.cpp.
◆ script()
Kross::Script * Action::script | ( | ) | const |
- Returns
- the Kross::Script implementation used by the scripting backend. This returns NULL until the action got triggered or if there was an error before that.
Normally it shouldn't be necessary to deal with the scripting backend depending instance of a Kross::Script implementation since this Action class already decorates all the things needed. It may however be useful to provide additional interpreter dependent functionality.
Definition at line 280 of file action.cpp.
◆ setCode
|
slot |
Set the scriptcode code
this Action should execute.
Definition at line 337 of file action.cpp.
◆ setDescription
|
slot |
Set the optional description for this Action.
Definition at line 300 of file action.cpp.
◆ setEnabled
|
slot |
Set the enable state of this Action to enabled
.
Definition at line 325 of file action.cpp.
◆ setFile
|
slot |
Set the script file that should be executed.
Definition at line 371 of file action.cpp.
◆ setIconName
|
slot |
Set the name of the icon to iconname
.
Definition at line 312 of file action.cpp.
◆ setInterpreter
|
slot |
Set the name of the interpreter (javascript, python or ruby).
Definition at line 352 of file action.cpp.
◆ setOption
Set the Interpreter::Option value.
Definition at line 426 of file action.cpp.
◆ started
|
signal |
This signal is emitted before the script got executed.
◆ toDomElement() [1/2]
QDomElement Action::toDomElement | ( | ) | const |
- Returns
- a QDomElement that contains the settings like e.g. the displayed text, the file to execute or the used interpreter of this Action instance.
Definition at line 220 of file action.cpp.
◆ toDomElement() [2/2]
QDomElement Action::toDomElement | ( | const QStringList & | searchPath | ) | const |
- Returns
- a QDomElement that contains the settings like e.g. the displayed text, the file to execute or the used interpreter of this Action instance.
- Parameters
-
searchPath if given, find the closest directory containing the scriptfile and write relative filepath
Definition at line 225 of file action.cpp.
◆ updated
|
signal |
This signal is emitted if the content of the Action was changed.
The ActionCollection instances this Action is a child of are connected with this signal to fire up their own updated signal if an Action of them was updated.
◆ version
|
slot |
- Returns
- the version number this Action has. Per default 0 is returned.
Definition at line 290 of file action.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Nov 30 2023 04:02:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.