implement page switching

This commit is contained in:
Damien Churchill 2009-04-08 20:28:39 +00:00
parent e3171671f0
commit 62375c7109

View File

@ -64,7 +64,8 @@ Copyright:
collapsible: true collapsible: true
}, { }, {
region: 'center', region: 'center',
title: 'Test', title: ' ',
layout: 'fit',
margins: '5 5 5 5', margins: '5 5 5 5',
cmargins: '5 5 5 5' cmargins: '5 5 5 5'
}]; }];
@ -76,37 +77,69 @@ Copyright:
PreferencesWindow.superclass.initComponent.call(this); PreferencesWindow.superclass.initComponent.call(this);
this.categoriesGrid = this.items.get(0); this.categoriesGrid = this.items.get(0);
this.configPanel = this.items.get(1); this.configPanel = this.items.get(1);
this.pages = {};
this.on('show', this.onShow.bindWithEvent(this)); this.on('show', this.onShow.bindWithEvent(this));
}, },
addPage: function(name, page) { addPage: function(name, page) {
var store = this.categoriesGrid.getStore(); var store = this.categoriesGrid.getStore();
store.loadData([[name]], true); store.loadData([[name]], true);
this.pages[name] = page;
}, },
onPageSelect: function(selModel, rowIndex, r) { onPageSelect: function(selModel, rowIndex, r) {
this.configPanel.removeAll();
this.currentPage = rowIndex; this.currentPage = rowIndex;
this.configPanel.setTitle(r.get('name')); var name = r.get('name');
this.configPanel.setTitle(name);
this.pages[name] = this.configPanel.add(this.pages[name]);
this.doLayout();
}, },
onShow: function() { onShow: function() {
if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
this.categoriesGrid.getSelectionModel().selectFirstRow();
}
} }
}); });
Deluge.Preferences = new PreferencesWindow(); Deluge.Preferences = new PreferencesWindow();
})(); })();
Deluge.Preferences.addPage(_('Downloads'), { Deluge.Preferences.addPage(_('Downloads'), {
border: false,
html: 'downloads'
}); });
Deluge.Preferences.addPage(_('Network'), {}); Deluge.Preferences.addPage(_('Network'), {
Deluge.Preferences.addPage(_('Bandwidth'), {}); border: false,
Deluge.Preferences.addPage(_('Interface'), {}); html: 'network'
Deluge.Preferences.addPage(_('Other'), {}); });
Deluge.Preferences.addPage(_('Daemon'), {}); Deluge.Preferences.addPage(_('Bandwidth'), {
Deluge.Preferences.addPage(_('Queue'), {}); border: false,
Deluge.Preferences.addPage(_('Proxy'), {}); html: 'bandwidth'
Deluge.Preferences.addPage(_('Notification'), {}); });
Deluge.Preferences.addPage(_('Plugins'), {}); Deluge.Preferences.addPage(_('Interface'), {
border: false,
html: 'interface'
});
Deluge.Preferences.addPage(_('Other'), {
border: false,
html: 'other'
});
Deluge.Preferences.addPage(_('Daemon'), {
border: false,
html: 'daemon'
});
Deluge.Preferences.addPage(_('Queue'), {
border: false,
html: 'queue'
});
Deluge.Preferences.addPage(_('Proxy'), {
border: false,
html: 'proxy'
});
Deluge.Preferences.addPage(_('Notification'), {
border: false,
html: 'notification'
});
Deluge.Preferences.addPage(_('Plugins'), {
border: false,
html: 'plugins'
});