2020-06-13 12:39:34 +00:00
|
|
|
/**
|
|
|
|
* Tray icon
|
|
|
|
*
|
|
|
|
* @author Pierre Hubert
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
|
2020-06-13 12:59:02 +00:00
|
|
|
#include "notificationsnumber.h"
|
|
|
|
|
2020-06-13 12:39:34 +00:00
|
|
|
class TrayIcon : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TrayIcon(QObject *parent = nullptr);
|
|
|
|
~TrayIcon();
|
|
|
|
|
2020-06-13 12:59:02 +00:00
|
|
|
public slots:
|
|
|
|
void onNewNumber(const NotificationsNumber &number);
|
|
|
|
|
2020-06-13 12:39:34 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onQuit();
|
|
|
|
|
|
|
|
private:
|
2020-06-13 12:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a notification
|
|
|
|
*
|
|
|
|
* @param n The number of unread conversations
|
|
|
|
*/
|
|
|
|
void showNotification(const NotificationsNumber &n);
|
|
|
|
|
2020-06-13 15:19:43 +00:00
|
|
|
/**
|
|
|
|
* Refresh the icon shown in the taskbar
|
|
|
|
*/
|
|
|
|
void refreshIcon();
|
|
|
|
|
2020-06-13 12:59:02 +00:00
|
|
|
// Class members
|
2020-06-13 12:39:34 +00:00
|
|
|
QMenu *mMenu;
|
|
|
|
QSystemTrayIcon mTrayIcon;
|
2020-06-13 12:59:02 +00:00
|
|
|
int mOldNumber = 0;
|
2020-06-13 12:39:34 +00:00
|
|
|
};
|
|
|
|
|