Skip to content

Commit

Permalink
feat: add button to hide SAVE_CONFIG button for pending bed_mesh (#1255)
Browse files Browse the repository at this point in the history
Co-authored-by: th33xitus <[email protected]>
fixes #1066
  • Loading branch information
meteyou authored Feb 5, 2023
1 parent d29ce0a commit 0f94e80
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/TheTopbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
style="display: none"
@change="uploadAndStart" />
<v-btn
v-if="klippyIsConnected && saveConfigPending"
v-if="showSaveConfigButton"
tile
:icon="$vuetify.breakpoint.smAndDown"
:text="$vuetify.breakpoint.mdAndUp"
Expand Down Expand Up @@ -196,6 +196,20 @@ export default class TheTopbar extends Mixins(BaseMixin) {
return this.$store.state.printer.configfile?.save_config_pending ?? false
}
get hideSaveConfigForBedMash() {
return this.$store.state.gui.uiSettings.hideSaveConfigForBedMash ?? false
}
get showSaveConfigButton() {
if (!this.klipperReadyForGui) return false
if (!this.hideSaveConfigForBedMash) return this.saveConfigPending
let pendingKeys = Object.keys(this.$store.state.printer.configfile?.save_config_pending_items ?? {})
pendingKeys = pendingKeys.filter((key: string) => !key.startsWith('bed_mesh '))
return pendingKeys.length > 0
}
get printerName(): string {
if (this.$store.state.gui.general.printername.length) return this.$store.state.gui.general.printername
Expand Down
15 changes: 15 additions & 0 deletions src/components/settings/SettingsUiSettingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@
outlined
dense />
</settings-row>
<v-divider class="my-2"></v-divider>
<settings-row
:title="$t('Settings.UiSettingsTab.HideSaveConfigButtonForBedMesh').toString()"
:sub-title="$t('Settings.UiSettingsTab.HideSaveConfigButtonForBedMeshDescription').toString()"
:dynamic-slot-width="true">
<v-switch v-model="hideSaveConfigForBedMash" hide-details class="mt-0" />
</settings-row>
</v-card-text>
</v-card>
</div>
Expand Down Expand Up @@ -318,6 +325,14 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin) {
return items
}
get hideSaveConfigForBedMash() {
return this.$store.state.gui.uiSettings.hideSaveConfigForBedMash ?? false
}
set hideSaveConfigForBedMash(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.hideSaveConfigForBedMash', value: newVal })
}
clearColorObject(color: any): string {
if (typeof color === 'object' && 'hex' in color) color = color.hex
if (color.length > 7) color = color.substr(0, 7)
Expand Down
2 changes: 2 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,8 @@
"GcodeThumbnails": "G-Code Vorschaubilder",
"GcodeThumbnailsDescription": "Klicke auf die Schaltfläche um zum Leitfaden zu gelangen.",
"Guide": "Leitfaden",
"HideSaveConfigButtonForBedMesh": "SAVE_CONFIG Schaltfläche ausblenden bei bed_mesh Änderungen",
"HideSaveConfigButtonForBedMeshDescription": "SAVE_CONFIG nicht anzeigen, wenn nur das Speichern eines bed_mesh in Klipper aussteht.",
"LockSliders": "Sperre Schieberegler auf Touchscreen Geräten",
"LockSlidersDelay": "Verzögerung der Sperre für Schieberegler",
"LockSlidersDelayDescription": "Schieberegler werden nach einer bestimmten Verzögerung gesperrt. Wenn 0 oder leer, dann sperren Schieberegler nur nach wechseln/neuladen der Seite.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@
"GcodeThumbnails": "G-Code thumbnails",
"GcodeThumbnailsDescription": "Click on the button to get to the instructions.",
"Guide": "Guide",
"HideSaveConfigButtonForBedMesh": "Hide SAVE_CONFIG button for bed_mesh changes",
"HideSaveConfigButtonForBedMeshDescription": "Hide SAVE_CONFIG, if only bed_mesh changes are pending to be saved in Klipper.",
"LockSliders": "Lock sliders on touchscreen devices",
"LockSlidersDelay": "Slider lock delay",
"LockSlidersDelayDescription": "Sliders will lock after a given delay. If set to 0 or left blank, sliders will only lock on page change/reload.",
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const getDefaultState = (): GuiState => {
boolWebcamNavi: false,
navigationStyle: 'iconsAndText',
powerDeviceName: null,
hideSaveConfigForBedMash: false,
},
view: {
blockFileUpload: false,
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export interface GuiState {
boolWebcamNavi: boolean
navigationStyle: 'iconsAndText' | 'iconsOnly'
powerDeviceName: string | null
hideSaveConfigForBedMash: boolean
}
view: {
blockFileUpload: boolean
Expand Down

0 comments on commit 0f94e80

Please sign in to comment.