Commit 00962d08 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Task Manager] Use libnotificationmanager for notification badges and application job reporting

This removes the setting from the individual plasmoid and has it follow global settings in the new KCM.
Since the new JobsModel also emits application jobs via the Unity launcher API, the codepath for dealing with jobs is dropped
and instead it only listens to Unity signals now.

Differential Revision: https://phabricator.kde.org/D21061
parent be5819d0
......@@ -70,6 +70,7 @@ set_package_properties(KF5QQC2DeskopStyle PROPERTIES
)
find_package(LibKWorkspace 5.14.90 CONFIG REQUIRED)
find_package(LibNotificationManager 5.15.80 CONFIG REQUIRED)
find_package(LibTaskManager 5.14.90 CONFIG REQUIRED)
find_package(LibNotificationManager 5.14.90 CONFIG REQUIRED)
find_package(LibColorCorrect 5.14.90 CONFIG REQUIRED)
......
......@@ -29,6 +29,7 @@ target_link_libraries(taskmanagerplugin
KF5::KIOFileWidgets # KFilePlacesModel
KF5::Plasma
KF5::Service
KF5::WindowSystem)
KF5::WindowSystem
PW::LibNotificationManager)
install(TARGETS taskmanagerplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/taskmanager)
......@@ -87,10 +87,6 @@
</choices>
<default>0</default>
</entry>
<entry name="smartLaunchersEnabled" type="Bool">
<label>Whether to show progress and status information on task buttons.</label>
<default>true</default>
</entry>
<entry name="indicateAudioStreams" type="Bool">
<label>Whether to indicate applications that are playing audio including an option to mute them.</label>
<default>true</default>
......
......@@ -34,7 +34,6 @@ Item {
property alias cfg_showToolTips: showToolTips.checked
property alias cfg_highlightWindows: highlightWindows.checked
property alias cfg_smartLaunchersEnabled: smartLaunchers.checked
property bool cfg_indicateAudioStreams
property alias cfg_iconSize: iconSize.value
property alias cfg_maxStripes: maxStripes.value
......@@ -55,11 +54,6 @@ Item {
text: i18n("Highlight windows when hovering over tasks")
}
CheckBox {
id: smartLaunchers
text: i18n("Show progress and status information in task buttons")
}
CheckBox {
id: indicateAudioStreams
text: i18n("Mark applications that play audio")
......
......@@ -55,7 +55,7 @@ MouseArea {
property int pressY: -1
property QtObject contextMenu: null
property int wheelDelta: 0
readonly property bool smartLauncherEnabled: plasmoid.configuration.smartLaunchersEnabled && !inPopup && model.IsStartup !== true
readonly property bool smartLauncherEnabled: !inPopup && model.IsStartup !== true
property QtObject smartLauncherItem: null
property alias toolTipAreaItem: toolTipArea
......@@ -381,7 +381,7 @@ MouseArea {
});
toolTipDelegate.smartLauncherCountVisible = Qt.binding(function() {
return plasmoid.configuration.smartLaunchersEnabled && task.smartLauncherItem && task.smartLauncherItem.countVisible;
return task.smartLauncherItem && task.smartLauncherItem.countVisible;
});
toolTipDelegate.smartLauncherCount = Qt.binding(function() {
return toolTipDelegate.smartLauncherCountVisible ? task.smartLauncherItem.count : 0;
......@@ -395,7 +395,7 @@ MouseArea {
anchors.fill: frame
asynchronous: true
source: "TaskProgressOverlay.qml"
active: plasmoid.configuration.smartLaunchersEnabled && task.smartLauncherItem && task.smartLauncherItem.progressVisible
active: task.smartLauncherItem && task.smartLauncherItem.progressVisible
}
Item {
......@@ -448,7 +448,7 @@ MouseArea {
height: parent.height
asynchronous: true
source: "TaskBadgeOverlay.qml"
active: plasmoid.configuration.smartLaunchersEnabled && height >= units.iconSizes.small
active: height >= units.iconSizes.small
&& task.smartLauncherItem && task.smartLauncherItem.countVisible
}
......
/***************************************************************************
* Copyright (C) 2016 Kai Uwe Broulik <kde@privat.broulik.de> *
* Copyright (C) 2016, 2019 Kai Uwe Broulik <kde@privat.broulik.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -25,13 +25,14 @@
#include <QHash>
#include <QVariantMap>
#include <Plasma/DataEngine>
#include <notificationmanager/jobsmodel.h>
class QDBusServiceWatcher;
class QString;
namespace Plasma {
class DataEngineConsumer;
namespace NotificationManager
{
class Settings;
}
namespace SmartLauncher {
......@@ -53,7 +54,6 @@ public:
explicit Backend(QObject *parent = nullptr);
~Backend() override;
bool available() const;
bool hasLauncher(const QString &storageId) const;
int count(const QString &uri) const;
......@@ -64,9 +64,6 @@ public:
QHash<QString, QString> unityMappingRules() const;
public slots:
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
signals:
void countChanged(const QString &uri, int count);
void countVisibleChanged(const QString &uri, bool countVisible);
......@@ -74,14 +71,16 @@ signals:
void progressVisibleChanged(const QString &uri, bool progressVisible);
void urgentChanged(const QString &uri, bool urgent);
void reloadRequested(const QString &uri);
void launcherRemoved(const QString &uri);
private slots:
void update(const QString &uri, const QMap<QString, QVariant> &properties);
private:
bool setupUnity();
bool setupApplicationJobs();
void reload();
void setupUnity();
void setupApplicationJobs();
void onServiceUnregistered(const QString &service);
......@@ -90,23 +89,27 @@ private:
const QVariantMap &properties, // the map of properties we're given by DBus
const QString &property, // the property we're looking for
T *entryMember, // the member variable we're going to write our result in
// the getter for this property which might return something different from the raw value
T (Backend::*getter)(const QString &) const,
// the change signal that will be emitted if the property has changed
void (Backend::*changeSignal)(const QString &, T))
{
auto foundProperty = properties.constFind(property);
if (foundProperty != properties.constEnd()) {
const T oldSanitizedValue = ((this)->*getter)(storageId);
T newValue = foundProperty->value<T>();
*entryMember = newValue;
if (newValue != *entryMember) {
*entryMember = newValue;
emit ((this)->*changeSignal)(storageId, newValue);
const T newSanitizedValue = ((this)->*getter)(storageId);
if (newSanitizedValue != oldSanitizedValue) {
emit ((this)->*changeSignal)(storageId, newSanitizedValue);
}
}
}
void onApplicationJobAdded(const QString &source);
void onApplicationJobRemoved(const QString &source);
void updateApplicationJobPercent(const QString &storageId, Entry *entry);
bool doNotDisturbMode() const;
// Unity Launchers
QDBusServiceWatcher *m_watcher;
......@@ -118,14 +121,14 @@ private:
QHash<QString, QString> m_unityMappingRules;
// Application Jobs
Plasma::DataEngineConsumer *m_dataEngineConsumer;
Plasma::DataEngine *m_dataEngine;
QHash<QString, QString> m_dataSourceToStorageId; // <Job 1, foo.desktop>
QHash<QString, QStringList> m_storageIdToJobs; // <foo.desktop, <Job 1, Job 2, ..>>
QHash<QString, int> m_jobProgress; // <Job 1, 42>
NotificationManager::JobsModel::Ptr m_jobsModel;
NotificationManager::Settings *m_settings = nullptr;
QHash<QString, Entry> m_launchers;
QStringList m_badgeBlacklist;
bool m_available = false;
};
......
/***************************************************************************
* Copyright (C) 2016 Kai Uwe Broulik <kde@privat.broulik.de> *
* Copyright (C) 2016, 2019 Kai Uwe Broulik <kde@privat.broulik.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -38,53 +38,58 @@ QWeakPointer<Backend> Item::s_backend;
void Item::init()
{
if (m_inited || m_storageId.isEmpty() || !m_backendPtr || !m_backendPtr->available()) {
if (m_inited || m_storageId.isEmpty() || !m_backendPtr) {
return;
}
connect(m_backendPtr.data(), &Backend::reloadRequested, this, [this](const QString &uri) {
if (uri.isEmpty() || m_storageId == uri) {
populate();
}
});
connect(m_backendPtr.data(), &Backend::launcherRemoved, this, [this](const QString &uri) {
if (m_storageId == uri) {
if (uri.isEmpty() || m_storageId == uri) {
clear();
}
});
connect(m_backendPtr.data(), &Backend::countChanged, this, [this](const QString &uri, int count) {
if (m_storageId == uri) {
if (uri.isEmpty() || m_storageId == uri) {
setCount(count);
}
});
connect(m_backendPtr.data(), &Backend::countVisibleChanged, this, [this](const QString &uri, bool countVisible) {
if (m_storageId == uri) {
if (uri.isEmpty() || m_storageId == uri) {
setCountVisible(countVisible);
}
});
connect(m_backendPtr.data(), &Backend::progressChanged, this, [this](const QString &uri, int progress) {
if (m_storageId == uri) {
if (uri.isEmpty() || m_storageId == uri) {
setProgress(progress);
}
});
connect(m_backendPtr.data(), &Backend::progressVisibleChanged, this, [this](const QString &uri, bool progressVisible) {
if (m_storageId == uri) {
if (uri.isEmpty() || m_storageId == uri) {
setProgressVisible(progressVisible);
}
});
connect(m_backendPtr.data(), &Backend::urgentChanged, this, [this](const QString &uri, bool urgent) {
if (m_storageId == uri) {
if (uri.isEmpty() || m_storageId == uri) {
setUrgent(urgent);
}
});
m_available = true;
emit availableChanged(m_available);
m_inited = true;
}
void Item::populate()
{
if (!m_backendPtr || !m_backendPtr->available() || m_storageId.isEmpty()) {
if (!m_backendPtr || m_storageId.isEmpty()) {
return;
}
......@@ -156,10 +161,6 @@ void Item::setLauncherUrl(const QUrl &launcherUrl)
}
}
bool Item::available() const
{
return m_available;
}
int Item::count() const
{
......
/***************************************************************************
* Copyright (C) 2016 Kai Uwe Broulik <kde@privat.broulik.de> *
* Copyright (C) 2016, 2019 Kai Uwe Broulik <kde@privat.broulik.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -35,8 +35,6 @@ class Item : public QObject
Q_PROPERTY(QUrl launcherUrl READ launcherUrl WRITE setLauncherUrl NOTIFY launcherUrlChanged)
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(bool countVisible READ countVisible NOTIFY countVisibleChanged)
Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
......@@ -50,8 +48,6 @@ public:
QUrl launcherUrl() const;
void setLauncherUrl(const QUrl &launcherUrl);
bool available() const;
int count() const;
bool countVisible() const;
int progress() const;
......@@ -61,8 +57,6 @@ public:
signals:
void launcherUrlChanged(const QUrl &launcherUrl);
void availableChanged(bool available);
void countChanged(int count);
void countVisibleChanged(bool countVisible);
void progressChanged(int progress);
......@@ -88,7 +82,6 @@ private:
QUrl m_launcherUrl;
QString m_storageId;
bool m_available = false;
bool m_inited = false;
int m_count = 0;
......
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