summary refs log tree commit diff
path: root/include/TextInputWidget.h
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/TextInputWidget.h
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/TextInputWidget.h')
-rw-r--r--include/TextInputWidget.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h

index 6d28009e..b89b7753 100644 --- a/include/TextInputWidget.h +++ b/include/TextInputWidget.h
@@ -27,12 +27,12 @@ #include "FlatButton.h" #include "LoadingIndicator.h" -#include "dialogs/PreviewImageOverlay.h" +#include "dialogs/PreviewUploadOverlay.h" #include "emoji/PickButton.h" namespace dialogs { -class PreviewImageOverlay; +class PreviewUploadOverlay; } class FilteredTextEdit : public QTextEdit @@ -53,9 +53,13 @@ signals: void heightChanged(int height); void startedTyping(); void stoppedTyping(); + void startedUpload(); void message(QString); void command(QString name, QString args); - void image(const QSharedPointer<QIODevice> iodev, const QString &img_name); + void image(QSharedPointer<QIODevice> data, const QString &filename); + void audio(QSharedPointer<QIODevice> data, const QString &filename); + void video(QSharedPointer<QIODevice> data, const QString &filename); + void file(QSharedPointer<QIODevice> data, const QString &filename); protected: void keyPressEvent(QKeyEvent *event) override; @@ -67,11 +71,12 @@ private: size_t history_index_; QTimer *typingTimer_; - dialogs::PreviewImageOverlay previewDialog_; + dialogs::PreviewUploadOverlay previewDialog_; void textChanged(); - void receiveImage(const QByteArray img, const QString &img_name); + void uploadData(const QByteArray data, const QString &media, const QString &filename); void afterCompletion(int); + void showPreview(const QMimeData *source, const QStringList &formats); }; class TextInputWidget : public QWidget @@ -95,9 +100,10 @@ signals: void sendTextMessage(QString msg); void sendEmoteMessage(QString msg); - void uploadImage(QSharedPointer<QIODevice> data, const QString &filename); - void uploadFile(QSharedPointer<QIODevice> data, const QString &filename); - void uploadAudio(QSharedPointer<QIODevice> data, const QString &filename); + void uploadImage(const QSharedPointer<QIODevice> data, const QString &filename); + void uploadFile(const QSharedPointer<QIODevice> data, const QString &filename); + void uploadAudio(const QSharedPointer<QIODevice> data, const QString &filename); + void uploadVideo(const QSharedPointer<QIODevice> data, const QString &filename); void sendJoinRoomRequest(const QString &room);