Fix system tray, clean it up

At first I noticed it wasn't working like it should, then realised it
was using APIs that are largely unadvised. Also I saw there's some kind
of system to render numbers in there but this is also something we
generally do not do. There's better ways to display such information
(e.g. using the com.canonical.Unity interface), so I wouldn't bother
having ad-hoc code in there. And if we need to have it, we better have
it in KNotifications.
It now will also use the icon from the theme.
This commit is contained in:
Aleix Pol
2020-11-24 03:21:25 +01:00
committed by Aleix Pol Gonzalez
parent fe63b0c9a7
commit 0906e0c680
3 changed files with 11 additions and 193 deletions

View File

@@ -13,32 +13,12 @@
#include <QIconEngine>
#include <QPainter>
#include <QRect>
#include <QSystemTrayIcon>
#include <KStatusNotifierItem>
class MsgCountComposedIcon : public QIconEngine
{
public:
MsgCountComposedIcon(const QString &filename);
virtual void paint(QPainter *p, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
virtual QIconEngine *clone() const override;
virtual QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) const override;
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
int msgCount = 0;
bool isOnline = true; // Default to false?
private:
const int BubbleDiameter = 14;
QIcon icon_;
};
class TrayIcon : public QSystemTrayIcon
class TrayIcon : public KStatusNotifierItem
{
Q_OBJECT
Q_PROPERTY(QString iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
Q_PROPERTY(int notificationCount READ notificationCount WRITE setNotificationCount NOTIFY notificationCountChanged)
Q_PROPERTY(bool isOnline READ isOnline WRITE setIsOnline NOTIFY isOnlineChanged)
public:
TrayIcon(QObject *parent = nullptr);
@@ -49,12 +29,6 @@ public:
}
void setIconSource(const QString &source);
int notificationCount()
{
return m_notificationCount;
}
void setNotificationCount(int count);
bool isOnline()
{
return m_isOnline;
@@ -70,13 +44,7 @@ Q_SIGNALS:
private:
QString m_iconSource;
int m_notificationCount = 0;
bool m_isOnline = true;
QAction *viewAction_;
QAction *quitAction_;
MsgCountComposedIcon *icon_ = nullptr;
};
#endif // TRAYICON_H