mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Reenable ImageOverlay
This commit is contained in:
parent
82091999c4
commit
9b18440b4f
3 changed files with 34 additions and 1 deletions
|
@ -5,10 +5,16 @@ Item {
|
|||
height: 300 * eventData.proportionalHeight
|
||||
|
||||
Image {
|
||||
id: img
|
||||
anchors.fill: parent
|
||||
|
||||
source: eventData.url.replace("mxc://", "image://MxcImage/")
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: timelineManager.openImageOverlay(img.source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
|
||||
#include "Logging.h"
|
||||
#include "MxcImageProvider.h"
|
||||
#include "dialogs/ImageOverlay.h"
|
||||
|
||||
TimelineViewManager::TimelineViewManager(QWidget *parent)
|
||||
: imgProvider(new MxcImageProvider())
|
||||
{
|
||||
qmlRegisterUncreatableMetaObject(qml_mtx_events::staticMetaObject,
|
||||
"com.github.nheko",
|
||||
|
@ -18,7 +20,7 @@ TimelineViewManager::TimelineViewManager(QWidget *parent)
|
|||
container = QWidget::createWindowContainer(view, parent);
|
||||
container->setMinimumSize(200, 200);
|
||||
view->rootContext()->setContextProperty("timelineManager", this);
|
||||
view->engine()->addImageProvider("MxcImage", new MxcImageProvider());
|
||||
view->engine()->addImageProvider("MxcImage", imgProvider);
|
||||
view->setSource(QUrl("qrc:///qml/TimelineView.qml"));
|
||||
}
|
||||
|
||||
|
@ -52,6 +54,27 @@ TimelineViewManager::setHistoryView(const QString &room_id)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::openImageOverlay(QString url) const
|
||||
{
|
||||
QQuickImageResponse *imgResponse =
|
||||
imgProvider->requestImageResponse(url.remove("image://mxcimage/"), QSize());
|
||||
connect(imgResponse, &QQuickImageResponse::finished, this, [imgResponse]() {
|
||||
if (!imgResponse->errorString().isEmpty()) {
|
||||
nhlog::ui()->error("Error when retrieving image for overlay: {}",
|
||||
imgResponse->errorString().toStdString());
|
||||
return;
|
||||
}
|
||||
auto pixmap = QPixmap::fromImage(imgResponse->textureFactory()->image());
|
||||
|
||||
auto imgDialog = new dialogs::ImageOverlay(pixmap);
|
||||
imgDialog->show();
|
||||
// connect(imgDialog, &dialogs::ImageOverlay::saving, this,
|
||||
// &ImageItem::saveAs);
|
||||
Q_UNUSED(imgDialog);
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::updateReadReceipts(const QString &room_id,
|
||||
const std::vector<QString> &event_ids)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
class MxcImageProvider;
|
||||
|
||||
class TimelineViewManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -33,6 +35,7 @@ public:
|
|||
void clearAll() { models.clear(); }
|
||||
|
||||
Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; }
|
||||
Q_INVOKABLE void openImageOverlay(QString url) const;
|
||||
|
||||
signals:
|
||||
void clearRoomMessageCount(QString roomid);
|
||||
|
@ -75,6 +78,7 @@ private:
|
|||
QQuickView *view;
|
||||
QWidget *container;
|
||||
TimelineModel *timeline_ = nullptr;
|
||||
MxcImageProvider *imgProvider;
|
||||
|
||||
QHash<QString, QSharedPointer<TimelineModel>> models;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue