From e23d56aeec177a187143dd9d2b5bdc00782b61a3 Mon Sep 17 00:00:00 2001 From: Arno Pigeon Date: Tue, 12 Dec 2023 19:59:09 +0100 Subject: [PATCH 1/3] feat: Button to copy bed mesh into clipboard as image Add a button to the bed mesh card to a copy bed mesh image to clipboard Signed-off-by: Arno Pigeon --- .../widgets/bedmesh/BedMeshCard.vue | 28 ++++++++++++++++++- .../widgets/bedmesh/BedMeshChart.vue | 8 ++++++ src/locales/en.yaml | 1 + src/locales/fr.yaml | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/components/widgets/bedmesh/BedMeshCard.vue b/src/components/widgets/bedmesh/BedMeshCard.vue index 9c159d2271..88839b5166 100644 --- a/src/components/widgets/bedmesh/BedMeshCard.vue +++ b/src/components/widgets/bedmesh/BedMeshCard.vue @@ -31,7 +31,24 @@ $fullScreen - + diff --git a/src/components/widgets/bedmesh/BedMeshChart.vue b/src/components/widgets/bedmesh/BedMeshChart.vue index 253ec862db..56d9201356 100644 --- a/src/components/widgets/bedmesh/BedMeshChart.vue +++ b/src/components/widgets/bedmesh/BedMeshChart.vue @@ -241,6 +241,14 @@ export default class BedMeshChart extends Mixins(BrowserMixin) { } return text } + + async copyImage () { + const type = 'image/png' + const image = await fetch(this.chart.getDataURL({ type: 'png', backgroundColor: '#262629' })) + const blob = await image.blob() + const data = [new ClipboardItem({ [type]: blob })] + await navigator.clipboard.write(data) + } } diff --git a/src/locales/en.yaml b/src/locales/en.yaml index 328fff43f2..0a68601ff8 100644 --- a/src/locales/en.yaml +++ b/src/locales/en.yaml @@ -22,6 +22,7 @@ app: delete: Delete Profile load: Load Profile save: Commits calibrated profile to printer.cfg + copy_image: Copy bed mesh image chart: label: current: Actual diff --git a/src/locales/fr.yaml b/src/locales/fr.yaml index 6bbd7c6e06..f91a23adc0 100644 --- a/src/locales/fr.yaml +++ b/src/locales/fr.yaml @@ -22,6 +22,7 @@ app: delete: Supprime le profil load: Charger le profil save: Enregistrer le profil calibré dans 'printer.cfg' + copy_image: Copier l'image du bed mesh chart: label: current: Courant From 674231deb23ca62d0aa263a50b0d81a0a41a68d7 Mon Sep 17 00:00:00 2001 From: Pedro Lamas Date: Wed, 13 Dec 2023 10:51:40 +0000 Subject: [PATCH 2/3] refactor: generic code & style refactor Signed-off-by: Pedro Lamas --- .../widgets/bedmesh/BedMeshCard.vue | 69 +++++++++++-------- .../widgets/bedmesh/BedMeshChart.vue | 8 ++- src/globals.ts | 4 +- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/components/widgets/bedmesh/BedMeshCard.vue b/src/components/widgets/bedmesh/BedMeshCard.vue index 88839b5166..235a3b23a3 100644 --- a/src/components/widgets/bedmesh/BedMeshCard.vue +++ b/src/components/widgets/bedmesh/BedMeshCard.vue @@ -7,11 +7,9 @@ :collapsable="!fullscreen" layout-path="dashboard.bed-mesh-card" > -