From dbd2bebe6c2765ffdcdf0dd7fb59443aa9e103ee Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 21 Mar 2022 05:05:29 +0100 Subject: Show some previews in upload window --- src/timeline/InputBar.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/timeline/InputBar.h') diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 46563bbb..4472fe84 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -53,11 +53,11 @@ class MediaUpload : public QObject { Q_OBJECT // Q_PROPERTY(bool uploading READ uploading NOTIFY uploadingChanged) - // Q_PROPERTY(MediaType mediaType READ type NOTIFY mediaTypeChanged) + Q_PROPERTY(int mediaType READ type NOTIFY mediaTypeChanged) // // https://stackoverflow.com/questions/33422265/pass-qimage-to-qml/68554646#68554646 // Q_PROPERTY(QUrl thumbnail READ thumbnail NOTIFY thumbnailChanged) // Q_PROPERTY(QString humanSize READ humanSize NOTIFY huSizeChanged) - // Q_PROPERTY(QString filename READ filename NOTIFY filenameChanged) + Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) // Q_PROPERTY(QString mimetype READ mimetype NOTIFY mimetypeChanged) // Q_PROPERTY(int height READ height NOTIFY heightChanged) // Q_PROPERTY(int width READ width NOTIFY widthChanged) @@ -73,7 +73,7 @@ public: Video, Audio, }; - Q_ENUM(MediaType); + Q_ENUM(MediaType) explicit MediaUpload(std::unique_ptr data, QString mimetype, @@ -81,6 +81,17 @@ public: bool encrypt, QObject *parent = nullptr); + [[nodiscard]] int type() const + { + if (mimeClass_ == u"video") + return MediaType::Video; + else if (mimeClass_ == u"audio") + return MediaType::Audio; + else if (mimeClass_ == u"image") + return MediaType::Image; + else + return MediaType::File; + } [[nodiscard]] QString url() const { return url_; } [[nodiscard]] QString mimetype() const { return mimetype_; } [[nodiscard]] QString mimeClass() const { return mimeClass_; } @@ -102,9 +113,19 @@ public: QString thumbnailUrl() const { return thumbnailUrl_; } [[nodiscard]] uint64_t thumbnailSize() const { return thumbnailSize_; } + void setFilename(QString fn) + { + if (fn != originalFilename_) { + originalFilename_ = std::move(fn); + emit filenameChanged(); + } + } + signals: void uploadComplete(MediaUpload *self, QString url); void uploadFailed(MediaUpload *self); + void filenameChanged(); + void mediaTypeChanged(); public slots: void startUpload(); -- cgit 1.5.1