🐞 fix(editor): save fontsize immediately

- save the fontsize immediately after changing it on the editor
- "restart on save" to active as default
This commit is contained in:
thelastWallE 2021-10-21 22:22:04 +02:00
parent b0ee099a41
commit c9b2d3a49b
3 changed files with 44 additions and 14 deletions

View File

@ -135,12 +135,12 @@ class KlipperPlugin(
old_config="",
logpath="/tmp/klippy.log",
reload_command="RESTART",
restart_onsave=False,
restart_onsave=True,
confirm_reload=True,
shortStatus_navbar=True,
shortStatus_sidebar=True,
parse_check=False,
fontsize=9
fontsize=12
)
)

View File

@ -251,6 +251,36 @@ $(function () {
}
};
self.saveOption = function(dir, option, value) {
if (! (_.includes(["fontsize", "confirm_reload"], option)) ) {
return;
}
if (option && dir) {
let data = {
plugins: {
klipper:{
[dir]: {
[option]: value
}
}
}
};
OctoPrint.settings
.save(data);
} else if (option) {
let data = {
plugins: {
klipper:{
[option]: value
}
}
};
OctoPrint.settings
.save(data);
}
}
self.requestRestart = function () {
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_KLIPPER_CONFIG)) return;
@ -260,16 +290,7 @@ $(function () {
self.showPopUp("success", gettext("Reloaded Klipper"), "command: " + response.command);
});
if (index == 1) {
self.settings
.saveData({
plugins: {
klipper: {
configuration: {
confirm_reload: false
}
}
}
});
self.saveOption("configuration", "confirm_reload", false);
}
};

View File

@ -219,30 +219,39 @@ $(function () {
self.settings.settings.plugins.klipper.configuration.fontsize(
self.settings.settings.plugins.klipper.configuration.fontsize() - 1
);
if (self.settings.settings.plugins.klipper.configuration.fontsize() < 9) {
self.settings.settings.plugins.klipper.configuration.fontsize(9);
}
var fontsize = self.settings.settings.plugins.klipper.configuration.fontsize()
if (editor) {
editor.setFontSize(
self.settings.settings.plugins.klipper.configuration.fontsize()
fontsize
);
editor.resize();
}
self.klipperViewModel.saveOption("configuration", "fontsize", fontsize);
};
self.plusFontsize = function () {
self.settings.settings.plugins.klipper.configuration.fontsize(
self.settings.settings.plugins.klipper.configuration.fontsize() + 1
);
if (self.settings.settings.plugins.klipper.configuration.fontsize() > 20) {
self.settings.settings.plugins.klipper.configuration.fontsize(20);
}
var fontsize = self.settings.settings.plugins.klipper.configuration.fontsize()
if (editor) {
editor.setFontSize(
self.settings.settings.plugins.klipper.configuration.fontsize()
fontsize
);
editor.resize();
}
self.klipperViewModel.saveOption("configuration", "fontsize", fontsize);
};
self.reloadFromFile = function () {