diff --git a/deluge/ui/web/js/deluge-all/Menus.js b/deluge/ui/web/js/deluge-all/Menus.js index c01fbfa11..78c5ac108 100644 --- a/deluge/ui/web/js/deluge-all/Menus.js +++ b/deluge/ui/web/js/deluge-all/Menus.js @@ -240,147 +240,6 @@ deluge.menus.torrent = new Ext.menu.Menu({ }] }); -deluge.menus.connections = new Deluge.StatusbarMenu({ - id: 'connectionsMenu', - items: [{ - text: '50', - value: '50', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - },{ - text: '100', - value: '100', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - },{ - text: '200', - value: '200', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - },{ - text: '300', - value: '300', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - },{ - text: '500', - value: '500', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - },{ - text: _('Unlimited'), - value: '-1', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - },'-',{ - text: _('Other'), - value: 'other', - group: 'max_connections_global', - checked: false, - checkHandler: onLimitChanged - }] -}); - -deluge.menus.download = new Deluge.StatusbarMenu({ - id: 'downspeedMenu', - items: [{ - value: '5', - text: '5 KiB/s', - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '10', - text: '10 KiB/s', - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '30', - text: '30 KiB/s', - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '80', - text: '80 KiB/s', - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '300', - text: '300 KiB/s', - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '-1', - text: _('Unlimited'), - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - },'-',{ - value: 'other', - text: _('Other'), - group: 'max_download_speed', - checked: false, - checkHandler: onLimitChanged - }] -}); - -deluge.menus.upload = new Deluge.StatusbarMenu({ - id: 'upspeedMenu', - items: [{ - value: '5', - text: '5 KiB/s', - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '10', - text: '10 KiB/s', - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '30', - text: '30 KiB/s', - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '80', - text: '80 KiB/s', - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '300', - text: '300 KiB/s', - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - },{ - value: '-1', - text: _('Unlimited'), - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - },'-',{ - value: 'other', - text: _('Other'), - group: 'max_upload_speed', - checked: false, - checkHandler: onLimitChanged - }] -}); - deluge.menus.filePriorities = new Ext.menu.Menu({ id: 'filePrioritiesMenu', items: [{ @@ -409,16 +268,3 @@ deluge.menus.filePriorities = new Ext.menu.Menu({ filePriority: 5 }] }); - -function onLimitChanged(item, checked) { - if (item.value == "other") { - } else { - config = {} - config[item.group] = item.value - deluge.client.core.set_config(config, { - success: function() { - deluge.ui.update(); - } - }); - } -} diff --git a/deluge/ui/web/js/deluge-all/Statusbar.js b/deluge/ui/web/js/deluge-all/Statusbar.js index 6136d2e80..579f12678 100644 --- a/deluge/ui/web/js/deluge-all/Statusbar.js +++ b/deluge/ui/web/js/deluge-all/Statusbar.js @@ -55,21 +55,132 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { cls: 'x-btn-text-icon', iconCls: 'x-deluge-connections', tooltip: _('Connections'), - menu: deluge.menus.connections + menu: new Deluge.StatusbarMenu({ + items: [{ + text: '50', + value: '50', + group: 'max_connections_global', + checked: false + },{ + text: '100', + value: '100', + group: 'max_connections_global', + checked: false + },{ + text: '200', + value: '200', + group: 'max_connections_global', + checked: false + },{ + text: '300', + value: '300', + group: 'max_connections_global', + checked: false + },{ + text: '500', + value: '500', + group: 'max_connections_global', + checked: false + },{ + text: _('Unlimited'), + value: '-1', + group: 'max_connections_global', + checked: false + },'-',{ + text: _('Other'), + value: 'other', + group: 'max_connections_global', + checked: false + }] + }), }, '-', { id: 'statusbar-downspeed', text: ' ', cls: 'x-btn-text-icon', iconCls: 'x-deluge-downloading', tooltip: _('Download Speed'), - menu: deluge.menus.download + menu: new Deluge.StatusbarMenu({ + items: [{ + value: '5', + text: '5 KiB/s', + group: 'max_download_speed', + checked: false + },{ + value: '10', + text: '10 KiB/s', + group: 'max_download_speed', + checked: false + },{ + value: '30', + text: '30 KiB/s', + group: 'max_download_speed', + checked: false + },{ + value: '80', + text: '80 KiB/s', + group: 'max_download_speed', + checked: false + },{ + value: '300', + text: '300 KiB/s', + group: 'max_download_speed', + checked: false + },{ + value: '-1', + text: _('Unlimited'), + group: 'max_download_speed', + checked: false + },'-',{ + value: 'other', + text: _('Other'), + group: 'max_download_speed', + checked: false + }] + }), }, '-', { id: 'statusbar-upspeed', text: ' ', cls: 'x-btn-text-icon', iconCls: 'x-deluge-seeding', tooltip: _('Upload Speed'), - menu: deluge.menus.upload + menu: new Deluge.StatusbarMenu({ + items: [{ + value: '5', + text: '5 KiB/s', + group: 'max_upload_speed', + checked: false + },{ + value: '10', + text: '10 KiB/s', + group: 'max_upload_speed', + checked: false + },{ + value: '30', + text: '30 KiB/s', + group: 'max_upload_speed', + checked: false + },{ + value: '80', + text: '80 KiB/s', + group: 'max_upload_speed', + checked: false + },{ + value: '300', + text: '300 KiB/s', + group: 'max_upload_speed', + checked: false + },{ + value: '-1', + text: _('Unlimited'), + group: 'max_upload_speed', + checked: false + },'-',{ + value: 'other', + text: _('Other'), + group: 'max_upload_speed', + checked: false + }] + }) }, '-', { id: 'statusbar-traffic', text: ' ', @@ -140,6 +251,9 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { var str = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value; } item.setText(str); + + if (!item.menu) return; + item.menu.setValue(config.limit.value); }.createDelegate(this); updateStat('connections', { @@ -171,7 +285,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { }, format: '{0} ({1})' }); - + updateStat('traffic', { value: { value: stats.download_protocol_rate, @@ -186,10 +300,6 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { this.items.get('statusbar-dht').setText(stats.dht_nodes); this.items.get('statusbar-freespace').setText(fsize(stats.free_space)); - - deluge.menus.connections.setValue(stats.max_num_connections); - deluge.menus.download.setValue(stats.max_download); - deluge.menus.upload.setValue(stats.max_upload); } }); deluge.statusbar = new Deluge.Statusbar(); diff --git a/deluge/ui/web/js/deluge-all/StatusbarMenu.js b/deluge/ui/web/js/deluge-all/StatusbarMenu.js index fa3a7a6f7..b7f394871 100644 --- a/deluge/ui/web/js/deluge-all/StatusbarMenu.js +++ b/deluge/ui/web/js/deluge-all/StatusbarMenu.js @@ -37,6 +37,14 @@ Ext.ns('Deluge'); * @extends Ext.menu.Menu */ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { + + initComponent: function() { + Deluge.StatusbarMenu.superclass.initComponent.call(this); + this.items.each(function(item) { + if (item.getXType() != 'menucheckitem') return; + item.on('checkchange', this.onLimitChanged, this); + }, this); + }, setValue: function(value) { var beenSet = false; @@ -65,5 +73,21 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { other.suspendEvents(); other.setChecked(true); other.resumeEvents(); - } + }, + + onLimitChanged: function(item, checked) { + if (!checked) return; // we don't care about unchecks + + if (item.value == 'other') { + // pop up other limit window in due course + } else { + config = {} + config[item.group] = item.value + deluge.client.core.set_config(config, { + success: function() { + deluge.ui.update(); + } + }); + } + } });