Plasma::AbstractRunner

Search for usage in LXR

#include <KRunner/AbstractRunner>

Inheritance diagram for Plasma::AbstractRunner:

Public Types

typedef QList< AbstractRunner * > List
 
enum  Priority {
  LowestPriority = 0, LowPriority, NormalPriority, HighPriority,
  HighestPriority
}
 
enum  Speed { SlowSpeed, NormalSpeed }
 

Properties

QString description
 
QIcon icon
 
QString id
 
bool matchingSuspended
 
QRegularExpression matchRegex
 
int minLetterCount
 
QString name
 
- Properties inherited from QObject
 objectName
 

Signals

void matchingSuspended (bool suspended)
 
void prepare ()
 
void teardown ()
 

Public Member Functions

virtual QStringList categories () const
 
virtual QIcon categoryIcon (const QString &category) const
 
virtual void createRunOptions (QWidget *widget)
 
RunnerSyntaxdefaultSyntax () const
 
QString description () const
 
bool hasMatchRegex () const
 
bool hasRunOptions ()
 
QIcon icon () const
 
QString id () const
 
RunnerContext::Types ignoredTypes () const
 
bool isMatchingSuspended () const
 
virtual void match (Plasma::RunnerContext &context)
 
QRegularExpression matchRegex () const
 
KPluginInfo metadata () const
 
KPluginMetaData metadata (RunnerReturnPluginMetaDataConstant) const
 
int minLetterCount () const
 
QString name () const
 
Package package () const
 
void performMatch (Plasma::RunnerContext &context)
 
Priority priority () const
 
virtual void reloadConfiguration ()
 
virtual void run (const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
 
void setIgnoredTypes (RunnerContext::Types types)
 
void setMatchRegex (const QRegularExpression &regex)
 
void setMinLetterCount (int count)
 
void setTriggerWords (const QStringList &triggerWords)
 
Speed speed () const
 
QList< RunnerSyntaxsyntaxes () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () 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< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, 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 QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
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)
 
QThreadthread () const const
 

Protected Member Functions

 AbstractRunner (const KPluginMetaData &pluginMetaData, QObject *parent=nullptr)
 
 AbstractRunner (const KService::Ptr service, QObject *parent=nullptr)
 
 AbstractRunner (QObject *parent, const KPluginMetaData &pluginMetaData, const QVariantList &args)
 
 AbstractRunner (QObject *parent, const QVariantList &args)
 
 AbstractRunner (QObject *parent=nullptr, const QString &path=QString())
 
QActionaction (const QString &id) const
 
QHash< QString, QAction * > actions () const
 
virtual QList< QAction * > actionsForMatch (const Plasma::QueryMatch &match)
 
QActionaddAction (const QString &id, const QIcon &icon, const QString &text)
 
void addAction (const QString &id, QAction *action)
 
void addSyntax (const RunnerSyntax &syntax)
 
void clearActions ()
 
KConfigGroup config () const
 
Q_INVOKABLE DataEnginedataEngine (const QString &name) const
 
virtual void init ()
 
virtual QMimeDatamimeDataForMatch (const Plasma::QueryMatch &match)
 
void removeAction (const QString &id)
 
void setDefaultSyntax (const RunnerSyntax &syntax)
 
void setHasRunOptions (bool hasRunOptions)
 
void setPriority (Priority newPriority)
 
void setSpeed (Speed newSpeed)
 
void setSyntaxes (const QList< RunnerSyntax > &syns)
 
void suspendMatching (bool suspend)
 
- Protected Member Functions inherited from QObject
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
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Related Functions

(Note that these are not member functions.)

#define K_EXPORT_PLASMA_RUNNER(libname, classname)
 
#define K_EXPORT_PLASMA_RUNNER_WITH_JSON(classname, jsonFile)   K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, jsonFile, registerPlugin<classname>();)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
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)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

An abstract base class for Plasma Runner plugins.

Be aware that runners have to be thread-safe. This is due to the fact that each runner is executed in its own thread for each new term. Thus, a runner may be executed more than once at the same time. See match() for details. To let krunner expose a global shortcut for the single runner query mode, the runner must set the "X-Plasma-AdvertiseSingleRunnerMode" key to true in the .desktop file and set a default syntax. See setDefaultSyntax() for details.

Definition at line 68 of file abstractrunner.h.

Member Typedef Documentation

◆ List

An ordered list of runners.

Definition at line 98 of file abstractrunner.h.

Member Enumeration Documentation

◆ Priority

Specifies a priority for the runner.

Definition at line 89 of file abstractrunner.h.

◆ Speed

Specifies a nominal speed for the runner.

Definition at line 82 of file abstractrunner.h.

Constructor & Destructor Documentation

◆ AbstractRunner() [1/4]

Plasma::AbstractRunner::AbstractRunner ( QObject parent,
const KPluginMetaData pluginMetaData,
const QVariantList &  args 
)
protected

Constructor for a KRunner plugin.

Parameters
parentparent object for this runner
pluginMetaDatametadata that was embedded in the runner
argsfor compatibility with KPluginFactory, should be passed on to the parent constructor
Since
5.72

Definition at line 59 of file abstractrunner.cpp.

◆ AbstractRunner() [2/4]

Plasma::AbstractRunner::AbstractRunner ( const KService::Ptr  service,
QObject parent = nullptr 
)
explicitprotected

◆ AbstractRunner() [3/4]

Plasma::AbstractRunner::AbstractRunner ( const KPluginMetaData pluginMetaData,
QObject parent = nullptr 
)
explicitprotected
Since
5.72

Definition at line 42 of file abstractrunner.cpp.

◆ AbstractRunner() [4/4]

Plasma::AbstractRunner::AbstractRunner ( QObject parent,
const QVariantList &  args 
)
protected

Member Function Documentation

◆ action()

QAction * Plasma::AbstractRunner::action ( const QString id) const
protected

Returns the action associated with the id.

Deprecated:
Since 5.86, create the QAction instances manually and store them in a custom container instead

Definition at line 214 of file abstractrunner.cpp.

◆ actions()

QHash< QString, QAction * > Plasma::AbstractRunner::actions ( ) const
protected

Returns all registered actions.

Deprecated:
Since 5.86, create the QAction instances manually and store them in a custom container instead

Definition at line 219 of file abstractrunner.cpp.

◆ actionsForMatch()

QList< QAction * > Plasma::AbstractRunner::actionsForMatch ( const Plasma::QueryMatch match)
protectedvirtual

A given match can have more than action that can be performed on it.

For example, a song match returned by a music player runner can be queued, added to the playlist, or played.

Call this method to add actions that can be performed by the runner. Actions must first be added to the runner's action registry. Note: execution of correct action is left up to the runner.

Definition at line 190 of file abstractrunner.cpp.

◆ addAction() [1/2]

QAction * Plasma::AbstractRunner::addAction ( const QString id,
const QIcon icon,
const QString text 
)
protected

Creates and then adds an action to the action registry.

AbstractRunner assumes ownership of the created action.

See also
QueryMatch::setActions
actionsForMatch
Parameters
idA unique identifier string
iconThe icon to display
textThe text to display
Returns
the created QAction
Deprecated:
Since 5.86 create the QAction instance manually
// in the runner class definition
QList<QAction *> m_actions;
// when initializing the runner, optionally set the date if needed
auto action = new QAction(QIcon::fromTheme(iconName), text, this);
m_actions << action;
// when creating the match
match.setActions(m_actions);

Definition at line 196 of file abstractrunner.cpp.

◆ addAction() [2/2]

void Plasma::AbstractRunner::addAction ( const QString id,
QAction action 
)
protected

Adds an action to the runner's action registry.

The QAction must be created within the GUI thread; do not create it within the match method of AbstractRunner.

Parameters
idA unique identifier string
actionThe QAction to be stored
Deprecated:
Since 5.86, create the QAction instance manually

Definition at line 203 of file abstractrunner.cpp.

◆ addSyntax()

void Plasma::AbstractRunner::addSyntax ( const RunnerSyntax syntax)
protected

Adds a registered syntax that this runner understands.

This is used to display to the user what this runner can understand and how it can be used.

Parameters
syntaxthe syntax to register
Since
4.3

Definition at line 115 of file abstractrunner.cpp.

◆ categories()

QStringList Plasma::AbstractRunner::categories ( ) const
virtual

Return a list of categories that this runner provides.

By default this list just contains the runners name. It is used by the runner manager to disable certain runners if all the categories they provide have been disabled.

This list of categories is also used to provide a better way to configure the runner instead of the typical on / off switch.

Deprecated:
Since 5.76, feature is unused. You can still set the category property in the QueryMatch

Definition at line 318 of file abstractrunner.cpp.

◆ categoryIcon()

QIcon Plasma::AbstractRunner::categoryIcon ( const QString category) const
virtual

Returns the icon which accurately describes the category category.

This is meant to be used in a configuration dialog when showing all the categories.

By default this returns the icon of the AbstractRunner

Definition at line 325 of file abstractrunner.cpp.

◆ clearActions()

void Plasma::AbstractRunner::clearActions ( )
protected

Clears the action registry.

The action pool deletes the actions.

Deprecated:
Since 5.86, use a custom container to store the QAction instances instead

Definition at line 224 of file abstractrunner.cpp.

◆ config()

KConfigGroup Plasma::AbstractRunner::config ( ) const
protected

Provides access to the runner's configuration object.

Definition at line 100 of file abstractrunner.cpp.

◆ createRunOptions()

void Plasma::AbstractRunner::createRunOptions ( QWidget widget)
virtual

If hasRunOptions() returns true, this method may be called to get a widget displaying the options the user can interact with to modify the behaviour of what happens when a given match is selected.

Parameters
widgetthe parent of the options widgets.
Deprecated:
Since 5.0, this feature has been defunct

Definition at line 256 of file abstractrunner.cpp.

◆ dataEngine()

DataEngine * Plasma::AbstractRunner::dataEngine ( const QString name) const
protected

Loads the given DataEngine.

Tries to load the data engine given by name. Each engine is only loaded once, and that instance is re-used on all subsequent requests.

If the data engine was not found, an invalid data engine is returned (see DataEngine::isValid()).

Note that you should not delete the returned engine.

Parameters
nameName of the data engine to load
Returns
pointer to the data engine if it was loaded, or an invalid data engine if the requested engine could not be loaded
Since
4.4
Deprecated:
Since 5.73, DataEngines are deprecated, use e.g. a shared library to provide the data instead.

Definition at line 403 of file abstractrunner.cpp.

◆ defaultSyntax()

RunnerSyntax * Plasma::AbstractRunner::defaultSyntax ( ) const
Returns
the default syntax for the runner or nullptr if no default syntax has been defined
Since
4.4
Deprecated:
Since 5.76, feature is unused.

Definition at line 149 of file abstractrunner.cpp.

◆ description()

QString Plasma::AbstractRunner::description ( ) const
Returns
the description of this Runner

◆ hasMatchRegex()

bool Plasma::AbstractRunner::hasMatchRegex ( ) const

If the runner has a valid regex and non empty regex.

Returns
hasMatchRegex
Since
5.75

Definition at line 465 of file abstractrunner.cpp.

◆ hasRunOptions()

bool Plasma::AbstractRunner::hasRunOptions ( )

If the runner has options that the user can interact with to modify what happens when run or one of the actions created in match is called, the runner should return true.

Deprecated:
Since 5.0, this feature has been defunct

Definition at line 242 of file abstractrunner.cpp.

◆ icon()

QIcon Plasma::AbstractRunner::icon ( ) const
Returns
the icon for this Runner

◆ id()

QString Plasma::AbstractRunner::id ( ) const
Returns
an id string for the Runner

◆ ignoredTypes()

RunnerContext::Types Plasma::AbstractRunner::ignoredTypes ( ) const

Returns the OR'ed value of all the Information types (as defined in RunnerContext::Type) this runner is not interested in.

Returns
OR'ed value of black listed types
Deprecated:
This feature is deprecated

Definition at line 298 of file abstractrunner.cpp.

◆ init()

void Plasma::AbstractRunner::init ( )
protectedvirtual

Reimplement this slot to run any initialization routines on first load.

By default, it calls reloadConfiguration(); for scripted Runners this method also sets up the ScriptEngine.

Definition at line 397 of file abstractrunner.cpp.

◆ isMatchingSuspended()

bool Plasma::AbstractRunner::isMatchingSuspended ( ) const
Returns
true if the runner is currently busy with non-interuptable work, signaling that new threads should not be created for it at this time
Since
4.6

Definition at line 409 of file abstractrunner.cpp.

◆ match()

void Plasma::AbstractRunner::match ( Plasma::RunnerContext context)
virtual

This is the main query method.

It should trigger creation of QueryMatch instances through RunnerContext::addMatch and RunnerContext::addMatches.

If the runner can run precisely the requested term (RunnerContext::query()), it should create an exact match by setting the type to RunnerContext::ExactMatch. The first runner that creates a QueryMatch will be the default runner. Other runner's matches will be suggested in the interface. Non-exact matches should be offered via RunnerContext::PossibleMatch.

The match will be activated via run() if the user selects it.

Each runner is executed in its own thread. Whenever the user input changes this method is called again. Thus, it needs to be thread-safe. Also, all matches need to be reported once this method returns. Asynchronous runners therefore need to make use of a local event loop to wait for all matches.

It is recommended to use local status data in async runners. The simplest way is to have a separate class doing all the work like so:

void MyFancyAsyncRunner::match(RunnerContext &context)
{
QEventLoop loop;
MyAsyncWorker worker(context);
connect(&worker, &MyAsyncWorker::finished, &loop, &MyAsyncWorker::quit);
worker.work();
loop.exec();
}

Here MyAsyncWorker creates all the matches and calls RunnerContext::addMatch in some internal slot. It emits the finished() signal once done which will quit the loop and make the match() method return. The local status is kept entirely in MyAsyncWorker which makes match() trivially thread-safe.

If a particular match supports multiple actions, set up the corresponding actions in the actionsForMatch method. Do not call any of the action methods within this method!

Execution of the correct action should be handled in the run method. @caution This method needs to be thread-safe since KRunner will simply start a new thread for each new term.

Warning
Returning from this method means to end execution of the runner.
See also
run(), RunnerContext::addMatch, RunnerContext::addMatches, QueryMatch

Definition at line 331 of file abstractrunner.cpp.

◆ matchingSuspended

void Plasma::AbstractRunner::matchingSuspended ( bool  suspended)
signal

Emitted when the runner enters or exits match suspension.

See also
matchingSuspended
Since
4.6

◆ matchRegex()

QRegularExpression Plasma::AbstractRunner::matchRegex ( ) const

If this regex is set with a not empty pattern it must match the query in order for the performMatch/match being called.

Just like the minLetterCount property this check is ignored when the runner is in the singleRunnerMode. In case both the regex and the letter count is set the letter count is checked first.

Returns
matchRegex property
See also
hasMatchRegex
Since
5.75

◆ metadata() [1/2]

KPluginInfo Plasma::AbstractRunner::metadata ( ) const
Returns
the plugin info for this runner
Deprecated:
since 5.72, use metaData(Plasma::RunnerReturnPluginMetaDataConstant) instead, see its API docs

Definition at line 372 of file abstractrunner.cpp.

◆ metadata() [2/2]

KPluginMetaData Plasma::AbstractRunner::metadata ( RunnerReturnPluginMetaDataConstant  ) const
Returns
the plugin metadata for this runner

Overload to get non-deprecated metadata format. Use like this:

KPluginMetaData md = runner->metadata(Plasma::RunnerReturnPluginMetaData);

If you disable the deprecated version using the KRUNNER_DISABLE_DEPRECATED_BEFORE_AND_AT macro, then you can omit Plasma::RunnerReturnPluginMetaDataConstant and use it like this:

KPluginMetaData md = runner->metadata();
Since
5.72

Definition at line 381 of file abstractrunner.cpp.

◆ mimeDataForMatch()

QMimeData * Plasma::AbstractRunner::mimeDataForMatch ( const Plasma::QueryMatch match)
protectedvirtual

Reimplement this slot if you want your runner to support serialization and drag and drop.

Since
4.5

Definition at line 231 of file abstractrunner.cpp.

◆ minLetterCount()

int Plasma::AbstractRunner::minLetterCount ( ) const

This is the minimum letter count for the query.

If the query is shorter than this value and KRunner is not in the singleRunnerMode, the performMatch and consequently match method is not called. This can be set using the X-Plasma-Runner-Min-Letter-Count property or the setMinLetterCount method.

See also
setMinLetterCount
match
performMatch
Returns
minLetterCount property
Since
5.75

◆ name()

QString Plasma::AbstractRunner::name ( ) const
Returns
the user visible engine name for the Runner

◆ package()

Package Plasma::AbstractRunner::package ( ) const

Accessor for the associated Package object if any.

Note that the returned pointer is only valid for the lifetime of the runner.

Returns
the Package object, which may be invalid
Deprecated:
since 5.28, use KPackage::Package instead, no accessor in this class

Definition at line 387 of file abstractrunner.cpp.

◆ performMatch()

void Plasma::AbstractRunner::performMatch ( Plasma::RunnerContext context)

Triggers a call to match.

This will call match() internally.

Parameters
contextthe search context used in executing this match.
Deprecated:
Since 5.81, use match(Plasma::RunnerContext &context) instead. This method contains logic to delay slow runners, which is now deprecated. Consequently you should call match(Plasma::RunnerContext &context) directly.

Definition at line 156 of file abstractrunner.cpp.

◆ prepare

void Plasma::AbstractRunner::prepare ( )
signal

This signal is emitted when matching is about to commence, giving runners an opportunity to prepare themselves, e.g.

loading data sets or preparing IPC or network connections. This method should be fast so as not to cause slow downs. Things that take longer or which should be loaded once and remain extant for the lifespan of the AbstractRunner should be done in init().

See also
init()
Since
4.4

◆ priority()

AbstractRunner::Priority Plasma::AbstractRunner::priority ( ) const

The priority of the runner.

See also
setPriority

Definition at line 287 of file abstractrunner.cpp.

◆ reloadConfiguration()

void Plasma::AbstractRunner::reloadConfiguration ( )
virtual

Signal runner to reload its configuration.

Definition at line 111 of file abstractrunner.cpp.

◆ removeAction()

void Plasma::AbstractRunner::removeAction ( const QString id)
protected

Removes the action from the action registry.

AbstractRunner deletes the action once removed.

Parameters
idThe id of the action to be removed
Deprecated:
Since 5.86, deprecated for lack of usage

Definition at line 208 of file abstractrunner.cpp.

◆ run()

void Plasma::AbstractRunner::run ( const Plasma::RunnerContext context,
const Plasma::QueryMatch match 
)
virtual

Called whenever an exact or possible match associated with this runner is triggered.

Parameters
contextThe context in which the match is triggered, i.e. for which the match was created.
matchThe actual match to run/execute.

Definition at line 311 of file abstractrunner.cpp.

◆ setDefaultSyntax()

void Plasma::AbstractRunner::setDefaultSyntax ( const RunnerSyntax syntax)
protected

Set syntax as the default syntax for the runner; the default syntax will be substituted to the empty query in single runner mode.

This is also used to display to the user what this runner can understand and how it can be used. The default syntax is automatically added to the list of registered syntaxes, there is no need to add it using addSyntax. Note that there can be only one default syntax; if called more than once, the last call will determine the default syntax. A default syntax (even trivial) is required to advertise single runner mode

Parameters
syntaxthe syntax to register and to set as default
Since
4.4
Deprecated:
Since 5.76, feature is unused. Use addSyntax() instead.

Definition at line 131 of file abstractrunner.cpp.

◆ setHasRunOptions()

void Plasma::AbstractRunner::setHasRunOptions ( bool  hasRunOptions)
protected

Sets whether or not the runner has options for matches.

Deprecated:
Since 5.0, this feature has been defunct

Definition at line 249 of file abstractrunner.cpp.

◆ setIgnoredTypes()

void Plasma::AbstractRunner::setIgnoredTypes ( RunnerContext::Types  types)

Sets the types this runner will ignore.

If the value from RunnerContext::type() is contained in the ignored types the match() method won't be called. This way there is no unnecessary thread spawned. The same RunnerContext from which the type gets read is later passed into the match(Plasma::RunnerContext &context) method call.

Parameters
typesOR'ed listed of ignored types
Deprecated:
feature is deprecated. Consider using the minLetterCount and matchRegex properties instead. These properties also prevent thread spawning, but can be used far more precise. If you want to have this kind of optimization for older KRunner versions you could wrap this inside of an version if statement:
#if KRUNNER_VERSION < QT_VERSION_CHECK(5, 76, 0)
//set ignore types
#endif

The minLetterCount and matchRegex can be set with a similar version check or added to the desktop file. If an older KRunner version loads such a desktop file these unknown properties are just ignored.

See also
minLetterCount
matchRegex

Definition at line 305 of file abstractrunner.cpp.

◆ setMatchRegex()

void Plasma::AbstractRunner::setMatchRegex ( const QRegularExpression regex)

Set the matchRegex property.

Parameters
regex
Since
5.75

Definition at line 439 of file abstractrunner.cpp.

◆ setMinLetterCount()

void Plasma::AbstractRunner::setMinLetterCount ( int  count)

Set the minLetterCount property.

Parameters
count
Since
5.75

Definition at line 429 of file abstractrunner.cpp.

◆ setPriority()

void Plasma::AbstractRunner::setPriority ( Priority  newPriority)
protected

Sets the priority of the runner.

Lower priority runners are executed only after higher priority runners.

Definition at line 292 of file abstractrunner.cpp.

◆ setSpeed()

void Plasma::AbstractRunner::setSpeed ( Speed  newSpeed)
protected

Sets the nominal speed of the runner.

Only slow runners need to call this within their constructor because the default speed is NormalSpeed. Runners that use D-Bus should call this within their constructors.

Deprecated:
Since 5.81, the concept of delayed runners is deprecated. If you have resource or memory intensive tasks consider porting the runner to a D-Bus runner. Otherwise you can set the priority of the runner to LowPriority and implement the wait using a QTimer and an event loop. It is important to check if the RunnerContext is still valid after the waiting interval.

Definition at line 279 of file abstractrunner.cpp.

◆ setSyntaxes()

void Plasma::AbstractRunner::setSyntaxes ( const QList< RunnerSyntax > &  syns)
protected

Sets the list of syntaxes; passing in an empty list effectively clears the syntaxes.

Parameters
thesyntaxes to register for this runner
Since
4.3

Definition at line 138 of file abstractrunner.cpp.

◆ setTriggerWords()

void Plasma::AbstractRunner::setTriggerWords ( const QStringList triggerWords)

Constructs internally a regex which requires the query to start with the trigger words.

Multiple words are concatenated with or, for instance: "^word1|word2|word3". The trigger words are internally escaped. Also the minLetterCount is set to the shortest word in the list.

Since
5.75
See also
matchRegex

Definition at line 445 of file abstractrunner.cpp.

◆ speed()

AbstractRunner::Speed Plasma::AbstractRunner::speed ( ) const

The nominal speed of the runner.

See also
setSpeed

Definition at line 263 of file abstractrunner.cpp.

◆ suspendMatching()

void Plasma::AbstractRunner::suspendMatching ( bool  suspend)
protected

Sets whether or not the runner is available for match requests.

Useful to prevent more thread spawning when the thread is in a busy state.

Definition at line 414 of file abstractrunner.cpp.

◆ syntaxes()

QList< RunnerSyntax > Plasma::AbstractRunner::syntaxes ( ) const
Returns
the syntaxes the runner has registered that it accepts and understands
Since
4.3

Definition at line 143 of file abstractrunner.cpp.

◆ teardown

void Plasma::AbstractRunner::teardown ( )
signal

This signal is emitted when a session of matches is complete, giving runners the opportunity to tear down anything set up as a result of the prepare() method.

Since
4.4

Friends And Related Function Documentation

◆ K_EXPORT_PLASMA_RUNNER

#define K_EXPORT_PLASMA_RUNNER (   libname,
  classname 
)
related
Value:
K_EXPORT_PLASMA_RUNNER_WARNING("Deprecated. Since 5.72, use K_EXPORT_PLASMA_RUNNER_WITH_JSON(classname, jsonFile) instead") \
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();)

Registers a runner plugin.

Deprecated:
Since 5.72, use K_EXPORT_PLASMA_RUNNER_WITH_JSON(classname, jsonFile) instead

Definition at line 723 of file abstractrunner.h.

◆ K_EXPORT_PLASMA_RUNNER_WITH_JSON

#define K_EXPORT_PLASMA_RUNNER_WITH_JSON (   classname,
  jsonFile 
)    K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, jsonFile, registerPlugin<classname>();)
related

Registers a runner plugin with JSON metadata.

Parameters
classnamename of the AbstractRunner derived class.
jsonFilename of the JSON file to be compiled into the plugin as metadata
Since
5.72
Deprecated:
Since 5.88 use K_PLUGIN_CLASS_WITH_JSON instead

Definition at line 740 of file abstractrunner.h.


The documentation for this class was generated from the following files:
QIcon fromTheme(const QString &name)
int exec(QEventLoop::ProcessEventsFlags flags)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual void match(Plasma::RunnerContext &context)
This is the main query method.
QAction * action(const QString &id) const
Returns the action associated with the id.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 6 2023 04:18:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.