2021-03-05 02:35:15 +03: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 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;
|
|
|
|
|
2017-05-21 16:36:06 +03:00
|
|
|
class MsgCountComposedIcon : public QIconEngine
|
|
|
|
{
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
class TrayIcon : public QSystemTrayIcon
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2017-05-21 16:36:06 +03:00
|
|
|
public:
|
2021-09-18 01:22:33 +03:00
|
|
|
TrayIcon(const QString &filename, QWidget *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
|
|
|
};
|