mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-12 19:28:42 +00:00
Webui applies changes when OK clicked in Preferences
This commit is contained in:
parent
ba60ae09d5
commit
ec27028f1b
1 changed files with 27 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*!
|
/*!
|
||||||
* Deluge.preferences.PreferencesWindow.js
|
* Deluge.preferences.PreferencesWindow.js
|
||||||
*
|
*
|
||||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -106,7 +106,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
this.addButton(_('Close'), this.onClose, this);
|
this.addButton(_('Close'), this.onClose, this);
|
||||||
this.addButton(_('Apply'), this.onApply, this);
|
this.addButton(_('Apply'), this.onApply, this);
|
||||||
this.addButton(_('Ok'), this.onOk, this);
|
this.addButton(_('Ok'), this.onOk, this);
|
||||||
|
|
||||||
this.optionsManager = new Deluge.OptionsManager();
|
this.optionsManager = new Deluge.OptionsManager();
|
||||||
this.on('afterrender', this.onAfterRender, this);
|
this.on('afterrender', this.onAfterRender, this);
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
|
@ -128,7 +128,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
this.addPage(new Deluge.preferences.Cache());
|
this.addPage(new Deluge.preferences.Cache());
|
||||||
this.addPage(new Deluge.preferences.Plugins());
|
this.addPage(new Deluge.preferences.Plugins());
|
||||||
},
|
},
|
||||||
|
|
||||||
onApply: function(e) {
|
onApply: function(e) {
|
||||||
var changed = this.optionsManager.getDirty();
|
var changed = this.optionsManager.getDirty();
|
||||||
if (!Ext.isObjectEmpty(changed)) {
|
if (!Ext.isObjectEmpty(changed)) {
|
||||||
|
@ -137,13 +137,13 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var page in this.pages) {
|
for (var page in this.pages) {
|
||||||
if (this.pages[page].onApply) this.pages[page].onApply();
|
if (this.pages[page].onApply) this.pages[page].onApply();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the options manager for the preferences window.
|
* Return the options manager for the preferences window.
|
||||||
* @returns {Deluge.OptionsManager} the options manager
|
* @returns {Deluge.OptionsManager} the options manager
|
||||||
|
@ -151,7 +151,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
getOptionsManager: function() {
|
getOptionsManager: function() {
|
||||||
return this.optionsManager;
|
return this.optionsManager;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a page to the preferences window.
|
* Adds a page to the preferences window.
|
||||||
* @param {Mixed} page
|
* @param {Mixed} page
|
||||||
|
@ -166,7 +166,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
this.pages[name].index = -1;
|
this.pages[name].index = -1;
|
||||||
return this.pages[name];
|
return this.pages[name];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a preferences page from the window.
|
* Removes a preferences page from the window.
|
||||||
* @param {mixed} name
|
* @param {mixed} name
|
||||||
|
@ -179,12 +179,12 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
delete this.pages[page.title];
|
delete this.pages[page.title];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select which preferences page is displayed.
|
* Select which preferences page is displayed.
|
||||||
* @param {String} page The page name to change to
|
* @param {String} page The page name to change to
|
||||||
*/
|
*/
|
||||||
selectPage: function(page) {
|
selectPage: function(page) {
|
||||||
if (this.pages[page].index < 0) {
|
if (this.pages[page].index < 0) {
|
||||||
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
||||||
}
|
}
|
||||||
this.list.select(this.pages[page].index);
|
this.list.select(this.pages[page].index);
|
||||||
|
@ -192,24 +192,24 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
// private
|
// private
|
||||||
doSelectPage: function(page) {
|
doSelectPage: function(page) {
|
||||||
if (this.pages[page].index < 0) {
|
if (this.pages[page].index < 0) {
|
||||||
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
||||||
}
|
}
|
||||||
this.configPanel.getLayout().setActiveItem(this.pages[page].index);
|
this.configPanel.getLayout().setActiveItem(this.pages[page].index);
|
||||||
this.currentPage = page;
|
this.currentPage = page;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGotConfig: function(config) {
|
onGotConfig: function(config) {
|
||||||
this.getOptionsManager().set(config);
|
this.getOptionsManager().set(config);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onPageSelect: function(list, selections) {
|
onPageSelect: function(list, selections) {
|
||||||
var r = list.getRecord(selections[0]);
|
var r = list.getRecord(selections[0]);
|
||||||
this.doSelectPage(r.get('name'));
|
this.doSelectPage(r.get('name'));
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onSetConfig: function() {
|
onSetConfig: function() {
|
||||||
this.getOptionsManager().commit();
|
this.getOptionsManager().commit();
|
||||||
|
@ -222,7 +222,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
}
|
}
|
||||||
this.configPanel.getLayout().setActiveItem(0);
|
this.configPanel.getLayout().setActiveItem(0);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
if (!deluge.client.core) return;
|
if (!deluge.client.core) return;
|
||||||
|
@ -239,7 +239,18 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onOk: function() {
|
onOk: function() {
|
||||||
deluge.client.core.set_config(this.optionsManager.getDirty());
|
var changed = this.optionsManager.getDirty();
|
||||||
|
if (!Ext.isObjectEmpty(changed)) {
|
||||||
|
deluge.client.core.set_config(changed, {
|
||||||
|
success: this.onSetConfig,
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var page in this.pages) {
|
||||||
|
if (this.pages[page].onOk) this.pages[page].onOk();
|
||||||
|
}
|
||||||
|
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue