nheko/src/TrayIcon.h

49 lines
1.1 KiB
C
Raw Normal View History

2021-03-05 00:35:15 +01:00
// SPDX-FileCopyrightText: 2017 Konstantinos Sideris <siderisk@auth.gr>
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
2017-05-21 15:36:06 +02:00
#pragma once
#include <QIcon>
#include <QIconEngine>
#include <QRect>
#include <QSystemTrayIcon>
2020-01-31 06:12:02 +01:00
class QAction;
class QPainter;
2017-05-21 15:36:06 +02:00
class MsgCountComposedIcon : public QIconEngine
{
public:
2021-09-18 00:22:33 +02:00
MsgCountComposedIcon(const QString &filename);
2017-05-21 15:36:06 +02:00
2021-09-18 00:22:33 +02:00
void paint(QPainter *p, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
QIconEngine *clone() const override;
QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) const override;
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
2017-05-21 15:36:06 +02:00
2021-09-18 00:22:33 +02:00
int msgCount = 0;
2017-05-21 15:36:06 +02:00
private:
2021-09-18 00:22:33 +02:00
const int BubbleDiameter = 17;
2017-05-21 15:36:06 +02:00
2021-09-18 00:22:33 +02:00
QIcon icon_;
2017-05-21 15:36:06 +02:00
};
class TrayIcon : public QSystemTrayIcon
{
2021-09-18 00:22:33 +02:00
Q_OBJECT
2017-05-21 15:36:06 +02:00
public:
2021-09-18 00:22:33 +02:00
TrayIcon(const QString &filename, QWidget *parent);
2017-05-21 15:36:06 +02:00
public slots:
2021-09-18 00:22:33 +02:00
void setUnreadCount(int count);
2017-05-21 15:36:06 +02:00
private:
2021-09-18 00:22:33 +02:00
QAction *viewAction_;
QAction *quitAction_;
2017-05-21 15:36:06 +02:00
2021-09-18 00:22:33 +02:00
MsgCountComposedIcon *icon_;
2017-05-21 15:36:06 +02:00
};