fix setting a custom limit when one is already set

focus and select the spinner contents upon window show
This commit is contained in:
Damien Churchill 2010-04-28 13:39:56 +01:00
parent c8c5e3449a
commit 066d199c78
2 changed files with 23 additions and 15 deletions

View File

@ -71,6 +71,7 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Ok'), this.onOkClick, this); this.addButton(_('Ok'), this.onOkClick, this);
this.afterMethod('show', this.doFocusField, this);
}, },
setValue: function(value) { setValue: function(value) {
@ -91,5 +92,9 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
} }
}); });
this.hide(); this.hide();
},
doFocusField: function() {
this.form.getForm().findField('limit').focus(true, 10);
} }
}); });

View File

@ -44,7 +44,11 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
this.items.each(function(item) { this.items.each(function(item) {
if (item.getXType() != 'menucheckitem') return; if (item.getXType() != 'menucheckitem') return;
item.on('checkchange', this.onLimitChanged, this); if (item.value == 'other') {
item.on('click', this.onOtherClicked, this);
} else {
item.on('checkchange', this.onLimitChanged, this);
}
}, this); }, this);
}, },
@ -78,20 +82,19 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
}, },
onLimitChanged: function(item, checked) { onLimitChanged: function(item, checked) {
if (!checked) return; // we don't care about unchecks if (!checked || item.value == 'other') return; // we don't care about unchecks or other
var config = {}
config[item.group] = item.value
deluge.client.core.set_config(config, {
success: function() {
deluge.ui.update();
}
});
},
if (item.value == 'other') { onOtherClicked: function(item, e) {
this.otherWin.group = item.group; this.otherWin.group = item.group;
this.otherWin.setValue(this.value); this.otherWin.setValue(this.value);
this.otherWin.show(); this.otherWin.show();
} else {
config = {}
config[item.group] = item.value
deluge.client.core.set_config(config, {
success: function() {
deluge.ui.update();
}
});
}
} }
}); });