mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
a6cb81fd43
commit
179618edbf
@ -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();
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user