Commit 665836f5 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Simplify runners using new methods

parent cb8e1f7b
......@@ -284,6 +284,7 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
}
match.setData(result);
match.setId(term);
match.setActions(actions().values());
context.addMatch(match);
}
}
......@@ -343,13 +344,6 @@ void CalculatorRunner::run(const Plasma::RunnerContext &context, const Plasma::Q
}
}
QList<QAction *> CalculatorRunner::actionsForMatch(const Plasma::QueryMatch &match)
{
Q_UNUSED(match)
return actions().values();
}
QMimeData * CalculatorRunner::mimeDataForMatch(const Plasma::QueryMatch &match)
{
//qDebug();
......
......@@ -43,7 +43,6 @@ class CalculatorRunner : public Plasma::AbstractRunner
protected Q_SLOTS:
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override;
QList<QAction *> actionsForMatch(const Plasma::QueryMatch &match) override;
QMimeData * mimeDataForMatch(const Plasma::QueryMatch &match) override;
private:
......
......@@ -134,6 +134,7 @@ void KillRunner::match(Plasma::RunnerContext &context)
match.setIconName(QStringLiteral("application-exit"));
match.setData(pid);
match.setId(name);
match.setActions(m_actionList);
// Set the relevance
switch (m_sorting) {
......@@ -181,11 +182,4 @@ void KillRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMa
killAction.execute();
}
QList<QAction*> KillRunner::actionsForMatch(const Plasma::QueryMatch &match)
{
Q_UNUSED(match)
return m_actionList;
}
#include "killrunner.moc"
......@@ -45,7 +45,6 @@ public:
void match(Plasma::RunnerContext &context) override;
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override;
QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match) override;
void reloadConfiguration() override;
private Q_SLOTS:
......
......@@ -96,6 +96,9 @@ void RecentDocuments::match(Plasma::RunnerContext &context)
match.setIconName(KIO::iconNameForUrl(url));
match.setRelevance(relevance);
match.setData(QVariant(url));
if (url.isLocalFile()) {
match.setActions(actions().values());
}
match.setText(name);
QString destUrlString = KShell::tildeCollapse(url.adjusted(QUrl::RemoveFilename).path());
......@@ -120,16 +123,6 @@ void RecentDocuments::run(const Plasma::RunnerContext &context, const Plasma::Qu
run->setRunExecutables(false);
}
QList<QAction *> RecentDocuments::actionsForMatch(const Plasma::QueryMatch &match)
{
const QUrl url = match.data().toUrl();
if (url.isLocalFile()) {
return actions().values();
}
return {};
}
QMimeData * RecentDocuments::mimeDataForMatch(const Plasma::QueryMatch& match)
{
QMimeData *result = new QMimeData();
......
......@@ -35,7 +35,6 @@ class RecentDocuments : public Plasma::AbstractRunner {
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override;
private Q_SLOTS:
QList<QAction *> actionsForMatch(const Plasma::QueryMatch &match) override;
QMimeData * mimeDataForMatch(const Plasma::QueryMatch &match) override;
};
......
......@@ -71,6 +71,7 @@ void ShellRunner::match(Plasma::RunnerContext &context)
match.setText(i18n("Run %1", term));
match.setData(QVariantList({command, envs}));
match.setRelevance(0.7);
match.setActions(m_actionList);
context.addMatch(match);
}
}
......@@ -88,13 +89,6 @@ void ShellRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryM
job->start();
}
QList<QAction *> ShellRunner::actionsForMatch(const Plasma::QueryMatch &match)
{
Q_UNUSED(match)
return m_actionList;
}
bool ShellRunner::parseENVVariables(const QString &query, QStringList &envs, QString &command)
{
const static QRegularExpression envRegex = QRegularExpression(QStringLiteral("^.+=.+$"));
......
......@@ -35,7 +35,6 @@ class ShellRunner : public Plasma::AbstractRunner
void match(Plasma::RunnerContext &context) override;
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action) override;
QList<QAction *> actionsForMatch(const Plasma::QueryMatch &match) override;
private:
bool parseENVVariables(const QString &query, QStringList &envs, QString &command);
......
......@@ -95,7 +95,7 @@ void WebshortcutRunner::configurePrivateBrowsingActions()
m_privateAction = action;
const QString actionText = containsPrivate ? i18n("Search in private window") : i18n("Search in incognito window");
const QIcon icon = QIcon::fromTheme(QStringLiteral("view-private"), QIcon::fromTheme(QStringLiteral("view-hidden")));
addAction(QStringLiteral("privateSearch"), icon, actionText);
m_match.setActions({addAction(QStringLiteral("privateSearch"), icon, actionText)});
return;
}
}
......@@ -146,12 +146,6 @@ void WebshortcutRunner::match(Plasma::RunnerContext &context)
context.addMatch(m_match);
}
QList<QAction *> WebshortcutRunner::actionsForMatch(const Plasma::QueryMatch &match)
{
Q_UNUSED(match)
return actions().values();
}
void WebshortcutRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
QUrl location;
......
......@@ -30,7 +30,6 @@ class WebshortcutRunner : public Plasma::AbstractRunner
~WebshortcutRunner() override;
void match(Plasma::RunnerContext &context) override;
QList<QAction *> actionsForMatch(const Plasma::QueryMatch &match) override;
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override;
private Q_SLOTS:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment