Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/recentusagemodel.cpp
Show All 20 Lines | |||||
21 | #include "actionlist.h" | 21 | #include "actionlist.h" | ||
22 | #include "appsmodel.h" | 22 | #include "appsmodel.h" | ||
23 | #include "appentry.h" | 23 | #include "appentry.h" | ||
24 | #include "kastatsfavoritesmodel.h" | 24 | #include "kastatsfavoritesmodel.h" | ||
25 | 25 | | |||
26 | #include <config-X11.h> | 26 | #include <config-X11.h> | ||
27 | 27 | | |||
28 | #include <QIcon> | 28 | #include <QIcon> | ||
29 | #include <QMimeDatabase> | ||||
29 | #include <QQmlEngine> | 30 | #include <QQmlEngine> | ||
31 | #include <QTimer> | ||||
30 | #if HAVE_X11 | 32 | #if HAVE_X11 | ||
31 | #include <QX11Info> | 33 | #include <QX11Info> | ||
32 | #endif | 34 | #endif | ||
33 | 35 | | |||
34 | #include <KActivities/ResourceInstance> | 36 | #include <KActivities/ResourceInstance> | ||
35 | #include <KFileItem> | 37 | #include <KFileItem> | ||
36 | #include <KLocalizedString> | 38 | #include <KLocalizedString> | ||
39 | #include <KMimeTypeTrader> | ||||
37 | #include <KRun> | 40 | #include <KRun> | ||
38 | #include <KService> | 41 | #include <KService> | ||
39 | #include <KStartupInfo> | 42 | #include <KStartupInfo> | ||
40 | 43 | | |||
41 | #include <KActivities/Stats/Cleaning> | 44 | #include <KActivities/Stats/Cleaning> | ||
42 | #include <KActivities/Stats/ResultModel> | 45 | #include <KActivities/Stats/ResultModel> | ||
43 | #include <KActivities/Stats/Terms> | 46 | #include <KActivities/Stats/Terms> | ||
44 | 47 | | |||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Line(s) | 277 | { | |||
275 | Q_UNUSED(argument) | 278 | Q_UNUSED(argument) | ||
276 | 279 | | |||
277 | bool withinBounds = row >= 0 && row < rowCount(); | 280 | bool withinBounds = row >= 0 && row < rowCount(); | ||
278 | 281 | | |||
279 | if (actionId.isEmpty() && withinBounds) { | 282 | if (actionId.isEmpty() && withinBounds) { | ||
280 | const QString &resource = resourceAt(row); | 283 | const QString &resource = resourceAt(row); | ||
281 | 284 | | |||
282 | if (!resource.startsWith(QLatin1String("applications:"))) { | 285 | if (!resource.startsWith(QLatin1String("applications:"))) { | ||
283 | new KRun(docData(resource, Kicker::UrlRole).toUrl(), 0); | 286 | const QUrl resourceUrl = docData(resource, Kicker::UrlRole).toUrl(); | ||
287 | const QList<QUrl> urlsList{resourceUrl}; | ||||
288 | | ||||
anthonyfieroniUnsubmitted Done anthonyfieroni: ```
const QList<QUrl> urlsList{ resourceUrl };
``` | |||||
289 | QMimeDatabase db; | ||||
290 | QMimeType mime = db.mimeTypeForUrl(resourceUrl); | ||||
291 | KService::Ptr service = KMimeTypeTrader::self()->preferredService(mime.name()); | ||||
292 | if (service) { | ||||
293 | KRun::runApplication(*service, urlsList, nullptr); | ||||
294 | } else { | ||||
anthonyfieroni: ```
if (service) {
``` | |||||
295 | QTimer::singleShot(0, [urlsList] { | ||||
296 | KRun::displayOpenWithDialog(urlsList, nullptr); | ||||
297 | }); | ||||
298 | } | ||||
299 | | ||||
anthonyfieroni: const | |||||
284 | return true; | 300 | return true; | ||
285 | } | 301 | } | ||
286 | 302 | | |||
287 | const QString storageId = resource.section(':', 1); | 303 | const QString storageId = resource.section(':', 1); | ||
288 | KService::Ptr service = KService::serviceByStorageId(storageId); | 304 | KService::Ptr service = KService::serviceByStorageId(storageId); | ||
289 | 305 | | |||
290 | if (!service) { | 306 | if (!service) { | ||
291 | return false; | 307 | return false; | ||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |