diff options
Diffstat (limited to 'indra/newview/llfloaternamedesc.cpp')
| -rw-r--r-- | indra/newview/llfloaternamedesc.cpp | 204 | 
1 files changed, 102 insertions, 102 deletions
diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index bbe125659f..01c50d89c5 100644 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -1,25 +1,25 @@ -/**  +/**   * @file llfloaternamedesc.cpp   * @brief LLFloaterNameDesc class implementation   *   * $LicenseInfo:firstyear=2002&license=viewerlgpl$   * Second Life Viewer Source Code   * Copyright (C) 2010, Linden Research, Inc. - *  + *   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public   * License as published by the Free Software Foundation;   * version 2.1 of the License only. - *  + *   * This library is distributed in the hope that it will be useful,   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   * Lesser General Public License for more details. - *  + *   * You should have received a copy of the GNU Lesser General Public   * License along with this library; if not, write to the Free Software   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA - *  + *   * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA   * $/LicenseInfo$   */ @@ -41,8 +41,8 @@  #include "lldir.h"  #include "llfloaterperms.h"  #include "llviewercontrol.h" -#include "llviewermenufile.h"	// upload_new_resource() -#include "llstatusbar.h"	// can_afford_transaction() +#include "llviewermenufile.h"   // upload_new_resource() +#include "llstatusbar.h"    // can_afford_transaction()  #include "llnotificationsutil.h"  #include "lluictrlfactory.h"  #include "llstring.h" @@ -63,11 +63,11 @@ const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;  // LLFloaterNameDesc()  //-----------------------------------------------------------------------------  LLFloaterNameDesc::LLFloaterNameDesc(const LLSD& filename ) -	: LLFloater(filename), -	  mIsAudio(false)	   +    : LLFloater(filename), +      mIsAudio(false)  { -	mFilenameAndPath = filename.asString(); -	mFilename = gDirUtilp->getBaseFileName(mFilenameAndPath, false); +    mFilenameAndPath = filename.asString(); +    mFilename = gDirUtilp->getBaseFileName(mFilenameAndPath, false);  }  //----------------------------------------------------------------------------- @@ -75,86 +75,86 @@ LLFloaterNameDesc::LLFloaterNameDesc(const LLSD& filename )  //-----------------------------------------------------------------------------  bool LLFloaterNameDesc::postBuild()  { -	LLRect r; +    LLRect r; + +    std::string asset_name = mFilename; +    LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); +    LLStringUtil::replaceChar(asset_name, '|', '?'); +    LLStringUtil::stripNonprintable(asset_name); +    LLStringUtil::trim(asset_name); + +    asset_name = gDirUtilp->getBaseFileName(asset_name, true); // no extsntion -	std::string asset_name = mFilename; -	LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); -	LLStringUtil::replaceChar(asset_name, '|', '?'); -	LLStringUtil::stripNonprintable(asset_name); -	LLStringUtil::trim(asset_name); +    setTitle(mFilename); -	asset_name = gDirUtilp->getBaseFileName(asset_name, true); // no extsntion +    centerWithin(gViewerWindow->getRootView()->getRect()); -	setTitle(mFilename); +    S32 line_width = getRect().getWidth() - 2 * PREVIEW_HPAD; +    S32 y = getRect().getHeight() - PREVIEW_LINE_HEIGHT; -	centerWithin(gViewerWindow->getRootView()->getRect()); +    r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT ); +    y -= PREVIEW_LINE_HEIGHT; -	S32 line_width = getRect().getWidth() - 2 * PREVIEW_HPAD; -	S32 y = getRect().getHeight() - PREVIEW_LINE_HEIGHT; +    r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT ); -	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT ); -	y -= PREVIEW_LINE_HEIGHT; +    getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this)); +    getChild<LLUICtrl>("name_form")->setValue(LLSD(asset_name)); -	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );     +    LLLineEditor *NameEditor = getChild<LLLineEditor>("name_form"); +    if (NameEditor) +    { +        NameEditor->setMaxTextLength(DB_INV_ITEM_NAME_STR_LEN); +        NameEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); +    } -	getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this)); -	getChild<LLUICtrl>("name_form")->setValue(LLSD(asset_name)); +    y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f); +    y -= PREVIEW_LINE_HEIGHT; -	LLLineEditor *NameEditor = getChild<LLLineEditor>("name_form"); -	if (NameEditor) -	{ -		NameEditor->setMaxTextLength(DB_INV_ITEM_NAME_STR_LEN); -		NameEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); -	} +    r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT ); +    getChild<LLUICtrl>("description_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this)); +    LLLineEditor *DescEditor = getChild<LLLineEditor>("description_form"); +    if (DescEditor) +    { +        DescEditor->setMaxTextLength(DB_INV_ITEM_DESC_STR_LEN); +        DescEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); +    } -	y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f); -	y -= PREVIEW_LINE_HEIGHT; +    y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f); -	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );   -	getChild<LLUICtrl>("description_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this)); -	LLLineEditor *DescEditor = getChild<LLLineEditor>("description_form"); -	if (DescEditor) -	{ -		DescEditor->setMaxTextLength(DB_INV_ITEM_DESC_STR_LEN); -		DescEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); -	} +    // Cancel button +    getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnCancel, this)); -	y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f); +    S32 expected_upload_cost = getExpectedUploadCost(); +    getChild<LLUICtrl>("ok_btn")->setLabelArg("[AMOUNT]", llformat("%d", expected_upload_cost)); -	// Cancel button -	getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnCancel, this)); +    LLTextBox* info_text = getChild<LLTextBox>("info_text"); +    if (info_text) +    { +        info_text->setValue(LLTrans::getString("UploadFeeInfo")); +    } -	S32 expected_upload_cost = getExpectedUploadCost(); -	getChild<LLUICtrl>("ok_btn")->setLabelArg("[AMOUNT]", llformat("%d", expected_upload_cost)); +    setDefaultBtn("ok_btn"); -	LLTextBox* info_text = getChild<LLTextBox>("info_text"); -	if (info_text) -	{ -		info_text->setValue(LLTrans::getString("UploadFeeInfo")); -	} -	 -	setDefaultBtn("ok_btn"); -	 -	return true; +    return true;  }  S32 LLFloaterNameDesc::getExpectedUploadCost() const  {      std::string exten = gDirUtilp->getExtension(mFilename); -	LLAssetType::EType asset_type; -	S32 upload_cost = -1; -	if (LLResourceUploadInfo::findAssetTypeOfExtension(exten, asset_type)) -	{ -		if (!LLAgentBenefitsMgr::current().findUploadCost(asset_type, upload_cost)) -		{ -			LL_WARNS() << "Unable to find upload cost for asset type " << asset_type << LL_ENDL; -		} -	} -	else -	{ -		LL_WARNS() << "Unable to find upload cost for " << mFilename << LL_ENDL; -	} -	return upload_cost; +    LLAssetType::EType asset_type; +    S32 upload_cost = -1; +    if (LLResourceUploadInfo::findAssetTypeOfExtension(exten, asset_type)) +    { +        if (!LLAgentBenefitsMgr::current().findUploadCost(asset_type, upload_cost)) +        { +            LL_WARNS() << "Unable to find upload cost for asset type " << asset_type << LL_ENDL; +        } +    } +    else +    { +        LL_WARNS() << "Unable to find upload cost for " << mFilename << LL_ENDL; +    } +    return upload_cost;  }  //----------------------------------------------------------------------------- @@ -162,7 +162,7 @@ S32 LLFloaterNameDesc::getExpectedUploadCost() const  //-----------------------------------------------------------------------------  LLFloaterNameDesc::~LLFloaterNameDesc()  { -	gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() +    gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit()  }  // Sub-classes should override this function if they allow editing @@ -178,7 +178,7 @@ void LLFloaterNameDesc::onCommit()  //-----------------------------------------------------------------------------  void LLFloaterNameDesc::doCommit()  { -	onCommit(); +    onCommit();  }  //----------------------------------------------------------------------------- @@ -186,10 +186,10 @@ void LLFloaterNameDesc::doCommit()  //-----------------------------------------------------------------------------  void LLFloaterNameDesc::onBtnOK( )  { -	getChildView("ok_btn")->setEnabled(false); // don't allow inadvertent extra uploads -	 -	LLAssetStorage::LLStoreAssetCallback callback; -	S32 expected_upload_cost = getExpectedUploadCost(); +    getChildView("ok_btn")->setEnabled(false); // don't allow inadvertent extra uploads + +    LLAssetStorage::LLStoreAssetCallback callback; +    S32 expected_upload_cost = getExpectedUploadCost();      if (can_afford_transaction(expected_upload_cost))      {          void *nruserdata = NULL; @@ -214,7 +214,7 @@ void LLFloaterNameDesc::onBtnOK( )          LLNotificationsUtil::add("ErrorCannotAffordUpload", args);      } -	closeFloater(false); +    closeFloater(false);  }  //----------------------------------------------------------------------------- @@ -222,7 +222,7 @@ void LLFloaterNameDesc::onBtnOK( )  //-----------------------------------------------------------------------------  void LLFloaterNameDesc::onBtnCancel()  { -	closeFloater(false); +    closeFloater(false);  } @@ -231,19 +231,19 @@ void LLFloaterNameDesc::onBtnCancel()  //-----------------------------------------------------------------------------  LLFloaterSoundPreview::LLFloaterSoundPreview(const LLSD& filename ) -	: LLFloaterNameDesc(filename) +    : LLFloaterNameDesc(filename)  { -	mIsAudio = true; +    mIsAudio = true;  }  bool LLFloaterSoundPreview::postBuild()  { -	if (!LLFloaterNameDesc::postBuild()) -	{ -		return false; -	} -	getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); -	return true; +    if (!LLFloaterNameDesc::postBuild()) +    { +        return false; +    } +    getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); +    return true;  } @@ -252,18 +252,18 @@ bool LLFloaterSoundPreview::postBuild()  //-----------------------------------------------------------------------------  LLFloaterAnimPreview::LLFloaterAnimPreview(const LLSD& filename ) -	: LLFloaterNameDesc(filename) +    : LLFloaterNameDesc(filename)  {  }  bool LLFloaterAnimPreview::postBuild()  { -	if (!LLFloaterNameDesc::postBuild()) -	{ -		return false; -	} -	getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); -	return true; +    if (!LLFloaterNameDesc::postBuild()) +    { +        return false; +    } +    getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); +    return true;  }  //----------------------------------------------------------------------------- @@ -271,17 +271,17 @@ bool LLFloaterAnimPreview::postBuild()  //-----------------------------------------------------------------------------  LLFloaterScriptPreview::LLFloaterScriptPreview(const LLSD& filename ) -	: LLFloaterNameDesc(filename) +    : LLFloaterNameDesc(filename)  { -	mIsText = true; +    mIsText = true;  }  bool LLFloaterScriptPreview::postBuild()  { -	if (!LLFloaterNameDesc::postBuild()) -	{ -		return false; -	} -	getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); -	return true; +    if (!LLFloaterNameDesc::postBuild()) +    { +        return false; +    } +    getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); +    return true;  }  | 
