From fb9282f5887bec940139dd5969f78ee05b28c7e8 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 26 Jan 2020 23:19:20 +0100 Subject: [PATCH] moved UserNotify to MainPage level, and added RsEvent handling code in Posted --- libretroshare/src/retroshare/rsgxschannels.h | 4 ++ libretroshare/src/retroshare/rsposted.h | 9 ++-- libretroshare/src/services/p3gxschannels.cc | 15 ++++-- libretroshare/src/services/p3postbase.cc | 47 ++++++++++++++----- plugins/FeedReader/gui/FeedReaderDialog.cpp | 2 +- plugins/FeedReader/gui/FeedReaderDialog.h | 3 +- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 9 ++-- retroshare-gui/src/gui/ChatLobbyWidget.h | 4 +- .../src/gui/FileTransfer/TransfersDialog.cpp | 2 +- .../src/gui/FileTransfer/TransfersDialog.h | 2 +- retroshare-gui/src/gui/FriendsDialog.cpp | 2 +- retroshare-gui/src/gui/FriendsDialog.h | 2 +- retroshare-gui/src/gui/MainPage.cpp | 9 ++++ retroshare-gui/src/gui/MainWindow.cpp | 2 +- retroshare-gui/src/gui/NewsFeed.cpp | 2 +- retroshare-gui/src/gui/NewsFeed.h | 2 +- .../src/gui/Posted/PostedDialog.cpp | 31 +++++++++++- retroshare-gui/src/gui/Posted/PostedDialog.h | 6 ++- .../src/gui/Posted/PostedListWidget.cpp | 2 +- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 2 + .../src/gui/gxs/GxsGroupFrameDialog.h | 3 +- .../src/gui/gxschannels/GxsChannelDialog.cpp | 8 +++- .../src/gui/gxschannels/GxsChannelDialog.h | 3 +- .../src/gui/gxsforums/GxsForumsDialog.cpp | 2 +- .../src/gui/gxsforums/GxsForumsDialog.h | 4 +- .../src/gui/msgs/MessagesDialog.cpp | 2 +- retroshare-gui/src/gui/msgs/MessagesDialog.h | 3 +- retroshare-gui/src/retroshare-gui/mainpage.h | 9 +++- 28 files changed, 140 insertions(+), 51 deletions(-) diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 8e6939672..9fa2f8638 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -122,6 +122,10 @@ enum class RsChannelEventCode: uint8_t /// subscription for channel mChannelGroupId changed. SUBSCRIBE_STATUS_CHANGED = 0x06, + + /// existing message has been read or set to unread + READ_STATUS_CHANGED = 0x07, + }; struct RsGxsChannelEvent: RsEvent diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 211f67bb1..c8f3a313a 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -70,9 +70,12 @@ std::ostream &operator<<(std::ostream &out, const RsPostedPost &post); enum class RsPostedEventCode: uint8_t { - UNKNOWN = 0x00, - NEW_POSTED_GROUP = 0x01, - NEW_MESSAGE = 0x02 + UNKNOWN = 0x00, + NEW_POSTED_GROUP = 0x01, + NEW_MESSAGE = 0x02, + SUBSCRIBE_STATUS_CHANGED = 0x03, + UPDATED_POSTED_GROUP = 0x04, + UPDATED_MESSAGE = 0x05, }; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 800c148f4..e97c2389c 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -369,8 +369,8 @@ void p3GxsChannels::notifyChanges(std::vector &changes) if(!unprocessedGroups.empty()) request_SpecificSubscribedGroups(unprocessedGroups); - // the call below deletes changes and its content. - RsGxsIfaceHelper::receiveChanges(changes); +// // the call below deletes changes and its content. +// RsGxsIfaceHelper::receiveChanges(changes); } void p3GxsChannels::service_tick() @@ -1764,8 +1764,17 @@ void p3GxsChannels::setMessageReadStatus( uint32_t& token, if (read) status = 0; setMsgStatusFlags(token, msgId, status, mask); -} + if (rsEvents) + { + auto ev = std::make_shared(); + + ev->mChannelMsgId = msgId.second; + ev->mChannelGroupId = msgId.first; + ev->mChannelEventCode = RsChannelEventCode::READ_STATUS_CHANGED; + rsEvents->postEvent(ev); + } +} /********************************************************************************************/ /********************************************************************************************/ diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index 12799c4f7..a7e4cd476 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -91,8 +91,8 @@ void p3PostBase::notifyChanges(std::vector &changes) for(it = changes.begin(); it != changes.end(); ++it) { - RsGxsGroupChange *groupChange = dynamic_cast(*it); RsGxsMsgChange *msgChange = dynamic_cast(*it); + if (msgChange) { #ifdef POSTBASE_DEBUG @@ -124,31 +124,54 @@ void p3PostBase::notifyChanges(std::vector &changes) } } + RsGxsGroupChange *grpChange = dynamic_cast(*it); + /* pass on Group Changes to GUI */ - if (groupChange) + if (grpChange && rsEvents) { #ifdef POSTBASE_DEBUG std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification"; std::cerr << std::endl; #endif - std::list &groupList = groupChange->mGrpIdList; - - for(auto git = groupList.begin(); git != groupList.end(); ++git) + switch(grpChange->getType()) + { + default: + case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed { -#ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git; - std::cerr << std::endl; -#endif - - if (rsEvents && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) + std::list &grpList = grpChange->mGrpIdList; + std::list::iterator git; + for (git = grpList.begin(); git != grpList.end(); ++git) { + auto ev = std::make_shared(); + ev->mPostedGroupId = *git; + ev->mPostedEventCode = RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED; + rsEvents->postEvent(ev); + } + + } + break; + + case RsGxsNotify::TYPE_PUBLISHED: + case RsGxsNotify::TYPE_RECEIVED_NEW: + { + /* group received */ + const std::list& grpList = grpChange->mGrpIdList; + + for (auto git = grpList.begin(); git != grpList.end(); ++git) + { +#ifdef POSTBASE_DEBUG + std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git; + std::cerr << std::endl; +#endif auto ev = std::make_shared(); ev->mPostedGroupId = *git; ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP; rsEvents->postEvent(ev); } - } + } + break; + } } } receiveHelperChanges(changes); diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index ca86715e2..5a00cdd6d 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -133,7 +133,7 @@ FeedReaderDialog::~FeedReaderDialog() } } -UserNotify *FeedReaderDialog::getUserNotify(QObject *parent) +UserNotify *FeedReaderDialog::createUserNotify(QObject *parent) { return new FeedReaderUserNotify(this, mFeedReader, mNotify, parent); } diff --git a/plugins/FeedReader/gui/FeedReaderDialog.h b/plugins/FeedReader/gui/FeedReaderDialog.h index 80b6d25a3..a064df811 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.h +++ b/plugins/FeedReader/gui/FeedReaderDialog.h @@ -42,11 +42,10 @@ public: FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); ~FeedReaderDialog(); - virtual UserNotify *getUserNotify(QObject *parent); - static QIcon iconFromFeed(const FeedInfo &feedInfo); protected: + virtual UserNotify *createUserNotify(QObject *parent) override; virtual void showEvent(QShowEvent *event); bool eventFilter(QObject *obj, QEvent *ev); diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 1c5201343..b139d0113 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -226,12 +226,11 @@ ChatLobbyWidget::~ChatLobbyWidget() } } -UserNotify *ChatLobbyWidget::getUserNotify(QObject *parent) +UserNotify *ChatLobbyWidget::createUserNotify(QObject *parent) { - if (!myChatLobbyUserNotify){ - myChatLobbyUserNotify = new ChatLobbyUserNotify(parent); - connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int))); - } + myChatLobbyUserNotify = new ChatLobbyUserNotify(parent); + connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int))); + return myChatLobbyUserNotify; } diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 39422ec6a..8c6f07081 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -63,7 +63,7 @@ public: virtual QString pageName() const { return tr("Chats") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); //MainPage + virtual UserNotify *createUserNotify(QObject *parent) override; //MainPage virtual void updateDisplay(); @@ -137,7 +137,7 @@ private: QAction* showTopicAct; int getNumColVisible(); - ChatLobbyUserNotify* myChatLobbyUserNotify; + ChatLobbyUserNotify* myChatLobbyUserNotify; // local copy that avoids dynamic casts QAbstractButton* myInviteYesButton; GxsIdChooser* myInviteIdChooser; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 15b57e6d8..855d74ecb 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1114,7 +1114,7 @@ void TransfersDialog::activatePage(TransfersDialog::Page page) } } -UserNotify *TransfersDialog::getUserNotify(QObject *parent) +UserNotify *TransfersDialog::createUserNotify(QObject *parent) { return new TransferUserNotify(parent); } diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index eb39df9b9..83da19c5c 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -67,7 +67,7 @@ public: virtual QString pageName() const { return tr("Files") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); + virtual UserNotify *createUserNotify(QObject *parent) override; void activatePage(TransfersDialog::Page page) ; diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 152d3a96d..660f13fa7 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -163,7 +163,7 @@ void FriendsDialog::activatePage(FriendsDialog::Page page) } } -UserNotify *FriendsDialog::getUserNotify(QObject *parent) +UserNotify *FriendsDialog::createUserNotify(QObject *parent) { return new ChatUserNotify(parent); } diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index 6eb9cdf7a..bd8979224 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -55,7 +55,7 @@ public: virtual QString pageName() const { return tr("Network") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); + virtual UserNotify *createUserNotify(QObject *parent) override; static bool isGroupChatActive(); static void groupChatActivate(); diff --git a/retroshare-gui/src/gui/MainPage.cpp b/retroshare-gui/src/gui/MainPage.cpp index 087655572..545f1270e 100644 --- a/retroshare-gui/src/gui/MainPage.cpp +++ b/retroshare-gui/src/gui/MainPage.cpp @@ -31,6 +31,15 @@ MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, f mIcon = QIcon(); mName = ""; mHelp = ""; + mUserNotify = nullptr; +} + +UserNotify *MainPage::getUserNotify() +{ + if(!mUserNotify) + mUserNotify = createUserNotify(this); + + return mUserNotify; } void MainPage::registerHelpButton(QToolButton *button, const QString& help_html_text, const QString &code_name) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 6ec0c22f7..63a563dc4 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -469,7 +469,7 @@ void MainWindow::initStackedPage() //List All notify before Setting was created QList > >::iterator notifyIt; for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) { - UserNotify *userNotify = notifyIt->first->getUserNotify(this); + UserNotify *userNotify = notifyIt->first->getUserNotify(); if (userNotify) { userNotify->initialize(ui->toolBarPage, notifyIt->second.first, notifyIt->second.second); connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine())); diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index c64c758ea..2f70340be 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -141,7 +141,7 @@ NewsFeed::~NewsFeed() } } -UserNotify *NewsFeed::getUserNotify(QObject *parent) +UserNotify *NewsFeed::createUserNotify(QObject *parent) { return new NewsFeedUserNotify(this, parent); } diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index ec9aabcb5..9f43c0df8 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -70,7 +70,7 @@ public: virtual QString pageName() const { return tr("Log") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); + virtual UserNotify *createUserNotify(QObject *parent) override; /* FeedHolder Functions (for FeedItem functionality) */ virtual QScrollArea *getScrollArea(); diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index edf09ff20..f4a59ad03 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -26,6 +26,7 @@ #include "gui/gxs/GxsGroupShareKey.h" #include "gui/settings/rsharesettings.h" #include "gui/common/GroupTreeWidget.h" +#include "util/qtthreadsutils.h" #include @@ -43,13 +44,41 @@ public: PostedDialog::PostedDialog(QWidget *parent) : GxsGroupFrameDialog(rsPosted, parent) { + mEventHandlerId = 0; + // Needs to be asynced because this function is likely to be called by another thread! + + rsEvents->registerEventsHandler(RsEventType::GXS_POSTED, [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId ); } +void PostedDialog::handleEvent_main_thread(std::shared_ptr event) +{ + if(event->mType == RsEventType::GXS_POSTED) + { + const RsGxsPostedEvent *e = dynamic_cast(event.get()); + if(!e) return; + + switch(e->mPostedEventCode) + { + case RsPostedEventCode::NEW_MESSAGE: + case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; + case RsPostedEventCode::UPDATED_MESSAGE: // [[fallthrough]]; + updateDisplay(false); + break; + + case RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED: // [[fallthrough]]; + updateDisplay(true); + break; + default: break; + } + } +} + + PostedDialog::~PostedDialog() { } -UserNotify *PostedDialog::getUserNotify(QObject *parent) +UserNotify *PostedDialog::createUserNotify(QObject *parent) { return new PostedUserNotify(rsPosted, parent); } diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.h b/retroshare-gui/src/gui/Posted/PostedDialog.h index e3f681aa8..7f23ee24f 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedDialog.h @@ -40,9 +40,8 @@ public: virtual QString pageName() const { return tr("Links") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); - protected: + virtual UserNotify *createUserNotify(QObject *parent) override; virtual QString getHelpString() const ; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_POSTED; } virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Posted; } @@ -61,6 +60,9 @@ private: virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId); virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data virtual void loadGroupSummaryToken(const uint32_t &token, std::list &groupInfo, RsUserdata* &userdata); + + void handleEvent_main_thread(std::shared_ptr event); + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp index 9c86a2f9a..1373c6d9b 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidget.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidget.cpp @@ -23,6 +23,7 @@ #include "PostedListWidget.h" #include "ui_PostedListWidget.h" +#include "util/qtthreadsutils.h" #include "gui/gxs/GxsIdDetails.h" #include "PostedCreatePostDialog.h" #include "PostedItem.h" @@ -94,7 +95,6 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent /* Initialize GUI */ setGroupId(postedId); } - PostedListWidget::~PostedListWidget() { // save settings diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index a3984ae53..c54f6171f 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -1173,6 +1173,8 @@ void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token) } ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread); + + getUserNotify()->updateIcon(); } /*********************** **** **** **** ***********************/ diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 4e77ccb44..cc1fa7843 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -96,6 +96,8 @@ protected: virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata); virtual void checkRequestGroup(const RsGxsGroupId& /* grpId */) {} // overload this one in order to retrieve full group data when the group is browsed + void updateMessageSummaryList(RsGxsGroupId groupId); + private slots: void todo(); @@ -153,7 +155,6 @@ private: void initUi(); - void updateMessageSummaryList(RsGxsGroupId groupId); void updateSearchResults(); void openGroupInNewTab(const RsGxsGroupId &groupId); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 2e1b6dc7e..67bbce334 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -64,7 +64,11 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr ev switch(e->mChannelEventCode) { - case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true); + case RsChannelEventCode::READ_STATUS_CHANGED: + updateMessageSummaryList(e->mChannelGroupId); + break; + case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: + updateDisplay(true); break; default: break; @@ -92,7 +96,7 @@ QString GxsChannelDialog::getHelpString() const return hlp_str ; } -UserNotify *GxsChannelDialog::getUserNotify(QObject *parent) +UserNotify *GxsChannelDialog::createUserNotify(QObject *parent) { return new GxsChannelUserNotify(rsGxsChannels, parent); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h index 5d80be518..4c9c6eb95 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h @@ -39,8 +39,6 @@ public: virtual QString pageName() const { return tr("Channels") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); - void shareOnChannel(const RsGxsGroupId& channel_id, const QList& file_link) ; protected: @@ -54,6 +52,7 @@ protected: virtual TurtleRequestId distantSearch(const QString& search_string) ; virtual void checkRequestGroup(const RsGxsGroupId& grpId) ; + virtual UserNotify *createUserNotify(QObject *parent) override; private slots: void toggleAutoDownload(); void setDefaultDirectory(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 2282db1bb..839908ba0 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -102,7 +102,7 @@ void GxsForumsDialog::shareInMessage(const RsGxsGroupId& forum_id,const QListshow(); } -UserNotify *GxsForumsDialog::getUserNotify(QObject *parent) +UserNotify *GxsForumsDialog::createUserNotify(QObject *parent) { return new GxsForumUserNotify(rsGxsForums, parent); } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h index 6a21c8de9..9b6da9d00 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h @@ -37,11 +37,11 @@ public: virtual QString pageName() const { return tr("Forums") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); - void shareInMessage(const RsGxsGroupId& forum_id, const QList& file_link) ; protected: + virtual UserNotify *createUserNotify(QObject *parent) override; + virtual QString getHelpString() const ; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; } virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Forum; } diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index fca0e8cbf..62a027a51 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -325,7 +325,7 @@ MessagesDialog::~MessagesDialog() processSettings(false); } -UserNotify *MessagesDialog::getUserNotify(QObject *parent) +UserNotify *MessagesDialog::createUserNotify(QObject *parent) { return new MessageUserNotify(parent); } diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 1671df268..a8115d466 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -50,8 +50,6 @@ public: virtual QString pageName() const { return tr("Mail") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); - // replaced by shortcut // virtual void keyPressEvent(QKeyEvent *) ; @@ -64,6 +62,7 @@ signals: void messagesLoaded(); protected: + virtual UserNotify *createUserNotify(QObject *parent) override; bool eventFilter(QObject *obj, QEvent *ev); int getSelectedMessages(QList& mid); diff --git a/retroshare-gui/src/retroshare-gui/mainpage.h b/retroshare-gui/src/retroshare-gui/mainpage.h index dc1853556..c96706e7e 100644 --- a/retroshare-gui/src/retroshare-gui/mainpage.h +++ b/retroshare-gui/src/retroshare-gui/mainpage.h @@ -55,14 +55,19 @@ public: void setHelpText(QString help) { mHelp = help; } virtual void retranslateUi() {} - virtual UserNotify *getUserNotify(QObject */*parent*/) { return NULL; } + + // Override this if needed. + virtual UserNotify *createUserNotify(QObject */*parent*/) { return NULL; } // Call this to add some help info to the page. The way the info is // shown is handled by showHelp() below; // void registerHelpButton(QToolButton *button, const QString& help_html_text, const QString &code_name) ; + UserNotify *getUserNotify() ; + protected: + virtual void showEvent(QShowEvent *); private: @@ -71,6 +76,8 @@ private: QString mName; QString mHelp; QString mHelpCodeName; + + UserNotify *mUserNotify; }; #endif