From afcff8f8278501136b6a67e1f8eabac304fd22c2 Mon Sep 17 00:00:00 2001 From: Kieran Date: Sat, 4 Feb 2023 16:47:19 -0800 Subject: [PATCH] feat: setting to disable automatic gcode loading on mobile (#1028) Signed-off-by: Kieran Eglin Co-authored-by: Mathis Mensing Co-authored-by: Pedro Lamas --- .../settings/GcodePreviewSettings.vue | 29 +++++++++++++++++++ .../gcode-preview/GcodePreviewCard.vue | 4 +++ src/locales/de.yaml | 1 + src/locales/en.yaml | 1 + src/store/config/state.ts | 1 + src/store/config/types.ts | 1 + 6 files changed, 37 insertions(+) diff --git a/src/components/settings/GcodePreviewSettings.vue b/src/components/settings/GcodePreviewSettings.vue index 2d416fe2ba..daae443fe4 100644 --- a/src/components/settings/GcodePreviewSettings.vue +++ b/src/components/settings/GcodePreviewSettings.vue @@ -129,6 +129,19 @@ /> + + @@ -270,6 +283,22 @@ export default class GcodePreviewSettings extends Vue { value, server: true }) + + if (!value) { + this.autoLoadMobileOnPrintStart = false + } + } + + get autoLoadMobileOnPrintStart () { + return this.$store.state.config.uiSettings.gcodePreview.autoLoadMobileOnPrintStart + } + + set autoLoadMobileOnPrintStart (value: boolean) { + this.$store.dispatch('config/saveByPath', { + path: 'uiSettings.gcodePreview.autoLoadMobileOnPrintStart', + value, + server: true + }) } get autoFollowOnFileLoad () { diff --git a/src/components/widgets/gcode-preview/GcodePreviewCard.vue b/src/components/widgets/gcode-preview/GcodePreviewCard.vue index e6b8bf67e8..ac64e3b842 100644 --- a/src/components/widgets/gcode-preview/GcodePreviewCard.vue +++ b/src/components/widgets/gcode-preview/GcodePreviewCard.vue @@ -355,6 +355,10 @@ export default class GcodePreviewCard extends Mixins(StateMixin, FilesMixin) { } get autoLoadOnPrintStart () { + if (this.isMobile) { + return this.$store.state.config.uiSettings.gcodePreview.autoLoadMobileOnPrintStart + } + return this.$store.state.config.uiSettings.gcodePreview.autoLoadOnPrintStart } diff --git a/src/locales/de.yaml b/src/locales/de.yaml index d84d1becdd..56949ac132 100644 --- a/src/locales/de.yaml +++ b/src/locales/de.yaml @@ -455,6 +455,7 @@ app: auto_edit_extensions: Erweiterungen, die automatisch im Bearbeitungsmodus geöffnet werden auto_follow_on_file_load: Fortschritt beim Laden einer Datei automatisch folgen auto_load_on_print_start: Datei bei Druckstart automatisch laden + auto_load_mobile_on_print_start: Datei bei Druckstart auch auf mobilen Geräten laden camera_flip_x: Horizontal spiegeln camera_flip_y: Vertikal spiegeln camera_rotate_by: Rotieren um diff --git a/src/locales/en.yaml b/src/locales/en.yaml index cc86ad066f..a6245bae40 100644 --- a/src/locales/en.yaml +++ b/src/locales/en.yaml @@ -471,6 +471,7 @@ app: auto_edit_extensions: Extensions to automatically open in edit mode auto_follow_on_file_load: Automatically follow progress on file load auto_load_on_print_start: Automatically load file on print start + auto_load_mobile_on_print_start: Automatically load file on mobile devices axes: Axes camera_flip_x: Flip horizontally camera_flip_y: Flip vertically diff --git a/src/store/config/state.ts b/src/store/config/state.ts index 810a469e91..1ccbc2fbfa 100644 --- a/src/store/config/state.ts +++ b/src/store/config/state.ts @@ -118,6 +118,7 @@ export const defaultState = (): ConfigState => { showAnimations: true, groupLowerLayers: false, autoLoadOnPrintStart: false, + autoLoadMobileOnPrintStart: false, autoFollowOnFileLoad: true, autoZoom: false, flip: { diff --git a/src/store/config/types.ts b/src/store/config/types.ts index 14d0dd5959..526f93940a 100644 --- a/src/store/config/types.ts +++ b/src/store/config/types.ts @@ -175,6 +175,7 @@ export interface GcodePreviewConfig { showAnimations: boolean; groupLowerLayers: boolean; autoLoadOnPrintStart: boolean; + autoLoadMobileOnPrintStart: boolean; autoFollowOnFileLoad: boolean; autoZoom: boolean; flip: {