Added blinking of the systray icon for the notifier and enabled it for private chat.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5721 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-10-24 13:24:38 +00:00
parent a6cb81fd43
commit 179618edbf
3 changed files with 40 additions and 0 deletions

View File

@ -43,6 +43,7 @@ private:
virtual QIcon getIcon();
virtual QIcon getMainIcon(bool hasNew);
virtual unsigned int getNewCount();
virtual bool isBlinking() { return true; }
virtual void iconClicked();
};

View File

@ -22,6 +22,7 @@
#include <QMenu>
#include <QToolBar>
#include <QToolButton>
#include <QTimer>
#include "UserNotify.h"
@ -33,6 +34,12 @@ UserNotify::UserNotify(QObject *parent) :
mTrayIcon = NULL;
mNotifyIcon = NULL;
mNewCount = 0;
mLastBlinking = false;
mTimer = new QTimer(this);
mTimer->setInterval(500);
connect(mTimer, SIGNAL(timeout()), this, SLOT(timer()));
}
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction)
@ -102,7 +109,11 @@ void UserNotify::updateIcon()
if (count) {
mTrayIcon->setToolTip("RetroShare\n" + getTrayMessage(count > 1).arg(count));
mTrayIcon->show();
if (!mTimer->isActive()) {
mTimer->start();
}
} else {
mTimer->stop();
mTrayIcon->hide();
}
}
@ -140,3 +151,26 @@ void UserNotify::trayIconClicked(QSystemTrayIcon::ActivationReason e)
iconClicked();
}
}
void UserNotify::timer()
{
bool blinking = isBlinking();
if (mTrayIcon) {
if (blinking) {
/* blink icon */
if (mTrayIcon->icon().isNull()) {
mTrayIcon->setIcon(getIcon());
} else {
mTrayIcon->setIcon(QIcon());
}
} else {
if (mLastBlinking) {
/* reset icon */
mTrayIcon->setIcon(getIcon());
}
}
}
mLastBlinking = blinking;
}

View File

@ -28,6 +28,7 @@
class QToolBar;
class QToolButton;
class QAction;
class QTimer;
class UserNotify : public QObject
{
@ -52,11 +53,13 @@ public slots:
private slots:
void trayIconClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
void timer();
private:
virtual QIcon getIcon() { return QIcon(); }
virtual QIcon getMainIcon(bool /*hasNew*/) { return QIcon(); }
virtual unsigned int getNewCount() { return 0; }
virtual bool isBlinking() { return false; }
virtual QString getTrayMessage(bool plural);
virtual QString getNotifyMessage(bool plural);
@ -69,6 +72,8 @@ private:
QAction *mNotifyIcon;
unsigned int mNewCount;
QString mButtonText;
QTimer *mTimer;
bool mLastBlinking;
};
#endif // USERNOTIFY_H