Changeset View
Changeset View
Standalone View
Standalone View
applets/icon/iconapplet.cpp
Show All 36 Lines | |||||
37 | #include <KAuthorized> | 37 | #include <KAuthorized> | ||
38 | #include <KDesktopFile> | 38 | #include <KDesktopFile> | ||
39 | #include <KFileItemActions> | 39 | #include <KFileItemActions> | ||
40 | #include <KFileItemListProperties> | 40 | #include <KFileItemListProperties> | ||
41 | #include <KJobWidgets> | 41 | #include <KJobWidgets> | ||
42 | #include <KLocalizedString> | 42 | #include <KLocalizedString> | ||
43 | #include <KProtocolManager> | 43 | #include <KProtocolManager> | ||
44 | #include <KRun> | 44 | #include <KRun> | ||
45 | #include <KStartupInfo> | | |||
46 | 45 | | |||
47 | #include <KIO/DropJob> | 46 | #include <KIO/DropJob> | ||
48 | #include <KIO/FavIconRequestJob> | 47 | #include <KIO/FavIconRequestJob> | ||
49 | #include <KIO/OpenFileManagerWindowJob> | 48 | #include <KIO/OpenFileManagerWindowJob> | ||
50 | #include <KIO/StatJob> | 49 | #include <KIO/StatJob> | ||
51 | 50 | | |||
51 | #include <startuptasksmodel.h> | ||||
52 | | ||||
52 | IconApplet::IconApplet(QObject *parent, const QVariantList &data) | 53 | IconApplet::IconApplet(QObject *parent, const QVariantList &data) | ||
53 | : Plasma::Applet(parent, data) | 54 | : Plasma::Applet(parent, data) | ||
54 | { | 55 | { | ||
55 | 56 | | |||
56 | } | 57 | } | ||
57 | 58 | | |||
58 | IconApplet::~IconApplet() | 59 | IconApplet::~IconApplet() | ||
59 | { | 60 | { | ||
▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Line(s) | 389 | if (m_openContainingFolderAction) { | |||
389 | actions << m_openContainingFolderAction; | 390 | actions << m_openContainingFolderAction; | ||
390 | } | 391 | } | ||
391 | 392 | | |||
392 | return actions; | 393 | return actions; | ||
393 | } | 394 | } | ||
394 | 395 | | |||
395 | void IconApplet::run() | 396 | void IconApplet::run() | ||
396 | { | 397 | { | ||
397 | if (!m_startupInfo) { | 398 | if (!m_startupTasksModel) { | ||
398 | m_startupInfo = new KStartupInfo(KStartupInfo::CleanOnCantDetect, this); | 399 | m_startupTasksModel = new TaskManager::StartupTasksModel(this); | ||
399 | 400 | | |||
400 | const KConfig klaunchrc("klaunchrc"); | 401 | auto handleRow = [this](bool busy, const QModelIndex &parent, int first, int last) { | ||
401 | KConfigGroup c = KConfigGroup(&klaunchrc, "TaskbarButtonSettings"); | 402 | Q_UNUSED(parent); | ||
402 | m_startupInfo->setTimeout(c.readEntry("Timeout", 5)); | 403 | for (int i = first; i <= last; ++i) { | ||
403 | 404 | const QModelIndex idx = m_startupTasksModel->index(i, 0); | |||
davidedmundson: should this be index(i, 0) ?
| |||||
broulik: Good spot, indeed | |||||
404 | connect(m_startupInfo, &KStartupInfo::gotNewStartup, this, [this](const KStartupInfoId &id, const KStartupInfoData &data) { | 405 | if (idx.data(TaskManager::AbstractTasksModel::LauncherUrlWithoutIcon).toUrl() == QUrl::fromLocalFile(m_localPath)) { | ||
405 | Q_UNUSED(id); | 406 | setBusy(busy); | ||
406 | if (data.applicationId() == m_localPath) { | 407 | break; | ||
407 | setBusy(true); | 408 | } | ||
408 | } | 409 | } | ||
409 | }); | 410 | }; | ||
410 | connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, [this](const KStartupInfoId &id, const KStartupInfoData &data) { | 411 | | ||
411 | Q_UNUSED(id); | 412 | using namespace std::placeholders; | ||
412 | if (data.applicationId() == m_localPath) { | 413 | connect(m_startupTasksModel, &QAbstractItemModel::rowsInserted, this, std::bind(handleRow, true /*busy*/, _1, _2, _3)); | ||
413 | setBusy(false); | 414 | connect(m_startupTasksModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, std::bind(handleRow, false /*busy*/, _1, _2, _3)); | ||
414 | } | | |||
415 | }); | | |||
416 | } | 415 | } | ||
417 | 416 | | |||
418 | new KRun(QUrl::fromLocalFile(m_localPath), QApplication::desktop()); | 417 | new KRun(QUrl::fromLocalFile(m_localPath), QApplication::desktop()); | ||
419 | } | 418 | } | ||
420 | 419 | | |||
421 | void IconApplet::processDrop(QObject *dropEvent) | 420 | void IconApplet::processDrop(QObject *dropEvent) | ||
422 | { | 421 | { | ||
423 | Q_ASSERT(dropEvent); | 422 | Q_ASSERT(dropEvent); | ||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |
should this be index(i, 0) ?