Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: uses macro description as button tooltip #915

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/components/ui/AppMacroBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:disabled="(macro.disabledWhilePrinting && printerPrinting) || !klippyReady"
:style="borderStyle"
@click="$emit('click', macro.name)"
v-on="$listeners"
>
<slot />
</app-btn>
Expand All @@ -15,6 +16,7 @@
:disabled="(macro.disabledWhilePrinting && printerPrinting) || !klippyReady"
:style="borderStyle"
@click="$emit('click', macro.name)"
v-on="$listeners"
>
<slot />
</app-btn>
Expand Down Expand Up @@ -114,8 +116,12 @@ export default class AppMacroBtn extends Mixins(StateMixin) {
get runCommand () {
let s = this.macro.name
if (this.params) {
for (const param of Object.keys(this.params)) {
s += ` ${param}=${this.params[param].value}`
if (['m117', 'm118'].includes(this.macro.name)) {
s += ` ${this.params.message.value}`
} else {
for (const param of Object.keys(this.params)) {
s += ` ${param}=${this.params[param].value}`
}
}
}
return s
Expand All @@ -130,7 +136,10 @@ export default class AppMacroBtn extends Mixins(StateMixin) {

mounted () {
if (!this.macro.config || !this.macro.config.gcode) return []
if (this.macro.config.gcode) {

if (['m117', 'm118'].includes(this.macro.name)) {
this.$set(this.params, 'message', { value: '', reset: '' })
} else {
for (const { name, value } of gcodeMacroParams(this.macro.config.gcode)) {
if (!this.params[name]) {
this.$set(this.params, name, { value, reset: value })
Expand Down
61 changes: 39 additions & 22 deletions src/components/widgets/macros/Macros.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,27 @@
</v-expansion-panel-header>

<v-expansion-panel-content>
<app-macro-btn
<v-tooltip
v-for="macro in category.macros"
:key="`category-${macro.name}`"
:macro="macro"
:loading="hasWait(`${waits.onMacro}${macro.name}`)"
:elevation="2"
enable-params
class="me-2 mb-2 float-left"
@click="sendGcode($event, `${waits.onMacro}${macro.name}`)"
bottom
>
{{ macro.alias || macro.name }}
</app-macro-btn>
<template #activator="{ on, attrs }">
<app-macro-btn
v-bind="attrs"
:macro="macro"
:loading="hasWait(`${waits.onMacro}${macro.name}`)"
:elevation="2"
enable-params
class="me-2 mb-2 float-left"
v-on="on"
@click="sendGcode($event, `${waits.onMacro}${macro.name}`)"
>
{{ macro.alias || macro.name }}
</app-macro-btn>
</template>
<span>{{ macro.config.description }}</span>
</v-tooltip>
</v-expansion-panel-content>
</v-expansion-panel>

Expand Down Expand Up @@ -90,19 +99,27 @@
</v-expansion-panel-header>

<v-expansion-panel-content>
<template v-for="macro in uncategorizedMacros">
<app-macro-btn
:key="`category-${macro.name}`"
:macro="macro"
:loading="hasWait(`${waits.onMacro}${macro.name}`)"
:elevation="2"
enable-params
class="me-2 mb-2 float-left"
@click="sendGcode($event, `${waits.onMacro}${macro.name}`)"
>
{{ macro.alias || macro.name }}
</app-macro-btn>
</template>
<v-tooltip
v-for="macro in uncategorizedMacros"
:key="`category-${macro.name}`"
bottom
>
<template #activator="{ on, attrs }">
<app-macro-btn
v-bind="attrs"
:macro="macro"
:loading="hasWait(`${waits.onMacro}${macro.name}`)"
:elevation="2"
enable-params
class="me-2 mb-2 float-left"
v-on="on"
@click="sendGcode($event, `${waits.onMacro}${macro.name}`)"
>
{{ macro.alias || macro.name }}
</app-macro-btn>
</template>
<span>{{ macro.config.description }}</span>
</v-tooltip>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
Expand Down