FIX DEV-42093 - Make sure to navigate home if current URL is empty on "Apply"

This change gets rid of the crufty (and confusing) "apply()"
functions from llpanelmediasettings*.  Those functions were
never being called, yet changes were being made in them.

Instead, I added "preApply()" and "postApply()" to each of
these panels, which the floater (who really does the "apply()"ing)
now calls before and after it applies the changes to the
media data.
master
Rick Pasetto 2009-11-09 16:56:33 -08:00
parent c9937716aa
commit ebbb468a79
7 changed files with 158 additions and 120 deletions

View File

@ -145,13 +145,18 @@ LLFloaterMediaSettings* LLFloaterMediaSettings::getInstance()
//static
void LLFloaterMediaSettings::apply()
{
LLSD settings;
sInstance->mPanelMediaSettingsGeneral->preApply();
sInstance->mPanelMediaSettingsGeneral->getValues( settings );
sInstance->mPanelMediaSettingsSecurity->getValues( settings );
sInstance->mPanelMediaSettingsSecurity->preApply();
sInstance->mPanelMediaSettingsSecurity->getValues( settings );
sInstance->mPanelMediaSettingsPermissions->preApply();
sInstance->mPanelMediaSettingsPermissions->getValues( settings );
LLSelectMgr::getInstance()->selectionSetMedia( LLTextureEntry::MF_HAS_MEDIA );
LLSelectMgr::getInstance()->selectionSetMediaData(settings);
sInstance->mPanelMediaSettingsGeneral->postApply();
sInstance->mPanelMediaSettingsSecurity->postApply();
sInstance->mPanelMediaSettingsPermissions->postApply();
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -366,21 +366,15 @@ void LLPanelMediaSettingsGeneral::onCommitHomeURL( LLUICtrl* ctrl, void *userdat
void LLPanelMediaSettingsGeneral::onBtnResetCurrentUrl(LLUICtrl* ctrl, void *userdata)
{
LLPanelMediaSettingsGeneral* self =(LLPanelMediaSettingsGeneral *)userdata;
self->navigateHomeSelectedFace();
self->navigateHomeSelectedFace(false);
}
////////////////////////////////////////////////////////////////////////////////
// static
void LLPanelMediaSettingsGeneral::apply( void* userdata )
//
void LLPanelMediaSettingsGeneral::preApply()
{
LLPanelMediaSettingsGeneral *self =(LLPanelMediaSettingsGeneral *)userdata;
self->mHomeURL->onCommit();
// build LLSD Fragment
LLSD media_data_general;
self->getValues(media_data_general);
// this merges contents of LLSD passed in with what's there so this is ok
LLSelectMgr::getInstance()->selectionSetMediaData( media_data_general );
// Make sure the home URL entry is committed
mHomeURL->onCommit();
}
////////////////////////////////////////////////////////////////////////////////
@ -392,13 +386,24 @@ void LLPanelMediaSettingsGeneral::getValues( LLSD &fill_me_in )
fill_me_in[LLMediaEntry::AUTO_SCALE_KEY] = mAutoScale->getValue();
fill_me_in[LLMediaEntry::AUTO_ZOOM_KEY] = mAutoZoom->getValue();
fill_me_in[LLMediaEntry::CONTROLS_KEY] = mControls->getCurrentIndex();
fill_me_in[LLMediaEntry::CURRENT_URL_KEY] = mCurrentURL->getValue();
//Don't fill in current URL: this is only supposed to get changed via navigate
// fill_me_in[LLMediaEntry::CURRENT_URL_KEY] = mCurrentURL->getValue();
fill_me_in[LLMediaEntry::HEIGHT_PIXELS_KEY] = mHeightPixels->getValue();
fill_me_in[LLMediaEntry::HOME_URL_KEY] = mHomeURL->getValue();
fill_me_in[LLMediaEntry::FIRST_CLICK_INTERACT_KEY] = mFirstClick->getValue();
fill_me_in[LLMediaEntry::WIDTH_PIXELS_KEY] = mWidthPixels->getValue();
}
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsGeneral::postApply()
{
// Make sure to navigate to the home URL if the current URL is empty and
// autoplay is on
navigateHomeSelectedFace(true);
}
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsGeneral::setParent( LLFloaterMediaSettings* parent )
@ -406,33 +411,37 @@ void LLPanelMediaSettingsGeneral::setParent( LLFloaterMediaSettings* parent )
mParent = parent;
};
bool LLPanelMediaSettingsGeneral::navigateHomeSelectedFace()
////////////////////////////////////////////////////////////////////////////////
//
bool LLPanelMediaSettingsGeneral::navigateHomeSelectedFace(bool only_if_current_is_empty)
{
// HACK: This is directly referencing an impl name. BAD!
// This can be removed when we have a truly generic media browser that only
// builds an impl based on the type of url it is passed.
struct functor_navigate_media : public LLSelectedTEGetFunctor< bool>
{
functor_navigate_media(bool flag) : only_if_current_is_empty(flag) {}
bool get( LLViewerObject* object, S32 face )
{
if ( object )
if ( object->getTE(face) )
if ( object->getTE(face)->getMediaData() )
if ( object && object->getTE(face) && object->permModify() )
{
const LLMediaEntry *media_data = object->getTE(face)->getMediaData();
if ( media_data )
{
if (!only_if_current_is_empty || (media_data->getCurrentURL().empty() && media_data->getAutoPlay()))
{
if(object->permModify())
viewer_media_t media_impl =
LLViewerMedia::getMediaImplFromTextureID(object->getTE(face)->getMediaData()->getMediaID());
if(media_impl)
{
viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(object->getTE(face)->getMediaData()->getMediaID());
if(media_impl)
{
media_impl->navigateHome();
return true;
}
}
media_impl->navigateHome();
return true;
}
}
return false;
};
}
}
return false;
};
bool only_if_current_is_empty;
} functor_navigate_media;
} functor_navigate_media(only_if_current_is_empty);
bool all_face_media_navigated = false;
LLObjectSelectionHandle selected_objects =LLSelectMgr::getInstance()->getSelection();

View File

@ -47,21 +47,30 @@ class LLFloaterMediaSettings;
class LLPanelMediaSettingsGeneral : public LLPanel
{
public:
LLPanelMediaSettingsGeneral();
~LLPanelMediaSettingsGeneral();
// XXX TODO: put these into a common parent class?
// Hook that the floater calls before applying changes from the panel
void preApply();
// Function that asks the panel to fill in values associated with the panel
void getValues(LLSD &fill_me_in);
// Hook that the floater calls after applying changes to the panel
void postApply();
BOOL postBuild();
/*virtual*/ void draw();
/*virtual*/ void onClose(bool app_quitting);
static void apply(void*);
void getValues(LLSD &fill_me_in);
LLPanelMediaSettingsGeneral();
~LLPanelMediaSettingsGeneral();
void setParent( LLFloaterMediaSettings* parent );
static void initValues( void* userdata, const LLSD& media_settings ,bool editable);
static void clearValues( void* userdata, bool editable);
bool navigateHomeSelectedFace();
// Navigates the current selected face to the Home URL.
// If 'only_if_current_is_empty' is "true", it only performs
// the operation if: 1) the current URL is empty, and 2) auto play is true.
bool navigateHomeSelectedFace(bool only_if_current_is_empty);
void updateMediaPreview();
const std::string getHomeUrl();

View File

@ -218,17 +218,10 @@ void LLPanelMediaSettingsPermissions::initValues( void* userdata, const LLSD& me
}
////////////////////////////////////////////////////////////////////////////////
// static
void LLPanelMediaSettingsPermissions::apply( void* userdata )
//
void LLPanelMediaSettingsPermissions::preApply()
{
LLPanelMediaSettingsPermissions *self =(LLPanelMediaSettingsPermissions *)userdata;
// build LLSD Fragment
LLSD media_data_permissions;
self->getValues(media_data_permissions);
// this merges contents of LLSD passed in with what's there so this is ok
LLSelectMgr::getInstance()->selectionSetMediaData( media_data_permissions );
// no-op
}
////////////////////////////////////////////////////////////////////////////////
@ -254,3 +247,11 @@ void LLPanelMediaSettingsPermissions::getValues( LLSD &fill_me_in )
fill_me_in[LLMediaEntry::PERMS_CONTROL_KEY] = control;
fill_me_in[LLMediaEntry::PERMS_INTERACT_KEY] = interact;
}
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsPermissions::postApply()
{
// no-op
}

View File

@ -46,26 +46,32 @@ class LLNameBox;
class LLPanelMediaSettingsPermissions : public LLPanel
{
public:
BOOL postBuild();
virtual void draw();
static void apply(void*);
void getValues(LLSD &fill_me_in);
LLPanelMediaSettingsPermissions();
~LLPanelMediaSettingsPermissions();
static void initValues( void* userdata, const LLSD& media_settings, bool editable );
static void clearValues( void* userdata, bool editable);
private:
LLCheckBoxCtrl* mPermsOwnerInteract;
LLCheckBoxCtrl* mPermsOwnerControl;
LLNameBox* mPermsGroupName;
LLCheckBoxCtrl* mPermsGroupInteract;
LLCheckBoxCtrl* mPermsGroupControl;
LLCheckBoxCtrl* mPermsWorldInteract;
LLCheckBoxCtrl* mPermsWorldControl;
public:
LLPanelMediaSettingsPermissions();
~LLPanelMediaSettingsPermissions();
BOOL postBuild();
virtual void draw();
// XXX TODO: put these into a common parent class?
// Hook that the floater calls before applying changes from the panel
void preApply();
// Function that asks the panel to fill in values associated with the panel
void getValues(LLSD &fill_me_in);
// Hook that the floater calls after applying changes to the panel
void postApply();
static void initValues( void* userdata, const LLSD& media_settings, bool editable );
static void clearValues( void* userdata, bool editable);
private:
LLCheckBoxCtrl* mPermsOwnerInteract;
LLCheckBoxCtrl* mPermsOwnerControl;
LLNameBox* mPermsGroupName;
LLCheckBoxCtrl* mPermsGroupInteract;
LLCheckBoxCtrl* mPermsGroupControl;
LLCheckBoxCtrl* mPermsWorldInteract;
LLCheckBoxCtrl* mPermsWorldControl;
};
#endif // LL_LLPANELMEDIAMEDIASETTINGSPERMISSIONS_H

View File

@ -198,17 +198,12 @@ void LLPanelMediaSettingsSecurity::clearValues( void* userdata , bool editable)
self->mEnableWhiteList->setEnabled(editable);
self->mWhiteListList->setEnabled(editable);
}
////////////////////////////////////////////////////////////////////////////////
// static
void LLPanelMediaSettingsSecurity::apply( void* userdata )
{
LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata;
// build LLSD Fragment
LLSD media_data_security;
self->getValues(media_data_security);
// this merges contents of LLSD passed in with what's there so this is ok
LLSelectMgr::getInstance()->selectionSetMediaData( media_data_security );
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsSecurity::preApply()
{
// no-op
}
////////////////////////////////////////////////////////////////////////////////
@ -220,7 +215,7 @@ void LLPanelMediaSettingsSecurity::getValues( LLSD &fill_me_in )
// iterate over white list and extract items
std::vector< LLScrollListItem* > white_list_items = mWhiteListList->getAllData();
std::vector< LLScrollListItem* >::iterator iter = white_list_items.begin();
fill_me_in[LLMediaEntry::WHITELIST_KEY].clear();
fill_me_in.erase(LLMediaEntry::WHITELIST_KEY);
while( iter != white_list_items.end() )
{
std::string white_list_url = (*iter)->getValue().asString();
@ -229,23 +224,30 @@ void LLPanelMediaSettingsSecurity::getValues( LLSD &fill_me_in )
};
}
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsSecurity::postApply()
{
// no-op
}
///////////////////////////////////////////////////////////////////////////////
// Try to make a valid URL if a fragment (
// white list list box widget and build a list to test against. Can also
const std::string LLPanelMediaSettingsSecurity::makeValidUrl( const std::string& src_url )
{
// use LLURI to determine if we have a valid scheme
LLURI candidate_url( src_url );
if ( candidate_url.scheme().empty() )
{
LLURI candidate_url( src_url );
if ( candidate_url.scheme().empty() )
{
// build a URL comprised of default scheme and the original fragment
const std::string default_scheme( "http://" );
return default_scheme + src_url;
};
// we *could* test the "default scheme" + "original fragment" URL again
// using LLURI to see if it's valid but I think the outcome is the same
// in either case - our only option is to return the original URL
};
// we *could* test the "default scheme" + "original fragment" URL again
// using LLURI to see if it's valid but I think the outcome is the same
// in either case - our only option is to return the original URL
// we *think* the original url passed in was valid
return src_url;
@ -332,10 +334,10 @@ void LLPanelMediaSettingsSecurity::onBtnDel( void* userdata )
self->mWhiteListList->deleteSelectedItems();
}
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsSecurity::setParent( LLFloaterMediaSettings* parent )
{
mParent = parent;
};
////////////////////////////////////////////////////////////////////////////////
//
void LLPanelMediaSettingsSecurity::setParent( LLFloaterMediaSettings* parent )
{
mParent = parent;
};

View File

@ -41,31 +41,37 @@ class LLFloaterMediaSettings;
class LLPanelMediaSettingsSecurity : public LLPanel
{
public:
BOOL postBuild();
virtual void draw();
static void apply(void*);
void getValues(LLSD &fill_me_in);
LLPanelMediaSettingsSecurity();
~LLPanelMediaSettingsSecurity();
static void initValues( void* userdata, const LLSD& media_settings,bool editable );
static void clearValues( void* userdata, bool editable);
void addWhiteListItem(const std::string& url);
void setParent( LLFloaterMediaSettings* parent );
const std::string makeValidUrl( const std::string& src_url );
bool passesWhiteList( const std::string& added_url, const std::string& test_url );
protected:
LLFloaterMediaSettings* mParent;
private:
LLCheckBoxCtrl* mEnableWhiteList;
LLScrollListCtrl* mWhiteListList;
static void onBtnAdd(void*);
static void onBtnDel(void*);
public:
LLPanelMediaSettingsSecurity();
~LLPanelMediaSettingsSecurity();
BOOL postBuild();
virtual void draw();
// XXX TODO: put these into a common parent class?
// Hook that the floater calls before applying changes from the panel
void preApply();
// Function that asks the panel to fill in values associated with the panel
void getValues(LLSD &fill_me_in);
// Hook that the floater calls after applying changes to the panel
void postApply();
static void initValues( void* userdata, const LLSD& media_settings,bool editable );
static void clearValues( void* userdata, bool editable);
void addWhiteListItem(const std::string& url);
void setParent( LLFloaterMediaSettings* parent );
const std::string makeValidUrl( const std::string& src_url );
bool passesWhiteList( const std::string& added_url, const std::string& test_url );
protected:
LLFloaterMediaSettings* mParent;
private:
LLCheckBoxCtrl* mEnableWhiteList;
LLScrollListCtrl* mWhiteListList;
static void onBtnAdd(void*);
static void onBtnDel(void*);
};
#endif // LL_LLPANELMEDIAMEDIASETTINGSSECURITY_H