From 2fae4a87ba1e53b63742c1e3a749c48d63301cb7 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 18 May 2020 19:14:35 +0300 Subject: [PATCH] ContainmentInt is now resposible for all Tasks --- app/view/containmentinterface.cpp | 35 +++++++++++++++++++++++++++++++ app/view/containmentinterface.h | 13 +++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/view/containmentinterface.cpp b/app/view/containmentinterface.cpp index d76016c30..83f81065c 100644 --- a/app/view/containmentinterface.cpp +++ b/app/view/containmentinterface.cpp @@ -62,6 +62,9 @@ ContainmentInterface::ContainmentInterface(Latte::View *parent) m_appletsExpandedConnectionsTimer.start(); } }); + + connect(m_latteTasksModel, &TasksModel::countChanged, this, &ContainmentInterface::onLatteTasksCountChanged); + connect(m_plasmaTasksModel, &TasksModel::countChanged, this, &ContainmentInterface::onPlasmaTasksCountChanged); } ContainmentInterface::~ContainmentInterface() @@ -441,6 +444,16 @@ bool ContainmentInterface::hasExpandedApplet() const return m_expandedAppletIds.count() > 0; } +bool ContainmentInterface::hasLatteTasks() const +{ + return (m_latteTasksModel->count() > 0); +} + +bool ContainmentInterface::hasPlasmaTasks() const +{ + return (m_plasmaTasksModel->count() > 0); +} + void ContainmentInterface::addExpandedApplet(const int &id) { if (m_expandedAppletIds.contains(id) && appletIsExpandable(id)) { @@ -498,6 +511,28 @@ void ContainmentInterface::on_appletExpandedChanged() } } +void ContainmentInterface::onLatteTasksCountChanged() +{ + if ((m_hasLatteTasks && m_latteTasksModel->count()>0) + || (!m_hasLatteTasks && m_latteTasksModel->count() == 0)) { + return; + } + + m_hasLatteTasks = (m_latteTasksModel->count() > 0); + emit hasLatteTasksChanged(); +} + +void ContainmentInterface::onPlasmaTasksCountChanged() +{ + if ((m_hasPlasmaTasks && m_plasmaTasksModel->count()>0) + || (!m_hasPlasmaTasks && m_plasmaTasksModel->count() == 0)) { + return; + } + + m_hasPlasmaTasks = (m_plasmaTasksModel->count() > 0); + emit hasPlasmaTasksChanged(); +} + bool ContainmentInterface::appletIsExpanded(const int id) { return m_expandedAppletIds.contains(id); diff --git a/app/view/containmentinterface.h b/app/view/containmentinterface.h index 28a5685f3..cbb9183e0 100644 --- a/app/view/containmentinterface.h +++ b/app/view/containmentinterface.h @@ -50,6 +50,8 @@ class ContainmentInterface: public QObject { Q_OBJECT Q_PROPERTY(bool hasExpandedApplet READ hasExpandedApplet NOTIFY hasExpandedAppletChanged) + Q_PROPERTY(bool hasLatteTasks READ hasLatteTasks NOTIFY hasLatteTasksChanged) + Q_PROPERTY(bool hasPlasmaTasks READ hasPlasmaTasks NOTIFY hasPlasmaTasksChanged) Q_PROPERTY(QAbstractListModel *latteTasksModel READ latteTasksModel() NOTIFY latteTasksModelChanged) Q_PROPERTY(QAbstractListModel *plasmaTasksModel READ plasmaTasksModel() NOTIFY plasmaTasksModelChanged) @@ -59,6 +61,8 @@ public: virtual ~ContainmentInterface(); bool hasExpandedApplet() const; + bool hasLatteTasks() const; + bool hasPlasmaTasks() const; bool applicationLauncherInPopup() const; bool applicationLauncherHasGlobalShortcut() const; @@ -92,8 +96,10 @@ public slots: Q_INVOKABLE bool appletIsExpanded(const int id); signals: - void hasExpandedAppletChanged(); void expandedAppletStateChanged(); + void hasExpandedAppletChanged(); + void hasLatteTasksChanged(); + void hasPlasmaTasksChanged(); void latteTasksModelChanged(); void plasmaTasksModelChanged(); @@ -104,6 +110,8 @@ private slots: void updateAppletsTracking(); void on_appletAdded(Plasma::Applet *applet); void on_appletExpandedChanged(); + void onLatteTasksCountChanged(); + void onPlasmaTasksCountChanged(); private: void addExpandedApplet(const int &id); @@ -112,6 +120,9 @@ private: bool appletIsExpandable(PlasmaQuick::AppletQuickItem *appletQuickItem); private: + bool m_hasLatteTasks{false}; + bool m_hasPlasmaTasks{false}; + QMetaMethod m_activateEntryMethod; QMetaMethod m_appletIdForIndexMethod; QMetaMethod m_newInstanceMethod;