diff options
author | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2010-03-16 15:30:01 +0200 |
---|---|---|
committer | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2010-03-16 15:30:01 +0200 |
commit | 97dea26dfca2ebd3d571f80c6e418d7c64779277 (patch) | |
tree | 96030ecdb096c85f1a40fe00897925cda5592b9f | |
parent | 3874823bd8a388979bad2d882d5d52bffb8d78da (diff) |
Updated normal task EXT-5905 - Resolving offers.
Implemented requested feature - "Resolving offer in the notification toast shouldn't remove offer panel form IM log until IM session is restarted"
--HG--
branch : product-engine
-rw-r--r-- | indra/llui/llnotifications.cpp | 9 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 3 | ||||
-rw-r--r-- | indra/newview/lltoastnotifypanel.cpp | 43 | ||||
-rw-r--r-- | indra/newview/lltoastnotifypanel.h | 15 |
4 files changed, 68 insertions, 2 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 7b8970a153..56ec8c4262 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -486,6 +486,7 @@ void LLNotification::updateFrom(LLNotificationPtr other) mForm = other->mForm; mResponseFunctorName = other->mResponseFunctorName; mRespondedTo = other->mRespondedTo; + mResponse = other->mResponse; mTemporaryResponder = other->mTemporaryResponder; update(); @@ -563,7 +564,9 @@ std::string LLNotification::getSelectedOptionName(const LLSD& response) void LLNotification::respond(const LLSD& response) { + // *TODO may remove mRespondedTo and use mResponce.isDefined() in isRespondedTo() mRespondedTo = true; + mResponse = response; // look up the functor LLNotificationFunctorRegistry::ResponseFunctor functor = LLNotificationFunctorRegistry::instance().getFunctor(mResponseFunctorName); @@ -875,7 +878,11 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt if (wasFound) { abortProcessing = mChanged(payload); - mItems.erase(pNotification); + // do not delete the notification to make LLChatHistory::appendMessage add notification panel to IM window + if( ! pNotification->getPayload()["reusable"].asBoolean() ) + { + mItems.erase(pNotification); + } onDelete(pNotification); } } diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 262633206b..a516a6723e 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -344,6 +344,7 @@ private: LLDate mExpiresAt; bool mCancelled; bool mRespondedTo; // once the notification has been responded to, this becomes true + LLSD mResponse; bool mIgnored; ENotificationPriority mPriority; LLNotificationFormPtr mForm; @@ -445,6 +446,8 @@ public: return mRespondedTo; } + const LLSD& getResponse() { return mResponse; } + bool isIgnored() const { return mIgnored; diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp index 77d1d1fc0b..530110239e 100644 --- a/indra/newview/lltoastnotifypanel.cpp +++ b/indra/newview/lltoastnotifypanel.cpp @@ -54,7 +54,9 @@ S32 BUTTON_WIDTH = 90; const LLFontGL* LLToastNotifyPanel::sFont = NULL; const LLFontGL* LLToastNotifyPanel::sFontSmall = NULL; +LLToastNotifyPanel::button_click_signal_t LLToastNotifyPanel::sButtonClickSignal; LLToastNotifyPanel::LLToastNotifyPanel(LLNotificationPtr& notification, const LLRect& rect) : + LLToastPanel(notification), mTextBox(NULL), mInfoPanel(NULL), @@ -202,6 +204,18 @@ mCloseNotificationOnDestroy(true) // adjust panel's height to the text size mInfoPanel->setFollowsAll(); snapToMessageHeight(mTextBox, MAX_LENGTH); + + if(notification->getPayload()["reusable"].asBoolean()) + { + mButtonClickConnection = sButtonClickSignal.connect( + boost::bind(&LLToastNotifyPanel::onToastPanelButtonClicked, this, _1, _2)); + + if(notification->isRespondedTo()) + { + // User selected an option in toast, now disable required buttons in IM window + disableRespondedOptions(notification); + } + } } void LLToastNotifyPanel::addDefaultButton() { @@ -269,6 +283,8 @@ LLButton* LLToastNotifyPanel::createButton(const LLSD& form_element, BOOL is_opt LLToastNotifyPanel::~LLToastNotifyPanel() { + mButtonClickConnection.disconnect(); + std::for_each(mBtnCallbackData.begin(), mBtnCallbackData.end(), DeletePointer()); if (mCloseNotificationOnDestroy && LLNotificationsUtil::find(mNotification->getID()) != NULL) { @@ -431,7 +447,7 @@ void LLToastNotifyPanel::onClickButton(void* data) if(is_reusable) { - self->disableButtons(self->mNotification->getName(), button_name); + sButtonClickSignal(self->mNotification->getID(), button_name); if(new_info) { @@ -445,3 +461,28 @@ void LLToastNotifyPanel::onClickButton(void* data) self->mControlPanel->setEnabled(FALSE); } } + +void LLToastNotifyPanel::onToastPanelButtonClicked(const LLUUID& notification_id, const std::string btn_name) +{ + if(mNotification->getID() == notification_id) + { + disableButtons(mNotification->getName(), btn_name); + } +} + +void LLToastNotifyPanel::disableRespondedOptions(LLNotificationPtr& notification) +{ + LLSD response = notification->getResponse(); + for (LLSD::map_const_iterator response_it = response.beginMap(); + response_it != response.endMap(); ++response_it) + { + if (response_it->second.isBoolean() && response_it->second.asBoolean()) + { + // that after multiple responses there can be many pressed buttons + // need to process them all + disableButtons(notification->getName(), response_it->first); + } + } +} + +// EOF diff --git a/indra/newview/lltoastnotifypanel.h b/indra/newview/lltoastnotifypanel.h index 1539c613af..d565085e3c 100644 --- a/indra/newview/lltoastnotifypanel.h +++ b/indra/newview/lltoastnotifypanel.h @@ -108,6 +108,21 @@ private: // internal handler for button being clicked static void onClickButton(void* data); + typedef boost::signals2::signal <void (const LLUUID& notification_id, const std::string btn_name)> + button_click_signal_t; + static button_click_signal_t sButtonClickSignal; + boost::signals2::connection mButtonClickConnection; + + /** + * handle sButtonClickSignal (to disable buttons) across all panels with given notification_id + */ + void onToastPanelButtonClicked(const LLUUID& notification_id, const std::string btn_name); + + /** + * Process response data. Will disable selected options + */ + void disableRespondedOptions(LLNotificationPtr& notification); + bool mIsTip; bool mAddedDefaultBtn; bool mIsScriptDialog; |