-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Replaced all input tag based image selection with the IPC openFile based solution. - Replaced showOpenDialog with openFile. - Fixed the input dialog. - Removed the now unused file upload dialog.
- Loading branch information
1 parent
3e41ec6
commit 13c970c
Showing
10 changed files
with
115 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<script setup lang="ts"> | ||
import { mdiFileImagePlus, mdiVideoInputHdmi } from '@mdi/js' | ||
import videoInputHdmiIcon from '@mdi/svg/svg/video-input-hdmi.svg' | ||
import { useObjectUrl } from '@vueuse/core' | ||
import { computed } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
const props = defineProps<{ | ||
image?: File | undefined | ||
}>() | ||
const emit = defineEmits<{ | ||
(on: 'update', file: File): void | ||
(on: 'change', file: File): void | ||
}>() | ||
const { t } = useI18n() | ||
const file = computed(() => props.image) | ||
const url = useObjectUrl(file) | ||
async function selectImage() { | ||
const results = await globalThis.services.system.openFile({ | ||
title: t('label.select'), | ||
filters: [ | ||
{ extensions: ['svg', 'png', 'gif', 'jpg', 'jpeg'], name: t('filter.all') }, | ||
{ extensions: ['jpg', 'jpeg'], name: t('filter.jpg') }, | ||
{ extensions: ['svg'], name: t('filter.svg') }, | ||
{ extensions: ['png'], name: t('filter.png') }, | ||
{ extensions: ['gif'], name: t('filter.gif') } | ||
] | ||
}) | ||
const newFile = results?.at(0) ?? null | ||
if (newFile != null) { | ||
emit('update', newFile) | ||
emit('change', newFile) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<VHover v-slot="{ isHovering, props: hover }"> | ||
<VAvatar | ||
id="replacableImage" | ||
size="128" | ||
v-bind="{ ...hover }" | ||
color="surface-lighten-1" | ||
rounded="lg" | ||
tile | ||
@click="selectImage"> | ||
<VImg v-if="url != null" width="128" :src="url" :lazy-src="videoInputHdmiIcon" :cover="false" /> | ||
<VIcon v-else :icon="mdiVideoInputHdmi" /> | ||
<VOverlay | ||
class="align-center justify-center text-center" | ||
:model-value="isHovering ?? false" | ||
theme="light" | ||
scrim="primary-darken-4" | ||
contained> | ||
<VIcon :icon="mdiFileImagePlus" /> | ||
<div>{{ t('action.select') }}</div> | ||
</VOverlay> | ||
</VAvatar> | ||
</VHover> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
#replacableImage { | ||
cursor: pointer; | ||
} | ||
</style> | ||
|
||
<i18n lang="yaml"> | ||
en: | ||
action: | ||
select: Select new image | ||
label: | ||
select: Select image | ||
filter: | ||
all: Support images | ||
svg: SVG images | ||
png: PNG images | ||
gif: GIF images | ||
jpg: JPEG Images | ||
</i18n> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.