@@ -261,27 +261,7 @@ void Application::setFeedReader(FeedReader* feed_reader) {
261
261
m_feedReader = feed_reader;
262
262
263
263
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);
285
265
}
286
266
287
267
IconFactory* Application::icons () {
@@ -422,7 +402,6 @@ SystemTrayIcon* Application::trayIcon() {
422
402
}
423
403
424
404
connect (m_trayIcon, &SystemTrayIcon::shown, m_feedReader->feedsModel (), &FeedsModel::notifyWithCounts);
425
- connect (m_feedReader->feedsModel (), &FeedsModel::messageCountsChanged, m_trayIcon, &SystemTrayIcon::setNumber);
426
405
}
427
406
428
407
return m_trayIcon;
@@ -561,6 +540,29 @@ void Application::onAboutToQuit() {
561
540
}
562
541
}
563
542
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
+
564
566
void Application::restart () {
565
567
m_shouldRestart = true ;
566
568
quit ();
0 commit comments