mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 07:28:39 +00:00
fixes to the M.O.M and the options details tab, still not 100% though
This commit is contained in:
parent
83f42f5bf8
commit
9c412e8aff
2 changed files with 29 additions and 17 deletions
|
@ -57,7 +57,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
this.fieldsets = {}, this.fields = {};
|
this.fieldsets = {}, this.fields = {};
|
||||||
this.optionsManager = new Deluge.MultiOptionsManager({
|
this.optionsManager = new Deluge.MultiOptionsManager({
|
||||||
defaults: {
|
options: {
|
||||||
'max_download_speed': -1,
|
'max_download_speed': -1,
|
||||||
'max_upload_speed': -1,
|
'max_upload_speed': -1,
|
||||||
'max_connections': -1,
|
'max_connections': -1,
|
||||||
|
@ -209,9 +209,10 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.is_auto_managed = this.fieldsets.queue.add({
|
this.fields.is_auto_managed = this.fieldsets.queue.add({
|
||||||
|
xtype: 'checkbox',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
id: 'is_auto_managed',
|
name: 'is_auto_managed',
|
||||||
boxLabel: _('Auto Managed'),
|
boxLabel: _('Auto Managed'),
|
||||||
width: 200,
|
width: 200,
|
||||||
colspan: 2
|
colspan: 2
|
||||||
|
@ -364,13 +365,14 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
if (this.torrentId) {
|
if (this.torrentId) this.optionsManager.reset(this.torrentId);
|
||||||
this.optionsManager.reset(this.torrentId);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
|
if (this.torrentId != torrentId) {
|
||||||
this.torrentId = torrentId;
|
this.torrentId = torrentId;
|
||||||
|
this.optionsManager.changeId(torrentId);
|
||||||
|
}
|
||||||
Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
|
Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this
|
scope: this
|
||||||
|
@ -378,7 +380,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onApply: function() {
|
onApply: function() {
|
||||||
var changed = this.optionsManager.getChanged(this.torrentId);
|
var changed = this.optionsManager.getDirty(this.torrentId);
|
||||||
if (!Ext.isEmpty(changed['prioritize_first_last'])) {
|
if (!Ext.isEmpty(changed['prioritize_first_last'])) {
|
||||||
var value = changed['prioritize_first_last'];
|
var value = changed['prioritize_first_last'];
|
||||||
Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
|
Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
|
||||||
|
@ -390,8 +392,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
}
|
}
|
||||||
Deluge.Client.core.set_torrent_options([this.torrentId], changed, {
|
Deluge.Client.core.set_torrent_options([this.torrentId], changed, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.optionsManager.set(this.torrentId, changed);
|
this.optionsManager.commit(this.torrentId);
|
||||||
this.optionsManager.reset(this.torrentId);
|
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
@ -411,8 +412,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
onRequestComplete: function(torrent, options) {
|
onRequestComplete: function(torrent, options) {
|
||||||
this.fields['private'].setDisabled(!torrent['private']);
|
this.fields['private'].setDisabled(!torrent['private']);
|
||||||
delete torrent['private'];
|
delete torrent['private'];
|
||||||
|
this.optionsManager.setDefault(this.torrentId, torrent);
|
||||||
this.optionsManager.update(this.torrentId, torrent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Deluge.Details.add(new Ext.deluge.details.OptionsTab());
|
Deluge.Details.add(new Ext.deluge.details.OptionsTab());
|
||||||
|
|
|
@ -149,14 +149,26 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @param {Object} value The value for the option
|
* @param {Object} value The value for the option
|
||||||
*/
|
*/
|
||||||
set: function(id, option, value) {
|
setDefault: function(id, option, value) {
|
||||||
if (typeof value === undefined) {
|
if (value === undefined) {
|
||||||
for (var key in option) {
|
for (var key in option) {
|
||||||
this.set(id, key, option[key]);
|
this.setDefault(id, key, option[key]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.changed[id]) this.changed[id] = {};
|
var oldValue = this.getDefault(id, option);
|
||||||
this.changed[id][option] = value;
|
value = this.convertValueType(oldValue, value);
|
||||||
|
|
||||||
|
// If the value is the same as the old value there is
|
||||||
|
// no point in setting it again.
|
||||||
|
if (oldValue == value) return;
|
||||||
|
|
||||||
|
// Store the new default
|
||||||
|
if (!this.stored[id]) this.stored[id] = {};
|
||||||
|
this.stored[id][option] = value;
|
||||||
|
|
||||||
|
if (!this.isDirty(id, option)) {
|
||||||
|
this.fireEvent('changed', id, option, value, oldValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue