summary refs log tree commit diff
path: root/include/dialogs
diff options
context:
space:
mode:
authorchristarazi <christarazi@users.noreply.github.com>2018-02-18 12:52:31 -0800
committermujx <mujx@users.noreply.github.com>2018-02-18 22:52:31 +0200
commitcd9d1a2ec69bf4c459f9e845293d5fd7dc1398d4 (patch)
treea3669f25c8ecaf716061b3080ae9f9073134da05 /include/dialogs
parentShow loading indicator while waiting for /login & /logout (diff)
downloadnheko-cd9d1a2ec69bf4c459f9e845293d5fd7dc1398d4.tar.xz
Support audio, video, generic file for pasting (#220)
* Refactor widget items to use same interface

* Support audio, video, generic file for pasting

* Add utils function for human readable file sizes

* Set correct MIME type for media messages

This change also determines the size of the upload once from the
ContentLengthHeader, rather than seeking the QIODevice and asking for
its size. This prevents any future trouble in case the QIODevice is
sequential (cannot be seeked). The MIME type is also determined at
upload once, rather than using the QIODevice and the underlying data
inside.

* Allow for file urls to be used as fall-back

This fixes an issue on macOS which uses `text/uri-list` for copying
files to the clipboard.

fixes #228 
Diffstat (limited to 'include/dialogs')
-rw-r--r--include/dialogs/PreviewUploadOverlay.h (renamed from include/dialogs/PreviewImageOverlay.h)22
1 files changed, 13 insertions, 9 deletions
diff --git a/include/dialogs/PreviewImageOverlay.h b/include/dialogs/PreviewUploadOverlay.h

index a1ab32ee..c9516719 100644 --- a/include/dialogs/PreviewImageOverlay.h +++ b/include/dialogs/PreviewUploadOverlay.h
@@ -28,28 +28,32 @@ class QMimeData; namespace dialogs { -class PreviewImageOverlay : public QWidget +class PreviewUploadOverlay : public QWidget { Q_OBJECT public: - PreviewImageOverlay(QWidget *parent = nullptr); + PreviewUploadOverlay(QWidget *parent = nullptr); - void setImageAndCreate(const QByteArray data, const QString &type); - void setImageAndCreate(const QString &path); + void setPreview(const QByteArray data, const QString &mime); + void setPreview(const QString &path); signals: - void confirmImageUpload(const QByteArray data, const QString &img_name); + void confirmUpload(const QByteArray data, const QString &media, const QString &filename); private: void init(); + void setLabels(const QString &type, const QString &mime, const int upload_size); + bool isImage_; QPixmap image_; - QByteArray imageData_; - QString imagePath_; + + QByteArray data_; + QString filePath_; + QString mediaType_; QLabel titleLabel_; - QLabel imageLabel_; - QLineEdit imageName_; + QLabel infoLabel_; + QLineEdit fileName_; FlatButton upload_; FlatButton cancel_;