summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRokas Kupstys <rokups@zoho.com>2017-10-01 12:13:10 +0300
committerRokas Kupstys <rokups@zoho.com>2017-10-01 12:15:38 +0300
commitda6e7c11dc9e387d8cf0009f91c966a3788a98d9 (patch)
tree091b71e20c4cb1b86c993da51da842e925707e7f /src
parentDon't move scrollbar to the bottom when it's active (diff)
downloadnheko-da6e7c11dc9e387d8cf0009f91c966a3788a98d9.tar.xz
Fixes #50.
On KDE desktop icon failed to appear because TrayIcon requested a zero-size rect. Implementing MsgCountComposedIcon::availableSizes() method fixes that.

After icon became visible it was not transparent, and places that should have been transparent contained artifacts likely due to uninitialized memory. Implementing MsgCountComposedIcon::pixmap() which returns a pixmap with alpha channel fixes that.
Diffstat (limited to 'src')
-rw-r--r--src/TrayIcon.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/TrayIcon.cc b/src/TrayIcon.cc

index a9e897d8..8d3dc99f 100644 --- a/src/TrayIcon.cc +++ b/src/TrayIcon.cc
@@ -17,6 +17,7 @@ #include <QApplication> #include <QTimer> +#include <QList> #include "TrayIcon.h" @@ -72,6 +73,34 @@ MsgCountComposedIcon::clone() const return new MsgCountComposedIcon(*this); } +QList<QSize> +MsgCountComposedIcon::availableSizes(QIcon::Mode mode, QIcon::State state) const +{ + Q_UNUSED(mode); + Q_UNUSED(state); + QList<QSize> sizes; + sizes.append(QSize(24, 24)); + sizes.append(QSize(32, 32)); + sizes.append(QSize(48, 48)); + sizes.append(QSize(64, 64)); + sizes.append(QSize(128, 128)); + sizes.append(QSize(256, 256)); + return sizes; +} + +QPixmap +MsgCountComposedIcon::pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) +{ + QImage img(size, QImage::Format_ARGB32); + img.fill(qRgba(0, 0, 0, 0)); + QPixmap result = QPixmap::fromImage(img, Qt::NoFormatConversion); + { + QPainter painter(&result); + paint(&painter, QRect(QPoint(0, 0), size), mode, state); + } + return result; +} + TrayIcon::TrayIcon(const QString &filename, QWidget *parent) : QSystemTrayIcon(parent) {