From b0345a6656b9e0ea4a2afb6a339afd204bfbce08 Mon Sep 17 00:00:00 2001 From: codestation Date: Tue, 17 Dec 2013 20:38:53 -0430 Subject: [PATCH] Change the tray ico color to indicate if the device is connected. --- qcmares.qrc | 2 ++ resources/images/psv_icon_16_dc.png | Bin 0 -> 301 bytes resources/images/psv_icon_dc.png | Bin 0 -> 336 bytes src/mainwidget.cpp | 22 ++++++++++++++++++++-- src/mainwidget.h | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 resources/images/psv_icon_16_dc.png create mode 100644 resources/images/psv_icon_dc.png diff --git a/qcmares.qrc b/qcmares.qrc index b9e6c18..bd04c4e 100644 --- a/qcmares.qrc +++ b/qcmares.qrc @@ -7,5 +7,7 @@ resources/images/psv_icon_16.png resources/images/qcma.png resources/images/edit-clear-locationbar-rtl.png + resources/images/psv_icon_dc.png + resources/images/psv_icon_16_dc.png diff --git a/resources/images/psv_icon_16_dc.png b/resources/images/psv_icon_16_dc.png new file mode 100644 index 0000000000000000000000000000000000000000..8f1008a6d93809bda9b530fd4693b12454260ca6 GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zKpodXn9)gNb_Gz7y~NYkmHjS{pa6&Jgb?> zrnt03QtRG`pZPZ!4!jq__S8+siskZAiDAEgn| z`QVCbhs&;zr5JV|BR>7^elcrGi-J^%dkX4>Y7DxJI5S$AGGnfiR^CY{{vx8Ezu&04ne#{2Kr zUT?MNv+i8I>XJ$CB8@G%(QXx1A}f}M9x(3t&>72beeWT&ayz@_QPq1F9zE~R{Me^G dr$yio(>JYrn`io-;Xscvc)I$ztaD0e0sy>0ilqPm literal 0 HcmV?d00001 diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp index fbe4bc5..b7cde85 100644 --- a/src/mainwidget.cpp +++ b/src/mainwidget.cpp @@ -77,10 +77,27 @@ void MainWidget::stopServer() void MainWidget::deviceDisconnect() { +#ifndef Q_OS_WIN32 + trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_dc.png")); +#else + trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16_dc.png")); +#endif + qDebug("Icon changed - disconnected"); setTrayTooltip(tr("Disconnected")); receiveMessage(tr("The device has been disconnected")); } +void MainWidget::deviceConnected(QString message) +{ + Q_UNUSED(message); +#ifndef Q_OS_WIN32 + trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon.png")); +#else + trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16.png")); +#endif + qDebug("Icon changed - connected"); +} + void MainWidget::prepareApplication() { connectSignals(); @@ -92,6 +109,7 @@ void MainWidget::connectSignals() { connect(&dialog, SIGNAL(finished(int)), this, SLOT(dialogResult(int))); connect(&manager, SIGNAL(stopped()), qApp, SLOT(quit())); + connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnected(QString))); connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(receiveMessage(QString))); connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(setTrayTooltip(QString))); connect(&manager, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect())); @@ -164,9 +182,9 @@ void MainWidget::createTrayIcon() trayIcon = new QSystemTrayIcon(this); trayIcon->setContextMenu(trayIconMenu); #ifndef Q_OS_WIN32 - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon.png")); + trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_dc.png")); #else - trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16.png")); + trayIcon->setIcon(QIcon(":/main/resources/images/psv_icon_16_dc.png")); #endif trayIcon->show(); // try to avoid the iconTray Qt bug diff --git a/src/mainwidget.h b/src/mainwidget.h index d877a1e..605b26f 100644 --- a/src/mainwidget.h +++ b/src/mainwidget.h @@ -69,6 +69,7 @@ private slots: void openManager(); void showAboutQt(); void showAboutDialog(); + void deviceConnected(QString message); void deviceDisconnect(); void dialogResult(int result); void receiveMessage(QString message);