store last process settings use for a selected devie

This commit is contained in:
Stewart Allen 2018-01-31 10:42:55 -05:00
commit 027c028202
2 changed files with 21 additions and 9 deletions

View file

@ -398,6 +398,9 @@ self.kiri.license = exports.LICENSE;
// custom devices by name
devices:{
},
// map of device to last process setting (name)
devproc: {
},
layers:{
layerOutline: true,
layerTrace: true,
@ -1925,8 +1928,8 @@ self.kiri.license = exports.LICENSE;
showDialog("catalog");
}
function loadNamedSetting(e) {
var name = e ? e.target.getAttribute("load") : settings.cproc[getMode()],
function loadNamedSetting(e, named) {
var name = e ? e.target.getAttribute("load") : named || settings.cproc[getMode()],
load = settings.sproc[getMode()][name];
if (!load) return;
for (var k in load) {
@ -1935,8 +1938,13 @@ self.kiri.license = exports.LICENSE;
}
settings.process.processName = name;
settings.cproc[getMode()] = name;
// associate named process with the current device
settings.devproc[currentDeviceName()] = name;
updateFields();
hideDialog();
if (!named) {
hideDialog();
}
updateSettings();
if (e) triggerSettingsEvent();
}
@ -2116,6 +2124,10 @@ self.kiri.license = exports.LICENSE;
triggerSettingsEvent();
}
function currentDeviceName() {
return settings.filter[getMode()];
}
function setControlsVisible(show) {
UI.ctrlLeft.style.display = show ? 'block' : 'none';
UI.ctrlRight.style.display = show ? 'block' : 'none';
@ -2874,10 +2886,6 @@ self.kiri.license = exports.LICENSE;
return typeof(val) !== 'undefined' ? val : dv;
}
function currentDeviceName() {
return settings.filter[getMode()];
}
// only for local filters
function updateDeviceCode(override) {
var oldname = getSelectedDevice(),
@ -2923,7 +2931,8 @@ self.kiri.license = exports.LICENSE;
var cmd = code.cmd || {},
set = code.settings || {},
local = isLocalDevice(devicename);
local = isLocalDevice(devicename),
dproc = settings.devproc[devicename];
settings.device = {
bedHeight: 2.5,
@ -3019,6 +3028,9 @@ self.kiri.license = exports.LICENSE;
settings.filter[getMode()] = devicename;
settings.cdev[getMode()] = dev;
// restore last process associated with this device
if (dproc) loadNamedSetting(null, dproc);
saveSettings();
} catch (e) {
console.log({error:e, device:code});

View file

@ -1,6 +1,6 @@
# Kiri:Moto todo
* store settings profile used per-device so re-loaded on device switch
* per-device settings: grid-print target
* prevent text selection of non-input
* widget general add-ons (fdm supports, cam tabs)
* bail on decimation if it's proving ineffective