Skip to content

Commit

Permalink
feat: show macro description as tooltip when hovering a macro (#1849)
Browse files Browse the repository at this point in the history
  • Loading branch information
dw-0 authored Apr 14, 2024
1 parent 85a178e commit 8d831f8
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/components/inputs/MacroButton.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<template>
<v-item-group class="d-inline-block">
<v-btn
small
:color="color"
:class="paramArray.length ? 'macroWithParameters' : ''"
:loading="loadings.includes('macro_' + macro.name)"
:disabled="disabled"
@click="doSendMacro(macro.name)">
{{ alias ? alias : macro.name.replace(/_/g, ' ') }}
</v-btn>
<v-tooltip :disabled="!hasDescription" top>
<template #activator="{ on, attrs }">
<v-btn
small
:color="color"
:class="paramArray.length ? 'macroWithParameters' : ''"
:loading="loadings.includes('macro_' + macro.name)"
:disabled="disabled"
v-bind="attrs"
v-on="on"
@click="doSendMacro(macro.name)">
{{ alias ? alias : macro.name.replace(/_/g, ' ') }}
</v-btn>
</template>
<span>{{ klipperMacro.description }}</span>
</v-tooltip>
<template v-if="paramArray.length">
<v-menu v-if="!isMobile" offset-y :close-on-content-click="false">
<template #activator="{ on, attrs }">
Expand Down Expand Up @@ -118,16 +125,18 @@ interface params {
components: { Panel },
})
export default class MacroButton extends Mixins(BaseMixin) {
DEFAULT_DESC = 'G-Code macro'
/**
* Icons
*/
mdiCloseThick = mdiCloseThick
mdiMenuDown = mdiMenuDown
mdiRefresh = mdiRefresh
private paramArray: string[] = []
private params: params = {}
private paramsDialog = false
paramArray: string[] = []
params: params = {}
paramsDialog = false
@Prop({ required: true })
declare readonly macro: GuiMacrosStateMacrogroupMacro | PrinterStateMacro
Expand Down Expand Up @@ -167,6 +176,10 @@ export default class MacroButton extends Mixins(BaseMixin) {
return 200 * this.paramCols
}
get hasDescription(): boolean {
return this.klipperMacro.description && this.klipperMacro.description !== this.DEFAULT_DESC
}
@Watch('klipperMacro')
klipperMacroChange() {
this.refreshParams()
Expand Down

0 comments on commit 8d831f8

Please sign in to comment.