From c4f03ca949c25b6fd5794ebada5c5e65154a33c0 Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Fri, 8 Apr 2011 19:21:21 +0300 Subject: STORM-595 FIXED (The presentation of IM sessions in message well depends on method that was used for opening IM window) - Added the callback with the timer on control name "ThrottleBandwidthKBPS" changes. Now message is sending to the simulator in 0.3 sec after LAST variable change. --- indra/newview/llfloaterpreference.cpp | 64 ++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index ffbb0efad3..87d8fca69f 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -43,6 +43,7 @@ #include "llcombobox.h" #include "llcommandhandler.h" #include "lldirpicker.h" +#include "lleventtimer.h" #include "llfeaturemanager.h" #include "llfocusmgr.h" //#include "llfirstuse.h" @@ -73,6 +74,7 @@ #include "llviewerwindow.h" #include "llviewermessage.h" #include "llviewershadermgr.h" +#include "llviewerthrottle.h" #include "llvotree.h" #include "llvosky.h" @@ -1534,10 +1536,56 @@ void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location) cache_location_editor->setToolTip(location); } +//------------------------------Updater--------------------------------------- + +static bool handleBandwidthChanged(const LLSD& newvalue) +{ + gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal()); + return true; +} + +class LLPanelPreference::Updater : public LLEventTimer +{ + +public: + + typedef boost::function callback_t; + + Updater(callback_t cb, F32 period) + :LLEventTimer(period), + mCallback(cb) + { + mEventTimer.stop(); + } + + virtual ~Updater(){} + + void update(const LLSD& new_value) + { + mNewValue = new_value; + mEventTimer.start(); + } + +protected: + + BOOL tick() + { + mCallback(mNewValue); + mEventTimer.stop(); + + return FALSE; + } + +private: + + LLSD mNewValue; + callback_t mCallback; +}; //---------------------------------------------------------------------------- static LLRegisterPanelClassWrapper t_places("panel_preference"); LLPanelPreference::LLPanelPreference() -: LLPanel() +: LLPanel(), + mBandWidthUpdater(NULL) { mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2)); mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1)); @@ -1607,10 +1655,24 @@ BOOL LLPanelPreference::postBuild() } } + //////////////////////PanelSetup /////////////////// + if (hasChild("max_bandwidth")) + { + mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), 0.3); + gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2)); + } + apply(); return true; } +LLPanelPreference::~LLPanelPreference() +{ + if (mBandWidthUpdater) + { + delete mBandWidthUpdater; + } +} void LLPanelPreference::apply() { // no-op -- cgit v1.2.3