mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-11-22 05:19:25 +00:00
Get more information about notifications
This commit is contained in:
parent
20ac62e147
commit
951cde4c4e
19
trayicon.cpp
19
trayicon.cpp
@ -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()
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user