From c66602deb759f882422dfe694f87643b7253c629 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Mon, 3 Nov 2025 09:16:48 +0100 Subject: [PATCH] Place CR icon correctly on (scaled) image Also, show "red dot" only if details not viewed already. --- src/assets/css/sendattachments.scss | 20 ---------- src/components/ImageWithProgress.vue | 13 ++++++- .../content-credentials/C2PAInfo.vue | 2 +- .../file_mode/SendAttachmentsLayout.vue | 37 ++++++++++++------- src/components/file_mode/ThumbnailView.vue | 35 ++++++++++++++++++ src/models/attachment.ts | 1 + src/models/attachmentManager.ts | 3 +- 7 files changed, 74 insertions(+), 37 deletions(-) diff --git a/src/assets/css/sendattachments.scss b/src/assets/css/sendattachments.scss index 256db11..d5663d8 100644 --- a/src/assets/css/sendattachments.scss +++ b/src/assets/css/sendattachments.scss @@ -109,26 +109,6 @@ $hiliteColor: #4642f1; height: 100%; object-fit: cover; } - - .send-attachments__selecting__current-item__preparing { - position: absolute; - right: 8px; - bottom: 4px; - display: flex; - flex-direction: column; - align-items: end; - justify-content: end; - } - - .send-attachments__selecting__current-item__cc { - position: absolute; - right: 12px; - bottom: 12px; - display: flex; - flex-direction: column; - align-items: end; - justify-content: end; - } } .file-drop-choose-files { diff --git a/src/components/ImageWithProgress.vue b/src/components/ImageWithProgress.vue index 8cf9c81..41ca3c4 100644 --- a/src/components/ImageWithProgress.vue +++ b/src/components/ImageWithProgress.vue @@ -1,5 +1,6 @@ @@ -12,10 +13,10 @@ import * as sdk from "matrix-js-sdk"; import logoMixin from "./logoMixin"; import LoadProgress from "./LoadProgress.vue"; import { VImg } from "vuetify/components/VImg"; +import { emit } from "process"; export default { name: "ImageWithProgress", - extends: VImg, components: { LoadProgress }, props: { loadingProgress: { @@ -28,6 +29,14 @@ export default { data() { return {}; }, + methods: { + loaded() { + this.$emit('loaded', this.$refs.image); + }, + handleResize() { + this.loaded(); + } + } }; diff --git a/src/components/content-credentials/C2PAInfo.vue b/src/components/content-credentials/C2PAInfo.vue index 61c50fd..5a6ab66 100644 --- a/src/components/content-credentials/C2PAInfo.vue +++ b/src/components/content-credentials/C2PAInfo.vue @@ -1,6 +1,6 @@ + +
+ +
@@ -58,6 +64,7 @@ function isAttachment(source: EventAttachment | Attachment | undefined): source const $$sanitize: any = inject("globalSanitize"); const thumbnailRef = useTemplateRef("thumbnailRef"); +const imageRef = useTemplateRef("imageRef"); interface ThumbnailProps { item?: EventAttachment | Attachment; @@ -78,6 +85,7 @@ let { isVideo, isImage, fileTypeIcon, fileTypeIconClass, fileName, fileSize, isP const fileURL: Ref = ref(undefined); const source: Ref = ref(undefined); const poster: Ref = ref(undefined); +const decoratorStyle: Ref = ref(undefined); const updateSource = () => { if (isEventAttachment(props.item)) { @@ -130,6 +138,33 @@ const updatePoster = () => { updateSource(); updatePoster(); +const imageLoaded = (image: any) => { + if (imageRef.value) { + const rect = image.$el.getBoundingClientRect(); + const nw = image.naturalWidth; + const nh = image.naturalHeight; + + let t = 0; + let l = 0; + let w = 0; + let h = 0; + + const wRatio = rect.width / rect.height; + const iRatio = nw / nh; + if (iRatio > wRatio) { + w = rect.width; + h = rect.width / iRatio; + } else { + w = rect.height * iRatio; + h = rect.height; + } + + l = (rect.width - w) / 2; + t = (rect.height -h) / 2; + + decoratorStyle.value = `position:absolute;top:${t}px;left:${l}px;width:${w}px;height:${h}px;display:flex;align-items:end;justify-content:end;padding:10px`; + } +} watch(props, (props: ThumbnailProps) => { const updates = useThumbnail(isEventAttachment(props.item) ? props.item.event : isAttachment(props.item) ? props.item.file : undefined); diff --git a/src/models/attachment.ts b/src/models/attachment.ts index 94e1c49..2fa4f9a 100644 --- a/src/models/attachment.ts +++ b/src/models/attachment.ts @@ -60,6 +60,7 @@ export type Attachment = { proof?: Proof; mediaMetadata?: MediaMetadata; thumbnail?: AttachmentThumbnail; + detailsViewed: boolean; sendInfo: AttachmentSendInfo; }; diff --git a/src/models/attachmentManager.ts b/src/models/attachmentManager.ts index 6ad6f32..abbb79d 100644 --- a/src/models/attachmentManager.ts +++ b/src/models/attachmentManager.ts @@ -58,6 +58,7 @@ export class AttachmentManager { status: "loading", file: file, useCompressed: false, + detailsViewed: false, sendInfo: { status: "initial", statusDate: 0, @@ -438,7 +439,7 @@ export class AttachmentManager { } } -export const createUploadBatch = (manager: AttachmentManager | null, room: Room | null): AttachmentBatch => { +export const createUploadBatch = (manager: AttachmentManager | null, room: KeanuRoom | null): AttachmentBatch => { const matrixClient = manager?.matrixClient; const maxSizeUploads = manager?.maxSizeUploads ?? 0;