summary refs log tree commit diff
path: root/src/timeline/InputBar.h
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-21 05:05:29 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-21 05:05:29 +0100
commitdbd2bebe6c2765ffdcdf0dd7fb59443aa9e103ee (patch)
tree8f7a47d341b0d58d18f3ae3de7b9e7b87972acf1 /src/timeline/InputBar.h
parentPlease clazy (diff)
downloadnheko-dbd2bebe6c2765ffdcdf0dd7fb59443aa9e103ee.tar.xz
Show some previews in upload window
Diffstat (limited to '')
-rw-r--r--src/timeline/InputBar.h27
1 files changed, 24 insertions, 3 deletions
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<QIODevice> 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();