Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/appentry.cpp
Show All 34 Lines | |||||
35 | #include <QX11Info> | 35 | #include <QX11Info> | ||
36 | #endif | 36 | #endif | ||
37 | 37 | | |||
38 | #include <KActivities/ResourceInstance> | 38 | #include <KActivities/ResourceInstance> | ||
39 | #include <KConfigGroup> | 39 | #include <KConfigGroup> | ||
40 | #include <KJob> | 40 | #include <KJob> | ||
41 | #include <KLocalizedString> | 41 | #include <KLocalizedString> | ||
42 | #include <KMimeTypeTrader> | 42 | #include <KMimeTypeTrader> | ||
43 | #include <KProtocolInfo> | ||||
43 | #include <KRun> | 44 | #include <KRun> | ||
44 | #include <KSycoca> | 45 | #include <KSycoca> | ||
45 | #include <KShell> | 46 | #include <KShell> | ||
46 | #include <KSharedConfig> | 47 | #include <KSharedConfig> | ||
47 | #include <KStartupInfo> | 48 | #include <KStartupInfo> | ||
48 | 49 | | |||
49 | #include <Plasma/Plasma> | 50 | #include <Plasma/Plasma> | ||
50 | 51 | | |||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 141 | { | |||
141 | return true; | 142 | return true; | ||
142 | } | 143 | } | ||
143 | 144 | | |||
144 | #ifdef HAVE_APPSTREAMQT | 145 | #ifdef HAVE_APPSTREAMQT | ||
145 | Q_GLOBAL_STATIC(AppStream::Pool, appstreamPool) | 146 | Q_GLOBAL_STATIC(AppStream::Pool, appstreamPool) | ||
146 | 147 | | |||
147 | QVariantList appstreamActions(const KService::Ptr &service) | 148 | QVariantList appstreamActions(const KService::Ptr &service) | ||
148 | { | 149 | { | ||
150 | QVariantList ret; | ||||
151 | | ||||
152 | const KService::Ptr appStreamHandler = KMimeTypeTrader::self()->preferredService(QStringLiteral("x-scheme-handler/appstream")); | ||||
153 | | ||||
154 | // Don't show action if we can't find any app to handle appstream:// URLs. | ||||
155 | if (!appStreamHandler) { | ||||
156 | if (!KProtocolInfo::isHelperProtocol(QStringLiteral("appstream")) | ||||
157 | || KProtocolInfo::exec(QStringLiteral("appstream")).isEmpty()) { | ||||
158 | return ret; | ||||
159 | } | ||||
160 | } | ||||
161 | | ||||
149 | if (!appstreamPool.exists()) { | 162 | if (!appstreamPool.exists()) { | ||
150 | appstreamPool->load(); | 163 | appstreamPool->load(); | ||
151 | } | 164 | } | ||
152 | 165 | | |||
153 | QVariantList ret; | | |||
154 | const auto components = appstreamPool->componentsById(service->desktopEntryName()+QLatin1String(".desktop")); | 166 | const auto components = appstreamPool->componentsById(service->desktopEntryName()+QLatin1String(".desktop")); | ||
155 | for(const auto &component: components) { | 167 | for(const auto &component: components) { | ||
156 | const QString componentId = component.id(); | 168 | const QString componentId = component.id(); | ||
157 | 169 | | |||
158 | QVariantMap appstreamAction = Kicker::createActionItem(i18nc("@action opens a software center with the application", "Manage '%1'...", component.name()), "manageApplication", QVariant(QStringLiteral("appstream://") + componentId)); | 170 | QVariantMap appstreamAction = Kicker::createActionItem(i18nc("@action opens a software center with the application", "Manage '%1'...", component.name()), "manageApplication", QVariant(QStringLiteral("appstream://") + componentId)); | ||
159 | appstreamAction[QStringLiteral("icon")] = QStringLiteral("applications-other"); | 171 | appstreamAction[QStringLiteral("icon")] = QStringLiteral("applications-other"); | ||
160 | ret << appstreamAction; | 172 | ret << appstreamAction; | ||
161 | } | 173 | } | ||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |