summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCho <cho@lindenlab.com>2013-12-04 18:19:47 +0000
committerCho <cho@lindenlab.com>2013-12-04 18:19:47 +0000
commitb6d02ae9c84e185f2507323c47c0475ce43f9e7a (patch)
tree1b283e5f807b64b8f7f8a46a63d1c5a964051095
parentffff7ef59f43c66f966f259cb30e069a2445aa66 (diff)
Added SLURL checkbox to floater_twitter for ACME-1216
-rw-r--r--indra/newview/llfloatertwitter.cpp96
-rw-r--r--indra/newview/llfloatertwitter.h4
-rw-r--r--indra/newview/skins/default/xui/en/floater_twitter.xml6
-rw-r--r--indra/newview/skins/default/xui/en/panel_twitter_photo.xml14
4 files changed, 92 insertions, 28 deletions
diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp
index 06d0fb5542..ea17497d95 100644
--- a/indra/newview/llfloatertwitter.cpp
+++ b/indra/newview/llfloatertwitter.cpp
@@ -66,6 +66,7 @@ mRefreshBtn(NULL),
mWorkingLabel(NULL),
mThumbnailPlaceholder(NULL),
mStatusTextBox(NULL),
+mLocationCheckbox(NULL),
mPhotoCheckbox(NULL),
mPostButton(NULL)
{
@@ -92,7 +93,10 @@ BOOL LLTwitterPhotoPanel::postBuild()
mWorkingLabel = getChild<LLUICtrl>("working_lbl");
mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder");
mStatusTextBox = getChild<LLUICtrl>("photo_status");
+ mLocationCheckbox = getChild<LLUICtrl>("add_location_cb");
+ mLocationCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddLocationToggled, this));
mPhotoCheckbox = getChild<LLUICtrl>("add_photo_cb");
+ mPhotoCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddPhotoToggled, this));
mPostButton = getChild<LLUICtrl>("post_photo_btn");
mCancelButton = getChild<LLUICtrl>("cancel_photo_btn");
@@ -109,30 +113,12 @@ void LLTwitterPhotoPanel::draw()
mStatusTextBox->setEnabled(no_ongoing_connection);
mResolutionComboBox->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean());
mRefreshBtn->setEnabled(no_ongoing_connection && mPhotoCheckbox->getValue().asBoolean());
+ mLocationCheckbox->setEnabled(no_ongoing_connection);
mPhotoCheckbox->setEnabled(no_ongoing_connection);
+ bool add_location = mLocationCheckbox->getValue().asBoolean();
bool add_photo = mPhotoCheckbox->getValue().asBoolean();
-
- // Restrict the status text length to Twitter's character limit
- LLTextEditor* status_text_box = dynamic_cast<LLTextEditor*>(mStatusTextBox);
- if (status_text_box)
- {
- int max_status_length = add_photo ? 100 : 140;
- status_text_box->setMaxTextLength(max_status_length);
- if (!add_photo)
- {
- if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length()))
- {
- status_text_box->setText(mOldStatusText);
- }
- mOldStatusText = "";
- }
- if (status_text_box->getText().length() > max_status_length)
- {
- mOldStatusText = status_text_box->getText();
- status_text_box->setText(mOldStatusText.substr(0, max_status_length));
- }
- }
+ updateStatusTextLength(false);
// Display the preview if one is available
if (previewp && previewp->getThumbnailImage())
@@ -169,7 +155,7 @@ void LLTwitterPhotoPanel::draw()
mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate()));
// Enable Post if we have a preview to send and no on going connection being processed
- mPostButton->setEnabled(no_ongoing_connection && ((add_photo && previewp && previewp->getSnapshotUpToDate()) || !mStatusTextBox->getValue().asString().empty()));
+ mPostButton->setEnabled(no_ongoing_connection && ((add_photo && previewp && previewp->getSnapshotUpToDate()) || add_location || !mStatusTextBox->getValue().asString().empty()));
// Draw the rest of the panel on top of it
LLPanel::draw();
@@ -213,6 +199,18 @@ void LLTwitterPhotoPanel::onVisibilityChange(const LLSD& new_visibility)
}
}
+void LLTwitterPhotoPanel::onAddLocationToggled()
+{
+ bool add_location = mLocationCheckbox->getValue().asBoolean();
+ updateStatusTextLength(!add_location);
+}
+
+void LLTwitterPhotoPanel::onAddPhotoToggled()
+{
+ bool add_photo = mPhotoCheckbox->getValue().asBoolean();
+ updateStatusTextLength(!add_photo);
+}
+
void LLTwitterPhotoPanel::onClickNewSnapshot()
{
LLSnapshotLivePreview* previewp = getPreviewView();
@@ -261,6 +259,26 @@ void LLTwitterPhotoPanel::sendPhoto()
{
// Get the status text
std::string status = mStatusTextBox->getValue().asString();
+
+ // Add the location if required
+ bool add_location = mLocationCheckbox->getValue().asBoolean();
+ if (add_location)
+ {
+ // Get the SLURL for the location
+ LLSLURL slurl;
+ LLAgentUI::buildSLURL(slurl);
+ std::string slurl_string = slurl.getSLURLString();
+
+ // Add query parameters so Google Analytics can track incoming clicks!
+ slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS;
+
+ // Add it to the status (pretty crude, but we don't have a better option with photos)
+ if (status.empty())
+ status = slurl_string;
+ else
+ status = status + " " + slurl_string;
+ }
+
// Add the photo if required
bool add_photo = mPhotoCheckbox->getValue().asBoolean();
@@ -292,6 +310,40 @@ void LLTwitterPhotoPanel::clearAndClose()
}
}
+void LLTwitterPhotoPanel::updateStatusTextLength(BOOL restore_old_status_text)
+{
+ bool add_location = mLocationCheckbox->getValue().asBoolean();
+ bool add_photo = mPhotoCheckbox->getValue().asBoolean();
+
+ // Restrict the status text length to Twitter's character limit
+ LLTextEditor* status_text_box = dynamic_cast<LLTextEditor*>(mStatusTextBox);
+ if (status_text_box)
+ {
+ int max_status_length = 140 - (add_location ? 40 : 0) - (add_photo ? 40 : 0);
+ status_text_box->setMaxTextLength(max_status_length);
+ if (restore_old_status_text)
+ {
+ if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length()))
+ {
+ status_text_box->setText(mOldStatusText);
+ }
+ if (mOldStatusText.length() <= max_status_length)
+ {
+ mOldStatusText = "";
+ }
+ }
+ if (status_text_box->getText().length() > max_status_length)
+ {
+ if (mOldStatusText.length() < status_text_box->getText().length() || status_text_box->getText() != mOldStatusText.substr(0, status_text_box->getText().length()))
+ {
+ mOldStatusText = status_text_box->getText();
+ }
+ status_text_box->setText(mOldStatusText.substr(0, max_status_length));
+ }
+ }
+
+}
+
void LLTwitterPhotoPanel::updateControls()
{
LLSnapshotLivePreview* previewp = getPreviewView();
diff --git a/indra/newview/llfloatertwitter.h b/indra/newview/llfloatertwitter.h
index 686e167b1f..be3a099d5f 100644
--- a/indra/newview/llfloatertwitter.h
+++ b/indra/newview/llfloatertwitter.h
@@ -46,6 +46,8 @@ public:
LLSnapshotLivePreview* getPreviewView();
void onVisibilityChange(const LLSD& new_visibility);
+ void onAddLocationToggled();
+ void onAddPhotoToggled();
void onClickNewSnapshot();
void onSend();
bool onTwitterConnectStateChange(const LLSD& data);
@@ -53,6 +55,7 @@ public:
void sendPhoto();
void clearAndClose();
+ void updateStatusTextLength(BOOL restore_old_status_text);
void updateControls();
void updateResolution(BOOL do_update);
void checkAspectRatio(S32 index);
@@ -67,6 +70,7 @@ private:
LLUICtrl * mWorkingLabel;
LLUICtrl * mThumbnailPlaceholder;
LLUICtrl * mStatusTextBox;
+ LLUICtrl * mLocationCheckbox;
LLUICtrl * mPhotoCheckbox;
LLUICtrl * mPostButton;
LLUICtrl* mCancelButton;
diff --git a/indra/newview/skins/default/xui/en/floater_twitter.xml b/indra/newview/skins/default/xui/en/floater_twitter.xml
index 7007a14cdb..751914141c 100644
--- a/indra/newview/skins/default/xui/en/floater_twitter.xml
+++ b/indra/newview/skins/default/xui/en/floater_twitter.xml
@@ -10,10 +10,10 @@
single_instance="true"
reuse_instance="true"
title="TWITTER"
- height="482"
+ height="502"
width="304">
<panel
- height="482"
+ height="502"
width="304"
visible="true"
name="background"
@@ -27,7 +27,7 @@
tab_height="30"
tab_position="top"
top="7"
- height="437"
+ height="457"
halign="center">
<panel
filename="panel_twitter_photo.xml"
diff --git a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml b/indra/newview/skins/default/xui/en/panel_twitter_photo.xml
index 8e2412c84e..3ddec9b989 100644
--- a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml
+++ b/indra/newview/skins/default/xui/en/panel_twitter_photo.xml
@@ -1,19 +1,19 @@
<panel
- height="400"
+ height="420"
width="304"
layout="topleft"
name="panel_twitter_photo">
<layout_stack
layout="topleft"
border_size="0"
- height="392"
+ height="412"
follows="all"
orientation="vertical"
name="stack_photo"
top="8">
<layout_panel
name="text_panel"
- height="140">
+ height="160">
<text
length="1"
follows="top|left|right"
@@ -39,6 +39,14 @@
<check_box
follows="left|top"
initial_value="true"
+ label="Include SL location"
+ name="add_location_cb"
+ left="9"
+ height="16"
+ top_pad="10"/>
+ <check_box
+ follows="left|top"
+ initial_value="true"
label="Include a photo"
name="add_photo_cb"
left="9"