mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
Show count of new messages in the toolbar.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5394 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
121d49e5d1
commit
2921cbaf23
@ -47,7 +47,6 @@
|
|||||||
#include "connect/ConnectFriendWizard.h"
|
#include "connect/ConnectFriendWizard.h"
|
||||||
#include "forums/CreateForum.h"
|
#include "forums/CreateForum.h"
|
||||||
#include "gui/common/AvatarDefs.h"
|
#include "gui/common/AvatarDefs.h"
|
||||||
#include "gui/mainpagestack.h"
|
|
||||||
#include "groups/CreateGroup.h"
|
#include "groups/CreateGroup.h"
|
||||||
#include "im_history/ImHistoryBrowser.h"
|
#include "im_history/ImHistoryBrowser.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
@ -372,7 +372,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) {
|
for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) {
|
||||||
UserNotify *userNotify = notifyIt->first->getUserNotify(this);
|
UserNotify *userNotify = notifyIt->first->getUserNotify(this);
|
||||||
if (userNotify) {
|
if (userNotify) {
|
||||||
userNotify->initialize(notifyIt->second);
|
userNotify->initialize(ui.toolBar, notifyIt->second);
|
||||||
connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine()));
|
connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine()));
|
||||||
userNotifyList.push_back(userNotify);
|
userNotifyList.push_back(userNotify);
|
||||||
}
|
}
|
||||||
@ -660,9 +660,9 @@ void MainWindow::postModDirectories(bool update_local)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a new action associated with a config page. */
|
/** Creates a new action associated with a config page. */
|
||||||
QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
|
QAction *MainWindow::createPageAction(const QIcon &icon, const QString &text, QActionGroup *group)
|
||||||
{
|
{
|
||||||
QAction *action = new QAction(img, text, group);
|
QAction *action = new QAction(icon, text, group);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setFont(FONT);
|
action->setFont(FONT);
|
||||||
return action;
|
return action;
|
||||||
|
@ -208,7 +208,7 @@ private:
|
|||||||
BandwidthGraph* _bandwidthGraph;
|
BandwidthGraph* _bandwidthGraph;
|
||||||
|
|
||||||
/** Creates a new action for a Main page. */
|
/** Creates a new action for a Main page. */
|
||||||
QAction* createPageAction(QIcon img, QString text, QActionGroup *group);
|
QAction* createPageAction(const QIcon &icon, const QString &text, QActionGroup *group);
|
||||||
/** Adds a new action to the toolbar. */
|
/** Adds a new action to the toolbar. */
|
||||||
void addAction(QAction *action, const char *slot = 0);
|
void addAction(QAction *action, const char *slot = 0);
|
||||||
|
|
||||||
|
@ -1,18 +1,49 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "UserNotify.h"
|
#include "UserNotify.h"
|
||||||
|
|
||||||
UserNotify::UserNotify(QObject *parent) :
|
UserNotify::UserNotify(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
mMainIcon = NULL;
|
mMainToolButton = NULL;
|
||||||
|
mMainAction = NULL;
|
||||||
mTrayIcon = NULL;
|
mTrayIcon = NULL;
|
||||||
mNotifyIcon = NULL;
|
mNotifyIcon = NULL;
|
||||||
newCount = 0;
|
newCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserNotify::initialize(QAction *mainAction)
|
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction)
|
||||||
{
|
{
|
||||||
mMainIcon = mainAction;
|
mMainAction = mainAction;
|
||||||
|
if (mMainAction) {
|
||||||
|
buttonText = mMainAction->text();
|
||||||
|
if (mainToolBar) {
|
||||||
|
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserNotify::createIcons(QMenu *notifyMenu)
|
void UserNotify::createIcons(QMenu *notifyMenu)
|
||||||
@ -46,8 +77,21 @@ void UserNotify::updateIcon()
|
|||||||
{
|
{
|
||||||
unsigned int count = getNewCount();
|
unsigned int count = getNewCount();
|
||||||
|
|
||||||
if (mMainIcon) {
|
if (mMainAction) {
|
||||||
mMainIcon->setIcon(getMainIcon(count > 0));
|
mMainAction->setIcon(getMainIcon(count > 0));
|
||||||
|
mMainAction->setText((count > 0) ? QString("%1 (%2)").arg(buttonText).arg(count) : buttonText);
|
||||||
|
|
||||||
|
QFont font = mMainAction->font();
|
||||||
|
font.setBold(count > 0);
|
||||||
|
mMainAction->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mMainToolButton) {
|
||||||
|
mMainToolButton->setStyleSheet((count > 0) ? "QToolButton { color: #E21D3A; }" : "");
|
||||||
|
|
||||||
|
QFont font = mMainToolButton->font();
|
||||||
|
font.setBold(count > 0);
|
||||||
|
mMainToolButton->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTrayIcon) {
|
if (mTrayIcon) {
|
||||||
@ -73,7 +117,7 @@ void UserNotify::updateIcon()
|
|||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
count = newCount;
|
newCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserNotify::getTrayMessage(bool plural)
|
QString UserNotify::getTrayMessage(bool plural)
|
||||||
|
@ -1,9 +1,32 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
#ifndef USERNOTIFY_H
|
#ifndef USERNOTIFY_H
|
||||||
#define USERNOTIFY_H
|
#define USERNOTIFY_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
class QToolBar;
|
||||||
|
class QToolButton;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
class UserNotify : public QObject
|
class UserNotify : public QObject
|
||||||
@ -13,7 +36,7 @@ class UserNotify : public QObject
|
|||||||
public:
|
public:
|
||||||
UserNotify(QObject *parent = 0);
|
UserNotify(QObject *parent = 0);
|
||||||
|
|
||||||
void initialize(QAction *mainAction);
|
void initialize(QToolBar *mainToolBar, QAction *mainAction);
|
||||||
void createIcons(QMenu *notifyMenu);
|
void createIcons(QMenu *notifyMenu);
|
||||||
|
|
||||||
virtual bool hasSetting(QString &/*name*/) { return false; }
|
virtual bool hasSetting(QString &/*name*/) { return false; }
|
||||||
@ -40,10 +63,12 @@ private:
|
|||||||
|
|
||||||
virtual void iconClicked() {}
|
virtual void iconClicked() {}
|
||||||
|
|
||||||
QAction *mMainIcon;
|
QToolButton *mMainToolButton;
|
||||||
|
QAction *mMainAction;
|
||||||
QSystemTrayIcon *mTrayIcon;
|
QSystemTrayIcon *mTrayIcon;
|
||||||
QAction *mNotifyIcon;
|
QAction *mNotifyIcon;
|
||||||
unsigned int newCount;
|
unsigned int newCount;
|
||||||
|
QString buttonText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USERNOTIFY_H
|
#endif // USERNOTIFY_H
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
TransferUserNotify::TransferUserNotify(QObject *parent) :
|
TransferUserNotify::TransferUserNotify(QObject *parent) :
|
||||||
UserNotify(parent)
|
UserNotify(parent)
|
||||||
{
|
{
|
||||||
newCount = 0;
|
newTransferCount = 0;
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(downloadCompleteCountChanged(int)), this, SLOT(downloadCountChanged(int)));
|
connect(NotifyQt::getInstance(), SIGNAL(downloadCompleteCountChanged(int)), this, SLOT(downloadCountChanged(int)));
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ QIcon TransferUserNotify::getMainIcon(bool hasNew)
|
|||||||
|
|
||||||
unsigned int TransferUserNotify::getNewCount()
|
unsigned int TransferUserNotify::getNewCount()
|
||||||
{
|
{
|
||||||
return newCount;
|
return newTransferCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TransferUserNotify::getTrayMessage(bool plural)
|
QString TransferUserNotify::getTrayMessage(bool plural)
|
||||||
@ -100,6 +100,6 @@ void TransferUserNotify::iconClicked()
|
|||||||
|
|
||||||
void TransferUserNotify::downloadCountChanged(int count)
|
void TransferUserNotify::downloadCountChanged(int count)
|
||||||
{
|
{
|
||||||
newCount = count;
|
newTransferCount = count;
|
||||||
updateIcon();
|
updateIcon();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ private:
|
|||||||
virtual QString getNotifyMessage(bool plural);
|
virtual QString getNotifyMessage(bool plural);
|
||||||
virtual void iconClicked();
|
virtual void iconClicked();
|
||||||
|
|
||||||
int newCount;
|
unsigned int newTransferCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSFERUSERNOTIFY_H
|
#endif // TRANSFERUSERNOTIFY_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user