reflow settings restoration and progressive saves
This commit is contained in:
parent
697f24703d
commit
f2672adcb7
2 changed files with 69 additions and 54 deletions
|
|
@ -571,8 +571,10 @@
|
|||
if (!cp.hasOwnProperty(k)) continue;
|
||||
np[k] = cp[k];
|
||||
}
|
||||
s.cproc[API.mode.get()] = name;
|
||||
s.cproc[mode] = name;
|
||||
s.devproc[s.device.deviceName] = name;
|
||||
API.conf.save();
|
||||
API.conf.update();
|
||||
API.event.settings();
|
||||
}
|
||||
});
|
||||
|
|
@ -1933,27 +1935,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
let current = settings(),
|
||||
control = current.controller;
|
||||
|
||||
platform.deselect();
|
||||
CATALOG.addFileListener(updateCatalog);
|
||||
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
|
||||
SPACE.platform.setZOff(0.2);
|
||||
|
||||
// restore UI state from settings
|
||||
UI.showOrigin.checked = control.showOrigin;
|
||||
UI.showRulers.checked = control.showRulers;
|
||||
UI.showSpeeds.checked = control.showSpeeds;
|
||||
UI.freeLayout.checked = control.freeLayout;
|
||||
UI.autoLayout.checked = control.autoLayout;
|
||||
UI.alignTop.checked = control.alignTop;
|
||||
UI.reverseZoom.checked = control.reverseZoom;
|
||||
UI.decimate.checked = control.decimate;
|
||||
lineTypeSave();
|
||||
detailSave();
|
||||
updateFPS();
|
||||
|
||||
// load script extensions
|
||||
if (SETUP.s) SETUP.s.forEach(function(lib) {
|
||||
let scr = DOC.createElement('script');
|
||||
|
|
@ -1991,6 +1972,30 @@
|
|||
console.log({octoprint:ohost});
|
||||
}
|
||||
|
||||
// bind this to UI so main can call it on settings import
|
||||
UI.sync = function() {
|
||||
const current = settings();
|
||||
const control = current.controller;
|
||||
const process = settings.process;
|
||||
|
||||
platform.deselect();
|
||||
CATALOG.addFileListener(updateCatalog);
|
||||
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
|
||||
SPACE.platform.setZOff(0.2);
|
||||
|
||||
// restore UI state from settings
|
||||
UI.showOrigin.checked = control.showOrigin;
|
||||
UI.showRulers.checked = control.showRulers;
|
||||
UI.showSpeeds.checked = control.showSpeeds;
|
||||
UI.freeLayout.checked = control.freeLayout;
|
||||
UI.autoLayout.checked = control.autoLayout;
|
||||
UI.alignTop.checked = control.alignTop;
|
||||
UI.reverseZoom.checked = control.reverseZoom;
|
||||
UI.decimate.checked = control.decimate;
|
||||
lineTypeSave();
|
||||
detailSave();
|
||||
updateFPS();
|
||||
|
||||
// optional set-and-lock mode (hides mode menu)
|
||||
let SETMODE = SETUP.mode ? SETUP.mode[0] : null;
|
||||
|
||||
|
|
@ -2000,23 +2005,29 @@
|
|||
// setup default mode and enable mode locking, if set
|
||||
API.mode.set(SETMODE || STARTMODE || current.mode, SETMODE);
|
||||
|
||||
// update everything dependent on the platform size
|
||||
platform.update_size();
|
||||
|
||||
// restore expert setting preference
|
||||
API.mode.set_expert(control.expert);
|
||||
|
||||
// setup tab visibility watcher
|
||||
// DOC.addEventListener('visibilitychange', function() { document.title = document.hidden });
|
||||
|
||||
// fill device list
|
||||
updateDeviceList();
|
||||
|
||||
// ensure settings has gcode
|
||||
selectDevice(DEVNAME || API.device.get(), DEVNAME);
|
||||
|
||||
// ensure field data propagation
|
||||
API.conf.update();
|
||||
// update ui fields from settings
|
||||
API.view.update_fields();
|
||||
|
||||
// default to ARRANGE view mode
|
||||
API.view.set(VIEWS.ARRANGE);
|
||||
|
||||
// add ability to override
|
||||
API.show.controls(API.feature.controls);
|
||||
|
||||
// update everything dependent on the platform size
|
||||
platform.update_size();
|
||||
};
|
||||
|
||||
UI.sync();
|
||||
|
||||
// load settings provided in url hash
|
||||
loadSettingsFromServer();
|
||||
|
|
@ -2029,12 +2040,6 @@
|
|||
API.event.alerts(true);
|
||||
};
|
||||
|
||||
// default to ARRANGE view mode
|
||||
API.view.set(VIEWS.ARRANGE);
|
||||
|
||||
// add ability to override
|
||||
API.show.controls(API.feature.controls);
|
||||
|
||||
// enable modal hiding
|
||||
$('mod-x').onclick = API.modal.hide;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
VIEWS = CONF.VIEWS,
|
||||
clone = Object.clone,
|
||||
settings = clone(CONF.template),
|
||||
// settingsDefault = clone(settings),
|
||||
// ---------------
|
||||
Widget = kiri.Widget,
|
||||
newWidget = kiri.newWidget,
|
||||
|
|
@ -1465,16 +1464,17 @@
|
|||
updateSettingsFromFields(device.extruders[device.internal]);
|
||||
}
|
||||
API.conf.save();
|
||||
// platform.update_stock();
|
||||
$('mode-device').innerText = settings.device.deviceName;
|
||||
$('mode-profile').innerText = settings.process.processName;
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
let view = SPACE.view.save();
|
||||
const view = SPACE.view.save();
|
||||
if (view.left || view.up) {
|
||||
settings.controller.view = view;
|
||||
}
|
||||
const mode = settings.mode, name = settings.process.processName;
|
||||
settings.sproc[mode][name] = settings.process;
|
||||
settings.device.bedRound = UI.deviceRound.checked;
|
||||
settings.device.originCenter = UI.deviceOrigin.checked;
|
||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||
|
|
@ -1491,6 +1491,7 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (LOCAL) console.log('import',data);
|
||||
let isSettings = (data.settings && data.version && data.time);
|
||||
let isDevice = (data.device && data.version && data.time);
|
||||
if (!isSettings && !isDevice) {
|
||||
|
|
@ -1501,8 +1502,12 @@
|
|||
function doit() {
|
||||
if (isSettings) {
|
||||
settings = CONF.normalize(data.settings);
|
||||
API.conf.save();
|
||||
API.space.reload();
|
||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||
if (LOCAL) console.log('settings',Object.clone(settings));
|
||||
restoreSettings();
|
||||
restoreWorkspace(() => {
|
||||
UI.sync();
|
||||
}, true);
|
||||
}
|
||||
if (isDevice) {
|
||||
if (settings.devices[data.device]) {
|
||||
|
|
@ -1657,7 +1662,12 @@
|
|||
}
|
||||
SPACE.scene.freeze(fz);
|
||||
|
||||
if (skip_widget_load) return;
|
||||
if (skip_widget_load) {
|
||||
if (ondone) {
|
||||
ondone();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// remove any widgets from platform
|
||||
forAllWidgets(function(widget) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue