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->createIcons(notifyMenu);
|
||||||
userNotify->updateIcon();
|
userNotify->updateIcon();
|
||||||
}
|
}
|
||||||
|
updateTrayCombine();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<UserNotify*> &MainWindow::getUserNotifyList()
|
const QList<UserNotify*> &MainWindow::getUserNotifyList()
|
||||||
|
@ -32,14 +32,14 @@ UserNotify::UserNotify(QObject *parent) :
|
|||||||
mMainAction = NULL;
|
mMainAction = NULL;
|
||||||
mTrayIcon = NULL;
|
mTrayIcon = NULL;
|
||||||
mNotifyIcon = NULL;
|
mNotifyIcon = NULL;
|
||||||
newCount = 0;
|
mNewCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction)
|
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction)
|
||||||
{
|
{
|
||||||
mMainAction = mainAction;
|
mMainAction = mainAction;
|
||||||
if (mMainAction) {
|
if (mMainAction) {
|
||||||
buttonText = mMainAction->text();
|
mButtonText = mMainAction->text();
|
||||||
if (mainToolBar) {
|
if (mainToolBar) {
|
||||||
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||||
}
|
}
|
||||||
@ -59,12 +59,16 @@ void UserNotify::createIcons(QMenu *notifyMenu)
|
|||||||
mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked()));
|
mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked()));
|
||||||
mNotifyIcon->setVisible(false);
|
mNotifyIcon->setVisible(false);
|
||||||
}
|
}
|
||||||
} else if (mTrayIcon == NULL) {
|
} else {
|
||||||
|
DELETE_OBJECT(mNotifyIcon);
|
||||||
|
|
||||||
|
if (mTrayIcon == NULL) {
|
||||||
/* Create the tray icon for messages */
|
/* Create the tray icon for messages */
|
||||||
mTrayIcon = new QSystemTrayIcon(this);
|
mTrayIcon = new QSystemTrayIcon(this);
|
||||||
mTrayIcon->setIcon(getIcon());
|
mTrayIcon->setIcon(getIcon());
|
||||||
connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
|
connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DELETE_OBJECT(mTrayIcon);
|
DELETE_OBJECT(mTrayIcon);
|
||||||
DELETE_OBJECT(mNotifyIcon);
|
DELETE_OBJECT(mNotifyIcon);
|
||||||
@ -79,7 +83,7 @@ void UserNotify::updateIcon()
|
|||||||
|
|
||||||
if (mMainAction) {
|
if (mMainAction) {
|
||||||
mMainAction->setIcon(getMainIcon(count > 0));
|
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();
|
QFont font = mMainAction->font();
|
||||||
font.setBold(count > 0);
|
font.setBold(count > 0);
|
||||||
@ -113,11 +117,11 @@ void UserNotify::updateIcon()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newCount != count) {
|
if (mNewCount != count) {
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
newCount = count;
|
mNewCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserNotify::getTrayMessage(bool plural)
|
QString UserNotify::getTrayMessage(bool plural)
|
||||||
|
@ -67,8 +67,8 @@ private:
|
|||||||
QAction *mMainAction;
|
QAction *mMainAction;
|
||||||
QSystemTrayIcon *mTrayIcon;
|
QSystemTrayIcon *mTrayIcon;
|
||||||
QAction *mNotifyIcon;
|
QAction *mNotifyIcon;
|
||||||
unsigned int newCount;
|
unsigned int mNewCount;
|
||||||
QString buttonText;
|
QString mButtonText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USERNOTIFY_H
|
#endif // USERNOTIFY_H
|
||||||
|
Loading…
Reference in New Issue
Block a user