Skip to content

Commit 0134101

Browse files
committed
bit polished numbers
1 parent 61030b7 commit 0134101

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

resources/scripts/7za

src/librssguard/miscellaneous/application.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -261,27 +261,7 @@ void Application::setFeedReader(FeedReader* feed_reader) {
261261
m_feedReader = feed_reader;
262262

263263
connect(m_feedReader, &FeedReader::feedUpdatesFinished, this, &Application::onFeedUpdatesFinished);
264-
265-
#if defined(Q_OS_LINUX)
266-
connect(m_feedReader->feedsModel(), &FeedsModel::messageCountsChanged, this,
267-
[=](int unread_messages, bool any_feed_has_unread_messages) {
268-
QDBusMessage signal = QDBusMessage::createSignal(
269-
"/",
270-
"com.canonical.Unity.LauncherEntry",
271-
"Update");
272-
273-
signal << QSL("application://%1").arg(APP_DESKTOP_ENTRY_FILE);
274-
275-
QVariantMap setProperty;
276-
277-
setProperty.insert("count", qint64(unread_messages));
278-
setProperty.insert("count-visible", unread_messages > 0);
279-
280-
signal << setProperty;
281-
282-
QDBusConnection::sessionBus().send(signal);
283-
});
284-
#endif
264+
connect(m_feedReader->feedsModel(), &FeedsModel::messageCountsChanged, this, &Application::showMessagesNumber);
285265
}
286266

287267
IconFactory* Application::icons() {
@@ -422,7 +402,6 @@ SystemTrayIcon* Application::trayIcon() {
422402
}
423403

424404
connect(m_trayIcon, &SystemTrayIcon::shown, m_feedReader->feedsModel(), &FeedsModel::notifyWithCounts);
425-
connect(m_feedReader->feedsModel(), &FeedsModel::messageCountsChanged, m_trayIcon, &SystemTrayIcon::setNumber);
426405
}
427406

428407
return m_trayIcon;
@@ -561,6 +540,29 @@ void Application::onAboutToQuit() {
561540
}
562541
}
563542

543+
void Application::showMessagesNumber(int unread_messages, bool any_feed_has_unread_messages) {
544+
if (m_trayIcon != nullptr) {
545+
m_trayIcon->setNumber(unread_messages, any_feed_has_unread_messages);
546+
}
547+
548+
#if defined(Q_OS_LINUX)
549+
QDBusMessage signal = QDBusMessage::createSignal(QSL("/"),
550+
QSL("com.canonical.Unity.LauncherEntry"),
551+
QSL("Update"));
552+
553+
signal << QSL("application://%1").arg(APP_DESKTOP_ENTRY_FILE);
554+
555+
QVariantMap setProperty;
556+
557+
setProperty.insert("count", qint64(unread_messages));
558+
setProperty.insert("count-visible", unread_messages > 0);
559+
560+
signal << setProperty;
561+
562+
QDBusConnection::sessionBus().send(signal);
563+
#endif
564+
}
565+
564566
void Application::restart() {
565567
m_shouldRestart = true;
566568
quit();

src/librssguard/miscellaneous/application.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
134134
void onCommitData(QSessionManager& manager);
135135
void onSaveState(QSessionManager& manager);
136136
void onAboutToQuit();
137+
void showMessagesNumber(int unread_messages, bool any_feed_has_unread_messages);
137138

138139
#if defined(USE_WEBENGINE)
139140
void downloadRequested(QWebEngineDownloadItem* download_item);

0 commit comments

Comments
 (0)