diff options
Diffstat (limited to 'src/timeline/widgets')
-rw-r--r-- | src/timeline/widgets/AudioItem.cc | 6 | ||||
-rw-r--r-- | src/timeline/widgets/FileItem.cc | 6 | ||||
-rw-r--r-- | src/timeline/widgets/ImageItem.cc | 17 | ||||
-rw-r--r-- | src/timeline/widgets/VideoItem.cc | 2 |
4 files changed, 25 insertions, 6 deletions
diff --git a/src/timeline/widgets/AudioItem.cc b/src/timeline/widgets/AudioItem.cc index 5d9dd77b..e84cbb3a 100644 --- a/src/timeline/widgets/AudioItem.cc +++ b/src/timeline/widgets/AudioItem.cc @@ -89,14 +89,16 @@ AudioItem::AudioItem(QSharedPointer<MatrixClient> client, AudioItem::AudioItem(QSharedPointer<MatrixClient> client, const QString &url, + const QSharedPointer<QIODevice> data, const QString &filename, QWidget *parent) : QWidget(parent) , url_{url} - , text_{QFileInfo(filename).fileName()} + , text_{QFileInfo{filename}.fileName()} , client_{client} { - readableFileSize_ = calculateFileSize(QFileInfo(filename).size()); + Q_UNUSED(data); + readableFileSize_ = calculateFileSize(QFileInfo{filename}.size()); init(); } diff --git a/src/timeline/widgets/FileItem.cc b/src/timeline/widgets/FileItem.cc index 3c38dc31..a6159309 100644 --- a/src/timeline/widgets/FileItem.cc +++ b/src/timeline/widgets/FileItem.cc @@ -76,14 +76,16 @@ FileItem::FileItem(QSharedPointer<MatrixClient> client, FileItem::FileItem(QSharedPointer<MatrixClient> client, const QString &url, + const QSharedPointer<QIODevice> data, const QString &filename, QWidget *parent) : QWidget(parent) , url_{url} - , text_{QFileInfo(filename).fileName()} + , text_{QFileInfo{filename}.fileName()} , client_{client} { - readableFileSize_ = calculateFileSize(QFileInfo(filename).size()); + Q_UNUSED(data); + readableFileSize_ = calculateFileSize(QFileInfo{filename}.size()); init(); } diff --git a/src/timeline/widgets/ImageItem.cc b/src/timeline/widgets/ImageItem.cc index 9038456d..48a4c1eb 100644 --- a/src/timeline/widgets/ImageItem.cc +++ b/src/timeline/widgets/ImageItem.cc @@ -61,11 +61,12 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client, ImageItem::ImageItem(QSharedPointer<MatrixClient> client, const QString &url, + const QSharedPointer<QIODevice> data, const QString &filename, QWidget *parent) : QWidget(parent) , url_{url} - , text_{QFileInfo(filename).fileName()} + , text_{filename} , client_{client} { setMouseTracking(true); @@ -83,7 +84,19 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client, url_ = QString("%1/_matrix/media/r0/download/%2") .arg(client_.data()->getHomeServer().toString(), media_params); - setImage(QPixmap(filename)); + if (data.isNull()) { + qWarning() << "No image data to display"; + return; + } + + if (data->reset()) { + QPixmap p; + p.loadFromData(data->readAll()); + setImage(p); + } else { + qWarning() << "Failed to seek to beginning of device:" << data->errorString(); + return; + } } void diff --git a/src/timeline/widgets/VideoItem.cc b/src/timeline/widgets/VideoItem.cc index b3987b83..b46dff7b 100644 --- a/src/timeline/widgets/VideoItem.cc +++ b/src/timeline/widgets/VideoItem.cc @@ -66,6 +66,7 @@ VideoItem::VideoItem(QSharedPointer<MatrixClient> client, VideoItem::VideoItem(QSharedPointer<MatrixClient> client, const QString &url, + const QSharedPointer<QIODevice> data, const QString &filename, QWidget *parent) : QWidget(parent) @@ -73,6 +74,7 @@ VideoItem::VideoItem(QSharedPointer<MatrixClient> client, , text_{QFileInfo(filename).fileName()} , client_{client} { + Q_UNUSED(data); readableFileSize_ = calculateFileSize(QFileInfo(filename).size()); init(); |