• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • plasma
  • scripting
runnerscript.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2007 by Aaron Seigo <aseigo@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include "plasma/scripting/runnerscript.h"
21
22#include "plasma/abstractrunner.h"
23#include "plasma/dataenginemanager.h"
24#include "plasma/package.h"
25#include "plasma/private/abstractrunner_p.h"
26
27namespace Plasma
28{
29
30class RunnerScriptPrivate
31{
32public:
33 AbstractRunner *runner;
34};
35
36RunnerScript::RunnerScript(QObject *parent)
37 : ScriptEngine(parent),
38 d(new RunnerScriptPrivate)
39{
40}
41
42RunnerScript::~RunnerScript()
43{
44 delete d;
45}
46
47void RunnerScript::setRunner(AbstractRunner *runner)
48{
49 d->runner = runner;
50 connect(runner, SIGNAL(prepare()), this, SIGNAL(prepare()));
51 connect(runner, SIGNAL(teardown()), this, SIGNAL(teardown()));
52}
53
54AbstractRunner *RunnerScript::runner() const
55{
56 return d->runner;
57}
58
59void RunnerScript::match(Plasma::RunnerContext &search)
60{
61 Q_UNUSED(search);
62}
63
64void RunnerScript::run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action)
65{
66 Q_UNUSED(search);
67 Q_UNUSED(action);
68}
69
70DataEngine *RunnerScript::dataEngine(const QString &name)
71{
72 if (d->runner) {
73 return d->runner->dataEngine(name);
74 }
75
76 return DataEngineManager::self()->engine(QString());
77}
78
79KConfigGroup RunnerScript::config() const
80{
81 if (d->runner) {
82 return d->runner->config();
83 }
84 return KConfigGroup();
85}
86
87void RunnerScript::setIgnoredTypes(RunnerContext::Types types)
88{
89 if (d->runner) {
90 d->runner->setIgnoredTypes(types);
91 }
92}
93
94void RunnerScript::setHasRunOptions(bool hasRunOptions)
95{
96 if (d->runner) {
97 d->runner->setHasRunOptions(hasRunOptions);
98 }
99}
100
101void RunnerScript::setSpeed(AbstractRunner::Speed newSpeed)
102{
103 if (d->runner) {
104 d->runner->setSpeed(newSpeed);
105 }
106}
107
108void RunnerScript::setPriority(AbstractRunner::Priority newPriority)
109{
110 if (d->runner) {
111 d->runner->setPriority(newPriority);
112 }
113}
114
115KService::List RunnerScript::serviceQuery(const QString &serviceType,
116 const QString &constraint) const
117{
118 if (d->runner) {
119 return d->runner->serviceQuery(serviceType, constraint);
120 }
121 return KService::List();
122}
123
124QAction* RunnerScript::addAction(const QString &id, const QIcon &icon, const QString &text)
125{
126 if (d->runner) {
127 return d->runner->addAction(id, icon, text);
128 }
129 return 0;
130}
131
132void RunnerScript::addAction(const QString &id, QAction *action)
133{
134 if (d->runner) {
135 d->runner->addAction(id, action);
136 }
137}
138
139void RunnerScript::removeAction(const QString &id)
140{
141 if (d->runner) {
142 d->runner->removeAction(id);
143 }
144}
145
146QAction* RunnerScript::action(const QString &id) const
147{
148 if (d->runner) {
149 return d->runner->action(id);
150 }
151 return 0;
152}
153
154QHash<QString, QAction*> RunnerScript::actions() const
155{
156 if (d->runner) {
157 return d->runner->actions();
158 }
159 return QHash<QString, QAction*>();
160}
161
162void RunnerScript::clearActions()
163{
164 if (d->runner) {
165 d->runner->clearActions();
166 }
167}
168
169void RunnerScript::addSyntax(const RunnerSyntax &syntax)
170{
171 if (d->runner) {
172 d->runner->addSyntax(syntax);
173 }
174}
175
176void RunnerScript::setSyntaxes(const QList<RunnerSyntax> &syns)
177{
178 if (d->runner) {
179 d->runner->setSyntaxes(syns);
180 }
181}
182
183const Package *RunnerScript::package() const
184{
185 return d->runner ? d->runner->package() : 0;
186}
187
188KPluginInfo RunnerScript::description() const
189{
190 return d->runner ? d->runner->d->runnerDescription : KPluginInfo();
191}
192
193QString RunnerScript::mainScript() const
194{
195 if (!package()) {
196 return QString();
197 } else {
198 return package()->filePath("mainscript");
199 }
200}
201
202} // Plasma namespace
203
204#include "runnerscript.moc"
abstractrunner.h
Plasma::AbstractRunner
An abstract base class for Plasma Runner plugins.
Definition: abstractrunner.h:64
Plasma::AbstractRunner::Speed
Speed
Specifies a nominal speed for the runner.
Definition: abstractrunner.h:73
Plasma::AbstractRunner::Priority
Priority
Specifies a priority for the runner.
Definition: abstractrunner.h:79
Plasma::DataEngineManager::self
static DataEngineManager * self()
Singleton pattern accessor.
Definition: dataenginemanager.cpp:90
Plasma::DataEngineManager::engine
Plasma::DataEngine * engine(const QString &name) const
Returns a data engine object if one is loaded and available.
Definition: dataenginemanager.cpp:106
Plasma::DataEngine
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:59
Plasma::Package
object representing an installed Plasmagik package
Definition: package.h:43
Plasma::Package::filePath
QString filePath(const char *fileType, const QString &filename) const
Get the path to a given file.
Definition: package.cpp:213
Plasma::QueryMatch
A match returned by an AbstractRunner in response to a given RunnerContext.
Definition: querymatch.h:48
Plasma::RunnerContext
The RunnerContext class provides information related to a search, including the search term,...
Definition: runnercontext.h:47
Plasma::RunnerScript::teardown
void teardown()
Plasma::RunnerScript::runner
AbstractRunner * runner() const
Returns the Plasma::AbstractRunner associated with this script component.
Definition: runnerscript.cpp:54
Plasma::RunnerScript::prepare
void prepare()
Plasma::RunnerScript::package
const Package * package() const
Definition: runnerscript.cpp:183
Plasma::RunnerScript::action
QAction * action(const QString &id) const
Definition: runnerscript.cpp:146
Plasma::RunnerSyntax
Definition: runnersyntax.h:41
Plasma::ScriptEngine
The base class for scripting interfaces to be used in loading plasmoids of a given language.
Definition: scriptengine.h:66
QObject
dataenginemanager.h
Plasma
Namespace for everything in libplasma.
Definition: abstractdialogmanager.cpp:25
package.h
runnerscript.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal