mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
Fix UserNotify ToolTip
This commit is contained in:
parent
33007f902f
commit
e2e89dc971
@ -66,12 +66,12 @@ unsigned int TransferUserNotify::getNewCount()
|
||||
|
||||
QString TransferUserNotify::getTrayMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("You have %1 completed downloads") : tr("You have %1 completed download");
|
||||
return plural ? tr("You have %1 completed transfers") : tr("You have %1 completed transfer");
|
||||
}
|
||||
|
||||
QString TransferUserNotify::getNotifyMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("%1 completed downloads") : tr("%1 completed download");
|
||||
return plural ? tr("%1 completed transfers") : tr("%1 completed transfer");
|
||||
}
|
||||
|
||||
void TransferUserNotify::iconClicked()
|
||||
|
@ -30,16 +30,17 @@ class TransferUserNotify : public UserNotify
|
||||
public:
|
||||
TransferUserNotify(QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
virtual QString textInfo() const override { return tr("completed transfer(s)"); }
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual unsigned int getNewCount();
|
||||
virtual QString getTrayMessage(bool plural);
|
||||
virtual QString getNotifyMessage(bool plural);
|
||||
virtual void iconClicked();
|
||||
virtual QIcon getIcon() override;
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
virtual unsigned int getNewCount() override;
|
||||
|
||||
virtual QString getTrayMessage(bool plural) override;
|
||||
virtual QString getNotifyMessage(bool plural) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
|
||||
unsigned int newTransferCount;
|
||||
};
|
||||
|
@ -491,7 +491,7 @@ void MainWindow::initStackedPage()
|
||||
for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) {
|
||||
UserNotify *userNotify = notifyIt->first->getUserNotify();
|
||||
if (userNotify) {
|
||||
userNotify->initialize(ui->toolBarPage, notifyIt->second.first, notifyIt->second.second,userNotify->textInfo());
|
||||
userNotify->initialize(ui->toolBarPage, notifyIt->second.first, notifyIt->second.second);
|
||||
connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine()));
|
||||
userNotifyList.push_back(userNotify);
|
||||
}
|
||||
|
@ -46,6 +46,16 @@ QIcon PostedUserNotify::getMainIcon(bool hasNew)
|
||||
return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/posted-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/posted.png");
|
||||
}
|
||||
|
||||
QString PostedUserNotify::getTrayMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("You have %1 new board posts") : tr("You have %1 new board post");
|
||||
}
|
||||
|
||||
QString PostedUserNotify::getNotifyMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("%1 new board post") : tr("%1 new board post");
|
||||
}
|
||||
|
||||
void PostedUserNotify::iconClicked()
|
||||
{
|
||||
MainWindow::showWindow(MainWindow::Posted);
|
||||
|
@ -28,15 +28,18 @@ class PostedUserNotify : public GxsUserNotify
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||
explicit PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
virtual QString textInfo() const override { return tr("new board post(s)"); }
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual void iconClicked();
|
||||
virtual QIcon getIcon() override;
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
|
||||
virtual QString getTrayMessage(bool plural) override;
|
||||
virtual QString getNotifyMessage(bool plural) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
};
|
||||
|
||||
#endif // POSTEDUSERNOTIFY_H
|
||||
|
@ -136,12 +136,12 @@ unsigned int ChatLobbyUserNotify::getNewCount()
|
||||
|
||||
QString ChatLobbyUserNotify::getTrayMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("You have %1 new messages") : tr("You have %1 new message");
|
||||
return plural ? tr("You have %1 mentions") : tr("You have %1 mention");
|
||||
}
|
||||
|
||||
QString ChatLobbyUserNotify::getNotifyMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("%1 new messages") : tr("%1 new message");
|
||||
return plural ? tr("%1 mentions") : tr("%1 mention");
|
||||
}
|
||||
|
||||
void ChatLobbyUserNotify::iconClicked()
|
||||
|
@ -63,7 +63,6 @@ public:
|
||||
QString textToNotify() { return _textToNotify.join("\n");}
|
||||
void setTextCaseSensitive(bool value);
|
||||
bool isTextCaseSensitive() {return _bTextCaseSensitive;}
|
||||
virtual QString textInfo() const override { return tr("mention(s)"); }
|
||||
|
||||
signals:
|
||||
void countChanged(ChatLobbyId id, unsigned int count);
|
||||
|
@ -94,6 +94,16 @@ unsigned int ChatUserNotify::getNewCount()
|
||||
return sum;
|
||||
}
|
||||
|
||||
QString ChatUserNotify::getTrayMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("You have %1 mentions") : tr("You have %1 mention");
|
||||
}
|
||||
|
||||
QString ChatUserNotify::getNotifyMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("%1 mentions") : tr("%1 mention");
|
||||
}
|
||||
|
||||
void ChatUserNotify::iconClicked()
|
||||
{
|
||||
ChatDialog *chatDialog = NULL;
|
||||
|
@ -34,23 +34,26 @@ class ChatUserNotify : public UserNotify
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static void getPeersWithWaitingChat(std::vector<RsPeerId>& peers);
|
||||
static void clearWaitingChat(ChatId id);
|
||||
static void getPeersWithWaitingChat(std::vector<RsPeerId>& peers);
|
||||
static void clearWaitingChat(ChatId id);
|
||||
|
||||
ChatUserNotify(QObject *parent = 0);
|
||||
~ChatUserNotify();
|
||||
~ChatUserNotify();
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
virtual QString textInfo() const override { return tr("mention(s)"); }
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
private slots:
|
||||
void chatMessageReceived(ChatMessage msg);
|
||||
void chatMessageReceived(ChatMessage msg);
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual unsigned int getNewCount();
|
||||
virtual void iconClicked();
|
||||
virtual QIcon getIcon() override;
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
virtual unsigned int getNewCount() override;
|
||||
|
||||
virtual QString getTrayMessage(bool plural) override;
|
||||
virtual QString getNotifyMessage(bool plural) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
};
|
||||
|
||||
#endif // CHATUSERNOTIFY_H
|
||||
|
@ -26,17 +26,13 @@
|
||||
#include "rshare.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
UserNotify::UserNotify(QObject *parent) :
|
||||
QObject(parent)
|
||||
UserNotify::UserNotify(QObject *parent)
|
||||
: QObject(parent)
|
||||
, mMainToolButton(nullptr), mMainAction(nullptr)
|
||||
, mListItem(nullptr), mTrayIcon(nullptr)
|
||||
, mNotifyIcon(nullptr), mNewCount(0)
|
||||
, mLastBlinking(false)
|
||||
{
|
||||
mMainToolButton = NULL;
|
||||
mMainAction = NULL;
|
||||
mListItem = NULL;
|
||||
mTrayIcon = NULL;
|
||||
mNotifyIcon = NULL;
|
||||
mNewCount = 0;
|
||||
mLastBlinking = false;
|
||||
|
||||
connect(rApp, SIGNAL(blink(bool)), this, SLOT(blink(bool)));
|
||||
}
|
||||
|
||||
@ -88,12 +84,11 @@ void UserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem,const QString& subtext)
|
||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem)
|
||||
{
|
||||
mMainAction = mainAction;
|
||||
if (mMainAction) {
|
||||
mButtonText = mMainAction->text();
|
||||
mButtonText2 = subtext;
|
||||
if (mainToolBar) {
|
||||
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||
}
|
||||
@ -106,14 +101,14 @@ void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWid
|
||||
|
||||
void UserNotify::createIcons(QMenu *notifyMenu)
|
||||
{
|
||||
#define DELETE_OBJECT(x) if (x) { delete(x); x = NULL; }
|
||||
#define DELETE_OBJECT(x) if (x) { delete(x); x = nullptr; }
|
||||
|
||||
/* Create systray icons or actions */
|
||||
if (notifyEnabled()) {
|
||||
if (notifyCombined()) {
|
||||
DELETE_OBJECT(mTrayIcon);
|
||||
|
||||
if (mNotifyIcon == NULL) {
|
||||
if (mNotifyIcon == nullptr) {
|
||||
mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked()));
|
||||
mNotifyIcon->setVisible(false);
|
||||
connect(mNotifyIcon, SIGNAL(hovered()), this, SLOT(trayIconHovered()));
|
||||
@ -168,16 +163,15 @@ void UserNotify::update()
|
||||
mMainAction->setIcon(getMainIcon(count > 0));
|
||||
|
||||
if(count > 0)
|
||||
{
|
||||
if(!mButtonText2.isNull())
|
||||
mMainAction->setToolTip(QString("%1 (%2 %3)").arg(mButtonText).arg(count).arg(mButtonText2));
|
||||
else
|
||||
mMainAction->setToolTip(QString("%1 (%2)").arg(mButtonText).arg(count));
|
||||
|
||||
{
|
||||
mMainAction->setText(QString("%1 (%2)").arg(mButtonText).arg(count));
|
||||
}
|
||||
else
|
||||
mMainAction->setToolTip(QString("%1 (%2)").arg(mButtonText, getNotifyMessage(count > 1).arg(count) ));
|
||||
}
|
||||
else
|
||||
{
|
||||
mMainAction->setText(mButtonText);
|
||||
mMainAction->setToolTip(mButtonText);
|
||||
}
|
||||
|
||||
QFont font = mMainAction->font();
|
||||
font.setBold(count > 0);
|
||||
|
@ -37,17 +37,13 @@ public:
|
||||
UserNotify(QObject *parent = 0);
|
||||
virtual ~UserNotify();
|
||||
|
||||
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem,const QString& subtext);
|
||||
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem);
|
||||
void createIcons(QMenu *notifyMenu);
|
||||
QSystemTrayIcon* getTrayIcon(){ return mTrayIcon;}
|
||||
QAction* getNotifyIcon(){ return mNotifyIcon;}
|
||||
|
||||
virtual bool hasSetting(QString */*name*/, QString */*group*/) { return false; }
|
||||
|
||||
// UserNotify is used to display tooltips when some services have no messages and so on, in the format of "Name (43242 new messages)"
|
||||
// This method is used to pass the string that comes after the number.
|
||||
virtual QString textInfo() const { return QString() ; }
|
||||
|
||||
bool notifyEnabled();
|
||||
bool notifyCombined();
|
||||
bool notifyBlink();
|
||||
@ -87,7 +83,6 @@ private:
|
||||
QAction *mNotifyIcon;
|
||||
unsigned int mNewCount;
|
||||
QString mButtonText;
|
||||
QString mButtonText2;
|
||||
bool mLastBlinking;
|
||||
};
|
||||
|
||||
|
@ -45,3 +45,14 @@ unsigned int NewsFeedUserNotify::getNewCount()
|
||||
{
|
||||
return mNewFeedCount;
|
||||
}
|
||||
|
||||
|
||||
QString NewsFeedUserNotify::getTrayMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("You have %1 logged events") : tr("You have %1 logged event");
|
||||
}
|
||||
|
||||
QString NewsFeedUserNotify::getNotifyMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("%1 logged events") : tr("%1 logged event");
|
||||
}
|
||||
|
@ -29,16 +29,18 @@ class NewsFeedUserNotify : public UserNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
virtual QString textInfo() const override { return tr("logged event(s)"); }
|
||||
public:
|
||||
NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent = 0);
|
||||
explicit NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent = 0);
|
||||
|
||||
private slots:
|
||||
void newsFeedChanged(int count);
|
||||
|
||||
private:
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual unsigned int getNewCount();
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
virtual unsigned int getNewCount() override;
|
||||
|
||||
virtual QString getTrayMessage(bool plural) override;
|
||||
virtual QString getNotifyMessage(bool plural) override;
|
||||
|
||||
private:
|
||||
unsigned int mNewFeedCount;
|
||||
|
@ -29,15 +29,15 @@ class GxsChannelUserNotify : public GxsUserNotify
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||
explicit GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
virtual QString textInfo() const override { return tr("new message(s)"); }
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual void iconClicked();
|
||||
virtual QIcon getIcon() override;
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
};
|
||||
|
||||
#endif // GXSCHANNELUSERNOTIFY_H
|
||||
|
@ -28,15 +28,15 @@ class GxsForumUserNotify : public GxsUserNotify
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||
explicit GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
virtual QString textInfo() const override { return tr("new message(s)"); }
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual void iconClicked();
|
||||
virtual QIcon getIcon() override;
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
};
|
||||
|
||||
#endif // FORUMUSERNOTIFY_H
|
||||
|
@ -58,6 +58,16 @@ unsigned int MessageUserNotify::getNewCount()
|
||||
return newInboxCount;
|
||||
}
|
||||
|
||||
QString MessageUserNotify::getTrayMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("You have %1 new mails") : tr("You have %1 new mail");
|
||||
}
|
||||
|
||||
QString MessageUserNotify::getNotifyMessage(bool plural)
|
||||
{
|
||||
return plural ? tr("%1 new mails") : tr("%1 new mail");
|
||||
}
|
||||
|
||||
void MessageUserNotify::iconClicked()
|
||||
{
|
||||
MainWindow::showWindow(MainWindow::Messages);
|
||||
|
@ -30,14 +30,17 @@ class MessageUserNotify : public UserNotify
|
||||
public:
|
||||
MessageUserNotify(QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
virtual QString textInfo() const override { return tr("new mail(s)"); }
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual unsigned int getNewCount();
|
||||
virtual void iconClicked();
|
||||
virtual QIcon getIcon() override;
|
||||
virtual QIcon getMainIcon(bool hasNew) override;
|
||||
virtual unsigned int getNewCount() override;
|
||||
|
||||
virtual QString getTrayMessage(bool plural) override;
|
||||
virtual QString getNotifyMessage(bool plural) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
};
|
||||
|
||||
#endif // MESSAGEUSERNOTIFY_H
|
||||
|
Loading…
Reference in New Issue
Block a user