Plasma::RunnerSyntax

Search for usage in LXR

Plasma::RunnerSyntax Class Reference

#include <KRunner/RunnerSyntax>

Public Member Functions

 RunnerSyntax (const QString &exampleQuery, const QString &description)
 
 RunnerSyntax (const QStringList &exampleQueries, const QString &description)
 
 RunnerSyntax (const RunnerSyntax &other)
 
void addExampleQuery (const QString &exampleQuery)
 
QString description () const
 
QStringList exampleQueries () const
 
QStringList exampleQueriesWithTermDescription () const
 
RunnerSyntaxoperator= (const RunnerSyntax &rhs)
 
QString searchTermDescription () const
 
void setDescription (const QString &description)
 
void setSearchTermDescription (const QString &description)
 

Detailed Description

Since
4.3

Represents a query prototype that the runner accepts. These can be created and registered with AbstractRunner::addSyntax(Syntax &) to allow applications to show to the user what the runner is currently capable of doing.

Lets say the runner has a trigger word and then the user can type anything after that. In that case you could use ":q:" as a placeholder, which will get expanded to i18n("search term") and be put in brackets.

Plasma::RunnerSyntax syntax(QStringLiteral("sometriggerword :q:"), i18n("Description for this syntax"));
addSyntax(syntax);

But if the query the user has to enter is sth. specific like a program, url or file you should use a custom placeholder to make it easier to understand.

Plasma::RunnerSyntax syntax(QStringLiteral("sometriggereword <%1>").arg(i18n("program name"))), i18n("Description for this syntax"));
addSyntax(syntax);

Definition at line 41 of file runnersyntax.h.

Constructor & Destructor Documentation

◆ RunnerSyntax() [1/3]

Plasma::RunnerSyntax::RunnerSyntax ( const QString exampleQuery,
const QString description 
)

Constructs a simple syntax object.

Parameters
exampleQuerySee the class description for examples and placeholder conventions.
descriptionA description of what the described syntax does from the user's point of view.

Definition at line 36 of file runnersyntax.cpp.

◆ RunnerSyntax() [2/3]

Plasma::RunnerSyntax::RunnerSyntax ( const QStringList exampleQueries,
const QString description 
)
explicit

Constructs a syntax object.

Parameters
exampleQuerySee the class description for examples and placeholder conventions.
descriptionA description of what the described syntax does from the user's point of view.
Since
5.106

Definition at line 41 of file runnersyntax.cpp.

◆ RunnerSyntax() [3/3]

Plasma::RunnerSyntax::RunnerSyntax ( const RunnerSyntax other)

Copy constructor.

Definition at line 47 of file runnersyntax.cpp.

Member Function Documentation

◆ addExampleQuery()

void Plasma::RunnerSyntax::addExampleQuery ( const QString exampleQuery)

Adds a synonymous example query to this Syntax.

Some runners may accept multiple formulations of keywords to trigger the same behaviour. This allows the runner to show these relationships by grouping the example queries into one Syntax object

Parameters
exampleQuerySee the class description for examples and placeholder conventions.
Deprecated:
Since 5.106, use constructor taking example query QStringList

Definition at line 61 of file runnersyntax.cpp.

◆ description()

QString Plasma::RunnerSyntax::description ( ) const
Returns
the description of what the syntax does from the user's point of view

Definition at line 92 of file runnersyntax.cpp.

◆ exampleQueries()

QStringList Plasma::RunnerSyntax::exampleQueries ( ) const
Returns
the example queries associated with this Syntax object

Definition at line 67 of file runnersyntax.cpp.

◆ exampleQueriesWithTermDescription()

QStringList Plasma::RunnerSyntax::exampleQueriesWithTermDescription ( ) const
Returns
the example queries associated with this Syntax object, with the searchTermDescription replacing instances of :q:. Used for showing the queries in the user interface.
Deprecated:
Since 5.76, the description should be directly set when creating the example query. To display the queries in the user interface. Use exampleQueries() instead.

Definition at line 73 of file runnersyntax.cpp.

◆ operator=()

RunnerSyntax & Plasma::RunnerSyntax::operator= ( const RunnerSyntax rhs)

Assignment operator.

Definition at line 54 of file runnersyntax.cpp.

◆ searchTermDescription()

QString Plasma::RunnerSyntax::searchTermDescription ( ) const
Returns
a description of the search term for this syntax
Deprecated:
Since 5.76, the description should be directly set when creating the example query.

Definition at line 111 of file runnersyntax.cpp.

◆ setDescription()

void Plasma::RunnerSyntax::setDescription ( const QString description)

Sets the description for the syntax, describing what it does from the user's point of view.

Deprecated:
Since 5.106, this should only be set when constructing the syntax

Definition at line 86 of file runnersyntax.cpp.

◆ setSearchTermDescription()

void Plasma::RunnerSyntax::setSearchTermDescription ( const QString description)

Sets the text that should be used to replace instances of :q: in the text.

By default this is the generic phrase "search term". If the syntax expects a specific kind of input, it may be defined here. A syntax used by a runner that changes the brightness of the display may set this to "brightness" for instance.

Deprecated:
Since 5.76, set the description directly when creating the example query. Use <my query description> instead of :q: when creating the string

Definition at line 104 of file runnersyntax.cpp.


The documentation for this class was generated from the following files:
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Oct 3 2023 03:48:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.