Browse Source

Fix alternative speed limits toggle behavior

adaptive-webui-19844
buinsky 10 years ago
parent
commit
0f56440dec
  1. 2
      src/webui/btjson.cpp
  2. 15
      src/webui/www/public/scripts/client.js

2
src/webui/btjson.cpp

@ -146,6 +146,7 @@ static const char KEY_TRANSFER_CONNECTION_STATUS[] = "connection_status";
// Sync main data keys // Sync main data keys
static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing"; static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing";
static const char KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS[] = "use_alt_speed_limits";
static const char KEY_FULL_UPDATE[] = "full_update"; static const char KEY_FULL_UPDATE[] = "full_update";
static const char KEY_RESPONSE_ID[] = "rid"; static const char KEY_RESPONSE_ID[] = "rid";
@ -333,6 +334,7 @@ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData
QVariantMap serverState = getTranserInfoMap(); QVariantMap serverState = getTranserInfoMap();
serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled();
serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = Preferences::instance()->isAltBandwidthEnabled();
data["server_state"] = serverState; data["server_state"] = serverState;
return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData)); return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData));

15
src/webui/www/public/scripts/client.js

@ -222,6 +222,11 @@ window.addEvent('load', function () {
$('queueingMenuItems').addClass('invisible'); $('queueingMenuItems').addClass('invisible');
} }
} }
if (alternativeSpeedLimits != serverState.use_alt_speed_limits) {
alternativeSpeedLimits = serverState.use_alt_speed_limits;
updateAltSpeedIcon(alternativeSpeedLimits);
}
}; };
var updateAltSpeedIcon = function(enabled) { var updateAltSpeedIcon = function(enabled) {
@ -231,16 +236,6 @@ window.addEvent('load', function () {
$('alternativeSpeedLimits').src = "images/slow_off.png" $('alternativeSpeedLimits').src = "images/slow_off.png"
} }
// Determine whether the alternative speed limits are enabled or not
new Request({url: 'command/alternativeSpeedLimitsEnabled',
method: 'get',
onSuccess : function (isEnabled) {
alternativeSpeedLimits = !!parseInt(isEnabled);
if (alternativeSpeedLimits)
$('alternativeSpeedLimits').src = "images/slow.png"
}
}).send();
$('alternativeSpeedLimits').addEvent('click', function() { $('alternativeSpeedLimits').addEvent('click', function() {
// Change icon immediately to give some feedback // Change icon immediately to give some feedback
updateAltSpeedIcon(!alternativeSpeedLimits); updateAltSpeedIcon(!alternativeSpeedLimits);

Loading…
Cancel
Save