Moves some constants out of llavatarconstants.h 8ebf8f4608bd: Change various const constants to constexpr e07d5d43ba30: CID-143595 30b6935fc66d: CID-143595 acc96f9051cb: Fix a memory leak in viewer side baking initial wearable setup Sync llmodel.* Changesets assimilated: f8f7706c2902: CID-143554 - fix out of bounds access 223eb65adce4: CID-143554 - Chase 2ceb49aaa133: CID-42838, CID-42930, CID-42933, CID-42938, CID-42940, CID-42945, CID-42948, CID-56111, CID-83907 d220005d9f23: Missing null check before deref 31dbb0f3b6ee: CID-42571 CID-42576 CID-42578 49caf082e65c: change unordered_map to flat_map Doesn't cause as many problems as a hashmap when it comes to assumptions in the LLUI system. f93f5e881484: "update" linux cef downgrade to fix javascript problems cba818dd9269: Various null checks and etc. 1b4c6bc483bb: CID-42847, CID-42854, CID-42886, CID-42921, CID-42922, CID-42923, CID-42924, CID-42925, CID-42927, CID-42928, CID-83871, CID-83876, CID-83878, CID-83880, CID-83900, CID-143573 0fe90cd9ec24: Various file size related things a79f6f653dca: CID-42918 - Initialize member pointers in LLFloaterGodTools 0b70d600d978: Tweak LLFloaterBuyLand initializations e8b173ffe813: CID-42854 - Additional fix to LLDrawInfo b5d745cf3fde: Fix signage 4f2e2f384781: Initialize and cleanup various class member variables. CID-42899, CID-42900, CID-42902, CID-42903, CID-42904, CID-42905, CID-42909, CID-42910, CID-42911, CID-42912, CID-42913, CID-42967, CID-83853, CID-83898, CID-83890, CID-143584 9851a3e39b4c: Fix platform specific include directories 5c074e84f1be: Initialize and clenaup various more class member variables. CID-42885, CID-42853, CID-42894, CID-42895, CID-42896, CID-83908, CID-143574, CID-143575, CID-143576, CID-143576, CID-143578 ac262854ac92: Brace sub-object in initialization to make our intentions clear to clang 358da477d4c1: More double brace init c3850119314a: Initialize various member pointers in panels CID-83902, CID-83903, CID-83905, CID-83909, CID-83911, CID-83912, CID-143572
323 lines
9.9 KiB
C++
323 lines
9.9 KiB
C++
/**
|
|
* @file llfloatermediasettings.cpp
|
|
* @brief Tabbed dialog for media settings - 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$
|
|
*/
|
|
|
|
#include "llviewerprecompiledheaders.h"
|
|
|
|
#include "llfloatermediasettings.h"
|
|
#include "llfloaterwhitelistentry.h"
|
|
#include "llpanelmediasettingsgeneral.h"
|
|
#include "llpanelmediasettingssecurity.h"
|
|
#include "llpanelmediasettingspermissions.h"
|
|
#include "llviewercontrol.h"
|
|
#include "lluictrlfactory.h"
|
|
#include "llbutton.h"
|
|
#include "llselectmgr.h"
|
|
#include "llsdutil.h"
|
|
|
|
LLFloaterMediaSettings* LLFloaterMediaSettings::sInstance = NULL;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
LLFloaterMediaSettings::LLFloaterMediaSettings(const LLSD& key)
|
|
: LLFloater(key),
|
|
mOKBtn(nullptr),
|
|
mCancelBtn(nullptr),
|
|
mApplyBtn(nullptr),
|
|
mTabContainer(nullptr),
|
|
mPanelMediaSettingsGeneral(nullptr),
|
|
mPanelMediaSettingsSecurity(nullptr),
|
|
mPanelMediaSettingsPermissions(nullptr),
|
|
mWaitingToClose( false ),
|
|
mIdenticalHasMediaInfo( true ),
|
|
mMultipleMedia(false),
|
|
mMultipleValidMedia(false)
|
|
{
|
|
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_media_settings.xml", NULL, false);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
LLFloaterMediaSettings::~LLFloaterMediaSettings()
|
|
{
|
|
if ( mPanelMediaSettingsGeneral )
|
|
{
|
|
delete mPanelMediaSettingsGeneral;
|
|
mPanelMediaSettingsGeneral = NULL;
|
|
}
|
|
|
|
if ( mPanelMediaSettingsSecurity )
|
|
{
|
|
delete mPanelMediaSettingsSecurity;
|
|
mPanelMediaSettingsSecurity = NULL;
|
|
}
|
|
|
|
if ( mPanelMediaSettingsPermissions )
|
|
{
|
|
delete mPanelMediaSettingsPermissions;
|
|
mPanelMediaSettingsPermissions = NULL;
|
|
}
|
|
|
|
sInstance = NULL;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
BOOL LLFloaterMediaSettings::postBuild()
|
|
{
|
|
mApplyBtn = getChild<LLButton>("Apply");
|
|
mApplyBtn->setClickedCallback(onBtnApply, this);
|
|
|
|
mCancelBtn = getChild<LLButton>("Cancel");
|
|
mCancelBtn->setClickedCallback(onBtnCancel, this);
|
|
|
|
mOKBtn = getChild<LLButton>("OK");
|
|
mOKBtn->setClickedCallback(onBtnOK, this);
|
|
|
|
mTabContainer = getChild<LLTabContainer>( "tab_container" );
|
|
|
|
mPanelMediaSettingsGeneral = new LLPanelMediaSettingsGeneral();
|
|
mTabContainer->addTabPanel( mPanelMediaSettingsGeneral, mPanelMediaSettingsGeneral->getLabel() );
|
|
mPanelMediaSettingsGeneral->setParent( this );
|
|
|
|
// note that "permissions" tab is really "Controls" tab - refs to 'perms' and
|
|
// 'permissions' not changed to 'controls' since we don't want to change
|
|
// shared files in server code and keeping everything the same seemed best.
|
|
mPanelMediaSettingsPermissions = new LLPanelMediaSettingsPermissions();
|
|
mTabContainer->addTabPanel( mPanelMediaSettingsPermissions, mPanelMediaSettingsPermissions->getLabel() );
|
|
|
|
mPanelMediaSettingsSecurity = new LLPanelMediaSettingsSecurity();
|
|
mTabContainer->addTabPanel( mPanelMediaSettingsSecurity, mPanelMediaSettingsSecurity->getLabel() );
|
|
mPanelMediaSettingsSecurity->setParent( this );
|
|
|
|
// restore the last tab viewed from persistance variable storage
|
|
if (!mTabContainer->selectTab(gSavedSettings.getS32("LastMediaSettingsTab")))
|
|
{
|
|
mTabContainer->selectFirstTab();
|
|
};
|
|
|
|
sInstance = this;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//static
|
|
LLFloaterMediaSettings* LLFloaterMediaSettings::getInstance()
|
|
{
|
|
if ( !sInstance )
|
|
{
|
|
sInstance = new LLFloaterMediaSettings(LLSD());
|
|
sInstance->setVisible(FALSE);
|
|
}
|
|
|
|
return sInstance;
|
|
}
|
|
|
|
//static
|
|
void LLFloaterMediaSettings::apply()
|
|
{
|
|
if (sInstance->haveValuesChanged())
|
|
{
|
|
LLSD settings;
|
|
sInstance->mPanelMediaSettingsGeneral->preApply();
|
|
sInstance->mPanelMediaSettingsGeneral->getValues( settings, false );
|
|
sInstance->mPanelMediaSettingsSecurity->preApply();
|
|
sInstance->mPanelMediaSettingsSecurity->getValues( settings, false );
|
|
sInstance->mPanelMediaSettingsPermissions->preApply();
|
|
sInstance->mPanelMediaSettingsPermissions->getValues( settings, false );
|
|
|
|
LLSelectMgr::getInstance()->selectionSetMedia( LLTextureEntry::MF_HAS_MEDIA, settings );
|
|
|
|
sInstance->mPanelMediaSettingsGeneral->postApply();
|
|
sInstance->mPanelMediaSettingsSecurity->postApply();
|
|
sInstance->mPanelMediaSettingsPermissions->postApply();
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
void LLFloaterMediaSettings::onClose(bool app_quitting)
|
|
{
|
|
if(mPanelMediaSettingsGeneral)
|
|
{
|
|
mPanelMediaSettingsGeneral->onClose(app_quitting);
|
|
}
|
|
if(LLFloaterWhiteListEntry::instanceExists())
|
|
LLFloaterWhiteListEntry::getInstance()->close(app_quitting);
|
|
|
|
LLFloater::onClose(app_quitting);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//static
|
|
void LLFloaterMediaSettings::initValues( const LLSD& media_settings, bool editable )
|
|
{
|
|
if (sInstance->hasFocus()) return;
|
|
|
|
sInstance->clearValues(editable);
|
|
// update all panels with values from simulator
|
|
sInstance->mPanelMediaSettingsGeneral->
|
|
initValues( sInstance->mPanelMediaSettingsGeneral, media_settings, editable );
|
|
|
|
sInstance->mPanelMediaSettingsSecurity->
|
|
initValues( sInstance->mPanelMediaSettingsSecurity, media_settings, editable );
|
|
|
|
sInstance->mPanelMediaSettingsPermissions->
|
|
initValues( sInstance->mPanelMediaSettingsPermissions, media_settings, editable );
|
|
|
|
// Squirrel away initial values
|
|
sInstance->mInitialValues.clear();
|
|
sInstance->mPanelMediaSettingsGeneral->getValues( sInstance->mInitialValues );
|
|
sInstance->mPanelMediaSettingsSecurity->getValues( sInstance->mInitialValues );
|
|
sInstance->mPanelMediaSettingsPermissions->getValues( sInstance->mInitialValues );
|
|
|
|
sInstance->mApplyBtn->setEnabled(editable);
|
|
sInstance->mOKBtn->setEnabled(editable);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
void LLFloaterMediaSettings::commitFields()
|
|
{
|
|
if (hasFocus())
|
|
{
|
|
LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
|
|
if (cur_focus && cur_focus->acceptsTextInput())
|
|
{
|
|
cur_focus->onCommit();
|
|
};
|
|
};
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//static
|
|
void LLFloaterMediaSettings::clearValues( bool editable)
|
|
{
|
|
if (sInstance)
|
|
{
|
|
// clean up all panels before updating
|
|
sInstance->mPanelMediaSettingsGeneral ->clearValues(sInstance->mPanelMediaSettingsGeneral, editable);
|
|
sInstance->mPanelMediaSettingsSecurity ->clearValues(sInstance->mPanelMediaSettingsSecurity, editable);
|
|
sInstance->mPanelMediaSettingsPermissions->clearValues(sInstance->mPanelMediaSettingsPermissions, editable);
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// static
|
|
void LLFloaterMediaSettings::onBtnOK( void* userdata )
|
|
{
|
|
sInstance->commitFields();
|
|
|
|
sInstance->apply();
|
|
|
|
sInstance->close();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// static
|
|
void LLFloaterMediaSettings::onBtnApply( void* userdata )
|
|
{
|
|
sInstance->commitFields();
|
|
|
|
sInstance->apply();
|
|
|
|
sInstance->mInitialValues.clear();
|
|
sInstance->mPanelMediaSettingsGeneral->getValues( sInstance->mInitialValues );
|
|
sInstance->mPanelMediaSettingsSecurity->getValues( sInstance->mInitialValues );
|
|
sInstance->mPanelMediaSettingsPermissions->getValues( sInstance->mInitialValues );
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// static
|
|
void LLFloaterMediaSettings::onBtnCancel( void* userdata )
|
|
{
|
|
sInstance->close();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// static
|
|
void LLFloaterMediaSettings::onTabChanged(void* user_data, bool from_click)
|
|
{
|
|
LLTabContainer* self = (LLTabContainer*)user_data;
|
|
gSavedSettings.setS32("LastMediaSettingsTab", self->getCurrentPanelIndex());
|
|
}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
const std::string LLFloaterMediaSettings::getHomeUrl()
|
|
{
|
|
if ( mPanelMediaSettingsGeneral )
|
|
return mPanelMediaSettingsGeneral->getHomeUrl();
|
|
else
|
|
return std::string( "" );
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// virtual
|
|
void LLFloaterMediaSettings::draw()
|
|
{
|
|
if (NULL != mApplyBtn)
|
|
{
|
|
// Set the enabled state of the "Apply" button if values changed
|
|
mApplyBtn->setEnabled( haveValuesChanged() );
|
|
}
|
|
|
|
LLFloater::draw();
|
|
}
|
|
|
|
|
|
//private
|
|
bool LLFloaterMediaSettings::haveValuesChanged() const
|
|
{
|
|
bool values_changed = false;
|
|
// *NOTE: The code below is very inefficient. Better to do this
|
|
// only when data change.
|
|
// Every frame, check to see what the values are. If they are not
|
|
// the same as the initial media data, enable the OK/Apply buttons
|
|
LLSD settings;
|
|
sInstance->mPanelMediaSettingsGeneral->getValues( settings );
|
|
sInstance->mPanelMediaSettingsSecurity->getValues( settings );
|
|
sInstance->mPanelMediaSettingsPermissions->getValues( settings );
|
|
LLSD::map_const_iterator iter = settings.beginMap();
|
|
LLSD::map_const_iterator end = settings.endMap();
|
|
for ( ; iter != end; ++iter )
|
|
{
|
|
const std::string ¤t_key = iter->first;
|
|
const LLSD ¤t_value = iter->second;
|
|
if ( ! llsd_equals(current_value, mInitialValues[current_key]))
|
|
{
|
|
values_changed = true;
|
|
break;
|
|
}
|
|
}
|
|
return values_changed;
|
|
}
|
|
|
|
bool LLFloaterMediaSettings::instanceExists()
|
|
{
|
|
return sInstance;
|
|
}
|
|
|
|
|