2 * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
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 version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "shellrunner.h"
23 #include <QPushButton>
25 #include <KAuthorized>
30 #include <KStandardDirs>
31 #include <KToolInvocation>
33 ShellRunner::ShellRunner(QObject
*parent
, const QVariantList
&args
)
34 : Plasma::AbstractRunner(parent
, args
),
38 KGlobal::locale()->insertCatalog("krunner_shellrunner");
40 setObjectName("Command");
41 setPriority(AbstractRunner::HighestPriority
);
42 m_enabled
= KAuthorized::authorizeKAction("shell_access");
43 setIgnoredTypes(Plasma::RunnerContext::Directory
| Plasma::RunnerContext::File
|
44 Plasma::RunnerContext::NetworkLocation
| Plasma::RunnerContext::UnknownType
|
45 Plasma::RunnerContext::Help
);
49 ShellRunner::~ShellRunner()
53 void ShellRunner::reloadConfig()
58 void ShellRunner::match(Plasma::RunnerContext
&context
)
64 if (context
.type() == Plasma::RunnerContext::Executable
||
65 context
.type() == Plasma::RunnerContext::ShellCommand
) {
66 const QString term
= context
.query();
67 Plasma::QueryMatch
match(this);
68 match
.setType(Plasma::QueryMatch::ExactMatch
);
69 match
.setIcon(KIcon("system-run"));
70 match
.setText(i18n("Run %1", term
));
71 match
.setRelevance(0.7);
72 context
.addMatch(term
, match
);
76 void ShellRunner::run(const Plasma::RunnerContext
&context
, const Plasma::QueryMatch
&match
)
78 QMutexLocker
lock(bigLock());
85 KToolInvocation::invokeTerminal(context
.query());
87 // reset for the next run!
90 KRun::runCommand(context
.query(), NULL
);
94 #include "shellrunner.moc"