Improvements!

Fix CMakeLists being out of order.
Add setting SnapshotFeedAddLocation to keep track of user's preference whether or not to include location in uploads to profile feed.
Clean up LLFloaterFeed to take only what it needs, also gave it a boost~
Remove saveFeed() from LLFloaterSnapshot, removing the dependency on LLWebProfile.
Compile fixes for LLFloaterSnapshot.
Prettied up the upload to feed floater.

TODO: Does Location even work? I can't get it to appear, never seems to get used right in v-d either.
This commit is contained in:
Lirusaito
2012-12-28 00:14:54 -05:00
parent be8f16a8e6
commit 2be305d39e
6 changed files with 74 additions and 164 deletions

View File

@@ -196,8 +196,9 @@ set(viewer_SOURCE_FILES
llfloaterevent.cpp llfloaterevent.cpp
llfloaterexploreanimations.cpp llfloaterexploreanimations.cpp
llfloaterexploresounds.cpp llfloaterexploresounds.cpp
llfloaterfriends.cpp llfloaterfeed.cpp
llfloaterfonttest.cpp llfloaterfonttest.cpp
llfloaterfriends.cpp
llfloatergesture.cpp llfloatergesture.cpp
llfloatergodtools.cpp llfloatergodtools.cpp
llfloatergroupinfo.cpp llfloatergroupinfo.cpp
@@ -241,7 +242,6 @@ set(viewer_SOURCE_FILES
llfloatersellland.cpp llfloatersellland.cpp
llfloatersettingsdebug.cpp llfloatersettingsdebug.cpp
llfloatersnapshot.cpp llfloatersnapshot.cpp
llfloaterfeed.cpp
llfloaterstats.cpp llfloaterstats.cpp
llfloatertelehub.cpp llfloatertelehub.cpp
llfloaterteleporthistory.cpp llfloaterteleporthistory.cpp
@@ -704,6 +704,7 @@ set(viewer_HEADER_FILES
llfloaterexploreanimations.h llfloaterexploreanimations.h
llfloaterexploresounds.h llfloaterexploresounds.h
llfloaterevent.h llfloaterevent.h
llfloaterfeed.h
llfloaterfonttest.h llfloaterfonttest.h
llfloaterfriends.h llfloaterfriends.h
llfloatergesture.h llfloatergesture.h
@@ -749,7 +750,6 @@ set(viewer_HEADER_FILES
llfloatersellland.h llfloatersellland.h
llfloatersettingsdebug.h llfloatersettingsdebug.h
llfloatersnapshot.h llfloatersnapshot.h
llfloaterfeed.h
llfloaterstats.h llfloaterstats.h
llfloatertelehub.h llfloatertelehub.h
llfloaterteleporthistory.h llfloaterteleporthistory.h

View File

@@ -8222,6 +8222,17 @@ This should be as low as possible, but too low may break functionality</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
</map> </map>
<key>SnapshotFeedAddLocation</key>
<map>
<key>Comment</key>
<string>Include your location in your uploads to profile feed.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>LeftClickShowMenu</key> <key>LeftClickShowMenu</key>
<map> <map>
<key>Comment</key> <key>Comment</key>

View File

@@ -35,87 +35,46 @@
#include "llfloaterfeed.h" #include "llfloaterfeed.h"
#include "llfontgl.h" #include "llfloatersnapshot.h"
#include "llsys.h"
#include "llgl.h"
#include "v3dmath.h"
#include "lldir.h"
#include "llagent.h"
#include "llui.h"
#include "lllineeditor.h"
#include "llviewertexteditor.h"
#include "llbutton.h"
#include "llnotificationsutil.h"
#include "llviewercontrol.h"
#include "llviewernetwork.h"
#include "lluictrlfactory.h"
#include "lluploaddialog.h"
#include "llviewerstats.h"
#include "llviewerwindow.h"
#include "llstatusbar.h"
#include "llviewerregion.h"
#include "lleconomy.h"
#include "lltrans.h"
#include "llgl.h"
#include "llglheaders.h"
#include "llimagepng.h" #include "llimagepng.h"
#include "llimagej2c.h" #include "llnotificationsutil.h"
#include "llvfile.h" #include "lluictrlfactory.h"
#include "llvfs.h" #include "llviewertexture.h"
#include "llviewerwindow.h"
#include "llwebprofile.h"
#include "llassetuploadresponders.h" #include <boost/bind.hpp>
#include "hippogridmanager.h"
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
/// Class LLFloaterFeed /// Class LLFloaterFeed
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
LLFloaterFeed::LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global) : LLFloaterFeed::LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale) :
LLFloater(std::string("Feed Floater")), LLFloater(std::string("Feed Floater")),
mPNGImage(png), mViewerImage(img), mImageScale(img_scale), mPosTakenGlobal(pos_taken_global), mHasFirstMsgFocus(false) mPNGImage(png), mViewerImage(img), mImageScale(img_scale)
{ {
} }
// Destroys the object // Destroys the object
LLFloaterFeed::~LLFloaterFeed() LLFloaterFeed::~LLFloaterFeed()
{ {
mPNGImage = NULL; mPNGImage = NULL;
} }
BOOL LLFloaterFeed::postBuild() BOOL LLFloaterFeed::postBuild()
{ {
childSetAction("cancel_btn", onClickCancel, this); getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterFeed::onClickCancel, this));
childSetAction("send_btn", onClickSend, this); getChild<LLUICtrl>("post_btn")->setCommitCallback(boost::bind(&LLFloaterFeed::onClickPost, this));
childDisable("from_form"); return true;
std::string name_string;
gAgent.buildFullname(name_string);
childSetValue("name_form", LLSD(name_string));
LLTextEditor* MsgField = getChild<LLTextEditor>("msg_form");
if (MsgField)
{
MsgField->setWordWrap(TRUE);
// For the first time a user focusess to .the msg box, all text will be selected.
MsgField->setFocusChangedCallback(boost::bind(&LLFloaterFeed::onMsgFormFocusRecieved, this, _1, MsgField));
}
childSetFocus("to_form", TRUE);
return TRUE;
} }
// static // static
LLFloaterFeed* LLFloaterFeed::showFromSnapshot(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& image_scale, LLVector3d const& pos_taken_global) LLFloaterFeed* LLFloaterFeed::showFromSnapshot(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& image_scale)
{ {
// Take the images from the caller // Take the images from the caller
// It's now our job to clean them up // It's now our job to clean them up
LLFloaterFeed* instance = new LLFloaterFeed(png, img, image_scale, pos_taken_global); LLFloaterFeed* instance = new LLFloaterFeed(png, img, image_scale);
LLUICtrlFactory::getInstance()->buildFloater(instance, "floater_snapshot_feed.xml"); LLUICtrlFactory::getInstance()->buildFloater(instance, "floater_snapshot_feed.xml");
@@ -174,66 +133,37 @@ void LLFloaterFeed::draw(void)
} }
} }
// static void LLFloaterFeed::onClickCancel()
void LLFloaterFeed::onClickCancel(void* data)
{ {
if (data) close(false);
{
LLFloaterFeed* self = (LLFloaterFeed*)data;
self->close(false);
}
} }
// static void LLFloaterFeed::onClickPost()
void LLFloaterFeed::onClickSend(void* data)
{ {
if (data) if (mPNGImage.notNull())
{
LLFloaterFeed* self = (LLFloaterFeed*)data;
std::string from(self->childGetValue("from_form").asString());
std::string to(self->childGetValue("to_form").asString());
if (self->mPNGImage.notNull())
{ {
self->sendFeed(); static LLCachedControl<bool> add_location("SnapshotFeedAddLocation");
const std::string caption = childGetValue("caption").asString();
LLWebProfile::setImageUploadResultCallback(boost::bind(&LLFloaterSnapshot::saveFeedDone, _1, mPNGImage));
LLWebProfile::uploadImage(mPNGImage, caption, add_location);
// give user feedback of the event
gViewerWindow->playSnapshotAnimAndSound();
// don't destroy the window until the upload is done
// this way we keep the information in the form
setVisible(FALSE);
// remove any dependency on snapshot floater
// so we outlive it during the upload.
LLFloater* dependee = getDependee();
if (dependee)
{
dependee->removeDependentFloater(this);
}
} }
else else
{ {
LLNotificationsUtil::add("ErrorProcessingSnapshot"); LLNotificationsUtil::add("ErrorProcessingSnapshot");
} }
}
}
void LLFloaterFeed::onMsgFormFocusRecieved(LLFocusableElement* receiver, LLTextEditor* msg_form)
{
if (msg_form && msg_form == receiver && msg_form->hasFocus() && !(mHasFirstMsgFocus))
{
mHasFirstMsgFocus = true;
msg_form->setText(LLStringUtil::null);
}
}
void LLFloaterFeed::sendFeed(void)
{
// upload the image
// DO THE UPLOAD HERE
// give user feedback of the event
gViewerWindow->playSnapshotAnimAndSound();
LLUploadDialog::modalUploadDialog(getString("upload_message"));
// don't destroy the window until the upload is done
// this way we keep the information in the form
setVisible(FALSE);
// also remove any dependency on another floater
// so that we can be sure to outlive it while we
// need to.
LLFloater* dependee = getDependee();
if (dependee)
{
dependee->removeDependentFloater(this);
}
} }

View File

@@ -34,45 +34,29 @@
#include "llfloater.h" // LLFloater #include "llfloater.h" // LLFloater
#include "v2math.h" // LLVector2 #include "v2math.h" // LLVector2
#include "v3dmath.h" // LLVector3d
#include "llpointer.h" // LLPointer #include "llpointer.h" // LLPointer
#include "llextendedstatus.h" // LLExtStat
class LLImagePNG; class LLImagePNG;
class LLViewerTexture; class LLViewerTexture;
class LLUUID;
class LLFocusableElement;
class LLTextEditor;
class LLSD;
class LLFloaterFeed : public LLFloater class LLFloaterFeed : public LLFloater
{ {
public: public:
LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global); LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale);
virtual ~LLFloaterFeed(); virtual ~LLFloaterFeed();
virtual BOOL postBuild(void); /*virtual*/ BOOL postBuild();
virtual void draw(void); /*virtual*/ void draw();
static LLFloaterFeed* showFromSnapshot(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global); static LLFloaterFeed* showFromSnapshot(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale);
static void onClickCancel(void* data); void onClickCancel();
static void onClickSend(void* data); void onClickPost();
static void uploadCallback(LLUUID const& asset_id, void* user_data, S32 result, LLExtStat ext_status);
void onMsgFormFocusRecieved(LLFocusableElement* receiver, LLTextEditor* msg_form);
bool missingSubjMsgAlertCallback(LLSD const& notification, LLSD const& response);
void sendFeed(void);
protected: protected:
LLPointer<LLImagePNG> mPNGImage; LLPointer<LLImagePNG> mPNGImage;
LLPointer<LLViewerTexture> mViewerImage; LLPointer<LLViewerTexture> mViewerImage;
LLVector2 mImageScale; const LLVector2 mImageScale;
LLVector3d mPosTakenGlobal;
bool mHasFirstMsgFocus;
}; };
#endif // LL_LLFLOATERFEED_H #endif // LL_LLFLOATERFEED_H

View File

@@ -83,7 +83,6 @@
#include "llnotificationsutil.h" #include "llnotificationsutil.h"
#include "llvfile.h" #include "llvfile.h"
#include "llvfs.h" #include "llvfs.h"
#include "llwebprofile.h"
#include "hippogridmanager.h" #include "hippogridmanager.h"
@@ -177,7 +176,6 @@ public:
void showFreezeFrameSnapshot(bool show); void showFreezeFrameSnapshot(bool show);
void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f); void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f);
LLFloaterFeed* getCaptionAndSaveFeed(); LLFloaterFeed* getCaptionAndSaveFeed();
void saveFeed(std::string const& caption, bool add_location);
LLFloaterPostcard* savePostcard(); LLFloaterPostcard* savePostcard();
void saveTexture(); void saveTexture();
void saveTextureDone(bool success, LLPointer<LLImageFormatted> const& formatted_image); void saveTextureDone(bool success, LLPointer<LLImageFormatted> const& formatted_image);
@@ -969,6 +967,9 @@ void LLSnapshotLivePreview::generateFormattedAndFullscreenPreview(bool delayed)
case SNAPSHOT_LOCAL: case SNAPSHOT_LOCAL:
format = mSnapshotFormat; format = mSnapshotFormat;
break; break;
default:
format = mSnapshotFormat;
break;
} }
if (mFormattedImage && if (mFormattedImage &&
@@ -1211,20 +1212,13 @@ LLFloaterFeed* LLSnapshotLivePreview::getCaptionAndSaveFeed()
return NULL; return NULL;
} }
LLFloaterFeed* floater = LLFloaterFeed::showFromSnapshot(png, mFullScreenPreviewTexture, image_scale, mPosTakenGlobal); LLFloaterFeed* floater = LLFloaterFeed::showFromSnapshot(png, mFullScreenPreviewTexture, image_scale);
//updateSnapshot(FALSE, FALSE); //updateSnapshot(FALSE, FALSE);
return floater; return floater;
} }
void LLSnapshotLivePreview::saveFeed(std::string const& caption, bool add_location)
{
DoutEntering(dc::notice, "LLSnapshotLivePreview::saveFeed()");
LLWebProfile::setImageUploadResultCallback(boost::bind(&LLFloaterSnapshot::saveFeedDone, _1, mFormattedImage));
LLWebProfile::uploadImage(mFormattedImage, caption, add_location);
}
LLFloaterPostcard* LLSnapshotLivePreview::savePostcard() LLFloaterPostcard* LLSnapshotLivePreview::savePostcard()
{ {
if(mFullScreenPreviewTexture.isNull()) if(mFullScreenPreviewTexture.isNull())
@@ -2694,6 +2688,9 @@ char const* LLSnapshotLivePreview::aspectComboName() const
case SNAPSHOT_LOCAL: case SNAPSHOT_LOCAL:
result = "local_aspect_combo"; result = "local_aspect_combo";
break; break;
default:
result= "";
break;
} }
return result; return result;
} }

View File

@@ -3,32 +3,20 @@
can_minimize="false" can_minimize="false"
title="Post to My Profile Feed" title="Post to My Profile Feed"
height="380" height="380"
width="480" width="370"
layout="topleft" layout="topleft"
name="floater_snapshot_profile" name="floater_snapshot_profile"
rect_control="FloaterSnapshotFeedRect"> rect_control="FloaterSnapshotFeedRect">
<text
length="1"
follows="top|left"
top="-180"
font="SansSerif"
height="16"
layout="topleft"
left="10"
name="caption_label"
right="-10"
type="string">
Enter text to post below:
</text>
<text_editor <text_editor
follows="all" follows="bottom|left"
height="155" bottom="40"
layout="topleft" hide_scrollbar="true"
length="1" length="1"
max_length="700" max_length="700"
name="caption" name="caption"
top="-180"
left="10"
right="-10" right="-10"
bottom_delta="30"
type="string" type="string"
word_wrap="true"/> word_wrap="true"/>
<check_box <check_box