1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Support for theming qTox tray and window icons

This patch adds ability to override qTox window and tray icons with ones from user's desktop theme. Some people prefer keeping tray icons consistent to achieve best looks.

Following theme icons used:
* qtox: general window icon which is also used in taskbar
* qtox-online, qtox-offline, qtox-busy, qtox-away, qtox-invisible, qtox-event: tray icons

If theme icon is not available then default built-in icon will be used.
This commit is contained in:
novist 2015-03-11 13:01:10 +02:00
parent fb63232318
commit 95649f2476
3 changed files with 18 additions and 6 deletions

View File

@ -331,7 +331,7 @@ void SystemTrayIcon::setVisible(bool newState)
} }
} }
void SystemTrayIcon::setIcon(QIcon &&icon) void SystemTrayIcon::setIcon(QIcon &icon)
{ {
if (false); if (false);
#ifdef ENABLE_SYSTRAY_STATUSNOTIFIER_BACKEND #ifdef ENABLE_SYSTRAY_STATUSNOTIFIER_BACKEND

View File

@ -17,7 +17,7 @@ public:
void show(); void show();
void hide(); void hide();
void setVisible(bool); void setVisible(bool);
void setIcon(QIcon&& icon); void setIcon(QIcon &icon);
signals: signals:
void activated(QSystemTrayIcon::ActivationReason); void activated(QSystemTrayIcon::ActivationReason);

View File

@ -92,6 +92,10 @@ void Widget::init()
{ {
ui->setupUi(this); ui->setupUi(this);
QIcon themeIcon = QIcon::fromTheme("qtox");
if (!themeIcon.isNull())
setWindowIcon(themeIcon);
timer = new QTimer(); timer = new QTimer();
timer->start(1000); timer->start(1000);
offlineMsgTimer = new QTimer(); offlineMsgTimer = new QTimer();
@ -224,6 +228,9 @@ void Widget::setTranslation()
void Widget::updateTrayIcon() void Widget::updateTrayIcon()
{ {
if (!icon)
return;
QString status; QString status;
if (eventIcon) if (eventIcon)
status = "event"; status = "event";
@ -233,10 +240,15 @@ void Widget::updateTrayIcon()
if (!status.length()) if (!status.length())
status = "offline"; status = "offline";
} }
QIcon ico = QIcon::fromTheme("qtox-" + status);
if (ico.isNull())
{
QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark"; QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark";
QString pic = ":img/taskbar/" + color + "/taskbar_" + status + ".svg"; ico = QIcon(":img/taskbar/" + color + "/taskbar_" + status + ".svg");
if (icon) }
icon->setIcon(QIcon(pic));
icon->setIcon(ico);
} }
Widget::~Widget() Widget::~Widget()