Skip to content

Commit

Permalink
refactor: refactor ToolheadControlPanel (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou committed Sep 5, 2023
1 parent e0f5166 commit ecaa894
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/components/inputs/ToolSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import { Component, Mixins, Prop, Watch } from 'vue-property-decorator'
import { Debounce } from 'vue-debounce-decorator'
import BaseMixin from '@/components/mixins/base'
import { mdiLockOpenVariantOutline, mdiLockOutline, mdiMinus, mdiPlus, mdiRestart } from '@mdi/js'
import { TranslateResult } from 'vue-i18n'
@Component
export default class ToolSlider extends Mixins(BaseMixin) {
Expand All @@ -107,7 +108,7 @@ export default class ToolSlider extends Mixins(BaseMixin) {
@Prop({ type: Number, required: true }) declare readonly target: number
@Prop({ type: String, required: true }) declare readonly command: string
@Prop({ type: String, default: '' }) declare readonly attributeName: string
@Prop({ type: String, default: '' }) declare readonly label: string
@Prop({ default: '' }) declare readonly label: string | TranslateResult
@Prop({ type: String, default: '' }) declare readonly icon: string
@Prop({ type: String, default: '%' }) declare readonly unit: string
@Prop({ type: Number, default: 1 }) declare readonly attributeScale: number
Expand Down
32 changes: 15 additions & 17 deletions src/components/panels/ToolheadControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@
<panel
v-if="klipperReadyForGui"
:icon="mdiGamepad"
:title="$t('Panels.ToolheadControlPanel.Headline').toString()"
:title="$t('Panels.ToolheadControlPanel.Headline')"
:collapsible="true"
card-class="toolhead-control-panel">
<!-- PANEL-HEADER 3-DOT-MENU -->
<template
v-if="
(controlStyle !== 'bars' && (existsZtilt || existsQGL)) ||
existsBedScrews ||
existsBedTilt ||
existsDeltaCalibrate ||
existsScrewsTilt
"
#buttons>
<template v-if="showButtons" #buttons>
<v-menu left offset-y :close-on-content-click="false" class="pa-0">
<template #activator="{ on, attrs }">
<v-btn icon tile v-bind="attrs" :disabled="['printing'].includes(printer_state)" v-on="on">
Expand Down Expand Up @@ -92,21 +84,21 @@
</v-menu>
</template>
<!-- MOVE TO CONTROL -->
<move-to-control class="py-0 pt-3"></move-to-control>
<move-to-control class="py-0 pt-3" />
<!-- AXIS CONTROL -->
<v-container v-if="axisControlVisible">
<component :is="`${controlStyle}-control`"></component>
<component :is="`${controlStyle}-control`" />
</v-container>
<!-- Z-OFFSET CONTROL -->
<v-divider :class="{ 'mt-3': !axisControlVisible }"></v-divider>
<v-divider :class="{ 'mt-3': !axisControlVisible }" />
<v-container>
<zoffset-control></zoffset-control>
<zoffset-control />
</v-container>
<!-- SPEED FACTOR -->
<v-divider></v-divider>
<v-divider />
<v-container>
<tool-slider
:label="$t('Panels.ToolheadControlPanel.SpeedFactor').toString()"
:label="$t('Panels.ToolheadControlPanel.SpeedFactor')"
:icon="mdiSpeedometer"
:target="speedFactor"
:min="1"
Expand All @@ -116,7 +108,7 @@
:dynamic-range="true"
:has-input-field="true"
command="M220"
attribute-name="S"></tool-slider>
attribute-name="S" />
</v-container>
</panel>
</template>
Expand Down Expand Up @@ -172,5 +164,11 @@ export default class ToolheadControlPanel extends Mixins(BaseMixin, ControlMixin
get axisControlVisible() {
return !(this.isPrinting && (this.$store.state.gui.control.hideDuringPrint ?? false))
}
get showButtons() {
if (this.controlStyle !== 'bars' && (this.existsZtilt || this.existsQGL)) return true
return this.existsBedScrews || this.existsBedTilt || this.existsDeltaCalibrate || this.existsScrewsTilt
}
}
</script>

0 comments on commit ecaa894

Please sign in to comment.