Upload code cleansing
I found our upload classes were in need of a tune up while researching Issue 896: Animation upload setting causes viewer crash So I started working to clean up llfloaterbvhpreview which lead me to llfloaternamedesc and the rest of our upload floaters I ended up pulling the sound upload hack out of LLFloaterNameDesc and into LLFloaterSoundPreview and moving LLFloaterAnimPreview into llfloaternamedesc.* Updated llviewermenufile.cpp a bit Removed setUploadAmount from LLFloaterImagePreview and LLFloaterBvhPreview as its purpose is served by LLGlobalEconomy::getPriceUpload and the hippogridmanager too. Fixed an issue with floater_animation_anim_preview.xml using [AMOUNT] instead of [UPLOADFEE] for its label. I'd say this might fix Issue 896, I certainly can't reproduce the crash I was having when testing for it anymore.
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
* @brief LLFloaterNameDesc class implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
@@ -70,31 +69,16 @@ const S32 PREF_BUTTON_HEIGHT = 16;
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLFloaterNameDesc()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLFloaterNameDesc::LLFloaterNameDesc(const std::string& filename )
|
||||
: LLFloater(std::string("Name/Description Floater"))
|
||||
{
|
||||
LLFloaterNameDesc::LLFloaterNameDesc(const LLSD& filename, void* item )
|
||||
: LLFloater(std::string("Name/Description Floater")),
|
||||
// <edit>
|
||||
mItem = NULL;
|
||||
mItem(item),
|
||||
// </edit>
|
||||
mFilenameAndPath = filename;
|
||||
mFilename = gDirUtilp->getBaseFileName(filename, false);
|
||||
// SL-5521 Maintain capitalization of filename when making the inventory item. JC
|
||||
//LLStringUtil::toLower(mFilename);
|
||||
mIsAudio = FALSE;
|
||||
}
|
||||
|
||||
// <edit>
|
||||
LLFloaterNameDesc::LLFloaterNameDesc(const std::string& filename, void* item )
|
||||
: LLFloater(std::string("Name/Description Floater"))
|
||||
mIsAudio(FALSE)
|
||||
{
|
||||
mItem = item;
|
||||
mFilenameAndPath = filename;
|
||||
mFilename = gDirUtilp->getBaseFileName(filename, false);
|
||||
// SL-5521 Maintain capitalization of filename when making the inventory item. JC
|
||||
//LLStringUtil::toLower(mFilename);
|
||||
mIsAudio = FALSE;
|
||||
mFilenameAndPath = filename.asString();
|
||||
mFilename = gDirUtilp->getBaseFileName(mFilenameAndPath, false);
|
||||
}
|
||||
// </edit>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// postBuild()
|
||||
@@ -109,11 +93,6 @@ BOOL LLFloaterNameDesc::postBuild()
|
||||
LLStringUtil::stripNonprintable(asset_name);
|
||||
LLStringUtil::trim(asset_name);
|
||||
|
||||
std::string exten = gDirUtilp->getExtension(asset_name);
|
||||
if (exten == "wav")
|
||||
{
|
||||
mIsAudio = TRUE;
|
||||
}
|
||||
asset_name = gDirUtilp->getBaseFileName(asset_name, true); // no extsntion
|
||||
|
||||
setTitle(mFilename);
|
||||
@@ -128,8 +107,8 @@ BOOL LLFloaterNameDesc::postBuild()
|
||||
|
||||
r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );
|
||||
|
||||
childSetCommitCallback("name_form", doCommit, this);
|
||||
childSetValue("name_form", LLSD(asset_name));
|
||||
getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this));
|
||||
getChild<LLUICtrl>("name_form")->setValue(LLSD(asset_name));
|
||||
|
||||
LLLineEditor *NameEditor = getChild<LLLineEditor>("name_form");
|
||||
if (NameEditor)
|
||||
@@ -142,7 +121,7 @@ BOOL LLFloaterNameDesc::postBuild()
|
||||
y -= PREVIEW_LINE_HEIGHT;
|
||||
|
||||
r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );
|
||||
childSetCommitCallback("description_form", doCommit, this);
|
||||
getChild<LLUICtrl>("description_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this));
|
||||
LLLineEditor *DescEditor = getChild<LLLineEditor>("description_form");
|
||||
if (DescEditor)
|
||||
{
|
||||
@@ -153,14 +132,10 @@ BOOL LLFloaterNameDesc::postBuild()
|
||||
y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);
|
||||
|
||||
// Cancel button
|
||||
childSetAction("cancel_btn", onBtnCancel, this);
|
||||
getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnCancel, this));
|
||||
|
||||
getChild<LLUICtrl>("ok_btn")->setLabelArg("[UPLOADFEE]", llformat("%s%d", gHippoGridManager->getConnectedGrid()->getCurrencySymbol().c_str(), LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()));
|
||||
|
||||
// OK button
|
||||
childSetLabelArg("ok_btn", "[UPLOADFEE]", gHippoGridManager->getConnectedGrid()->getUploadFee());
|
||||
if (exten == "wav")
|
||||
{
|
||||
childSetAction("ok_btn", onBtnOK, this);
|
||||
}
|
||||
setDefaultBtn("ok_btn");
|
||||
|
||||
return TRUE;
|
||||
@@ -182,45 +157,99 @@ void LLFloaterNameDesc::onCommit()
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
//-----------------------------------------------------------------------------
|
||||
// onCommit()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLFloaterNameDesc::doCommit( class LLUICtrl *, void* userdata )
|
||||
void LLFloaterNameDesc::doCommit()
|
||||
{
|
||||
LLFloaterNameDesc* self = (LLFloaterNameDesc*) userdata;
|
||||
self->onCommit();
|
||||
onCommit();
|
||||
}
|
||||
|
||||
// static
|
||||
//-----------------------------------------------------------------------------
|
||||
// onBtnOK()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLFloaterNameDesc::onBtnOK( void* userdata )
|
||||
void LLFloaterNameDesc::onBtnOK()
|
||||
{
|
||||
LLFloaterNameDesc *fp =(LLFloaterNameDesc *)userdata;
|
||||
|
||||
fp->childDisable("ok_btn"); // don't allow inadvertent extra uploads
|
||||
getChildView("ok_btn")->setEnabled(FALSE); // don't allow inadvertent extra uploads
|
||||
|
||||
LLAssetStorage::LLStoreAssetCallback callback = NULL;
|
||||
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
|
||||
void *nruserdata = NULL;
|
||||
std::string display_name = LLStringUtil::null;
|
||||
upload_new_resource(fp->mFilenameAndPath, // file
|
||||
fp->childGetValue("name_form").asString(),
|
||||
fp->childGetValue("description_form").asString(),
|
||||
upload_new_resource(mFilenameAndPath, // file
|
||||
getChild<LLUICtrl>("name_form")->getValue().asString(),
|
||||
getChild<LLUICtrl>("description_form")->getValue().asString(),
|
||||
0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
|
||||
LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
|
||||
display_name, callback, expected_upload_cost, nruserdata);
|
||||
fp->close(false);
|
||||
close(false);
|
||||
}
|
||||
|
||||
// static
|
||||
//-----------------------------------------------------------------------------
|
||||
// onBtnCancel()
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLFloaterNameDesc::onBtnCancel( void* userdata )
|
||||
void LLFloaterNameDesc::onBtnCancel()
|
||||
{
|
||||
LLFloaterNameDesc *fp =(LLFloaterNameDesc *)userdata;
|
||||
fp->close(false);
|
||||
close(false);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLFloaterSoundPreview()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLFloaterSoundPreview::LLFloaterSoundPreview(const LLSD& filename, void* item )
|
||||
: LLFloaterNameDesc(filename, item)
|
||||
{
|
||||
mIsAudio = TRUE;
|
||||
}
|
||||
|
||||
BOOL LLFloaterSoundPreview::postBuild()
|
||||
{
|
||||
if (!LLFloaterNameDesc::postBuild())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLFloaterAnimPreview()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLFloaterAnimPreview::LLFloaterAnimPreview(const LLSD& filename, void* item )
|
||||
: LLFloaterNameDesc(filename, item)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LLFloaterAnimPreview::postBuild()
|
||||
{
|
||||
if (!LLFloaterNameDesc::postBuild())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LLFloaterScriptPreview()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LLFloaterScriptPreview::LLFloaterScriptPreview(const LLSD& filename, void* item )
|
||||
: LLFloaterNameDesc(filename, item)
|
||||
{
|
||||
mIsText = TRUE;
|
||||
}
|
||||
|
||||
BOOL LLFloaterScriptPreview::postBuild()
|
||||
{
|
||||
if (!LLFloaterNameDesc::postBuild())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user