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 <QTimer>
|
||||
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/formmain.h"
|
||||
|
@ -20,6 +21,7 @@ SystemTrayIcon::SystemTrayIcon(const QString &normal_icon,
|
|||
|
||||
SystemTrayIcon::~SystemTrayIcon() {
|
||||
qDebug("Destroying SystemTrayIcon instance.");
|
||||
hide();
|
||||
}
|
||||
|
||||
bool SystemTrayIcon::isSystemTrayAvailable() {
|
||||
|
@ -42,6 +44,19 @@ SystemTrayIcon *SystemTrayIcon::getInstance() {
|
|||
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) {
|
||||
if (number < 0) {
|
||||
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
||||
|
|
|
@ -32,6 +32,10 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
|||
signals:
|
||||
|
||||
public slots:
|
||||
void show();
|
||||
|
||||
private slots:
|
||||
void show_private();
|
||||
|
||||
private:
|
||||
QString m_normalIcon;
|
||||
|
|
Loading…
Add table
Reference in a new issue