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
llfloaterexploreanimations.cpp
llfloaterexploresounds.cpp
llfloaterfriends.cpp
llfloaterfeed.cpp
llfloaterfonttest.cpp
llfloaterfriends.cpp
llfloatergesture.cpp
llfloatergodtools.cpp
llfloatergroupinfo.cpp
@@ -241,7 +242,6 @@ set(viewer_SOURCE_FILES
llfloatersellland.cpp
llfloatersettingsdebug.cpp
llfloatersnapshot.cpp
llfloaterfeed.cpp
llfloaterstats.cpp
llfloatertelehub.cpp
llfloaterteleporthistory.cpp
@@ -704,6 +704,7 @@ set(viewer_HEADER_FILES
llfloaterexploreanimations.h
llfloaterexploresounds.h
llfloaterevent.h
llfloaterfeed.h
llfloaterfonttest.h
llfloaterfriends.h
llfloatergesture.h
@@ -749,7 +750,6 @@ set(viewer_HEADER_FILES
llfloatersellland.h
llfloatersettingsdebug.h
llfloatersnapshot.h
llfloaterfeed.h
llfloaterstats.h
llfloatertelehub.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>
<integer>0</integer>
</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>
<map>
<key>Comment</key>

View File

@@ -35,87 +35,46 @@
#include "llfloaterfeed.h"
#include "llfontgl.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 "llfloatersnapshot.h"
#include "llimagepng.h"
#include "llimagej2c.h"
#include "llvfile.h"
#include "llvfs.h"
#include "llnotificationsutil.h"
#include "lluictrlfactory.h"
#include "llviewertexture.h"
#include "llviewerwindow.h"
#include "llwebprofile.h"
#include "llassetuploadresponders.h"
#include "hippogridmanager.h"
#include <boost/bind.hpp>
///----------------------------------------------------------------------------
/// Class LLFloaterFeed
///----------------------------------------------------------------------------
LLFloaterFeed::LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale, LLVector3d const& pos_taken_global) :
LLFloater(std::string("Feed Floater")),
mPNGImage(png), mViewerImage(img), mImageScale(img_scale), mPosTakenGlobal(pos_taken_global), mHasFirstMsgFocus(false)
LLFloaterFeed::LLFloaterFeed(LLImagePNG* png, LLViewerTexture* img, LLVector2 const& img_scale) :
LLFloater(std::string("Feed Floater")),
mPNGImage(png), mViewerImage(img), mImageScale(img_scale)
{
}
// Destroys the object
LLFloaterFeed::~LLFloaterFeed()
{
mPNGImage = NULL;
mPNGImage = NULL;
}
BOOL LLFloaterFeed::postBuild()
{
childSetAction("cancel_btn", onClickCancel, this);
childSetAction("send_btn", onClickSend, this);
getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterFeed::onClickCancel, this));
getChild<LLUICtrl>("post_btn")->setCommitCallback(boost::bind(&LLFloaterFeed::onClickPost, this));
childDisable("from_form");
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;
return true;
}
// 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
// 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");
@@ -174,66 +133,37 @@ void LLFloaterFeed::draw(void)
}
}
// static
void LLFloaterFeed::onClickCancel(void* data)
void LLFloaterFeed::onClickCancel()
{
if (data)
{
LLFloaterFeed* self = (LLFloaterFeed*)data;
self->close(false);
}
close(false);
}
// static
void LLFloaterFeed::onClickSend(void* data)
void LLFloaterFeed::onClickPost()
{
if (data)
{
LLFloaterFeed* self = (LLFloaterFeed*)data;
std::string from(self->childGetValue("from_form").asString());
std::string to(self->childGetValue("to_form").asString());
if (self->mPNGImage.notNull())
if (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
{
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 "v2math.h" // LLVector2
#include "v3dmath.h" // LLVector3d
#include "llpointer.h" // LLPointer
#include "llextendedstatus.h" // LLExtStat
class LLImagePNG;
class LLViewerTexture;
class LLUUID;
class LLFocusableElement;
class LLTextEditor;
class LLSD;
class LLFloaterFeed : public LLFloater
{
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 BOOL postBuild(void);
virtual void draw(void);
/*virtual*/ BOOL postBuild();
/*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);
static void onClickSend(void* data);
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);
void onClickCancel();
void onClickPost();
protected:
LLPointer<LLImagePNG> mPNGImage;
LLPointer<LLViewerTexture> mViewerImage;
LLVector2 mImageScale;
LLVector3d mPosTakenGlobal;
bool mHasFirstMsgFocus;
const LLVector2 mImageScale;
};
#endif // LL_LLFLOATERFEED_H

View File

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

View File

@@ -3,32 +3,20 @@
can_minimize="false"
title="Post to My Profile Feed"
height="380"
width="480"
width="370"
layout="topleft"
name="floater_snapshot_profile"
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
follows="all"
height="155"
layout="topleft"
follows="bottom|left"
bottom="40"
hide_scrollbar="true"
length="1"
max_length="700"
name="caption"
top="-180"
left="10"
right="-10"
bottom_delta="30"
type="string"
word_wrap="true"/>
<check_box