mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-11-22 13:29:25 +00:00
Start to build tray icons
This commit is contained in:
parent
2a536d57ed
commit
bf1ee550e3
@ -23,6 +23,7 @@ SOURCES += \
|
|||||||
notificationshelper.cpp \
|
notificationshelper.cpp \
|
||||||
notificationsnumber.cpp \
|
notificationsnumber.cpp \
|
||||||
refreshservice.cpp \
|
refreshservice.cpp \
|
||||||
|
trayicon.cpp \
|
||||||
wsclient.cpp
|
wsclient.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@ -35,6 +36,7 @@ HEADERS += \
|
|||||||
notificationshelper.h \
|
notificationshelper.h \
|
||||||
notificationsnumber.h \
|
notificationsnumber.h \
|
||||||
refreshservice.h \
|
refreshservice.h \
|
||||||
|
trayicon.h \
|
||||||
wsclient.h
|
wsclient.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "notificationshelper.h"
|
#include "notificationshelper.h"
|
||||||
|
#include "trayicon.h"
|
||||||
#include "wsclient.h"
|
#include "wsclient.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@ -30,4 +31,5 @@ private:
|
|||||||
static RefreshService *svc;
|
static RefreshService *svc;
|
||||||
WsClient mWsClient;
|
WsClient mWsClient;
|
||||||
NotificationsHelper mNotifsHelper;
|
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