mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed switching between combined and not combined tray icon notify with available messages.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5719 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b3d1e75455
commit
9953b3b640
@ -492,6 +492,7 @@ void MainWindow::createNotifyIcons()
|
||||
userNotify->createIcons(notifyMenu);
|
||||
userNotify->updateIcon();
|
||||
}
|
||||
updateTrayCombine();
|
||||
}
|
||||
|
||||
const QList<UserNotify*> &MainWindow::getUserNotifyList()
|
||||
|
@ -32,14 +32,14 @@ UserNotify::UserNotify(QObject *parent) :
|
||||
mMainAction = NULL;
|
||||
mTrayIcon = NULL;
|
||||
mNotifyIcon = NULL;
|
||||
newCount = 0;
|
||||
mNewCount = 0;
|
||||
}
|
||||
|
||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction)
|
||||
{
|
||||
mMainAction = mainAction;
|
||||
if (mMainAction) {
|
||||
buttonText = mMainAction->text();
|
||||
mButtonText = mMainAction->text();
|
||||
if (mainToolBar) {
|
||||
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||
}
|
||||
@ -59,12 +59,16 @@ void UserNotify::createIcons(QMenu *notifyMenu)
|
||||
mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked()));
|
||||
mNotifyIcon->setVisible(false);
|
||||
}
|
||||
} else if (mTrayIcon == NULL) {
|
||||
} else {
|
||||
DELETE_OBJECT(mNotifyIcon);
|
||||
|
||||
if (mTrayIcon == NULL) {
|
||||
/* Create the tray icon for messages */
|
||||
mTrayIcon = new QSystemTrayIcon(this);
|
||||
mTrayIcon->setIcon(getIcon());
|
||||
connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DELETE_OBJECT(mTrayIcon);
|
||||
DELETE_OBJECT(mNotifyIcon);
|
||||
@ -79,7 +83,7 @@ void UserNotify::updateIcon()
|
||||
|
||||
if (mMainAction) {
|
||||
mMainAction->setIcon(getMainIcon(count > 0));
|
||||
mMainAction->setText((count > 0) ? QString("%1 (%2)").arg(buttonText).arg(count) : buttonText);
|
||||
mMainAction->setText((count > 0) ? QString("%1 (%2)").arg(mButtonText).arg(count) : mButtonText);
|
||||
|
||||
QFont font = mMainAction->font();
|
||||
font.setBold(count > 0);
|
||||
@ -113,11 +117,11 @@ void UserNotify::updateIcon()
|
||||
}
|
||||
}
|
||||
|
||||
if (newCount != count) {
|
||||
if (mNewCount != count) {
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
newCount = count;
|
||||
mNewCount = count;
|
||||
}
|
||||
|
||||
QString UserNotify::getTrayMessage(bool plural)
|
||||
|
@ -67,8 +67,8 @@ private:
|
||||
QAction *mMainAction;
|
||||
QSystemTrayIcon *mTrayIcon;
|
||||
QAction *mNotifyIcon;
|
||||
unsigned int newCount;
|
||||
QString buttonText;
|
||||
unsigned int mNewCount;
|
||||
QString mButtonText;
|
||||
};
|
||||
|
||||
#endif // USERNOTIFY_H
|
||||
|
Loading…
Reference in New Issue
Block a user