Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/launchertasksmodel.cpp
Show First 20 Lines • Show All 538 Lines • ▼ Show 20 Line(s) | |||||
539 | 539 | | |||
540 | void LauncherTasksModel::requestNewInstance(const QModelIndex &index) | 540 | void LauncherTasksModel::requestNewInstance(const QModelIndex &index) | ||
541 | { | 541 | { | ||
542 | if (!index.isValid() || index.model() != this | 542 | if (!index.isValid() || index.model() != this | ||
543 | || index.row() < 0 || index.row() >= d->launchersOrder.count()) { | 543 | || index.row() < 0 || index.row() >= d->launchersOrder.count()) { | ||
544 | return; | 544 | return; | ||
545 | } | 545 | } | ||
546 | 546 | | |||
547 | const QUrl &url = d->launchersOrder.at(index.row()); | 547 | runApp(d->appData(d->launchersOrder.at(index.row()))); | ||
548 | | ||||
549 | quint32 timeStamp = 0; | | |||
550 | | ||||
551 | #if HAVE_X11 | | |||
552 | if (KWindowSystem::isPlatformX11()) { | | |||
553 | timeStamp = QX11Info::appUserTime(); | | |||
554 | } | | |||
555 | #endif | | |||
556 | | ||||
557 | if (url.scheme() == QLatin1String("preferred")) { | | |||
558 | const KService::Ptr service = KService::serviceByStorageId(defaultApplication(url)); | | |||
559 | | ||||
560 | if (!service && !service->isApplication()) { | | |||
561 | return; | | |||
562 | } | | |||
563 | | ||||
564 | KRun::runApplication(*service, QList<QUrl>(), nullptr, 0, {}, | | |||
565 | KStartupInfo::createNewStartupIdForTimestamp(timeStamp)); | | |||
566 | | ||||
567 | KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + service->storageId()), | | |||
568 | QStringLiteral("org.kde.libtaskmanager")); | | |||
569 | } else { | | |||
570 | const KService::Ptr service = KService::serviceByDesktopPath(url.toLocalFile()); | | |||
571 | | ||||
572 | if (service && service->isApplication()) { | | |||
573 | KRun::runApplication(*service, QList<QUrl>(), nullptr, 0, {}, | | |||
574 | KStartupInfo::createNewStartupIdForTimestamp(timeStamp)); | | |||
575 | | ||||
576 | KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + service->storageId()), | | |||
577 | QStringLiteral("org.kde.libtaskmanager")); | | |||
578 | } else { | | |||
579 | new KRun(url, 0, false, KStartupInfo::createNewStartupIdForTimestamp(timeStamp)); | | |||
580 | } | | |||
581 | } | | |||
582 | } | 548 | } | ||
583 | 549 | | |||
584 | void LauncherTasksModel::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) | 550 | void LauncherTasksModel::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) | ||
585 | { | 551 | { | ||
586 | if (!index.isValid() || index.model() != this | 552 | if (!index.isValid() || index.model() != this | ||
587 | || index.row() < 0 || index.row() >= d->launchersOrder.count() | 553 | || index.row() < 0 || index.row() >= d->launchersOrder.count() | ||
588 | || urls.isEmpty()) { | 554 | || urls.isEmpty()) { | ||
589 | return; | 555 | return; | ||
Show All 31 Lines |