From 0134101a105d48aa7f43d8a6ba83f55f66b6f588 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 21 Jun 2021 20:06:42 +0200 Subject: [PATCH] bit polished numbers --- resources/scripts/7za | 2 +- src/librssguard/miscellaneous/application.cpp | 46 ++++++++++--------- src/librssguard/miscellaneous/application.h | 1 + 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/resources/scripts/7za b/resources/scripts/7za index 47f412575..9c10723bf 160000 --- a/resources/scripts/7za +++ b/resources/scripts/7za @@ -1 +1 @@ -Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9 +Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749 diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index b3b1d9420..f6baeb3ff 100755 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -261,27 +261,7 @@ void Application::setFeedReader(FeedReader* feed_reader) { m_feedReader = feed_reader; connect(m_feedReader, &FeedReader::feedUpdatesFinished, this, &Application::onFeedUpdatesFinished); - -#if defined(Q_OS_LINUX) - connect(m_feedReader->feedsModel(), &FeedsModel::messageCountsChanged, this, - [=](int unread_messages, bool any_feed_has_unread_messages) { - QDBusMessage signal = QDBusMessage::createSignal( - "/", - "com.canonical.Unity.LauncherEntry", - "Update"); - - signal << QSL("application://%1").arg(APP_DESKTOP_ENTRY_FILE); - - QVariantMap setProperty; - - setProperty.insert("count", qint64(unread_messages)); - setProperty.insert("count-visible", unread_messages > 0); - - signal << setProperty; - - QDBusConnection::sessionBus().send(signal); - }); -#endif + connect(m_feedReader->feedsModel(), &FeedsModel::messageCountsChanged, this, &Application::showMessagesNumber); } IconFactory* Application::icons() { @@ -422,7 +402,6 @@ SystemTrayIcon* Application::trayIcon() { } connect(m_trayIcon, &SystemTrayIcon::shown, m_feedReader->feedsModel(), &FeedsModel::notifyWithCounts); - connect(m_feedReader->feedsModel(), &FeedsModel::messageCountsChanged, m_trayIcon, &SystemTrayIcon::setNumber); } return m_trayIcon; @@ -561,6 +540,29 @@ void Application::onAboutToQuit() { } } +void Application::showMessagesNumber(int unread_messages, bool any_feed_has_unread_messages) { + if (m_trayIcon != nullptr) { + m_trayIcon->setNumber(unread_messages, any_feed_has_unread_messages); + } + +#if defined(Q_OS_LINUX) + QDBusMessage signal = QDBusMessage::createSignal(QSL("/"), + QSL("com.canonical.Unity.LauncherEntry"), + QSL("Update")); + + signal << QSL("application://%1").arg(APP_DESKTOP_ENTRY_FILE); + + QVariantMap setProperty; + + setProperty.insert("count", qint64(unread_messages)); + setProperty.insert("count-visible", unread_messages > 0); + + signal << setProperty; + + QDBusConnection::sessionBus().send(signal); +#endif +} + void Application::restart() { m_shouldRestart = true; quit(); diff --git a/src/librssguard/miscellaneous/application.h b/src/librssguard/miscellaneous/application.h index 67af83abe..b12900039 100755 --- a/src/librssguard/miscellaneous/application.h +++ b/src/librssguard/miscellaneous/application.h @@ -134,6 +134,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication { void onCommitData(QSessionManager& manager); void onSaveState(QSessionManager& manager); void onAboutToQuit(); + void showMessagesNumber(int unread_messages, bool any_feed_has_unread_messages); #if defined(USE_WEBENGINE) void downloadRequested(QWebEngineDownloadItem* download_item);