From 265822ef20d90b0eb84e5b4c9a0847056095023a Mon Sep 17 00:00:00 2001
From: Cho <cho@lindenlab.com>
Date: Sat, 15 Mar 2014 00:57:35 +0100
Subject: Made location checkbox automatically unchecked when caption is empty
 for ACME-1375

---
 indra/newview/llfloaterfacebook.cpp | 22 +++++++++++++++++++---
 indra/newview/llfloaterfacebook.h   |  2 ++
 2 files changed, 21 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp
index fccb2799dc..6abb0aa0cc 100644
--- a/indra/newview/llfloaterfacebook.cpp
+++ b/indra/newview/llfloaterfacebook.cpp
@@ -195,7 +195,8 @@ mCaptionTextBox(NULL),
 mLocationCheckbox(NULL),
 mPostButton(NULL),
 mBigPreviewFloater(NULL),
-mQuality(MAX_QUALITY)
+mQuality(MAX_QUALITY),
+mIncludeLocation(TRUE)
 {
 	mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFacebookPhotoPanel::onSend, this));
 	mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFacebookPhotoPanel::onClickNewSnapshot, this));
@@ -226,6 +227,7 @@ BOOL LLFacebookPhotoPanel::postBuild()
 	mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder");
 	mCaptionTextBox = getChild<LLUICtrl>("photo_caption");
 	mLocationCheckbox = getChild<LLUICtrl>("add_location_cb");
+	mLocationCheckbox->setCommitCallback(boost::bind(&LLFacebookPhotoPanel::updateLocationCheckbox, this));
 	mPostButton = getChild<LLUICtrl>("post_photo_btn");
 	mCancelButton = getChild<LLUICtrl>("cancel_photo_btn");
 	mBigPreviewFloater = dynamic_cast<LLFloaterBigPreview*>(LLFloaterReg::getInstance("big_preview"));
@@ -282,7 +284,16 @@ void LLFacebookPhotoPanel::draw()
     mRefreshBtn->setEnabled(no_ongoing_connection);
     mBtnPreview->setEnabled(no_ongoing_connection);
     mLocationCheckbox->setEnabled(no_ongoing_connection && !mCaptionTextBox->getValue().asString().empty());
-    
+	
+	if (mCaptionTextBox->getValue().asString().empty())
+	{
+		mLocationCheckbox->setValue(FALSE);
+	}
+	else
+	{
+		mLocationCheckbox->setValue(mIncludeLocation);
+	}
+	
     // Reassign the preview floater if we have the focus and the preview exists
     if (hasFocus() && isPreviewVisible())
     {
@@ -452,7 +463,7 @@ void LLFacebookPhotoPanel::sendPhoto()
 	std::string caption = mCaptionTextBox->getValue().asString();
 
 	// Add the location if required
-	bool add_location = (mLocationCheckbox->getEnabled() && mLocationCheckbox->getValue().asBoolean());
+	bool add_location = mLocationCheckbox->getValue().asBoolean();
 	if (add_location)
 	{
 		// Get the SLURL for the location
@@ -571,6 +582,11 @@ void LLFacebookPhotoPanel::updateResolution(BOOL do_update)
 	}
 }
 
+void LLFacebookPhotoPanel::updateLocationCheckbox()
+{
+	mIncludeLocation = mLocationCheckbox->getValue().asBoolean();
+}
+
 void LLFacebookPhotoPanel::checkAspectRatio(S32 index)
 {
 	LLSnapshotLivePreview *previewp = getPreviewView() ;
diff --git a/indra/newview/llfloaterfacebook.h b/indra/newview/llfloaterfacebook.h
index 8eff46412d..5f2d53eaca 100644
--- a/indra/newview/llfloaterfacebook.h
+++ b/indra/newview/llfloaterfacebook.h
@@ -78,6 +78,7 @@ public:
 
 	void updateControls();
 	void updateResolution(BOOL do_update);
+	void updateLocationCheckbox();
 	void checkAspectRatio(S32 index);
 	LLUICtrl* getRefreshBtn();
 
@@ -102,6 +103,7 @@ private:
     LLFloaterBigPreview * mBigPreviewFloater;
     
     S32 mQuality;       // Compression quality
+	bool mIncludeLocation;
 };
 
 class LLFacebookCheckinPanel : public LLPanel
-- 
cgit v1.2.3