summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterpreference.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterpreference.cpp')
-rw-r--r--indra/newview/llfloaterpreference.cpp64
1 files changed, 63 insertions, 1 deletions
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<bool(const LLSD&)> 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<LLPanelPreference> 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