bit polished numbers

This commit is contained in:
Martin Rotter 2021-06-21 20:06:42 +02:00
parent 61030b7c86
commit 0134101a10
3 changed files with 26 additions and 23 deletions

@ -1 +1 @@
Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9
Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749

View File

@ -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();

View File

@ -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);