Change the tray ico color to indicate if the device is connected.

This commit is contained in:
codestation
2013-12-17 20:38:53 -04:30
parent 73a48a76f2
commit b0345a6656
5 changed files with 23 additions and 2 deletions

View File

@@ -7,5 +7,7 @@
<file>resources/images/psv_icon_16.png</file>
<file>resources/images/qcma.png</file>
<file>resources/images/edit-clear-locationbar-rtl.png</file>
<file>resources/images/psv_icon_dc.png</file>
<file>resources/images/psv_icon_16_dc.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

View File

@@ -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

View File

@@ -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);