Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasktools.cpp
Show All 15 Lines | |||||
16 | 16 | | |||
17 | You should have received a copy of the GNU Lesser General Public | 17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | 20 | | |||
21 | #include "tasktools.h" | 21 | #include "tasktools.h" | ||
22 | #include "abstracttasksmodel.h" | 22 | #include "abstracttasksmodel.h" | ||
23 | 23 | | |||
24 | #include <KActivities/ResourceInstance> | ||||
24 | #include <KConfigGroup> | 25 | #include <KConfigGroup> | ||
25 | #include <KDesktopFile> | 26 | #include <KDesktopFile> | ||
26 | #include <kemailsettings.h> | 27 | #include <kemailsettings.h> | ||
27 | #include <KFileItem> | 28 | #include <KFileItem> | ||
28 | #include <KMimeTypeTrader> | 29 | #include <KMimeTypeTrader> | ||
29 | #include <KRun> | 30 | #include <KRun> | ||
30 | #include <KSharedConfig> | 31 | #include <KSharedConfig> | ||
32 | #include <KStartupInfo> | ||||
33 | #include <KWindowSystem> | ||||
34 | | ||||
35 | #include <config-X11.h> | ||||
31 | 36 | | |||
32 | #include <QDir> | 37 | #include <QDir> | ||
33 | #include <QGuiApplication> | 38 | #include <QGuiApplication> | ||
34 | #include <QScreen> | 39 | #include <QScreen> | ||
40 | #if HAVE_X11 | ||||
41 | #include <QX11Info> | ||||
42 | #endif | ||||
35 | 43 | | |||
36 | namespace TaskManager | 44 | namespace TaskManager | ||
37 | { | 45 | { | ||
38 | 46 | | |||
39 | AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) | 47 | AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) | ||
40 | { | 48 | { | ||
41 | AppData data; | 49 | AppData data; | ||
42 | data.url = url; | 50 | data.url = url; | ||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Line(s) | 312 | if (distance < shortestDistance) { | |||
305 | shortestDistance = distance; | 313 | shortestDistance = distance; | ||
306 | screenGeometry = geometry; | 314 | screenGeometry = geometry; | ||
307 | } | 315 | } | ||
308 | } | 316 | } | ||
309 | 317 | | |||
310 | return screenGeometry; | 318 | return screenGeometry; | ||
311 | } | 319 | } | ||
312 | 320 | | |||
321 | void runApp(const AppData &appData) | ||||
322 | { | ||||
323 | if (appData.url.isValid()) { | ||||
324 | quint32 timeStamp = 0; | ||||
325 | | ||||
326 | #if HAVE_X11 | ||||
327 | if (KWindowSystem::isPlatformX11()) { | ||||
328 | timeStamp = QX11Info::appUserTime(); | ||||
329 | } | ||||
330 | #endif | ||||
331 | | ||||
332 | const KService::Ptr service = KService::serviceByDesktopPath(appData.url.toLocalFile()); | ||||
333 | | ||||
334 | if (service && service->isApplication()) { | ||||
335 | KRun::runApplication(*service, QList<QUrl>(), nullptr, 0, {}, | ||||
336 | KStartupInfo::createNewStartupIdForTimestamp(timeStamp)); | ||||
337 | | ||||
338 | KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + service->storageId()), | ||||
339 | QStringLiteral("org.kde.libtaskmanager")); | ||||
340 | } else { | ||||
341 | new KRun(appData.url, 0, false, KStartupInfo::createNewStartupIdForTimestamp(timeStamp)); | ||||
342 | | ||||
343 | if (!appData.id.isEmpty()) { | ||||
344 | KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + appData.id), | ||||
345 | QStringLiteral("org.kde.libtaskmanager")); | ||||
346 | } | ||||
347 | } | ||||
348 | } | ||||
349 | } | ||||
350 | | ||||
313 | } | 351 | } |