Commit 4c211cbf authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Icon Applet] Use libTaskManager for startup feedback

Makes it future-proof for Wayland (and Eike happy)

Differential Revision: https://phabricator.kde.org/D18727
parent a5ea555f
......@@ -13,8 +13,8 @@ target_link_libraries(plasma_applet_icon
KF5::KIOCore # for OpenFileManagerWindowJob
KF5::KIOGui # for FavIconRequestJob
KF5::KIOWidgets # for KRun
KF5::WindowSystem # for KStartupInfo
KF5::Plasma)
KF5::Plasma
PW::LibTaskManager)
install(TARGETS plasma_applet_icon DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)
......
......@@ -42,13 +42,14 @@
#include <KLocalizedString>
#include <KProtocolManager>
#include <KRun>
#include <KStartupInfo>
#include <KIO/DropJob>
#include <KIO/FavIconRequestJob>
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/StatJob>
#include <startuptasksmodel.h>
IconApplet::IconApplet(QObject *parent, const QVariantList &data)
: Plasma::Applet(parent, data)
{
......@@ -394,25 +395,23 @@ QList<QAction *> IconApplet::contextualActions()
void IconApplet::run()
{
if (!m_startupInfo) {
m_startupInfo = new KStartupInfo(KStartupInfo::CleanOnCantDetect, this);
const KConfig klaunchrc("klaunchrc");
KConfigGroup c = KConfigGroup(&klaunchrc, "TaskbarButtonSettings");
m_startupInfo->setTimeout(c.readEntry("Timeout", 5));
connect(m_startupInfo, &KStartupInfo::gotNewStartup, this, [this](const KStartupInfoId &id, const KStartupInfoData &data) {
Q_UNUSED(id);
if (data.applicationId() == m_localPath) {
setBusy(true);
}
});
connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, [this](const KStartupInfoId &id, const KStartupInfoData &data) {
Q_UNUSED(id);
if (data.applicationId() == m_localPath) {
setBusy(false);
if (!m_startupTasksModel) {
m_startupTasksModel = new TaskManager::StartupTasksModel(this);
auto handleRow = [this](bool busy, const QModelIndex &parent, int first, int last) {
Q_UNUSED(parent);
for (int i = first; i <= last; ++i) {
const QModelIndex idx = m_startupTasksModel->index(i, 0);
if (idx.data(TaskManager::AbstractTasksModel::LauncherUrlWithoutIcon).toUrl() == QUrl::fromLocalFile(m_localPath)) {
setBusy(busy);
break;
}
}
});
};
using namespace std::placeholders;
connect(m_startupTasksModel, &QAbstractItemModel::rowsInserted, this, std::bind(handleRow, true /*busy*/, _1, _2, _3));
connect(m_startupTasksModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, std::bind(handleRow, false /*busy*/, _1, _2, _3));
}
new KRun(QUrl::fromLocalFile(m_localPath), QApplication::desktop());
......
......@@ -32,6 +32,11 @@ class KStartupInfo;
class QMenu;
namespace TaskManager
{
class StartupTasksModel;
}
class IconApplet : public Plasma::Applet
{
Q_OBJECT
......@@ -102,6 +107,6 @@ private:
QPointer<KPropertiesDialog> m_configDialog;
KStartupInfo *m_startupInfo = nullptr;
TaskManager::StartupTasksModel *m_startupTasksModel = nullptr;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment