2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-03-05 02:35:15 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2017-05-21 16:36:06 +03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QIconEngine>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
|
2020-01-31 08:12:02 +03:00
|
|
|
class QAction;
|
|
|
|
class QPainter;
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class MsgCountComposedIcon final : public QIconEngine
|
2017-05-21 16:36:06 +03:00
|
|
|
{
|
|
|
|
public:
|
2021-09-18 01:22:33 +03:00
|
|
|
MsgCountComposedIcon(const QString &filename);
|
2017-05-21 16:36:06 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
void paint(QPainter *p, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
|
|
|
|
QIconEngine *clone() const override;
|
2021-12-28 22:09:08 +03:00
|
|
|
QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state)
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
const
|
|
|
|
#endif
|
|
|
|
override;
|
2021-09-18 01:22:33 +03:00
|
|
|
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
|
2017-05-21 16:36:06 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
int msgCount = 0;
|
2017-05-21 16:36:06 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
const int BubbleDiameter = 17;
|
2017-05-21 16:36:06 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
QIcon icon_;
|
2017-05-21 16:36:06 +03:00
|
|
|
};
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class TrayIcon final : public QSystemTrayIcon
|
2017-05-21 16:36:06 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2017-05-21 16:36:06 +03:00
|
|
|
public:
|
2022-01-12 21:09:46 +03:00
|
|
|
TrayIcon(const QString &filename, QWindow *parent);
|
2017-05-21 16:36:06 +03:00
|
|
|
|
|
|
|
public slots:
|
2021-09-18 01:22:33 +03:00
|
|
|
void setUnreadCount(int count);
|
2017-05-21 16:36:06 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
QAction *viewAction_;
|
|
|
|
QAction *quitAction_;
|
2017-05-21 16:36:06 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
MsgCountComposedIcon *icon_;
|
2017-05-21 16:36:06 +03:00
|
|
|
};
|