Merge pull request #71 from ilian6806/develop
Added option to hide state ui elementspull/75/head v1.0.1
commit
ce1ca3a114
|
|
@ -95,7 +95,7 @@ state.core = (function () {
|
|||
|
||||
store = new state.Store();
|
||||
|
||||
loadUI();
|
||||
loadUI(config);
|
||||
restoreTabs(config);
|
||||
|
||||
forEachElement(ELEMENTS, config, (element, tab) => {
|
||||
|
|
@ -177,16 +177,26 @@ state.core = (function () {
|
|||
};
|
||||
}
|
||||
|
||||
function loadUI() {
|
||||
function loadUI(config) {
|
||||
|
||||
let quickSettings = gradioApp().getElementById("quicksettings");
|
||||
let className = quickSettings.querySelector('button').className;
|
||||
let uiConfig = config['state_ui'];
|
||||
|
||||
if (!uiConfig || uiConfig.indexOf('Reset Button') > -1) {
|
||||
quickSettings.appendChild(createHeaderButton('State: Reset', "*️⃣", className, {}, actions.resetAll));
|
||||
}
|
||||
|
||||
if (!uiConfig || uiConfig.indexOf('Export Button') > -1) {
|
||||
quickSettings.appendChild(createHeaderButton('State: Export',"📤", className, {}, actions.exportState));
|
||||
}
|
||||
|
||||
if (!uiConfig || uiConfig.indexOf('Import Button') > -1) {
|
||||
let fileInput = createHeaderFileInput('State: Import',"📥", className);
|
||||
quickSettings.appendChild(fileInput.hiddenButton);
|
||||
quickSettings.appendChild(fileInput.button);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function restoreTabs(config) {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ state = window.state;
|
|||
|
||||
state.Store = function Store (prefix) {
|
||||
this.prefix = state.constants.LS_PREFIX + (prefix ? prefix + '-' : '');
|
||||
}
|
||||
};
|
||||
|
||||
state.Store.prototype.set = function (key, value) {
|
||||
if (key.startsWith(this.prefix)) {
|
||||
|
|
|
|||
|
|
@ -89,5 +89,17 @@ def on_ui_settings():
|
|||
]
|
||||
}, section=section))
|
||||
|
||||
shared.opts.add_option("state_ui", shared.OptionInfo([
|
||||
"Reset Button",
|
||||
"Import Button",
|
||||
"Export Button"
|
||||
], "State UI", gr.CheckboxGroup, lambda: {
|
||||
"choices": [
|
||||
"Reset Button",
|
||||
"Import Button",
|
||||
"Export Button"
|
||||
],
|
||||
}, section=section))
|
||||
|
||||
|
||||
scripts.script_callbacks.on_ui_settings(on_ui_settings)
|
||||
|
|
|
|||
Loading…
Reference in New Issue