From 35962b54e0afa14cd89eb028efb13787802c18a0 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Mon, 13 Sep 2010 20:39:15 +0100 Subject: Start to break the lltextbox toast into its own toast class instead of mega-overloading the generic notification panel. --- indra/newview/lltoastscripttextbox.cpp | 214 +++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 indra/newview/lltoastscripttextbox.cpp (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp new file mode 100644 index 0000000000..bb06976d40 --- /dev/null +++ b/indra/newview/lltoastscripttextbox.cpp @@ -0,0 +1,214 @@ +/** + * @file lltoastscripttextbox.cpp + * @brief Panel for script llTextBox dialogs + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lltoastscripttextbox.h" + +#include "llfocusmgr.h" + +#include "llbutton.h" +#include "lliconctrl.h" +#include "llinventoryfunctions.h" +#include "llnotifications.h" +#include "llviewertexteditor.h" + +#include "lluiconstants.h" +#include "llui.h" +#include "llviewercontrol.h" +#include "lltrans.h" +#include "llstyle.h" + +#include "llglheaders.h" +#include "llagent.h" +#include "llavatariconctrl.h" +#include "llfloaterinventory.h" +#include "llinventorytype.h" + +const S32 LLToastGroupNotifyPanel::DEFAULT_MESSAGE_MAX_LINE_COUNT = 7; + +LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification) +: LLToastPanel(notification), + mInventoryOffer(NULL) +{ + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_notify_textbox.xml"); + const LLSD& payload = notification->getPayload(); + LLGroupData groupData; + if (!gAgent.getGroupData(payload["group_id"].asUUID(),groupData)) + { + llwarns << "Group notice for unknown group: " << payload["group_id"].asUUID() << llendl; + } + + //group icon + LLIconCtrl* pGroupIcon = getChild("group_icon", TRUE); + pGroupIcon->setValue(groupData.mInsigniaID); + + //header title + const std::string& from_name = payload["sender_name"].asString(); + std::stringstream from; + from << from_name << "/" << groupData.mName; + LLTextBox* pTitleText = getChild("title"); + pTitleText->setValue(from.str()); + + //message subject + const std::string& subject = payload["subject"].asString(); + //message body + const std::string& message = payload["message"].asString(); + + std::string timeStr = "["+LLTrans::getString("UTCTimeWeek")+"],[" + +LLTrans::getString("UTCTimeDay")+"] [" + +LLTrans::getString("UTCTimeMth")+"] [" + +LLTrans::getString("UTCTimeYr")+"] [" + +LLTrans::getString("UTCTimeHr")+"]:[" + +LLTrans::getString("UTCTimeMin")+"]:[" + +LLTrans::getString("UTCTimeSec")+"] [" + +LLTrans::getString("UTCTimeTimezone")+"]"; + const LLDate timeStamp = notification->getDate(); + LLDate notice_date = timeStamp.notNull() ? timeStamp : LLDate::now(); + LLSD substitution; + substitution["datetime"] = (S32) notice_date.secondsSinceEpoch(); + LLStringUtil::format(timeStr, substitution); + + LLViewerTextEditor* pMessageText = getChild("message"); + pMessageText->clear(); + + LLStyle::Params style; + LLFontGL* subject_font = LLFontGL::getFontByName(getString("subject_font")); + if (subject_font) + style.font = subject_font; + pMessageText->appendText(subject, FALSE, style); + + LLFontGL* date_font = LLFontGL::getFontByName(getString("date_font")); + if (date_font) + style.font = date_font; + pMessageText->appendText(timeStr + "\n", TRUE, style); + + style.font = pMessageText->getDefaultFont(); + pMessageText->appendText(message, TRUE, style); + + //attachment + BOOL hasInventory = payload["inventory_offer"].isDefined(); + + //attachment text + LLTextBox * pAttachLink = getChild("attachment"); + //attachment icon + LLIconCtrl* pAttachIcon = getChild("attachment_icon", TRUE); + + //If attachment is empty let it be invisible and not take place at the panel + pAttachLink->setVisible(hasInventory); + pAttachIcon->setVisible(hasInventory); + if (hasInventory) { + pAttachLink->setValue(payload["inventory_name"]); + + mInventoryOffer = new LLOfferInfo(payload["inventory_offer"]); + getChild("attachment")->setClickedCallback(boost::bind( + &LLToastGroupNotifyPanel::onClickAttachment, this)); + + LLUIImagePtr attachIconImg = LLInventoryIcon::getIcon(mInventoryOffer->mType, + LLInventoryType::IT_TEXTURE); + pAttachIcon->setValue(attachIconImg->getName()); + } + + //ok button + LLButton* pOkBtn = getChild("btn_ok"); + pOkBtn->setClickedCallback((boost::bind(&LLToastGroupNotifyPanel::onClickOk, this))); + setDefaultBtn(pOkBtn); + + S32 maxLinesCount; + std::istringstream ss( getString("message_max_lines_count") ); + if (!(ss >> maxLinesCount)) + { + maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT; + } + snapToMessageHeight(pMessageText, maxLinesCount); +} + +// virtual +LLToastGroupNotifyPanel::~LLToastGroupNotifyPanel() +{ +} + +void LLToastGroupNotifyPanel::close() +{ + // The group notice dialog may be an inventory offer. + // If it has an inventory save button and that button is still enabled + // Then we need to send the inventory declined message + if(mInventoryOffer != NULL) + { + mInventoryOffer->forceResponse(IOR_DECLINE); + mInventoryOffer = NULL; + } + + die(); +} + +void LLToastGroupNotifyPanel::onClickOk() +{ + LLSD response = mNotification->getResponseTemplate(); + mNotification->respond(response); + close(); +} + +void LLToastGroupNotifyPanel::onClickAttachment() +{ + if (mInventoryOffer != NULL) { + mInventoryOffer->forceResponse(IOR_ACCEPT); + + LLTextBox * pAttachLink = getChild ("attachment"); + static const LLUIColor textColor = LLUIColorTable::instance().getColor( + "GroupNotifyDimmedTextColor"); + pAttachLink->setColor(textColor); + + LLIconCtrl* pAttachIcon = + getChild ("attachment_icon", TRUE); + pAttachIcon->setEnabled(FALSE); + + //if attachment isn't openable - notify about saving + if (!isAttachmentOpenable(mInventoryOffer->mType)) { + LLNotifications::instance().add("AttachmentSaved", LLSD(), LLSD()); + } + + mInventoryOffer = NULL; + } +} + +//static +bool LLToastGroupNotifyPanel::isAttachmentOpenable(LLAssetType::EType type) +{ + switch(type) + { + case LLAssetType::AT_LANDMARK: + case LLAssetType::AT_NOTECARD: + case LLAssetType::AT_IMAGE_JPEG: + case LLAssetType::AT_IMAGE_TGA: + case LLAssetType::AT_TEXTURE: + case LLAssetType::AT_TEXTURE_TGA: + return true; + default: + return false; + } +} + -- cgit v1.2.3 From 34a55f2f05036d465ae1ddad5031a3e3f892d549 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Mon, 20 Sep 2010 13:04:56 +0100 Subject: make this at least build, but no real flesh yet. --- indra/newview/lltoastscripttextbox.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index bb06976d40..a54594e474 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -48,9 +48,9 @@ #include "llfloaterinventory.h" #include "llinventorytype.h" -const S32 LLToastGroupNotifyPanel::DEFAULT_MESSAGE_MAX_LINE_COUNT = 7; +const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT = 7; -LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification) +LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) : LLToastPanel(notification), mInventoryOffer(NULL) { @@ -125,7 +125,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification mInventoryOffer = new LLOfferInfo(payload["inventory_offer"]); getChild("attachment")->setClickedCallback(boost::bind( - &LLToastGroupNotifyPanel::onClickAttachment, this)); + &LLToastScriptTextbox::onClickAttachment, this)); LLUIImagePtr attachIconImg = LLInventoryIcon::getIcon(mInventoryOffer->mType, LLInventoryType::IT_TEXTURE); @@ -134,7 +134,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification //ok button LLButton* pOkBtn = getChild("btn_ok"); - pOkBtn->setClickedCallback((boost::bind(&LLToastGroupNotifyPanel::onClickOk, this))); + pOkBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickOk, this))); setDefaultBtn(pOkBtn); S32 maxLinesCount; @@ -147,11 +147,11 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification } // virtual -LLToastGroupNotifyPanel::~LLToastGroupNotifyPanel() +LLToastScriptTextbox::~LLToastScriptTextbox() { } -void LLToastGroupNotifyPanel::close() +void LLToastScriptTextbox::close() { // The group notice dialog may be an inventory offer. // If it has an inventory save button and that button is still enabled @@ -165,14 +165,14 @@ void LLToastGroupNotifyPanel::close() die(); } -void LLToastGroupNotifyPanel::onClickOk() +void LLToastScriptTextbox::onClickOk() { LLSD response = mNotification->getResponseTemplate(); mNotification->respond(response); close(); } -void LLToastGroupNotifyPanel::onClickAttachment() +void LLToastScriptTextbox::onClickAttachment() { if (mInventoryOffer != NULL) { mInventoryOffer->forceResponse(IOR_ACCEPT); @@ -196,7 +196,7 @@ void LLToastGroupNotifyPanel::onClickAttachment() } //static -bool LLToastGroupNotifyPanel::isAttachmentOpenable(LLAssetType::EType type) +bool LLToastScriptTextbox::isAttachmentOpenable(LLAssetType::EType type) { switch(type) { -- cgit v1.2.3 From b6a498c3018976b97c2353be066502e4a298e156 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Tue, 28 Sep 2010 13:41:46 +0100 Subject: iterate iterate. --- indra/newview/lltoastscripttextbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index b203579362..7fef346ae5 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -51,7 +51,7 @@ const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT = 7; LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) -: LLToastPanel(notification), +: LLToastNotifyPanel(notification), mInventoryOffer(NULL) { buildFromFile( "panel_notify_textbox.xml"); -- cgit v1.2.3 From e73e8de56fc2a0fd35cde975f82ead1a02112cbe Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Tue, 28 Sep 2010 18:13:21 +0100 Subject: trivial reformat before I tear this apart. --- indra/newview/lltoastscripttextbox.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 7fef346ae5..64360b9e48 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -80,13 +80,13 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) const std::string& message = payload["message"].asString(); std::string timeStr = "["+LLTrans::getString("UTCTimeWeek")+"],[" - +LLTrans::getString("UTCTimeDay")+"] [" - +LLTrans::getString("UTCTimeMth")+"] [" - +LLTrans::getString("UTCTimeYr")+"] [" - +LLTrans::getString("UTCTimeHr")+"]:[" - +LLTrans::getString("UTCTimeMin")+"]:[" - +LLTrans::getString("UTCTimeSec")+"] [" - +LLTrans::getString("UTCTimeTimezone")+"]"; + +LLTrans::getString("UTCTimeDay")+"] [" + +LLTrans::getString("UTCTimeMth")+"] [" + +LLTrans::getString("UTCTimeYr")+"] [" + +LLTrans::getString("UTCTimeHr")+"]:[" + +LLTrans::getString("UTCTimeMin")+"]:[" + +LLTrans::getString("UTCTimeSec")+"] [" + +LLTrans::getString("UTCTimeTimezone")+"]"; const LLDate timeStamp = notification->getDate(); LLDate notice_date = timeStamp.notNull() ? timeStamp : LLDate::now(); LLSD substitution; -- cgit v1.2.3 From 32b04991c86b4e6467a23e6b5ce264e4ec5c2ad9 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 13:56:12 +0100 Subject: textbox dialog working, preparing to send response properly. --- indra/newview/lltoastscripttextbox.cpp | 41 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 64360b9e48..391aee79e8 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -57,25 +57,23 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) buildFromFile( "panel_notify_textbox.xml"); const LLSD& payload = notification->getPayload(); - LLGroupData groupData; - if (!gAgent.getGroupData(payload["group_id"].asUUID(),groupData)) - { - llwarns << "Group notice for unknown group: " << payload["group_id"].asUUID() << llendl; - } - - //group icon - LLIconCtrl* pGroupIcon = getChild("group_icon", TRUE); - pGroupIcon->setValue(groupData.mInsigniaID); - - //header title - const std::string& from_name = payload["sender_name"].asString(); - std::stringstream from; - from << from_name << "/" << groupData.mName; - LLTextBox* pTitleText = getChild("title"); - pTitleText->setValue(from.str()); + llwarns << "PAYLOAD " << payload << llendl; + llwarns << "TYPE " << notification->getType() << llendl; + llwarns << "MESSAGE " << notification->getMessage() << llendl; + llwarns << "LABEL " << notification->getLabel() << llendl; + llwarns << "URL " << notification->getURL() << llendl; + + /* +2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: PAYLOAD {'chat_channel':i-376,'object_id':ubb05bcf2-4eca-2203-13f4-b328411d344f,'sender':'216.82.20.80:13001'} +2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: TYPE notify +2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: MESSAGE Tofu Tester's 'lltextbox test' +Write something here... +2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: LABEL +2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: URL +*/ //message subject - const std::string& subject = payload["subject"].asString(); + //const std::string& subject = payload["subject"].asString(); //message body const std::string& message = payload["message"].asString(); @@ -97,10 +95,6 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) pMessageText->clear(); LLStyle::Params style; - LLFontGL* subject_font = LLFontGL::getFontByName(getString("subject_font")); - if (subject_font) - style.font = subject_font; - pMessageText->appendText(subject, FALSE, style); LLFontGL* date_font = LLFontGL::getFontByName(getString("date_font")); if (date_font) @@ -109,7 +103,7 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) style.font = pMessageText->getDefaultFont(); pMessageText->appendText(message, TRUE, style); - + /* //attachment BOOL hasInventory = payload["inventory_offer"].isDefined(); @@ -132,7 +126,7 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) LLInventoryType::IT_TEXTURE); pAttachIcon->setValue(attachIconImg->getName()); } - + */ //ok button LLButton* pOkBtn = getChild("btn_ok"); pOkBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickOk, this))); @@ -169,6 +163,7 @@ void LLToastScriptTextbox::close() void LLToastScriptTextbox::onClickOk() { LLSD response = mNotification->getResponseTemplate(); + response["OH MY GOD WHAT A HACK"] = true; mNotification->respond(response); close(); } -- cgit v1.2.3 From 921d6187073afa3e76e05395ddb8a64f9f479d68 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 14:10:04 +0100 Subject: clean up xui a bit, still working on proper script reponse. --- indra/newview/lltoastscripttextbox.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 391aee79e8..a9f8272ea9 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -151,12 +151,13 @@ void LLToastScriptTextbox::close() // The group notice dialog may be an inventory offer. // If it has an inventory save button and that button is still enabled // Then we need to send the inventory declined message + /* if(mInventoryOffer != NULL) { mInventoryOffer->forceResponse(IOR_DECLINE); mInventoryOffer = NULL; } - + */ die(); } @@ -166,8 +167,9 @@ void LLToastScriptTextbox::onClickOk() response["OH MY GOD WHAT A HACK"] = true; mNotification->respond(response); close(); + //llerrs << response << llendl; } - +/* void LLToastScriptTextbox::onClickAttachment() { if (mInventoryOffer != NULL) { @@ -190,7 +192,9 @@ void LLToastScriptTextbox::onClickAttachment() mInventoryOffer = NULL; } } +*/ + /* //static bool LLToastScriptTextbox::isAttachmentOpenable(LLAssetType::EType type) { @@ -208,3 +212,4 @@ bool LLToastScriptTextbox::isAttachmentOpenable(LLAssetType::EType type) } } + */ -- cgit v1.2.3 From 42ed8e8ffadd6bd7d8784084e9a29badf5d75c5c Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 17:03:05 +0100 Subject: response is starting to limp along. --- indra/newview/lltoastscripttextbox.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index a9f8272ea9..2a0d971a44 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -161,13 +161,15 @@ void LLToastScriptTextbox::close() die(); } +#include "lllslconstants.h" void LLToastScriptTextbox::onClickOk() { LLSD response = mNotification->getResponseTemplate(); - response["OH MY GOD WHAT A HACK"] = true; + //response["OH MY GOD WHAT A HACK"] = "woot"; + response[TEXTBOX_MAGIC_TOKEN] = "ffffffffuuuuu"; mNotification->respond(response); close(); - //llerrs << response << llendl; + llwarns << response << llendl; } /* void LLToastScriptTextbox::onClickAttachment() -- cgit v1.2.3 From 578ee535644931ede7dd74741d905d04d8da7fd6 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 17:20:16 +0100 Subject: work on response integrity. --- indra/newview/lltoastscripttextbox.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 2a0d971a44..91a4831a9c 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -164,12 +164,17 @@ void LLToastScriptTextbox::close() #include "lllslconstants.h" void LLToastScriptTextbox::onClickOk() { - LLSD response = mNotification->getResponseTemplate(); - //response["OH MY GOD WHAT A HACK"] = "woot"; - response[TEXTBOX_MAGIC_TOKEN] = "ffffffffuuuuu"; - mNotification->respond(response); - close(); - llwarns << response << llendl; + LLViewerTextEditor* pMessageText = getChild("message"); + + if (pMessageText) + { + LLSD response = mNotification->getResponseTemplate(); + //response["OH MY GOD WHAT A HACK"] = "woot"; + response[TEXTBOX_MAGIC_TOKEN] = pMessageText->getText(); + mNotification->respond(response); + close(); + llwarns << response << llendl; + } } /* void LLToastScriptTextbox::onClickAttachment() -- cgit v1.2.3 From ca1821048583acedaae7e1dbfe83a0b058faee2c Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 19:00:55 +0100 Subject: more robustness for empty-but-not-aborted textboxes. --- indra/newview/lltoastscripttextbox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 91a4831a9c..bdadff4cb0 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -171,6 +171,12 @@ void LLToastScriptTextbox::onClickOk() LLSD response = mNotification->getResponseTemplate(); //response["OH MY GOD WHAT A HACK"] = "woot"; response[TEXTBOX_MAGIC_TOKEN] = pMessageText->getText(); + if (response[TEXTBOX_MAGIC_TOKEN].asString().empty()) + { + // so we can distinguish between a successfully + // submitted blank textbox, and an ignored toast + response[TEXTBOX_MAGIC_TOKEN] = true; + } mNotification->respond(response); close(); llwarns << response << llendl; -- cgit v1.2.3 From 2669b54e2c25ca705c4a41a89d46dee7a199757e Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 19:13:02 +0100 Subject: start to de-cruftify. --- indra/newview/lltoastscripttextbox.cpp | 88 +--------------------------------- 1 file changed, 1 insertion(+), 87 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index bdadff4cb0..23ae4c142d 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -63,15 +63,6 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) llwarns << "LABEL " << notification->getLabel() << llendl; llwarns << "URL " << notification->getURL() << llendl; - /* -2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: PAYLOAD {'chat_channel':i-376,'object_id':ubb05bcf2-4eca-2203-13f4-b328411d344f,'sender':'216.82.20.80:13001'} -2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: TYPE notify -2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: MESSAGE Tofu Tester's 'lltextbox test' -Write something here... -2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: LABEL -2010-09-29T12:24:44Z WARNING: LLToastScriptTextbox: URL -*/ - //message subject //const std::string& subject = payload["subject"].asString(); //message body @@ -103,30 +94,7 @@ Write something here... style.font = pMessageText->getDefaultFont(); pMessageText->appendText(message, TRUE, style); - /* - //attachment - BOOL hasInventory = payload["inventory_offer"].isDefined(); - - //attachment text - LLTextBox * pAttachLink = getChild("attachment"); - //attachment icon - LLIconCtrl* pAttachIcon = getChild("attachment_icon", TRUE); - - //If attachment is empty let it be invisible and not take place at the panel - pAttachLink->setVisible(hasInventory); - pAttachIcon->setVisible(hasInventory); - if (hasInventory) { - pAttachLink->setValue(payload["inventory_name"]); - - mInventoryOffer = new LLOfferInfo(payload["inventory_offer"]); - getChild("attachment")->setClickedCallback(boost::bind( - &LLToastScriptTextbox::onClickAttachment, this)); - - LLUIImagePtr attachIconImg = LLInventoryIcon::getIcon(mInventoryOffer->mType, - LLInventoryType::IT_TEXTURE); - pAttachIcon->setValue(attachIconImg->getName()); - } - */ + //ok button LLButton* pOkBtn = getChild("btn_ok"); pOkBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickOk, this))); @@ -148,16 +116,6 @@ LLToastScriptTextbox::~LLToastScriptTextbox() void LLToastScriptTextbox::close() { - // The group notice dialog may be an inventory offer. - // If it has an inventory save button and that button is still enabled - // Then we need to send the inventory declined message - /* - if(mInventoryOffer != NULL) - { - mInventoryOffer->forceResponse(IOR_DECLINE); - mInventoryOffer = NULL; - } - */ die(); } @@ -182,47 +140,3 @@ void LLToastScriptTextbox::onClickOk() llwarns << response << llendl; } } -/* -void LLToastScriptTextbox::onClickAttachment() -{ - if (mInventoryOffer != NULL) { - mInventoryOffer->forceResponse(IOR_ACCEPT); - - LLTextBox * pAttachLink = getChild ("attachment"); - static const LLUIColor textColor = LLUIColorTable::instance().getColor( - "GroupNotifyDimmedTextColor"); - pAttachLink->setColor(textColor); - - LLIconCtrl* pAttachIcon = - getChild ("attachment_icon", TRUE); - pAttachIcon->setEnabled(FALSE); - - //if attachment isn't openable - notify about saving - if (!isAttachmentOpenable(mInventoryOffer->mType)) { - LLNotifications::instance().add("AttachmentSaved", LLSD(), LLSD()); - } - - mInventoryOffer = NULL; - } -} -*/ - - /* -//static -bool LLToastScriptTextbox::isAttachmentOpenable(LLAssetType::EType type) -{ - switch(type) - { - case LLAssetType::AT_LANDMARK: - case LLAssetType::AT_NOTECARD: - case LLAssetType::AT_IMAGE_JPEG: - case LLAssetType::AT_IMAGE_TGA: - case LLAssetType::AT_TEXTURE: - case LLAssetType::AT_TEXTURE_TGA: - return true; - default: - return false; - } -} - - */ -- cgit v1.2.3 From 4dfb0b7b2d76cf288cca34c23218c4769ec76991 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 29 Sep 2010 19:33:03 +0100 Subject: finally, properly(?) deal with submitting empty text. --- indra/newview/lltoastscripttextbox.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 23ae4c142d..95f70eda88 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -63,8 +63,6 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) llwarns << "LABEL " << notification->getLabel() << llendl; llwarns << "URL " << notification->getURL() << llendl; - //message subject - //const std::string& subject = payload["subject"].asString(); //message body const std::string& message = payload["message"].asString(); -- cgit v1.2.3 From dd6a77c9e1baeec7276d3599b73d5cde384e810f Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 30 Sep 2010 12:01:36 +0100 Subject: xui / panel format cleanup. --- indra/newview/lltoastscripttextbox.cpp | 48 ++++++---------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index 95f70eda88..581bb9519c 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -31,8 +31,6 @@ #include "llfocusmgr.h" #include "llbutton.h" -#include "lliconctrl.h" -#include "llinventoryfunctions.h" #include "llnotifications.h" #include "llviewertexteditor.h" @@ -44,59 +42,30 @@ #include "llglheaders.h" #include "llagent.h" -#include "llavatariconctrl.h" -#include "llfloaterinventory.h" -#include "llinventorytype.h" -const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT = 7; +const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 7; LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) -: LLToastNotifyPanel(notification), - mInventoryOffer(NULL) +: LLToastNotifyPanel(notification) { buildFromFile( "panel_notify_textbox.xml"); const LLSD& payload = notification->getPayload(); - llwarns << "PAYLOAD " << payload << llendl; - llwarns << "TYPE " << notification->getType() << llendl; - llwarns << "MESSAGE " << notification->getMessage() << llendl; - llwarns << "LABEL " << notification->getLabel() << llendl; - llwarns << "URL " << notification->getURL() << llendl; //message body const std::string& message = payload["message"].asString(); - std::string timeStr = "["+LLTrans::getString("UTCTimeWeek")+"],[" - +LLTrans::getString("UTCTimeDay")+"] [" - +LLTrans::getString("UTCTimeMth")+"] [" - +LLTrans::getString("UTCTimeYr")+"] [" - +LLTrans::getString("UTCTimeHr")+"]:[" - +LLTrans::getString("UTCTimeMin")+"]:[" - +LLTrans::getString("UTCTimeSec")+"] [" - +LLTrans::getString("UTCTimeTimezone")+"]"; - const LLDate timeStamp = notification->getDate(); - LLDate notice_date = timeStamp.notNull() ? timeStamp : LLDate::now(); - LLSD substitution; - substitution["datetime"] = (S32) notice_date.secondsSinceEpoch(); - LLStringUtil::format(timeStr, substitution); - LLViewerTextEditor* pMessageText = getChild("message"); pMessageText->clear(); LLStyle::Params style; - - LLFontGL* date_font = LLFontGL::getFontByName(getString("date_font")); - if (date_font) - style.font = date_font; - pMessageText->appendText(timeStr + "\n", TRUE, style); - style.font = pMessageText->getDefaultFont(); pMessageText->appendText(message, TRUE, style); - //ok button - LLButton* pOkBtn = getChild("btn_ok"); - pOkBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickOk, this))); - setDefaultBtn(pOkBtn); + //submit button + LLButton* pSubmitBtn = getChild("btn_submit"); + pSubmitBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickSubmit, this))); + setDefaultBtn(pSubmitBtn); S32 maxLinesCount; std::istringstream ss( getString("message_max_lines_count") ); @@ -104,7 +73,7 @@ LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) { maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT; } - snapToMessageHeight(pMessageText, maxLinesCount); + //snapToMessageHeight(pMessageText, maxLinesCount); } // virtual @@ -118,14 +87,13 @@ void LLToastScriptTextbox::close() } #include "lllslconstants.h" -void LLToastScriptTextbox::onClickOk() +void LLToastScriptTextbox::onClickSubmit() { LLViewerTextEditor* pMessageText = getChild("message"); if (pMessageText) { LLSD response = mNotification->getResponseTemplate(); - //response["OH MY GOD WHAT A HACK"] = "woot"; response[TEXTBOX_MAGIC_TOKEN] = pMessageText->getText(); if (response[TEXTBOX_MAGIC_TOKEN].asString().empty()) { -- cgit v1.2.3 From 29dc24a3ea8d6f3d3aa83fd6b22921937d0dd430 Mon Sep 17 00:00:00 2001 From: Paul Guslisty Date: Tue, 14 Dec 2010 14:53:51 +0200 Subject: STORM-713 FIXED XML/UI issues in llTextBox - As the class LLToastNotifyPanel is deprecated, made the class LLToastScriptTextbox derived directly from LLToastPanel. - Added callback for ignore button. Now LLToastScriptTextbox has its own XML, therefore it's not needed to dynamically create toast panel. Since LLToastNotifyPanel is deprecated all new notification toasts should be created this way. --- indra/newview/lltoastscripttextbox.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltoastscripttextbox.cpp') diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp index c013f521cc..2529ec865a 100644 --- a/indra/newview/lltoastscripttextbox.cpp +++ b/indra/newview/lltoastscripttextbox.cpp @@ -46,11 +46,16 @@ const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 7; -LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification) -: LLToastNotifyPanel(notification) +LLToastScriptTextbox::LLToastScriptTextbox(const LLNotificationPtr& notification) +: LLToastPanel(notification) { buildFromFile( "panel_notify_textbox.xml"); + LLTextEditor* text_editorp = getChild("text_editor_box"); + text_editorp->setValue(notification->getMessage()); + + getChild("ignore_btn")->setClickedCallback(boost::bind(&LLToastScriptTextbox::onClickIgnore, this)); + const LLSD& payload = notification->getPayload(); //message body @@ -107,3 +112,10 @@ void LLToastScriptTextbox::onClickSubmit() llwarns << response << llendl; } } + +void LLToastScriptTextbox::onClickIgnore() +{ + LLSD response = mNotification->getResponseTemplate(); + mNotification->respond(response); + close(); +} -- cgit v1.2.3