Skip to content

Commit d5926ee

Browse files
committed
refactor: move printer helper dialogs to root
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
1 parent 4dcbfa5 commit d5926ee

19 files changed

+167
-175
lines changed

src/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
<spool-selection-dialog />
8484
<action-command-prompt-dialog />
8585
<keyboard-shortcuts-dialog />
86+
<manual-probe-dialog />
87+
<bed-screws-adjust-dialog />
88+
<screws-tilt-adjust-dialog />
8689
</v-main>
8790

8891
<app-footer />

src/components/common/BedScrewsAdjustDialog.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<app-dialog
3-
v-model="open"
3+
v-model="bedScrewsAdjustDialogOpen"
44
:title="$t('app.tool.title.bed_screws_adjust')"
55
max-width="450"
66
@save="sendAccept"
@@ -91,22 +91,19 @@
9191
</template>
9292

9393
<script lang="ts">
94-
import { Component, Mixins, VModel, Watch } from 'vue-property-decorator'
94+
import { Component, Mixins, Watch } from 'vue-property-decorator'
9595
import StateMixin from '@/mixins/state'
9696
import ToolheadMixin from '@/mixins/toolhead'
9797
import type { BedScrews } from '@/store/printer/types'
9898
9999
@Component({})
100100
export default class BedScrewsAdjustDialog extends Mixins(StateMixin, ToolheadMixin) {
101-
@VModel({ type: Boolean })
102-
open?: boolean
103-
104101
get bedScrews (): BedScrews[] {
105102
return this.$store.getters['printer/getBedScrews'] as BedScrews[]
106103
}
107104
108105
get bedScrewsAdjust () {
109-
return this.$store.state.printer.printer.bed_screws
106+
return this.$store.state.printer.printer.bed_screws ?? {}
110107
}
111108
112109
get currentState () {
@@ -118,23 +115,34 @@ export default class BedScrewsAdjustDialog extends Mixins(StateMixin, ToolheadMi
118115
}
119116
120117
get currentScrewName () {
121-
return this.bedScrews[this.currentScrewIndex].prettyName
118+
return this.bedScrews[this.currentScrewIndex]?.prettyName
122119
}
123120
124121
get acceptedScrews () {
125122
return this.bedScrewsAdjust.accepted_screws
126123
}
127124
125+
get showBedScrewsAdjustDialogAutomatically (): boolean {
126+
return this.$store.state.config.uiSettings.general.showBedScrewsAdjustDialogAutomatically
127+
}
128+
128129
@Watch('isBedScrewsAdjustActive')
129130
onBedScrewsAdjustActive (value: boolean) {
130-
if (!value) {
131-
this.open = false
131+
if (
132+
!value ||
133+
(
134+
this.showBedScrewsAdjustDialogAutomatically &&
135+
this.klippyReady &&
136+
!this.printerPrinting
137+
)
138+
) {
139+
this.bedScrewsAdjustDialogOpen = value
132140
}
133141
}
134142
135143
sendAbort () {
136144
this.sendGcode('ABORT', this.$waits.onBedScrewsAdjust)
137-
this.open = false
145+
this.bedScrewsAdjustDialogOpen = false
138146
}
139147
140148
sendAdjusted () {

src/components/common/ManualProbeDialog.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<app-dialog
3-
v-model="open"
3+
v-model="manualProbeDialogOpen"
44
:title="$t('app.tool.title.manual_probe')"
55
:cancel-button-text="$t('app.general.btn.abort')"
66
:save-button-text="$t('app.general.btn.accept')"
@@ -134,15 +134,12 @@
134134
</template>
135135

136136
<script lang="ts">
137-
import { Component, Mixins, VModel, Watch } from 'vue-property-decorator'
137+
import { Component, Mixins, Watch } from 'vue-property-decorator'
138138
import StateMixin from '@/mixins/state'
139139
import ToolheadMixin from '@/mixins/toolhead'
140140
141141
@Component({})
142142
export default class ManualProbeDialog extends Mixins(StateMixin, ToolheadMixin) {
143-
@VModel({ type: Boolean })
144-
open?: boolean
145-
146143
get offsets () {
147144
return [
148145
1,
@@ -167,10 +164,21 @@ export default class ManualProbeDialog extends Mixins(StateMixin, ToolheadMixin)
167164
return this.manualProbe.z_position_upper?.toFixed(3)
168165
}
169166
167+
get showManualProbeDialogAutomatically (): boolean {
168+
return this.$store.state.config.uiSettings.general.showManualProbeDialogAutomatically
169+
}
170+
170171
@Watch('isManualProbeActive')
171172
onIsManualProbeActive (value: boolean) {
172-
if (!value) {
173-
this.open = false
173+
if (
174+
!value ||
175+
(
176+
this.showManualProbeDialogAutomatically &&
177+
this.klippyReady &&
178+
!this.printerPrinting
179+
)
180+
) {
181+
this.manualProbeDialogOpen = value
174182
}
175183
}
176184
@@ -180,7 +188,7 @@ export default class ManualProbeDialog extends Mixins(StateMixin, ToolheadMixin)
180188
181189
sendAbort () {
182190
this.sendGcode('ABORT', this.$waits.onManualProbe)
183-
this.open = false
191+
this.manualProbeDialogOpen = false
184192
}
185193
186194
sendAccept () {

src/components/common/ScrewsTiltAdjustDialog.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<app-dialog
3-
v-model="open"
3+
v-model="screwsTiltAdjustDialogOpen"
44
:title="$t('app.tool.title.screws_tilt_adjust')"
55
max-width="500"
66
@save="retry"
@@ -70,23 +70,34 @@
7070
</template>
7171

7272
<script lang="ts">
73-
import { Component, Mixins, VModel } from 'vue-property-decorator'
73+
import { Component, Mixins, Watch } from 'vue-property-decorator'
7474
import StateMixin from '@/mixins/state'
7575
import ToolheadMixin from '@/mixins/toolhead'
7676
import type { ScrewsTiltAdjust } from '@/store/printer/types'
7777
7878
@Component({})
7979
export default class ScrewsTiltAdjustDialog extends Mixins(StateMixin, ToolheadMixin) {
80-
@VModel({ type: Boolean })
81-
open?: boolean
82-
8380
get screwsTiltAdjust (): ScrewsTiltAdjust {
8481
return this.$store.getters['printer/getScrewsTiltAdjust'] as ScrewsTiltAdjust
8582
}
8683
84+
get showScrewsTiltAdjustDialogAutomatically (): boolean {
85+
return this.$store.state.config.uiSettings.general.showScrewsTiltAdjustDialogAutomatically
86+
}
87+
88+
@Watch('hasScrewsTiltAdjustResults')
89+
onHasScrewsTiltAdjustResults (value: boolean) {
90+
this.screwsTiltAdjustDialogOpen = (
91+
value &&
92+
this.showScrewsTiltAdjustDialogAutomatically &&
93+
this.klippyReady &&
94+
!this.printerPrinting
95+
)
96+
}
97+
8798
retry () {
8899
this.sendGcode('SCREWS_TILT_CALCULATE', this.$waits.onBedScrewsCalculate)
89-
this.open = false
100+
this.screwsTiltAdjustDialogOpen = false
90101
}
91102
92103
destroyed () {

src/components/widgets/bedmesh/BedMeshControls.vue

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,11 @@
264264
:adaptive="saveDialogState.adaptive"
265265
@save="handleMeshSave"
266266
/>
267-
268-
<manual-probe-dialog
269-
v-if="manualProbeDialogOpen"
270-
v-model="manualProbeDialogOpen"
271-
/>
272267
</collapsable-card>
273268
</template>
274269

275270
<script lang="ts">
276-
import { Component, Mixins, Watch } from 'vue-property-decorator'
271+
import { Component, Mixins } from 'vue-property-decorator'
277272
import SaveMeshDialog from './SaveMeshDialog.vue'
278273
import StateMixin from '@/mixins/state'
279274
import ToolheadMixin from '@/mixins/toolhead'
@@ -290,8 +285,6 @@ import type {
290285
}
291286
})
292287
export default class BedMesh extends Mixins(StateMixin, ToolheadMixin) {
293-
manualProbeDialogOpen = false
294-
295288
mapScaleLabels = ['min', '0.1', '0.2']
296289
boxScaleLabels = ['1.0', '1.5', '2.0']
297290
@@ -418,18 +411,6 @@ export default class BedMesh extends Mixins(StateMixin, ToolheadMixin) {
418411
adaptive: profile?.adaptive ?? false
419412
}
420413
}
421-
422-
get showManualProbeDialogAutomatically (): boolean {
423-
return this.$store.state.config.uiSettings.general.showManualProbeDialogAutomatically
424-
}
425-
426-
@Watch('isManualProbeActive')
427-
onIsManualProbeActive (value: boolean) {
428-
if (value && this.showManualProbeDialogAutomatically &&
429-
this.klippyReady && !this.printerPrinting) {
430-
this.manualProbeDialogOpen = true
431-
}
432-
}
433414
}
434415
</script>
435416

src/components/widgets/toolhead/ToolheadCard.vue

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
:disabled="!klippyReady || printerPrinting"
5656
small
5757
class="me-1 my-1"
58-
:color="forceMove ? 'error' : undefined"
58+
:color="forceMoveEnabled ? 'error' : undefined"
5959
@click="toggleForceMove"
6060
>
6161
FORCE_MOVE
@@ -131,26 +131,11 @@
131131
</template>
132132

133133
<toolhead />
134-
135-
<manual-probe-dialog
136-
v-if="manualProbeDialogOpen"
137-
v-model="manualProbeDialogOpen"
138-
/>
139-
140-
<bed-screws-adjust-dialog
141-
v-if="bedScrewsAdjustDialogOpen"
142-
v-model="bedScrewsAdjustDialogOpen"
143-
/>
144-
145-
<screws-tilt-adjust-dialog
146-
v-if="screwsTiltAdjustDialogOpen"
147-
v-model="screwsTiltAdjustDialogOpen"
148-
/>
149134
</collapsable-card>
150135
</template>
151136

152137
<script lang="ts">
153-
import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
138+
import { Component, Mixins, Prop } from 'vue-property-decorator'
154139
import StateMixin from '@/mixins/state'
155140
import ToolheadMixin from '@/mixins/toolhead'
156141
import Toolhead from './Toolhead.vue'
@@ -170,10 +155,6 @@ type Tool = {
170155
}
171156
})
172157
export default class ToolheadCard extends Mixins(StateMixin, ToolheadMixin) {
173-
manualProbeDialogOpen = false
174-
bedScrewsAdjustDialogOpen = false
175-
screwsTiltAdjustDialogOpen = false
176-
177158
@Prop({ type: Boolean })
178159
readonly menuCollapsed?: boolean
179160
@@ -383,59 +364,9 @@ export default class ToolheadCard extends Mixins(StateMixin, ToolheadMixin) {
383364
return this.$store.getters['printer/getHasRoundBed'] as boolean
384365
}
385366
386-
get showManualProbeDialogAutomatically (): boolean {
387-
return this.$store.state.config.uiSettings.general.showManualProbeDialogAutomatically
388-
}
389-
390-
get showBedScrewsAdjustDialogAutomatically (): boolean {
391-
return this.$store.state.config.uiSettings.general.showBedScrewsAdjustDialogAutomatically
392-
}
393-
394-
get showScrewsTiltAdjustDialogAutomatically (): boolean {
395-
return this.$store.state.config.uiSettings.general.showScrewsTiltAdjustDialogAutomatically
396-
}
397-
398-
get forceMove (): boolean {
399-
return this.$store.state.config.uiSettings.toolhead.forceMove
400-
}
401-
402-
@Watch('isManualProbeActive')
403-
onIsManualProbeActive (value: boolean) {
404-
if (
405-
value &&
406-
this.showManualProbeDialogAutomatically &&
407-
this.klippyReady &&
408-
!this.printerPrinting
409-
) {
410-
this.manualProbeDialogOpen = true
411-
}
412-
}
413-
414-
@Watch('isBedScrewsAdjustActive')
415-
onIsBedScrewsAdjustActive (value: boolean) {
416-
if (
417-
value &&
418-
this.showBedScrewsAdjustDialogAutomatically &&
419-
this.klippyReady &&
420-
!this.printerPrinting
421-
) {
422-
this.bedScrewsAdjustDialogOpen = true
423-
}
424-
}
425-
426-
@Watch('hasScrewsTiltAdjustResults')
427-
onHasScrewsTiltAdjustResults (value: boolean) {
428-
this.screwsTiltAdjustDialogOpen = (
429-
value &&
430-
this.showScrewsTiltAdjustDialogAutomatically &&
431-
this.klippyReady &&
432-
!this.printerPrinting
433-
)
434-
}
435-
436367
async toggleForceMove () {
437368
const result = (
438-
this.forceMove ||
369+
this.forceMoveEnabled ||
439370
!this.$store.state.config.uiSettings.general.forceMoveToggleWarning ||
440371
await this.$confirm(
441372
this.$tc('app.general.simple_form.msg.confirm_forcemove_toggle'),
@@ -444,11 +375,7 @@ export default class ToolheadCard extends Mixins(StateMixin, ToolheadMixin) {
444375
)
445376
446377
if (result) {
447-
this.$store.dispatch('config/saveByPath', {
448-
path: 'uiSettings.toolhead.forceMove',
449-
value: !this.forceMove,
450-
server: false
451-
})
378+
this.$store.dispatch('printer/forceMoveEnabled', !this.forceMoveEnabled)
452379
}
453380
}
454381
}

src/components/widgets/toolhead/ToolheadControlBars.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div v-if="!forceMove">
2+
<div v-if="!forceMoveEnabled">
33
<toolhead-control-bars-axis axis="X" />
44
<toolhead-control-bars-axis axis="Y" />
55
<toolhead-control-bars-axis axis="Z" />
@@ -73,9 +73,5 @@ export default class ToolheadControlBars extends Mixins(StateMixin, ToolheadMixi
7373
return steppers
7474
.filter(stepper => stepper.key.startsWith('stepper_'))
7575
}
76-
77-
get forceMove (): boolean {
78-
return this.$store.state.config.uiSettings.toolhead.forceMove
79-
}
8076
}
8177
</script>

src/components/widgets/toolhead/ToolheadControlCircle.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,6 @@ export default class ToolheadControlCircle extends Mixins(StateMixin, ToolheadMi
539539
return this.$store.state.config.uiSettings.general.toolheadCircleZMoveDistances
540540
}
541541
542-
get forceMove () {
543-
return this.$store.state.config.uiSettings.toolhead.forceMove
544-
}
545-
546542
get hasSteppersEnabled (): boolean {
547543
return this.$store.getters['printer/getHasSteppersEnabled'] as boolean
548544
}
@@ -729,7 +725,7 @@ export default class ToolheadControlCircle extends Mixins(StateMixin, ToolheadMi
729725
? -distance
730726
: distance
731727
732-
if (this.forceMove) {
728+
if (this.forceMoveEnabled) {
733729
const accel = axis === 'Z'
734730
? this.$store.getters['printer/getPrinterSettings']('printer.max_z_accel')
735731
: this.$store.state.printer.printer.toolhead.max_accel

0 commit comments

Comments
 (0)