mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-12-24 12:38:55 +00:00
Start to build tray icons
This commit is contained in:
parent
2a536d57ed
commit
bf1ee550e3
@ -23,6 +23,7 @@ SOURCES += \
|
||||
notificationshelper.cpp \
|
||||
notificationsnumber.cpp \
|
||||
refreshservice.cpp \
|
||||
trayicon.cpp \
|
||||
wsclient.cpp
|
||||
|
||||
HEADERS += \
|
||||
@ -35,6 +36,7 @@ HEADERS += \
|
||||
notificationshelper.h \
|
||||
notificationsnumber.h \
|
||||
refreshservice.h \
|
||||
trayicon.h \
|
||||
wsclient.h
|
||||
|
||||
FORMS += \
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "notificationshelper.h"
|
||||
#include "trayicon.h"
|
||||
#include "wsclient.h"
|
||||
|
||||
#include <QObject>
|
||||
@ -30,4 +31,5 @@ private:
|
||||
static RefreshService *svc;
|
||||
WsClient mWsClient;
|
||||
NotificationsHelper mNotifsHelper;
|
||||
TrayIcon mTrayIcon;
|
||||
};
|
||||
|
26
trayicon.cpp
Normal file
26
trayicon.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
|
||||
#include "trayicon.h"
|
||||
|
||||
TrayIcon::TrayIcon(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mMenu = new QMenu;
|
||||
|
||||
QAction *closeAction = mMenu->addAction(tr("Quit"));
|
||||
connect(closeAction, &QAction::triggered, this, &TrayIcon::onQuit);
|
||||
|
||||
mTrayIcon.setIcon(QIcon(":/logo_large.png"));
|
||||
mTrayIcon.setContextMenu(mMenu);
|
||||
mTrayIcon.show();
|
||||
}
|
||||
|
||||
TrayIcon::~TrayIcon()
|
||||
{
|
||||
mMenu->deleteLater();
|
||||
}
|
||||
|
||||
void TrayIcon::onQuit()
|
||||
{
|
||||
QApplication::exit();
|
||||
}
|
28
trayicon.h
Normal file
28
trayicon.h
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Tray icon
|
||||
*
|
||||
* @author Pierre Hubert
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
class TrayIcon : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrayIcon(QObject *parent = nullptr);
|
||||
~TrayIcon();
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void onQuit();
|
||||
|
||||
private:
|
||||
QMenu *mMenu;
|
||||
QSystemTrayIcon mTrayIcon;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user