mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added two buttons to the NotifyPage to show examples of the activated news feeds and toasters.
Can also be used to test the stylesheets. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5510 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
61429b0ddd
commit
345187262d
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
#include <retroshare/rsnotify.h>
|
#include <retroshare/rsnotify.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
|
#include <retroshare/rschannels.h>
|
||||||
|
#include <retroshare/rsforums.h>
|
||||||
|
#include <retroshare/rsmsgs.h>
|
||||||
|
|
||||||
#include "feeds/ChanNewItem.h"
|
#include "feeds/ChanNewItem.h"
|
||||||
#include "feeds/ChanMsgItem.h"
|
#include "feeds/ChanMsgItem.h"
|
||||||
@ -62,6 +65,8 @@ const uint32_t NEWSFEED_SECLIST = 0x000a;
|
|||||||
* #define NEWS_DEBUG 1
|
* #define NEWS_DEBUG 1
|
||||||
****/
|
****/
|
||||||
|
|
||||||
|
static NewsFeed *instance = NULL;
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
NewsFeed::NewsFeed(QWidget *parent)
|
NewsFeed::NewsFeed(QWidget *parent)
|
||||||
: MainPage (parent)
|
: MainPage (parent)
|
||||||
@ -69,15 +74,25 @@ NewsFeed::NewsFeed(QWidget *parent)
|
|||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
if (!instance) {
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
|
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
|
||||||
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
||||||
|
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NewsFeed::~NewsFeed()
|
||||||
|
{
|
||||||
|
if (instance == this) {
|
||||||
|
instance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NewsFeed::updateFeed()
|
void NewsFeed::updateFeed()
|
||||||
{
|
{
|
||||||
if (!rsNotify)
|
if (!rsNotify)
|
||||||
@ -162,14 +177,17 @@ void NewsFeed::updateFeed()
|
|||||||
if (flags & RS_FEED_TYPE_BLOG)
|
if (flags & RS_FEED_TYPE_BLOG)
|
||||||
addFeedItemBlogMsg(fi);
|
addFeedItemBlogMsg(fi);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RS_FEED_ITEM_CHAT_NEW:
|
case RS_FEED_ITEM_CHAT_NEW:
|
||||||
if (flags & RS_FEED_TYPE_CHAT)
|
if (flags & RS_FEED_TYPE_CHAT)
|
||||||
addFeedItemChatNew(fi);
|
addFeedItemChatNew(fi, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RS_FEED_ITEM_MESSAGE:
|
case RS_FEED_ITEM_MESSAGE:
|
||||||
if (flags & RS_FEED_TYPE_MSG)
|
if (flags & RS_FEED_TYPE_MSG)
|
||||||
addFeedItemMessage(fi);
|
addFeedItemMessage(fi);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RS_FEED_ITEM_FILES_NEW:
|
case RS_FEED_ITEM_FILES_NEW:
|
||||||
if (flags & RS_FEED_TYPE_FILES)
|
if (flags & RS_FEED_TYPE_FILES)
|
||||||
addFeedItemFilesNew(fi);
|
addFeedItemFilesNew(fi);
|
||||||
@ -180,6 +198,199 @@ void NewsFeed::updateFeed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewsFeed::testFeeds(uint notifyFlags)
|
||||||
|
{
|
||||||
|
if (!instance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint pos = 0;
|
||||||
|
|
||||||
|
while (notifyFlags) {
|
||||||
|
uint type = notifyFlags & (1 << pos);
|
||||||
|
notifyFlags &= ~(1 << pos);
|
||||||
|
++pos;
|
||||||
|
|
||||||
|
RsFeedItem fi;
|
||||||
|
|
||||||
|
switch(type) {
|
||||||
|
case RS_FEED_TYPE_PEER:
|
||||||
|
fi.mId1 = rsPeers->getOwnId();
|
||||||
|
|
||||||
|
instance->addFeedItemPeerConnect(fi);
|
||||||
|
instance->addFeedItemPeerDisconnect(fi);
|
||||||
|
instance->addFeedItemPeerNew(fi);
|
||||||
|
instance->addFeedItemPeerHello(fi);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_SECURITY:
|
||||||
|
fi.mId1 = rsPeers->getGPGOwnId();
|
||||||
|
fi.mId2 = rsPeers->getOwnId();
|
||||||
|
|
||||||
|
instance->addFeedItemSecurityConnectAttempt(fi);
|
||||||
|
instance->addFeedItemSecurityAuthDenied(fi);
|
||||||
|
instance->addFeedItemSecurityUnknownIn(fi);
|
||||||
|
instance->addFeedItemSecurityUnknownOut(fi);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_CHAN:
|
||||||
|
{
|
||||||
|
std::list<ChannelInfo> channelList;
|
||||||
|
rsChannels->getChannelList(channelList);
|
||||||
|
|
||||||
|
std::list<ChannelInfo>::iterator channelIt;
|
||||||
|
for (channelIt = channelList.begin(); channelIt != channelList.end(); ++channelIt) {
|
||||||
|
if (fi.mId1.empty()) {
|
||||||
|
/* store first channel */
|
||||||
|
fi.mId1 = channelIt->channelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!channelIt->channelDesc.empty()) {
|
||||||
|
/* take channel with description */
|
||||||
|
fi.mId1 = channelIt->channelId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance->addFeedItemChanNew(fi);
|
||||||
|
instance->addFeedItemChanUpdate(fi);
|
||||||
|
|
||||||
|
RsFeedItem fiMsg;
|
||||||
|
bool bFound = false;
|
||||||
|
|
||||||
|
for (channelIt = channelList.begin(); channelIt != channelList.end(); ++channelIt) {
|
||||||
|
std::list<ChannelMsgSummary> channelMsgs;
|
||||||
|
rsChannels->getChannelMsgList(channelIt->channelId, channelMsgs);
|
||||||
|
|
||||||
|
std::list<ChannelMsgSummary>::iterator msgIt;
|
||||||
|
for (msgIt = channelMsgs.begin(); msgIt != channelMsgs.end(); ++msgIt) {
|
||||||
|
if (fiMsg.mId2.empty()) {
|
||||||
|
/* store first channel message */
|
||||||
|
fiMsg.mId1 = msgIt->channelId;
|
||||||
|
fiMsg.mId2 = msgIt->msgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msgIt->msg.empty()) {
|
||||||
|
/* take channel message with description */
|
||||||
|
fiMsg.mId1 = msgIt->channelId;
|
||||||
|
fiMsg.mId2 = msgIt->msgId;
|
||||||
|
bFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bFound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance->addFeedItemChanMsg(fiMsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_FORUM:
|
||||||
|
{
|
||||||
|
std::list<ForumInfo> forumList;
|
||||||
|
rsForums->getForumList(forumList);
|
||||||
|
|
||||||
|
std::list<ForumInfo>::iterator forumIt;
|
||||||
|
for (forumIt = forumList.begin(); forumIt != forumList.end(); ++forumIt) {
|
||||||
|
if (fi.mId1.empty()) {
|
||||||
|
/* store first forum */
|
||||||
|
fi.mId1 = forumIt->forumId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!forumIt->forumDesc.empty()) {
|
||||||
|
/* take forum with description */
|
||||||
|
fi.mId1 = forumIt->forumId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance->addFeedItemForumNew(fi);
|
||||||
|
instance->addFeedItemForumUpdate(fi);
|
||||||
|
|
||||||
|
RsFeedItem fiMsg;
|
||||||
|
bool bFound = false;
|
||||||
|
|
||||||
|
for (forumIt = forumList.begin(); forumIt != forumList.end(); ++forumIt) {
|
||||||
|
std::list<ThreadInfoSummary> forumMsgs;
|
||||||
|
rsForums->getForumThreadList(forumIt->forumId, forumMsgs);
|
||||||
|
|
||||||
|
std::list<ThreadInfoSummary>::iterator msgIt;
|
||||||
|
for (msgIt = forumMsgs.begin(); msgIt != forumMsgs.end(); ++msgIt) {
|
||||||
|
if (fiMsg.mId2.empty()) {
|
||||||
|
/* store first forum message */
|
||||||
|
fiMsg.mId1 = msgIt->forumId;
|
||||||
|
fiMsg.mId2 = msgIt->msgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msgIt->msg.empty()) {
|
||||||
|
/* take channel message with description */
|
||||||
|
fiMsg.mId1 = msgIt->forumId;
|
||||||
|
fiMsg.mId2 = msgIt->msgId;
|
||||||
|
bFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bFound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance->addFeedItemForumMsg(fiMsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_BLOG:
|
||||||
|
// not used
|
||||||
|
// instance->addFeedItemBlogNew(fi);
|
||||||
|
// instance->addFeedItemBlogMsg(fi);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_CHAT:
|
||||||
|
fi.mId1 = rsPeers->getOwnId();
|
||||||
|
fi.mId2 = tr("This is a test.").toUtf8().constData();
|
||||||
|
|
||||||
|
instance->addFeedItemChatNew(fi, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_MSG:
|
||||||
|
{
|
||||||
|
std::list<MsgInfoSummary> msgList;
|
||||||
|
rsMsgs->getMessageSummaries(msgList);
|
||||||
|
|
||||||
|
std::list<MsgInfoSummary>::const_iterator msgIt;
|
||||||
|
for (msgIt = msgList.begin(); msgIt != msgList.end(); ++msgIt) {
|
||||||
|
if (fi.mId1.empty()) {
|
||||||
|
/* store first message */
|
||||||
|
fi.mId1 = msgIt->msgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msgIt->msgflags & RS_MSG_TRASH) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((msgIt->msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX) {
|
||||||
|
/* take message from inbox */
|
||||||
|
fi.mId1 = msgIt->msgId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance->addFeedItemMessage(fi);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RS_FEED_TYPE_FILES:
|
||||||
|
// not used
|
||||||
|
// instance->addFeedItemFilesNew(fi);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NewsFeed::addFeedItem(QWidget *item)
|
void NewsFeed::addFeedItem(QWidget *item)
|
||||||
{
|
{
|
||||||
item->setAttribute(Qt::WA_DeleteOnClose, true);
|
item->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
@ -485,14 +696,14 @@ void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewsFeed::addFeedItemChatNew(RsFeedItem &fi)
|
void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck)
|
||||||
{
|
{
|
||||||
#ifdef NEWS_DEBUG
|
#ifdef NEWS_DEBUG
|
||||||
std::cerr << "NewsFeed::addFeedItemChatNew()";
|
std::cerr << "NewsFeed::addFeedItemChatNew()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fi.mId1 == rsPeers->getOwnId()) {
|
if (!addWithoutCheck && fi.mId1 == rsPeers->getOwnId()) {
|
||||||
/* chat message from myself */
|
/* chat message from myself */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,14 @@ public:
|
|||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
NewsFeed(QWidget *parent = 0);
|
NewsFeed(QWidget *parent = 0);
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
|
virtual ~NewsFeed();
|
||||||
|
|
||||||
/* FeedHolder Functions (for FeedItem functionality) */
|
/* FeedHolder Functions (for FeedItem functionality) */
|
||||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||||
virtual void openChat(std::string peerId);
|
virtual void openChat(std::string peerId);
|
||||||
|
|
||||||
|
static void testFeeds(uint notifyFlags);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newsFeedChanged(int count);
|
void newsFeedChanged(int count);
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ private:
|
|||||||
void addFeedItemForumMsg(RsFeedItem &fi);
|
void addFeedItemForumMsg(RsFeedItem &fi);
|
||||||
void addFeedItemBlogNew(RsFeedItem &fi);
|
void addFeedItemBlogNew(RsFeedItem &fi);
|
||||||
void addFeedItemBlogMsg(RsFeedItem &fi);
|
void addFeedItemBlogMsg(RsFeedItem &fi);
|
||||||
void addFeedItemChatNew(RsFeedItem &fi);
|
void addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck);
|
||||||
void addFeedItemMessage(RsFeedItem &fi);
|
void addFeedItemMessage(RsFeedItem &fi);
|
||||||
void addFeedItemFilesNew(RsFeedItem &fi);
|
void addFeedItemFilesNew(RsFeedItem &fi);
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "notifyqt.h"
|
#include "notifyqt.h"
|
||||||
#include <retroshare/rsnotify.h>
|
#include <retroshare/rsnotify.h>
|
||||||
|
#include <retroshare/rspeers.h>
|
||||||
|
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
|
||||||
@ -56,6 +57,11 @@ public:
|
|||||||
{
|
{
|
||||||
this->widget = widget;
|
this->widget = widget;
|
||||||
|
|
||||||
|
/* Values from settings */
|
||||||
|
position = Settings->getToasterPosition();
|
||||||
|
Settings->getToasterMargin();
|
||||||
|
|
||||||
|
|
||||||
/* Standard values */
|
/* Standard values */
|
||||||
timeToShow = 500;
|
timeToShow = 500;
|
||||||
timeToLive = 3000;
|
timeToLive = 3000;
|
||||||
@ -70,6 +76,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
QWidget *widget;
|
QWidget *widget;
|
||||||
|
|
||||||
|
/* Values from settings */
|
||||||
|
RshareSettings::enumToasterPosition position;
|
||||||
|
QPoint margin;
|
||||||
|
|
||||||
/* Standard values */
|
/* Standard values */
|
||||||
int timeToShow;
|
int timeToShow;
|
||||||
int timeToLive;
|
int timeToLive;
|
||||||
@ -662,7 +672,7 @@ void NotifyQt::UpdateGUI()
|
|||||||
toaster = new Toaster(new ChatLobbyToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
toaster = new Toaster(new ChatLobbyToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RS_POPUP_CONNECT_ATTEMPT:
|
case RS_POPUP_CONNECT_ATTEMPT:
|
||||||
if (popupflags & RS_POPUP_CONNECT_ATTEMPT)
|
if (popupflags & RS_POPUP_CONNECT_ATTEMPT)
|
||||||
{
|
{
|
||||||
// id = gpgid
|
// id = gpgid
|
||||||
@ -725,6 +735,60 @@ void NotifyQt::UpdateGUI()
|
|||||||
startWaitingToasters();
|
startWaitingToasters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
|
||||||
|
{
|
||||||
|
QString title = tr("Test");
|
||||||
|
QString message = tr("This is a test.");
|
||||||
|
|
||||||
|
std::string id = rsPeers->getOwnId();
|
||||||
|
|
||||||
|
uint pos = 0;
|
||||||
|
|
||||||
|
while (notifyFlags) {
|
||||||
|
uint type = notifyFlags & (1 << pos);
|
||||||
|
notifyFlags &= ~(1 << pos);
|
||||||
|
++pos;
|
||||||
|
|
||||||
|
Toaster *toaster = NULL;
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case RS_POPUP_MSG:
|
||||||
|
toaster = new Toaster(new MessageToaster(id, title, message));
|
||||||
|
break;
|
||||||
|
case RS_POPUP_CONNECT:
|
||||||
|
toaster = new Toaster(new OnlineToaster(id));
|
||||||
|
break;
|
||||||
|
case RS_POPUP_DOWNLOAD:
|
||||||
|
toaster = new Toaster(new DownloadToaster(id, title));
|
||||||
|
break;
|
||||||
|
case RS_POPUP_CHAT:
|
||||||
|
toaster = new Toaster(new ChatToaster(id, message));
|
||||||
|
break;
|
||||||
|
case RS_POPUP_GROUPCHAT:
|
||||||
|
toaster = new Toaster(new GroupChatToaster(id, message));
|
||||||
|
break;
|
||||||
|
case RS_POPUP_CHATLOBBY:
|
||||||
|
toaster = new Toaster(new ChatLobbyToaster(id, title, message));
|
||||||
|
break;
|
||||||
|
case RS_POPUP_CONNECT_ATTEMPT:
|
||||||
|
toaster = new Toaster(new FriendRequestToaster(id, title, id));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toaster) {
|
||||||
|
/* init attributes */
|
||||||
|
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||||
|
toaster->position = (RshareSettings::enumToasterPosition) position;
|
||||||
|
toaster->margin = margin;
|
||||||
|
|
||||||
|
/* add toaster to waiting list */
|
||||||
|
// QMutexLocker lock(&waitingToasterMutex);
|
||||||
|
waitingToasterList.push_back(toaster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType)
|
void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -777,26 +841,23 @@ void NotifyQt::startWaitingToasters()
|
|||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());
|
QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());
|
||||||
|
|
||||||
RshareSettings::enumToasterPosition position = Settings->getToasterPosition();
|
switch (toaster->position) {
|
||||||
QPoint margin = Settings->getToasterMargin();
|
|
||||||
|
|
||||||
switch (position) {
|
|
||||||
case RshareSettings::TOASTERPOS_TOPLEFT:
|
case RshareSettings::TOASTERPOS_TOPLEFT:
|
||||||
toaster->startPos = QPoint(desktopGeometry.left() + margin.x(), desktopGeometry.top() - size.height());
|
toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.top() - size.height());
|
||||||
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + margin.y());
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y());
|
||||||
break;
|
break;
|
||||||
case RshareSettings::TOASTERPOS_TOPRIGHT:
|
case RshareSettings::TOASTERPOS_TOPRIGHT:
|
||||||
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - margin.x(), desktopGeometry.top() - size.height());
|
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.top() - size.height());
|
||||||
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + margin.y());
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y());
|
||||||
break;
|
break;
|
||||||
case RshareSettings::TOASTERPOS_BOTTOMLEFT:
|
case RshareSettings::TOASTERPOS_BOTTOMLEFT:
|
||||||
toaster->startPos = QPoint(desktopGeometry.left() + margin.x(), desktopGeometry.bottom());
|
toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.bottom());
|
||||||
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - margin.y());
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y());
|
||||||
break;
|
break;
|
||||||
case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default
|
case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default
|
||||||
default:
|
default:
|
||||||
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - margin.x(), desktopGeometry.bottom());
|
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.bottom());
|
||||||
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - margin.y());
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <retroshare/rsturtle.h>
|
#include <retroshare/rsturtle.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QPoint>
|
||||||
//#include <QMutex>
|
//#include <QMutex>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -62,6 +63,8 @@ class NotifyQt: public QObject, public NotifyBase
|
|||||||
/* Notify from GUI */
|
/* Notify from GUI */
|
||||||
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||||
|
|
||||||
|
void testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
|
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
|
||||||
// as they get queued by Qt.
|
// as they get queued by Qt.
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
#include "gui/common/UserNotify.h"
|
#include "gui/common/UserNotify.h"
|
||||||
|
#include "gui/notifyqt.h"
|
||||||
|
#include "gui/NewsFeed.h"
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
||||||
@ -36,6 +38,9 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
|||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
connect(ui.notifyButton, SIGNAL(clicked()), this, SLOT(testNotify()));
|
||||||
|
connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
|
||||||
|
|
||||||
/* add user notify */
|
/* add user notify */
|
||||||
QFont font = ui.notify_Peers->font(); // use font from existing checkbox
|
QFont font = ui.notify_Peers->font(); // use font from existing checkbox
|
||||||
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
||||||
@ -71,49 +76,59 @@ NotifyPage::~NotifyPage()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint NotifyPage::getNewsFlags()
|
||||||
|
{
|
||||||
|
uint newsFlags = 0;
|
||||||
|
|
||||||
|
if (ui.notify_Peers->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_PEER;
|
||||||
|
if (ui.notify_Channels->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_CHAN;
|
||||||
|
if (ui.notify_Forums->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_FORUM;
|
||||||
|
if (ui.notify_Blogs->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_BLOG;
|
||||||
|
if (ui.notify_Messages->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_MSG;
|
||||||
|
if (ui.notify_Chat->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_CHAT;
|
||||||
|
if (ui.notify_Security->isChecked())
|
||||||
|
newsFlags |= RS_FEED_TYPE_SECURITY;
|
||||||
|
|
||||||
|
return newsFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint NotifyPage::getNotifyFlags()
|
||||||
|
{
|
||||||
|
uint notifyFlags = 0;
|
||||||
|
|
||||||
|
if (ui.popup_Connect->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_CONNECT;
|
||||||
|
if (ui.popup_NewMsg->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_MSG;
|
||||||
|
if (ui.popup_DownloadFinished->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_DOWNLOAD;
|
||||||
|
if (ui.popup_PrivateChat->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_CHAT;
|
||||||
|
if (ui.popup_GroupChat->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_GROUPCHAT;
|
||||||
|
if (ui.popup_ChatLobby->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_CHATLOBBY;
|
||||||
|
if (ui.popup_ConnectAttempt->isChecked())
|
||||||
|
notifyFlags |= RS_POPUP_CONNECT_ATTEMPT;
|
||||||
|
|
||||||
|
return notifyFlags;
|
||||||
|
}
|
||||||
|
|
||||||
/** Saves the changes on this page */
|
/** Saves the changes on this page */
|
||||||
bool
|
bool
|
||||||
NotifyPage::save(QString &/*errmsg*/)
|
NotifyPage::save(QString &/*errmsg*/)
|
||||||
{
|
{
|
||||||
/* extract from rsNotify the flags */
|
/* extract from rsNotify the flags */
|
||||||
|
|
||||||
uint notifyflags = 0;
|
|
||||||
uint newsflags = 0;
|
|
||||||
uint chatflags = 0;
|
uint chatflags = 0;
|
||||||
uint messageflags = 0;
|
uint messageflags = 0;
|
||||||
|
|
||||||
if (ui.popup_Connect->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_CONNECT;
|
|
||||||
if (ui.popup_NewMsg->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_MSG;
|
|
||||||
if (ui.popup_DownloadFinished->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_DOWNLOAD;
|
|
||||||
if (ui.popup_PrivateChat->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_CHAT;
|
|
||||||
if (ui.popup_GroupChat->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_GROUPCHAT;
|
|
||||||
if (ui.popup_ChatLobby->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_CHATLOBBY;
|
|
||||||
if (ui.popup_ConnectAttempt->isChecked())
|
|
||||||
notifyflags |= RS_POPUP_CONNECT_ATTEMPT;
|
|
||||||
|
|
||||||
if (ui.notify_Peers->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_PEER;
|
|
||||||
if (ui.notify_Channels->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_CHAN;
|
|
||||||
if (ui.notify_Forums->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_FORUM;
|
|
||||||
if (ui.notify_Blogs->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_BLOG;
|
|
||||||
if (ui.notify_Chat->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_CHAT;
|
|
||||||
if (ui.notify_Messages->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_MSG;
|
|
||||||
if (ui.notify_Chat->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_CHAT;
|
|
||||||
if (ui.notify_Security->isChecked())
|
|
||||||
newsflags |= RS_FEED_TYPE_SECURITY;
|
|
||||||
|
|
||||||
if (ui.chat_NewWindow->isChecked())
|
if (ui.chat_NewWindow->isChecked())
|
||||||
chatflags |= RS_CHAT_OPEN;
|
chatflags |= RS_CHAT_OPEN;
|
||||||
if (ui.chat_Focus->isChecked())
|
if (ui.chat_Focus->isChecked())
|
||||||
@ -130,8 +145,8 @@ NotifyPage::save(QString &/*errmsg*/)
|
|||||||
notifyIt->mUserNotify->setNotifyEnabled(notifyIt->mEnabledCheckBox->isChecked(), notifyIt->mCombinedCheckBox->isChecked());
|
notifyIt->mUserNotify->setNotifyEnabled(notifyIt->mEnabledCheckBox->isChecked(), notifyIt->mCombinedCheckBox->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings->setNotifyFlags(notifyflags);
|
Settings->setNotifyFlags(getNotifyFlags());
|
||||||
Settings->setNewsFeedFlags(newsflags);
|
Settings->setNewsFeedFlags(getNewsFlags());
|
||||||
Settings->setChatFlags(chatflags);
|
Settings->setChatFlags(chatflags);
|
||||||
Settings->setMessageFlags(messageflags);
|
Settings->setMessageFlags(messageflags);
|
||||||
|
|
||||||
@ -235,3 +250,13 @@ void NotifyPage::notifyToggled()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotifyPage::testNotify()
|
||||||
|
{
|
||||||
|
NewsFeed::testFeeds(getNewsFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyPage::testToaster()
|
||||||
|
{
|
||||||
|
NotifyQt::getInstance()->testToaster(getNotifyFlags(), (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt(), QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()));
|
||||||
|
}
|
||||||
|
@ -59,8 +59,13 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void notifyToggled();
|
void notifyToggled();
|
||||||
|
void testToaster();
|
||||||
|
void testNotify();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint getNewsFlags();
|
||||||
|
uint getNotifyFlags();
|
||||||
|
|
||||||
QList<UserNotifySetting> mUserNotifySettingList;
|
QList<UserNotifySetting> mUserNotifySettingList;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>News Feed</string>
|
<string>News Feed</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -26,67 +26,95 @@
|
|||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="notify_Peers">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Peers</string>
|
<widget class="QCheckBox" name="notify_Peers">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Peers</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="notify_Channels">
|
||||||
|
<property name="text">
|
||||||
|
<string>Channels</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="notify_Forums">
|
||||||
|
<property name="text">
|
||||||
|
<string>Forums</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="notify_Blogs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Blogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="notify_Messages">
|
||||||
|
<property name="text">
|
||||||
|
<string>Messages</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="notify_Chat">
|
||||||
|
<property name="text">
|
||||||
|
<string>Chat</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="notify_Security">
|
||||||
|
<property name="text">
|
||||||
|
<string>Security</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="addFeedsAtEnd">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add feeds at end</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="notify_Channels">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Channels</string>
|
<widget class="QPushButton" name="notifyButton">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Test</string>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QCheckBox" name="notify_Forums">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Forums</string>
|
<spacer name="verticalSpacer_2">
|
||||||
</property>
|
<property name="orientation">
|
||||||
</widget>
|
<enum>Qt::Vertical</enum>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
<property name="sizeHint" stdset="0">
|
||||||
<widget class="QCheckBox" name="notify_Blogs">
|
<size>
|
||||||
<property name="text">
|
<width>20</width>
|
||||||
<string>Blogs</string>
|
<height>40</height>
|
||||||
</property>
|
</size>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
</spacer>
|
||||||
<item>
|
</item>
|
||||||
<widget class="QCheckBox" name="notify_Messages">
|
</layout>
|
||||||
<property name="text">
|
|
||||||
<string>Messages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="notify_Chat">
|
|
||||||
<property name="text">
|
|
||||||
<string>Chat</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="notify_Security">
|
|
||||||
<property name="text">
|
|
||||||
<string>Security</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="addFeedsAtEnd">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add feeds at end</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -149,53 +177,85 @@
|
|||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="popup_Connect">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Friend Connect</string>
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_Connect">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Friend Connect</string>
|
||||||
<widget class="QCheckBox" name="popup_NewMsg">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>New Message</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_NewMsg">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>New Message</string>
|
||||||
<widget class="QCheckBox" name="popup_DownloadFinished">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Download completed</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_DownloadFinished">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Download completed</string>
|
||||||
<widget class="QCheckBox" name="popup_PrivateChat">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Private Chat</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_PrivateChat">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Private Chat</string>
|
||||||
<widget class="QCheckBox" name="popup_GroupChat">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Group Chat</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_GroupChat">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Group Chat</string>
|
||||||
<widget class="QCheckBox" name="popup_ChatLobby">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Chat Lobby</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_ChatLobby">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Chat Lobby</string>
|
||||||
<widget class="QCheckBox" name="popup_ConnectAttempt">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Connect attempt</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QCheckBox" name="popup_ConnectAttempt">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect attempt</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="toasterButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Test</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
Loading…
Reference in New Issue
Block a user