|
|
|
@ -26,52 +26,25 @@ K_EXPORT_PLASMA_RUNNER(activities, ActivityRunner) |
|
|
|
|
|
|
|
|
|
|
|
ActivityRunner::ActivityRunner(QObject *parent, const QVariantList &args) |
|
|
|
ActivityRunner::ActivityRunner(QObject *parent, const QVariantList &args) |
|
|
|
: Plasma::AbstractRunner(parent, args), |
|
|
|
: Plasma::AbstractRunner(parent, args), |
|
|
|
m_activities(nullptr), |
|
|
|
m_activities(new KActivities::Controller(this)), |
|
|
|
m_consumer(nullptr), |
|
|
|
m_consumer(new KActivities::Consumer(this)), |
|
|
|
m_keywordi18n(i18nc("KRunner keyword", "activity")), |
|
|
|
m_keywordi18n(i18nc("KRunner keyword", "activity")), |
|
|
|
m_keyword(QStringLiteral("activity")), |
|
|
|
m_keyword(QStringLiteral("activity")) |
|
|
|
m_enabled(false) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(QStringLiteral("Activities")); |
|
|
|
setObjectName(QStringLiteral("Activities")); |
|
|
|
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | |
|
|
|
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | |
|
|
|
Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::Help); |
|
|
|
Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::Help); |
|
|
|
|
|
|
|
setDefaultSyntax(Plasma::RunnerSyntax(m_keywordi18n, i18n("Lists all activities currently available to be run."))); |
|
|
|
connect(this, &Plasma::AbstractRunner::prepare, this, &ActivityRunner::prep); |
|
|
|
addSyntax(Plasma::RunnerSyntax(i18nc("KRunner keyword", "activity :q:"), i18n("Switches to activity :q:."))); |
|
|
|
connect(this, &Plasma::AbstractRunner::teardown, this, &ActivityRunner::down); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qRegisterMetaType<KActivities::Consumer::ServiceStatus>(); |
|
|
|
qRegisterMetaType<KActivities::Consumer::ServiceStatus>(); |
|
|
|
|
|
|
|
connect(m_consumer, &KActivities::Consumer::serviceStatusChanged, this, &ActivityRunner::serviceStatusChanged); |
|
|
|
serviceStatusChanged(KActivities::Consumer::Running); |
|
|
|
serviceStatusChanged(m_activities->serviceStatus()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ActivityRunner::prep() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_activities) { |
|
|
|
|
|
|
|
m_activities = new KActivities::Controller(this); |
|
|
|
|
|
|
|
m_consumer = new KActivities::Consumer(this); |
|
|
|
|
|
|
|
connect(m_consumer, &KActivities::Consumer::serviceStatusChanged, |
|
|
|
|
|
|
|
this, &ActivityRunner::serviceStatusChanged); |
|
|
|
|
|
|
|
serviceStatusChanged(m_activities->serviceStatus()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ActivityRunner::down() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ActivityRunner::serviceStatusChanged(KActivities::Consumer::ServiceStatus status) |
|
|
|
void ActivityRunner::serviceStatusChanged(KActivities::Consumer::ServiceStatus status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const bool active = status != KActivities::Consumer::NotRunning; |
|
|
|
suspendMatching(status == KActivities::Consumer::NotRunning); |
|
|
|
if (m_enabled == active) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_enabled = active; |
|
|
|
|
|
|
|
QList<Plasma::RunnerSyntax> syntaxes; |
|
|
|
|
|
|
|
if (m_enabled) { |
|
|
|
|
|
|
|
setDefaultSyntax(Plasma::RunnerSyntax(m_keywordi18n, i18n("Lists all activities currently available to be run."))); |
|
|
|
|
|
|
|
addSyntax(Plasma::RunnerSyntax(i18nc("KRunner keyword", "activity :q:"), i18n("Switches to activity :q:."))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ActivityRunner::~ActivityRunner() |
|
|
|
ActivityRunner::~ActivityRunner() |
|
|
|
@ -80,10 +53,6 @@ ActivityRunner::~ActivityRunner() |
|
|
|
|
|
|
|
|
|
|
|
void ActivityRunner::match(Plasma::RunnerContext &context) |
|
|
|
void ActivityRunner::match(Plasma::RunnerContext &context) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_enabled) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QString term = context.query().trimmed(); |
|
|
|
const QString term = context.query().trimmed(); |
|
|
|
bool list = false; |
|
|
|
bool list = false; |
|
|
|
QString name; |
|
|
|
QString name; |
|
|
|
@ -167,10 +136,6 @@ void ActivityRunner::run(const Plasma::RunnerContext &context, const Plasma::Que |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(context) |
|
|
|
Q_UNUSED(context) |
|
|
|
|
|
|
|
|
|
|
|
if (!m_enabled || !m_activities) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_activities->setCurrentActivity(match.data().toString()); |
|
|
|
m_activities->setCurrentActivity(match.data().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|