mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
Added UserNotify to gxs channels and forums.
Count new messages by retrieving all messages of all subscribed groups until getServiceStatistic is available. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7435 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c32ac6821a
commit
bd58cca832
@ -28,34 +28,38 @@
|
||||
|
||||
UserNotify::UserNotify(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
mMainToolButton = NULL;
|
||||
mMainAction = NULL;
|
||||
mListItem = NULL;
|
||||
mTrayIcon = NULL;
|
||||
mNotifyIcon = NULL;
|
||||
mNewCount = 0;
|
||||
{
|
||||
mMainToolButton = NULL;
|
||||
mMainAction = NULL;
|
||||
mListItem = NULL;
|
||||
mTrayIcon = NULL;
|
||||
mNotifyIcon = NULL;
|
||||
mNewCount = 0;
|
||||
mLastBlinking = false;
|
||||
|
||||
connect(rApp, SIGNAL(blink(bool)), this, SLOT(blink(bool)));
|
||||
}
|
||||
|
||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem)
|
||||
{
|
||||
mMainAction = mainAction;
|
||||
if (mMainAction) {
|
||||
connect(rApp, SIGNAL(blink(bool)), this, SLOT(blink(bool)));
|
||||
}
|
||||
|
||||
UserNotify::~UserNotify()
|
||||
{
|
||||
}
|
||||
|
||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem)
|
||||
{
|
||||
mMainAction = mainAction;
|
||||
if (mMainAction) {
|
||||
mButtonText = mMainAction->text();
|
||||
if (mainToolBar) {
|
||||
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||
}
|
||||
}
|
||||
mListItem = listItem;
|
||||
if (mListItem && !mMainAction) {
|
||||
mButtonText = mMainAction->text();
|
||||
}
|
||||
}
|
||||
|
||||
void UserNotify::createIcons(QMenu *notifyMenu)
|
||||
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||
}
|
||||
}
|
||||
mListItem = listItem;
|
||||
if (mListItem && !mMainAction) {
|
||||
mButtonText = mMainAction->text();
|
||||
}
|
||||
}
|
||||
|
||||
void UserNotify::createIcons(QMenu *notifyMenu)
|
||||
{
|
||||
#define DELETE_OBJECT(x) if (x) { delete(x); x = NULL; }
|
||||
|
||||
@ -87,6 +91,16 @@ void UserNotify::createIcons(QMenu *notifyMenu)
|
||||
}
|
||||
|
||||
void UserNotify::updateIcon()
|
||||
{
|
||||
startUpdate();
|
||||
}
|
||||
|
||||
void UserNotify::startUpdate()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void UserNotify::update()
|
||||
{
|
||||
unsigned int count = getNewCount();
|
||||
|
||||
@ -96,20 +110,20 @@ void UserNotify::updateIcon()
|
||||
|
||||
QFont font = mMainAction->font();
|
||||
font.setBold(count > 0);
|
||||
mMainAction->setFont(font);
|
||||
}
|
||||
|
||||
if (mListItem) {
|
||||
mListItem->setIcon(getMainIcon(count > 0));
|
||||
mListItem->setText((count > 0) ? QString("%1 (%2)").arg(mButtonText).arg(count) : mButtonText);
|
||||
|
||||
QFont font = mListItem->font();
|
||||
font.setBold(count > 0);
|
||||
mListItem->setFont(font);
|
||||
}
|
||||
if (mMainToolButton) {
|
||||
mMainToolButton->setStyleSheet((count > 0) ? "QToolButton { color: #E21D3A; }" : "");
|
||||
|
||||
mMainAction->setFont(font);
|
||||
}
|
||||
|
||||
if (mListItem) {
|
||||
mListItem->setIcon(getMainIcon(count > 0));
|
||||
mListItem->setText((count > 0) ? QString("%1 (%2)").arg(mButtonText).arg(count) : mButtonText);
|
||||
|
||||
QFont font = mListItem->font();
|
||||
font.setBold(count > 0);
|
||||
mListItem->setFont(font);
|
||||
}
|
||||
if (mMainToolButton) {
|
||||
mMainToolButton->setStyleSheet((count > 0) ? "QToolButton { color: #E21D3A; }" : "");
|
||||
|
||||
QFont font = mMainToolButton->font();
|
||||
font.setBold(count > 0);
|
||||
mMainToolButton->setFont(font);
|
||||
|
@ -21,27 +21,27 @@
|
||||
|
||||
#ifndef USERNOTIFY_H
|
||||
#define USERNOTIFY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class QToolBar;
|
||||
class QToolButton;
|
||||
class QAction;
|
||||
//class QListWidgetItem;
|
||||
|
||||
class UserNotify : public QObject
|
||||
{
|
||||
|
||||
#include <QObject>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class QToolBar;
|
||||
class QToolButton;
|
||||
class QAction;
|
||||
|
||||
class UserNotify : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UserNotify(QObject *parent = 0);
|
||||
|
||||
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem);
|
||||
void createIcons(QMenu *notifyMenu);
|
||||
|
||||
virtual bool hasSetting(QString &/*name*/) { return false; }
|
||||
public:
|
||||
UserNotify(QObject *parent = 0);
|
||||
virtual ~UserNotify();
|
||||
|
||||
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem);
|
||||
void createIcons(QMenu *notifyMenu);
|
||||
|
||||
virtual bool hasSetting(QString &/*name*/) { return false; }
|
||||
virtual bool notifyEnabled() { return false; }
|
||||
virtual bool notifyCombined() { return false; }
|
||||
virtual bool notifyBlink() { return false; }
|
||||
@ -57,6 +57,10 @@ private slots:
|
||||
void trayIconClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
||||
void blink(bool on);
|
||||
|
||||
protected:
|
||||
virtual void startUpdate();
|
||||
void update();
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon() { return QIcon(); }
|
||||
virtual QIcon getMainIcon(bool /*hasNew*/) { return QIcon(); }
|
||||
@ -66,13 +70,14 @@ private:
|
||||
virtual QString getNotifyMessage(bool plural);
|
||||
|
||||
virtual void iconClicked() {}
|
||||
|
||||
QToolButton *mMainToolButton;
|
||||
QAction *mMainAction;
|
||||
QListWidgetItem *mListItem;
|
||||
QSystemTrayIcon *mTrayIcon;
|
||||
QAction *mNotifyIcon;
|
||||
unsigned int mNewCount;
|
||||
|
||||
private:
|
||||
QToolButton *mMainToolButton;
|
||||
QAction *mMainAction;
|
||||
QListWidgetItem *mListItem;
|
||||
QSystemTrayIcon *mTrayIcon;
|
||||
QAction *mNotifyIcon;
|
||||
unsigned int mNewCount;
|
||||
QString mButtonText;
|
||||
bool mLastBlinking;
|
||||
};
|
||||
|
131
retroshare-gui/src/gui/gxs/GxsUserNotify.cpp
Normal file
131
retroshare-gui/src/gui/gxs/GxsUserNotify.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 "GxsUserNotify.h"
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
|
||||
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
|
||||
#define TOKEN_TYPE_STATISTICS 1
|
||||
#define TOKEN_TYPE_GROUP_META 2
|
||||
|
||||
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||
UserNotify(parent), TokenResponse()
|
||||
{
|
||||
mNewMessageCount = 0;
|
||||
|
||||
mInterface = ifaceImpl;
|
||||
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
|
||||
|
||||
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl);
|
||||
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(updateIcon()));
|
||||
}
|
||||
|
||||
GxsUserNotify::~GxsUserNotify()
|
||||
{
|
||||
if (mTokenQueue) {
|
||||
delete(mTokenQueue);
|
||||
}
|
||||
if (mBase) {
|
||||
delete(mBase);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsUserNotify::startUpdate()
|
||||
{
|
||||
// uint32_t token;
|
||||
// GxsServiceStatistic stats;
|
||||
// mInterface->getServiceStatistic(token, stats);
|
||||
// TokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
||||
|
||||
mNewMessageCount = 0;
|
||||
|
||||
/* Get all messages until statistics are available */
|
||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_META);
|
||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_STATISTICS);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, TOKEN_TYPE_GROUP_META);
|
||||
}
|
||||
|
||||
void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
if (queue == mTokenQueue) {
|
||||
/* now switch on req */
|
||||
switch(req.mUserType) {
|
||||
case TOKEN_TYPE_STATISTICS:
|
||||
{
|
||||
GxsMsgMetaMap msgList;
|
||||
mInterface->getMsgSummary(req.mToken, msgList);
|
||||
|
||||
GxsMsgMetaMap::const_iterator groupIt;
|
||||
for (groupIt = msgList.begin(); groupIt != msgList.end(); ++groupIt) {
|
||||
const std::vector<RsMsgMetaData> &groupData = groupIt->second;
|
||||
|
||||
std::vector<RsMsgMetaData>::const_iterator msgIt;
|
||||
for (msgIt = groupData.begin(); msgIt != groupData.end(); ++msgIt) {
|
||||
const RsMsgMetaData &metaData = *msgIt;
|
||||
if (IS_MSG_NEW(metaData.mMsgStatus)) {
|
||||
++mNewMessageCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
break;
|
||||
case TOKEN_TYPE_GROUP_META:
|
||||
{
|
||||
std::list<RsGroupMetaData> groupMeta;
|
||||
mInterface->getGroupSummary(req.mToken, groupMeta);
|
||||
|
||||
if (!groupMeta.size()) {
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
std::list<RsGroupMetaData>::const_iterator groupIt;
|
||||
for (groupIt = groupMeta.begin(); groupIt != groupMeta.end(); groupIt++) {
|
||||
uint32_t flags = groupIt->mSubscribeFlags;
|
||||
if (IS_GROUP_SUBSCRIBED(flags)) {
|
||||
groupIds.push_back(groupIt->mGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!groupIds.size()) {
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_STATISTICS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
56
retroshare-gui/src/gui/gxs/GxsUserNotify.h
Normal file
56
retroshare-gui/src/gui/gxs/GxsUserNotify.h
Normal file
@ -0,0 +1,56 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 GXSUSERNOTIFY_H
|
||||
#define GXSUSERNOTIFY_H
|
||||
|
||||
#include <QObject>
|
||||
#include "gui/common/UserNotify.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class RsGxsIfaceHelper;
|
||||
class RsGxsUpdateBroadcastBase;
|
||||
|
||||
class GxsUserNotify : public UserNotify, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||
virtual ~GxsUserNotify();
|
||||
|
||||
/* TokenResponse */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected:
|
||||
virtual void startUpdate();
|
||||
|
||||
private:
|
||||
virtual unsigned int getNewCount() { return mNewMessageCount; }
|
||||
|
||||
private:
|
||||
RsGxsIfaceHelper *mInterface;
|
||||
TokenQueue *mTokenQueue;
|
||||
RsGxsUpdateBroadcastBase *mBase;
|
||||
unsigned int mNewMessageCount;
|
||||
};
|
||||
|
||||
#endif // GXSUSERNOTIFY_H
|
@ -22,6 +22,7 @@
|
||||
#include "GxsChannelDialog.h"
|
||||
#include "GxsChannelGroupDialog.h"
|
||||
#include "GxsChannelPostsWidget.h"
|
||||
#include "GxsChannelUserNotify.h"
|
||||
#include "gui/channels/ShareKey.h"
|
||||
#include "gui/feeds/GxsChannelPostItem.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
@ -44,10 +45,10 @@ GxsChannelDialog::~GxsChannelDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//UserNotify *GxsChannelDialog::getUserNotify(QObject *parent)
|
||||
//{
|
||||
// return new ChannelUserNotify(parent);
|
||||
//}
|
||||
UserNotify *GxsChannelDialog::getUserNotify(QObject *parent)
|
||||
{
|
||||
return new GxsChannelUserNotify(rsGxsChannels, parent);
|
||||
}
|
||||
|
||||
QString GxsChannelDialog::text(TextType type)
|
||||
{
|
||||
|
@ -40,7 +40,8 @@ public:
|
||||
virtual QString pageName() const { return tr("Channels") ; } //MainPage
|
||||
virtual QString helpText() const { return ""; } //MainPage
|
||||
|
||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||
virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
protected:
|
||||
RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||
private slots:
|
||||
|
93
retroshare-gui/src/gui/gxschannels/GxsChannelUserNotify.cpp
Normal file
93
retroshare-gui/src/gui/gxschannels/GxsChannelUserNotify.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 "GxsChannelUserNotify.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||
GxsUserNotify(ifaceImpl, parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool GxsChannelUserNotify::hasSetting(QString &name)
|
||||
{
|
||||
name = tr("Channel Post");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GxsChannelUserNotify::notifyEnabled()
|
||||
{
|
||||
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_CHANNELS);
|
||||
}
|
||||
|
||||
bool GxsChannelUserNotify::notifyCombined()
|
||||
{
|
||||
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_CHANNELS_COMBINED);
|
||||
}
|
||||
|
||||
bool GxsChannelUserNotify::notifyBlink()
|
||||
{
|
||||
return (Settings->getTrayNotifyBlinkFlags() & TRAYNOTIFY_BLINK_CHANNELS);
|
||||
}
|
||||
|
||||
void GxsChannelUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
|
||||
{
|
||||
uint notifyFlags = Settings->getTrayNotifyFlags();
|
||||
uint blinkFlags = Settings->getTrayNotifyBlinkFlags();
|
||||
|
||||
if (enabled) {
|
||||
notifyFlags |= TRAYNOTIFY_CHANNELS;
|
||||
} else {
|
||||
notifyFlags &= ~TRAYNOTIFY_CHANNELS;
|
||||
}
|
||||
|
||||
if (combined) {
|
||||
notifyFlags |= TRAYNOTIFY_CHANNELS_COMBINED;
|
||||
} else {
|
||||
notifyFlags &= ~TRAYNOTIFY_CHANNELS_COMBINED;
|
||||
}
|
||||
|
||||
if (blink) {
|
||||
blinkFlags |= TRAYNOTIFY_BLINK_CHANNELS;
|
||||
} else {
|
||||
blinkFlags &= ~TRAYNOTIFY_BLINK_CHANNELS;
|
||||
}
|
||||
|
||||
Settings->setTrayNotifyFlags(notifyFlags);
|
||||
Settings->setTrayNotifyBlinkFlags(blinkFlags);
|
||||
}
|
||||
|
||||
QIcon GxsChannelUserNotify::getIcon()
|
||||
{
|
||||
return QIcon(":/images/channels16.png");
|
||||
}
|
||||
|
||||
QIcon GxsChannelUserNotify::getMainIcon(bool hasNew)
|
||||
{
|
||||
return hasNew ? QIcon(":/images/channels_new.png") : QIcon(":/images/channels.png");
|
||||
}
|
||||
|
||||
void GxsChannelUserNotify::iconClicked()
|
||||
{
|
||||
MainWindow::showWindow(MainWindow::Channels);
|
||||
}
|
46
retroshare-gui/src/gui/gxschannels/GxsChannelUserNotify.h
Normal file
46
retroshare-gui/src/gui/gxschannels/GxsChannelUserNotify.h
Normal file
@ -0,0 +1,46 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 GXSCHANNELUSERNOTIFY_H
|
||||
#define GXSCHANNELUSERNOTIFY_H
|
||||
|
||||
#include "gui/gxs/GxsUserNotify.h"
|
||||
|
||||
class GxsChannelUserNotify : public GxsUserNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString &name);
|
||||
virtual bool notifyEnabled();
|
||||
virtual bool notifyCombined();
|
||||
virtual bool notifyBlink();
|
||||
virtual void setNotifyEnabled(bool enabled, bool combined, bool blink);
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual void iconClicked();
|
||||
};
|
||||
|
||||
#endif // GXSCHANNELUSERNOTIFY_H
|
93
retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.cpp
Normal file
93
retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 "GxsForumUserNotify.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||
GxsUserNotify(ifaceImpl, parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool GxsForumUserNotify::hasSetting(QString &name)
|
||||
{
|
||||
name = tr("Forum Post");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GxsForumUserNotify::notifyEnabled()
|
||||
{
|
||||
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_FORUMS);
|
||||
}
|
||||
|
||||
bool GxsForumUserNotify::notifyCombined()
|
||||
{
|
||||
return (Settings->getTrayNotifyFlags() & TRAYNOTIFY_FORUMS_COMBINED);
|
||||
}
|
||||
|
||||
bool GxsForumUserNotify::notifyBlink()
|
||||
{
|
||||
return (Settings->getTrayNotifyBlinkFlags() & TRAYNOTIFY_BLINK_FORUMS);
|
||||
}
|
||||
|
||||
void GxsForumUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
|
||||
{
|
||||
uint notifyFlags = Settings->getTrayNotifyFlags();
|
||||
uint blinkFlags = Settings->getTrayNotifyBlinkFlags();
|
||||
|
||||
if (enabled) {
|
||||
notifyFlags |= TRAYNOTIFY_FORUMS;
|
||||
} else {
|
||||
notifyFlags &= ~TRAYNOTIFY_FORUMS;
|
||||
}
|
||||
|
||||
if (combined) {
|
||||
notifyFlags |= TRAYNOTIFY_FORUMS_COMBINED;
|
||||
} else {
|
||||
notifyFlags &= ~TRAYNOTIFY_FORUMS_COMBINED;
|
||||
}
|
||||
|
||||
if (blink) {
|
||||
blinkFlags |= TRAYNOTIFY_BLINK_FORUMS;
|
||||
} else {
|
||||
blinkFlags &= ~TRAYNOTIFY_BLINK_FORUMS;
|
||||
}
|
||||
|
||||
Settings->setTrayNotifyFlags(notifyFlags);
|
||||
Settings->setTrayNotifyBlinkFlags(blinkFlags);
|
||||
}
|
||||
|
||||
QIcon GxsForumUserNotify::getIcon()
|
||||
{
|
||||
return QIcon(":/images/konversation16.png");
|
||||
}
|
||||
|
||||
QIcon GxsForumUserNotify::getMainIcon(bool hasNew)
|
||||
{
|
||||
return hasNew ? QIcon(":/images/forums_new.png") : QIcon(":/images/konversation.png");
|
||||
}
|
||||
|
||||
void GxsForumUserNotify::iconClicked()
|
||||
{
|
||||
MainWindow::showWindow(MainWindow::Forums);
|
||||
}
|
46
retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.h
Normal file
46
retroshare-gui/src/gui/gxsforums/GxsForumUserNotify.h
Normal file
@ -0,0 +1,46 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 GXSFORUMUSERNOTIFY_H
|
||||
#define GXSFORUMUSERNOTIFY_H
|
||||
|
||||
#include "gui/gxs/GxsUserNotify.h"
|
||||
|
||||
class GxsForumUserNotify : public GxsUserNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
||||
|
||||
virtual bool hasSetting(QString &name);
|
||||
virtual bool notifyEnabled();
|
||||
virtual bool notifyCombined();
|
||||
virtual bool notifyBlink();
|
||||
virtual void setNotifyEnabled(bool enabled, bool combined, bool blink);
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
virtual void iconClicked();
|
||||
};
|
||||
|
||||
#endif // FORUMUSERNOTIFY_H
|
@ -22,6 +22,7 @@
|
||||
#include "GxsForumsDialog.h"
|
||||
#include "GxsForumGroupDialog.h"
|
||||
#include "GxsForumThreadWidget.h"
|
||||
#include "GxsForumUserNotify.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/channels/ShareKey.h"
|
||||
@ -44,10 +45,10 @@ GxsForumsDialog::~GxsForumsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//UserNotify *GxsForumsDialog::getUserNotify(QObject *parent)
|
||||
//{
|
||||
// return new GxsForumUserNotify(parent);
|
||||
//}
|
||||
UserNotify *GxsForumsDialog::getUserNotify(QObject *parent)
|
||||
{
|
||||
return new GxsForumUserNotify(rsGxsForums, parent);
|
||||
}
|
||||
|
||||
QString GxsForumsDialog::text(TextType type)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
virtual QString pageName() const { return tr("Forums") ; } //MainPage
|
||||
virtual QString helpText() const { return ""; } //MainPage
|
||||
|
||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||
virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -1125,7 +1125,8 @@ gxsforums {
|
||||
gui/gxsforums/GxsForumGroupDialog.h \
|
||||
gui/gxsforums/CreateGxsForumMsg.h \
|
||||
gui/gxsforums/GxsForumThreadWidget.h \
|
||||
gui/gxsforums/GxsForumsFillThread.h
|
||||
gui/gxsforums/GxsForumsFillThread.h \
|
||||
gui/gxsforums/GxsForumUserNotify.h
|
||||
|
||||
FORMS += gui/gxsforums/CreateGxsForumMsg.ui \
|
||||
gui/gxsforums/GxsForumThreadWidget.ui
|
||||
@ -1134,7 +1135,8 @@ gxsforums {
|
||||
gui/gxsforums/GxsForumGroupDialog.cpp \
|
||||
gui/gxsforums/CreateGxsForumMsg.cpp \
|
||||
gui/gxsforums/GxsForumThreadWidget.cpp \
|
||||
gui/gxsforums/GxsForumsFillThread.cpp
|
||||
gui/gxsforums/GxsForumsFillThread.cpp \
|
||||
gui/gxsforums/GxsForumUserNotify.cpp
|
||||
}
|
||||
|
||||
|
||||
@ -1144,7 +1146,8 @@ gxschannels {
|
||||
gui/gxschannels/GxsChannelGroupDialog.h \
|
||||
gui/gxschannels/CreateGxsChannelMsg.h \
|
||||
gui/gxschannels/GxsChannelPostsWidget.h \
|
||||
gui/feeds/GxsChannelPostItem.h
|
||||
gui/feeds/GxsChannelPostItem.h \
|
||||
gui/gxschannels/GxsChannelUserNotify.h
|
||||
|
||||
FORMS += gui/gxschannels/GxsChannelPostsWidget.ui \
|
||||
gui/gxschannels/CreateGxsChannelMsg.ui \
|
||||
@ -1154,7 +1157,8 @@ gxschannels {
|
||||
gui/gxschannels/GxsChannelPostsWidget.cpp \
|
||||
gui/gxschannels/GxsChannelGroupDialog.cpp \
|
||||
gui/gxschannels/CreateGxsChannelMsg.cpp \
|
||||
gui/feeds/GxsChannelPostItem.cpp
|
||||
gui/feeds/GxsChannelPostItem.cpp \
|
||||
gui/gxschannels/GxsChannelUserNotify.cpp
|
||||
}
|
||||
|
||||
|
||||
@ -1211,6 +1215,7 @@ gxsgui {
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastPage.h \
|
||||
gui/gxs/GxsUserNotify.h \
|
||||
util/TokenQueue.h \
|
||||
util/RsGxsUpdateBroadcast.h \
|
||||
|
||||
@ -1244,6 +1249,7 @@ gxsgui {
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastPage.cpp \
|
||||
gui/gxs/GxsUserNotify.cpp \
|
||||
util/TokenQueue.cpp \
|
||||
util/RsGxsUpdateBroadcast.cpp \
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user