File indexing completed on 2024-05-12 05:38:20
0001 /* 0002 SPDX-FileCopyrightText: 2006 Aaron Seigo <aseigo@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #pragma once 0008 0009 #include <KRunner/AbstractRunner> 0010 #include <KService> 0011 0012 #include <PlasmaActivities/Consumer> 0013 #include <PlasmaActivities/Stats/ResultWatcher> 0014 #include <QMap> 0015 0016 using namespace KActivities::Stats; 0017 0018 /** 0019 * This class looks for matches in the set of .desktop files installed by 0020 * applications. This way the user can type exactly what they see in the 0021 * applications menu and have it start the appropriate app. Essentially anything 0022 * that KService knows about, this runner can launch 0023 */ 0024 0025 class ServiceRunner : public KRunner::AbstractRunner 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 ServiceRunner(QObject *parent, const KPluginMetaData &metaData); 0031 0032 void match(KRunner::RunnerContext &context) override; 0033 void run(const KRunner::RunnerContext &context, const KRunner::QueryMatch &match) override; 0034 void init() override; 0035 0036 struct ActivityFavourite { 0037 QStringList linkedActivities; 0038 bool isGlobal; 0039 }; 0040 QMap<QString, ActivityFavourite> m_favourites; 0041 0042 protected: 0043 void setupMatch(const KService::Ptr &service, KRunner::QueryMatch &action); 0044 0045 private: 0046 void processActivitiesResults(const ResultSet &results); 0047 const Query m_kactivitiesQuery; 0048 const ResultWatcher m_kactivitiesWatcher; 0049 const KActivities::Consumer m_activitiesConsuer; 0050 QList<KService::Ptr> m_services; 0051 bool m_matching = false; 0052 };