Get more information about notifications

This commit is contained in:
Pierre HUBERT 2020-06-13 17:47:35 +02:00
parent 20ac62e147
commit 951cde4c4e
2 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,14 @@ TrayIcon::TrayIcon(QObject *parent) : QObject(parent)
{
mMenu = new QMenu;
mUnreadNotifications = mMenu->addAction(tr("Loading..."));
mUnreadNotifications->setDisabled(true);
mUnreadConversations = mMenu->addAction(tr("Loading..."));
mUnreadConversations->setDisabled(true);
mMenu->addSeparator();
QAction *signOutAction = mMenu->addAction(tr("Sign out"));
connect(signOutAction, &QAction::triggered, this, &TrayIcon::askForSignOut);
@ -33,6 +41,17 @@ void TrayIcon::onNewNumber(const NotificationsNumber &number)
mOldNumber = number.sum();
refreshIcon();
mUnreadNotifications->setText(QString(number.newNotifs() < 2 ?
tr("%1 notification") :
tr("%1 notifications")
).arg(number.newNotifs()));
mUnreadConversations->setText(QString(number.unreadConversations() < 2 ?
tr("%1 unread conversation") :
tr("%1 unread conversations")
).arg(number.unreadConversations()));
}
void TrayIcon::onQuit()

View File

@ -6,6 +6,7 @@
#pragma once
#include <QAction>
#include <QObject>
#include <QSystemTrayIcon>
@ -43,6 +44,8 @@ private:
// Class members
QMenu *mMenu;
QAction *mUnreadNotifications;
QAction *mUnreadConversations;
QSystemTrayIcon mTrayIcon;
int mOldNumber = 0;
};