Changeset View
Changeset View
Standalone View
Standalone View
app/plasma/runner/kdevelopsessions.cpp
| Show All 19 Lines | |||||
| 20 | #include "kdevelopsessions.h" | 20 | #include "kdevelopsessions.h" | ||
| 21 | 21 | | |||
| 22 | #include <QCollator> | 22 | #include <QCollator> | ||
| 23 | #include <QDir> | 23 | #include <QDir> | ||
| 24 | #include <KLocalizedString> | 24 | #include <KLocalizedString> | ||
| 25 | 25 | | |||
| 26 | 26 | | |||
| 27 | #include <QDebug> | 27 | #include <QDebug> | ||
| 28 | #include <QIcon> | | |||
| 29 | #include <QFile> | 28 | #include <QFile> | ||
| 30 | #include <KDirWatch> | 29 | #include <KDirWatch> | ||
| 31 | #include <KToolInvocation> | 30 | #include <KToolInvocation> | ||
| 32 | #include <KConfig> | 31 | #include <KConfig> | ||
| 33 | #include <KConfigGroup> | 32 | #include <KConfigGroup> | ||
| 34 | #include <QStandardPaths> | 33 | #include <QStandardPaths> | ||
| 35 | 34 | | |||
| 36 | K_EXPORT_PLASMA_RUNNER(kdevelopsessions, KDevelopSessions) | 35 | K_EXPORT_PLASMA_RUNNER(kdevelopsessions, KDevelopSessions) | ||
| 37 | 36 | | |||
| 38 | bool kdevelopsessions_runner_compare_sessions(const Session &s1, const Session &s2) | 37 | bool kdevelopsessions_runner_compare_sessions(const Session &s1, const Session &s2) | ||
| 39 | { | 38 | { | ||
| 40 | QCollator c; | 39 | QCollator c; | ||
| 41 | return c.compare(s1.name, s2.name) < 0; | 40 | return c.compare(s1.name, s2.name) < 0; | ||
| 42 | } | 41 | } | ||
| 43 | 42 | | |||
| 44 | KDevelopSessions::KDevelopSessions(QObject *parent, const QVariantList& args) | 43 | KDevelopSessions::KDevelopSessions(QObject *parent, const QVariantList& args) | ||
| 45 | : Plasma::AbstractRunner(parent, args) | 44 | : Plasma::AbstractRunner(parent, args) | ||
| 46 | { | 45 | { | ||
| 47 | setObjectName(QStringLiteral("KDevelop Sessions")); | 46 | setObjectName(QStringLiteral("KDevelop Sessions")); | ||
| 48 | setIgnoredTypes(Plasma::RunnerContext::File | Plasma::RunnerContext::Directory | Plasma::RunnerContext::NetworkLocation); | 47 | setIgnoredTypes(Plasma::RunnerContext::File | Plasma::RunnerContext::Directory | Plasma::RunnerContext::NetworkLocation); | ||
| 49 | m_icon = QIcon::fromTheme(QStringLiteral("kdevelop")); | | |||
| 50 | 48 | | |||
| 51 | loadSessions(); | 49 | loadSessions(); | ||
| 52 | 50 | | |||
| 53 | // listen for changes to the list of kdevelop sessions | 51 | // listen for changes to the list of kdevelop sessions | ||
| 54 | auto *historyWatch = new KDirWatch(this); | 52 | auto *historyWatch = new KDirWatch(this); | ||
| 55 | const QStringList sessiondirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | 53 | const QStringList sessiondirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | ||
| 56 | QStringLiteral("kdevelop/sessions"), QStandardPaths::LocateDirectory); | 54 | QStringLiteral("kdevelop/sessions"), QStandardPaths::LocateDirectory); | ||
| 57 | for (const QString& dir : sessiondirs) { | 55 | for (const QString& dir : sessiondirs) { | ||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 149 | if (session.name.compare(term, Qt::CaseInsensitive) == 0) { | |||
| 153 | match.setType(Plasma::QueryMatch::ExactMatch); | 151 | match.setType(Plasma::QueryMatch::ExactMatch); | ||
| 154 | match.setRelevance(1.0); | 152 | match.setRelevance(1.0); | ||
| 155 | } else { | 153 | } else { | ||
| 156 | // fuzzy match of the session in "kdevelop $session" | 154 | // fuzzy match of the session in "kdevelop $session" | ||
| 157 | match.setType(Plasma::QueryMatch::PossibleMatch); | 155 | match.setType(Plasma::QueryMatch::PossibleMatch); | ||
| 158 | match.setRelevance(0.8); | 156 | match.setRelevance(0.8); | ||
| 159 | } | 157 | } | ||
| 160 | } | 158 | } | ||
| 161 | match.setIcon(m_icon); | 159 | match.setIconName(QStringLiteral("kdevelop")); | ||
| 162 | match.setData(session.id); | 160 | match.setData(session.id); | ||
| 163 | match.setText(session.name); | 161 | match.setText(session.name); | ||
| 164 | match.setSubtext(i18n("Open KDevelop Session")); | 162 | match.setSubtext(i18n("Open KDevelop Session")); | ||
| 165 | context.addMatch(match); | 163 | context.addMatch(match); | ||
| 166 | } | 164 | } | ||
| 167 | } | 165 | } | ||
| 168 | } | 166 | } | ||
| 169 | 167 | | |||
| Show All 14 Lines | |||||