nheko/src/TrayIcon.h

54 lines
1.2 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-FileCopyrightText: 2022 Nheko Contributors
2021-03-05 00:35:15 +01:00
//
// 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;
2022-10-10 14:38:29 +02:00
class MsgCountComposedIcon final : public QIconEngine
2017-05-21 15:36:06 +02:00
{
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;
2021-12-28 20:09:08 +01: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 00:22:33 +02:00
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
};
2022-10-10 14:38:29 +02:00
class TrayIcon final : public QSystemTrayIcon
2017-05-21 15:36:06 +02:00
{
2021-09-18 00:22:33 +02:00
Q_OBJECT
2017-05-21 15:36:06 +02:00
public:
2022-01-12 19:09:46 +01:00
TrayIcon(const QString &filename, QWindow *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
};