Fixed loading of system tray icon.
This commit is contained in:
parent
9a2b2ba591
commit
b0d5ddecd9
2 changed files with 19 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
|
@ -20,6 +21,7 @@ SystemTrayIcon::SystemTrayIcon(const QString &normal_icon,
|
||||||
|
|
||||||
SystemTrayIcon::~SystemTrayIcon() {
|
SystemTrayIcon::~SystemTrayIcon() {
|
||||||
qDebug("Destroying SystemTrayIcon instance.");
|
qDebug("Destroying SystemTrayIcon instance.");
|
||||||
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemTrayIcon::isSystemTrayAvailable() {
|
bool SystemTrayIcon::isSystemTrayAvailable() {
|
||||||
|
@ -42,6 +44,19 @@ SystemTrayIcon *SystemTrayIcon::getInstance() {
|
||||||
return m_trayIcon;
|
return m_trayIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemTrayIcon::show_private() {
|
||||||
|
QSystemTrayIcon::show();
|
||||||
|
qDebug("Tray icon displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemTrayIcon::show() {
|
||||||
|
// Delay avoids race conditions and tray icon is properly displayed.
|
||||||
|
qDebug("Showing tray icon with 1000 ms delay.");
|
||||||
|
QTimer::singleShot(1000,
|
||||||
|
Qt::CoarseTimer,
|
||||||
|
this, SLOT(show_private()));
|
||||||
|
}
|
||||||
|
|
||||||
void SystemTrayIcon::setNumber(int number) {
|
void SystemTrayIcon::setNumber(int number) {
|
||||||
if (number < 0) {
|
if (number < 0) {
|
||||||
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
||||||
|
|
|
@ -32,6 +32,10 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void show();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void show_private();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_normalIcon;
|
QString m_normalIcon;
|
||||||
|
|
Loading…
Add table
Reference in a new issue