Commit 48d80c96 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Remove activities runner

The plugin will be ported to DBus and live in
the kactivitymanagerd process.
parent 941d66f8
add_subdirectory(activities)
if(KF5Baloo_FOUND)
add_subdirectory(baloo)
endif()
......
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_activities\")
set(krunner_activities_SRCS
activityrunner.cpp
)
add_library(krunner_activities MODULE ${krunner_activities_SRCS})
kcoreaddons_desktop_to_json(krunner_activities plasma-runner-activityrunner.desktop )
target_link_libraries(krunner_activities KF5::Runner KF5::I18n KF5::Activities)
install(TARGETS krunner_activities DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner")
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/plasma_runner_activities.pot
rm -f rc.cpp
/*
* Copyright (C) 2011 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "activityrunner.h"
#include <QDebug>
#include <QIcon>
#include <klocalizedstring.h>
K_EXPORT_PLASMA_RUNNER_WITH_JSON(ActivityRunner, "plasma-runner-activityrunner.json")
ActivityRunner::ActivityRunner(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
: Plasma::AbstractRunner(parent, metaData, args)
, m_activities(new KActivities::Controller(this))
, m_consumer(new KActivities::Consumer(this))
, m_keywordi18n(i18nc("KRunner keyword", "activity"))
, m_keyword(QStringLiteral("activity"))
{
setObjectName(QStringLiteral("Activities"));
addSyntax(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:.")));
qRegisterMetaType<KActivities::Consumer::ServiceStatus>();
connect(m_consumer, &KActivities::Consumer::serviceStatusChanged, this, &ActivityRunner::serviceStatusChanged);
serviceStatusChanged(m_activities->serviceStatus());
setTriggerWords({m_keyword, m_keywordi18n});
}
void ActivityRunner::serviceStatusChanged(KActivities::Consumer::ServiceStatus status)
{
suspendMatching(status == KActivities::Consumer::NotRunning);
}
ActivityRunner::~ActivityRunner()
{
}
void ActivityRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query().trimmed();
bool list = false;
QString name;
if (term.startsWith(m_keywordi18n, Qt::CaseInsensitive)) {
if (term.size() == m_keywordi18n.size()) {
list = true;
} else {
name = term.right(term.size() - m_keywordi18n.size()).trimmed();
list = name.isEmpty();
}
} else if (term.startsWith(m_keyword, Qt::CaseInsensitive)) {
if (term.size() == m_keyword.size()) {
list = true;
} else {
name = term.right(term.size() - m_keyword.size()).trimmed();
list = name.isEmpty();
}
} else if (context.singleRunnerQueryMode()) {
name = term;
} else {
return;
}
QList<Plasma::QueryMatch> matches;
QStringList activities = m_consumer->activities();
std::sort(activities.begin(), activities.end());
const QString current = m_activities->currentActivity();
if (!context.isValid()) {
return;
}
if (list) {
for (const QString &activity : qAsConst(activities)) {
if (current == activity) {
continue;
}
KActivities::Info info(activity);
addMatch(info, matches);
if (!context.isValid()) {
return;
}
}
} else {
for (const QString &activity : qAsConst(activities)) {
if (current == activity) {
continue;
}
KActivities::Info info(activity);
if (info.name().startsWith(name, Qt::CaseInsensitive)) {
addMatch(info, matches);
}
if (!context.isValid()) {
return;
}
}
}
context.addMatches(matches);
}
void ActivityRunner::addMatch(const KActivities::Info &activity, QList<Plasma::QueryMatch> &matches)
{
Plasma::QueryMatch match(this);
match.setData(activity.id());
match.setType(Plasma::QueryMatch::ExactMatch);
match.setIconName(activity.icon().isEmpty() ? QStringLiteral("activities") : activity.icon());
match.setText(i18n("Switch to \"%1\"", activity.name()));
match.setRelevance(0.7 + ((activity.state() == KActivities::Info::Running || activity.state() == KActivities::Info::Starting) ? 0.1 : 0));
matches << match;
}
void ActivityRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
Q_UNUSED(context)
m_activities->setCurrentActivity(match.data().toString());
}
#include "activityrunner.moc"
/*
* Copyright (C) 2011 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef ACTIVITYRUNNER_H
#define ACTIVITYRUNNER_H
#include <krunner/abstractrunner.h>
#include <KActivities/Controller>
Q_DECLARE_METATYPE(KActivities::Consumer::ServiceStatus)
class ActivityRunner : public Plasma::AbstractRunner
{
Q_OBJECT
public:
ActivityRunner(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
~ActivityRunner() override;
void match(Plasma::RunnerContext &context) override;
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action) override;
private Q_SLOTS:
void serviceStatusChanged(KActivities::Consumer::ServiceStatus status);
private:
void addMatch(const KActivities::Info &activity, QList<Plasma::QueryMatch> &matches);
KActivities::Controller *m_activities;
KActivities::Consumer *m_consumer;
const QString m_keywordi18n;
const QString m_keyword;
};
#endif
[Desktop Entry]
Name=Activities
Name[ar]=الأنشطة
Name[ast]=Actividaes
Name[az]=İş Otaqları
Name[bg]=Дейности
Name[bs]=Motor aktivnosti
Name[ca]=Activitats
Name[ca@valencia]=Activitats
Name[cs]=Aktivity
Name[da]=Aktiviteter
Name[de]=Aktivitäten
Name[el]=Δραστηριότητες
Name[en_GB]=Activities
Name[es]=Actividades
Name[et]=Tegevused
Name[eu]=Jarduerak
Name[fa]=فعالیتها
Name[fi]=Aktiviteetit
Name[fr]=Activités
Name[ga]=Gníomhaíochtaí
Name[gl]=Actividades
Name[he]=פעילויות
Name[hr]=Aktivnosti
Name[hu]=Aktivitások
Name[ia]=Activitates
Name[id]=Activities
Name[is]=Virknistjóri
Name[it]=Attività
Name[ja]=アクティビティ
Name[kk]=Белсенділіктер
Name[km]=សកម្មភាព
Name[ko]=활동
Name[lt]=Veiklos
Name[lv]=Aktivitātes
Name[mr]=कार्यपध्दती
Name[nb]=Aktiviteter
Name[nds]=Aktiviteten
Name[nl]=Activiteiten
Name[nn]=Aktivitetar
Name[pa]=ਸਰਗਰਮੀਆਂ
Name[pl]=Aktywności
Name[pt]=Actividades
Name[pt_BR]=Atividades
Name[ro]=Activități
Name[ru]=Комнаты
Name[sk]=Aktivity
Name[sl]=Dejavnosti
Name[sr]=активности
Name[sr@ijekavian]=активности
Name[sr@ijekavianlatin]=aktivnosti
Name[sr@latin]=aktivnosti
Name[sv]=Aktiviteter
Name[tg]=Фаъолиятҳо
Name[tr]=Etkinlikler
Name[ug]=پائالىيەتلەر
Name[uk]=Простори дій
Name[vi]=Hoạt động
Name[wa]=Activités
Name[x-test]=xxActivitiesxx
Name[zh_CN]=活动
Name[zh_TW]=活動
Comment=List and switch between desktop activities
Comment[ar]=اسرد أنشطة سطح المكتب وبدّل بينها
Comment[az]=İş Masasına aid İş Otaqlarının siyahısı və onlar arasında keçid
Comment[bg]=Списък и превключване между дейностите
Comment[bs]=Prikaz i prebacivanje između aktivnosti radne površine
Comment[ca]=Llista i commuta entre les activitats d'escriptori
Comment[ca@valencia]=Llista i commuta entre activitats d'escriptori
Comment[cs]=Zobrazení a přepínač aktivit pracovní plochy
Comment[da]=Vis og skift mellem skrivebordsaktiviteter
Comment[de]=Aktivitäten anzeigen und zwischen ihnen umschalten
Comment[el]=Εμφάνιση και εναλλαγή μεταξύ των δραστηριοτήτων της επιφάνειας εργασίας
Comment[en_GB]=List and switch between desktop activities
Comment[es]=Ver y cambiar entre las actividades de escritorio
Comment[et]=Töölauategevuste näitamine ja nende vahel lülitamine
Comment[eu]=Zerrendatu mahaigaineko jarduerak eta batetik bestera aldatu
Comment[fi]=Luettele aktiviteetit ja vaihda niiden välillä
Comment[fr]=Affiche les activités du bureau et permet d'en changer
Comment[gl]=Lista e cambia entre actividades o escritorio
Comment[he]=הצגה והחלפה בין פעילויות שולחן עבודה
Comment[hr]=Izlistaj i prebacuj između aktivnosti radne površine
Comment[hu]=Asztali aktivitások listázása és váltás közöttük
Comment[ia]=Lista e commuta inter activitates de scriptorio
Comment[id]=Daftar dan beralih antara aktivitas desktop
Comment[is]=Telur upp og skiptir milli skjáborðsvirkni
Comment[it]=Elenca e passa tra le attività del desktop
Comment[ja]=デスクトップアクティビティを一覧表示して切り替える
Comment[kk]=Белсенділіктерді тізімдеу және ауыстыру
Comment[km]=មើល ហើយ​ប្ដូរ​ប្លង់​ផ្ទៃតុ​សកម្ម​
Comment[ko]=데스크톱 활동을 보거나 바꾸기
Comment[lt]=Išvardyti ir perjungti tarp darbalaukio veiklų
Comment[lv]=Parādīt un pārslēgties starp virtuālajām darbvirsmām
Comment[mr]=वेगळ्या डेस्कटॉप कार्यपध्दतीवर जाण्यासाठी यादी दर्शवा व बदला
Comment[nb]=Vis og bytt mellom skrivebordsaktiviteter
Comment[nds]=Aktiv Schriefdischakschonen ankieken un wesseln
Comment[nl]=Bureaubladactiviteiten laten zien en er tussen schakelen
Comment[nn]=Vis og byt mellom skrivebordsaktiviteter
Comment[pa]=ਡੈਸਕਟਾਪ ਸਰਗਰਮੀਆਂ ਵੇਖੋ ਅਤੇ ਉਹਨਾਂ ਵਿੱਚ ਜਾਓ
Comment[pl]=Wypisuje aktywności pulpitu oraz przełącza pomiędzy nimi
Comment[pt]=Ver e mudar de actividades no ambiente de trabalho
Comment[pt_BR]=Lista e alterna entre as atividades da área de trabalho
Comment[ro]=Vizualizează și schimbă între activitățile biroului
Comment[ru]=Просмотр и переключение между комнатами
Comment[sk]=Vypísať a prepínať medzi aktivitami pracovnej plochy
Comment[sl]=Oglejte si namizne dejavnosti in preklopite med njimi
Comment[sr]=Приказ и пребацивање између активности површи
Comment[sr@ijekavian]=Приказ и пребацивање између активности површи
Comment[sr@ijekavianlatin]=Prikaz i prebacivanje između aktivnosti površi
Comment[sr@latin]=Prikaz i prebacivanje između aktivnosti površi
Comment[sv]=Visa och byt mellan skrivbordsaktiviteter
Comment[tr]=Listele ve masaüstü eylemleri arasında değiştir
Comment[ug]=ئۈستەلئۈستى پائالىيەتلىرى ئارىسىدىكى تىزىم ۋە ئالماشتۇرۇش
Comment[uk]=Перегляд і перемикання між просторами дій стільниці
Comment[vi]=Liệt kê và chuyển giữa các Hoạt động ở bàn làm việc
Comment[wa]=Fé l' djivêye eyet passer d' ene activité do scribanne a ene ôte
Comment[x-test]=xxList and switch between desktop activitiesxx
Comment[zh_CN]=显示和切换桌面活动
Comment[zh_TW]=列出並在桌面活動間切換
X-KDE-ServiceTypes=Plasma/Runner
Type=Service
Icon=preferences-desktop-activities
X-KDE-PluginInfo-Author=Plasma Team
X-KDE-PluginInfo-Email=plasma-devel@kde.org
X-KDE-PluginInfo-Name=org.kde.activities
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-AdvertiseSingleRunnerQueryMode=true
Supports Markdown
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