Update badge counter only on change

This commit is contained in:
Konstantinos Sideris 2017-10-01 18:15:23 +03:00
parent 0c0ac68bc2
commit 6e0ae807d5
3 changed files with 14 additions and 12 deletions

View file

@ -380,14 +380,12 @@ TimelineView::init()
scrollbar_ = new ScrollBar(scroll_area_); scrollbar_ = new ScrollBar(scroll_area_);
scroll_area_->setVerticalScrollBar(scrollbar_); scroll_area_->setVerticalScrollBar(scrollbar_);
scroll_widget_ = new QWidget(); scroll_widget_ = new QWidget(this);
scroll_layout_ = new QVBoxLayout(); scroll_layout_ = new QVBoxLayout(scroll_widget_);
scroll_layout_->addStretch(1); scroll_layout_->addStretch(1);
scroll_layout_->setSpacing(0); scroll_layout_->setSpacing(0);
scroll_widget_->setLayout(scroll_layout_);
scroll_area_->setWidget(scroll_widget_); scroll_area_->setWidget(scroll_widget_);
top_layout_->addWidget(scroll_area_); top_layout_->addWidget(scroll_area_);

View file

@ -16,8 +16,8 @@
*/ */
#include <QApplication> #include <QApplication>
#include <QTimer>
#include <QList> #include <QList>
#include <QTimer>
#include "TrayIcon.h" #include "TrayIcon.h"
@ -132,15 +132,19 @@ TrayIcon::setUnreadCount(int count)
{ {
// Use the native badge counter in MacOS. // Use the native badge counter in MacOS.
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
if (count == 0) auto labelText = count == 0 ? "" : QString::number(count);
QtMac::setBadgeLabelText("");
else if (labelText == QtMac::badgeLabelText())
QtMac::setBadgeLabelText(QString::number(count)); return;
QtMac::setBadgeLabelText(labelText);
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
// FIXME: Find a way to use Windows apis for the badge counter (if any). // FIXME: Find a way to use Windows apis for the badge counter (if any).
#else #else
if (count == icon_->msgCount)
return;
// Custom drawing on Linux. // Custom drawing on Linux.
// FIXME: It doesn't seem to work on KDE.
MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone()); MsgCountComposedIcon *tmp = static_cast<MsgCountComposedIcon *>(icon_->clone());
tmp->msgCount = count; tmp->msgCount = count;