mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Don't use direct image response objects anymore
This commit is contained in:
parent
6c71802680
commit
ec6f0f9296
2 changed files with 40 additions and 28 deletions
|
@ -256,6 +256,11 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
|
||||||
isInitialSync_ = true;
|
isInitialSync_ = true;
|
||||||
emit initialSyncChanged(true);
|
emit initialSyncChanged(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(this,
|
||||||
|
&TimelineViewManager::openImageOverlayInternalCb,
|
||||||
|
this,
|
||||||
|
&TimelineViewManager::openImageOverlayInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -350,37 +355,40 @@ TimelineViewManager::escapeEmoji(QString str) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId) const
|
TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId)
|
||||||
{
|
{
|
||||||
if (mxcUrl.isEmpty()) {
|
if (mxcUrl.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QQuickImageResponse *imgResponse =
|
|
||||||
imgProvider->requestImageResponse(mxcUrl.remove("mxc://"), QSize());
|
MxcImageProvider::download(
|
||||||
connect(imgResponse, &QQuickImageResponse::finished, this, [this, eventId, imgResponse]() {
|
mxcUrl.remove("mxc://"), QSize(), [this, eventId](QString, QSize, QImage img, QString) {
|
||||||
if (!imgResponse->errorString().isEmpty()) {
|
if (img.isNull()) {
|
||||||
nhlog::ui()->error("Error when retrieving image for overlay: {}",
|
nhlog::ui()->error("Error when retrieving image for overlay.");
|
||||||
imgResponse->errorString().toStdString());
|
return;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
emit openImageOverlayInternalCb(eventId, std::move(img));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineViewManager::openImageOverlayInternal(QString eventId, QImage img)
|
||||||
|
{
|
||||||
|
auto pixmap = QPixmap::fromImage(img);
|
||||||
|
|
||||||
|
auto imgDialog = new dialogs::ImageOverlay(pixmap);
|
||||||
|
imgDialog->showFullScreen();
|
||||||
|
connect(imgDialog, &dialogs::ImageOverlay::saving, timeline_, [this, eventId, imgDialog]() {
|
||||||
|
// hide the overlay while presenting the save dialog for better
|
||||||
|
// cross platform support.
|
||||||
|
imgDialog->hide();
|
||||||
|
|
||||||
|
if (!timeline_->saveMedia(eventId)) {
|
||||||
|
imgDialog->show();
|
||||||
|
} else {
|
||||||
|
imgDialog->close();
|
||||||
}
|
}
|
||||||
auto pixmap = QPixmap::fromImage(imgResponse->textureFactory()->image());
|
|
||||||
|
|
||||||
auto imgDialog = new dialogs::ImageOverlay(pixmap);
|
|
||||||
imgDialog->showFullScreen();
|
|
||||||
connect(imgDialog,
|
|
||||||
&dialogs::ImageOverlay::saving,
|
|
||||||
timeline_,
|
|
||||||
[this, eventId, imgDialog]() {
|
|
||||||
// hide the overlay while presenting the save dialog for better
|
|
||||||
// cross platform support.
|
|
||||||
imgDialog->hide();
|
|
||||||
|
|
||||||
if (!timeline_->saveMedia(eventId)) {
|
|
||||||
imgDialog->show();
|
|
||||||
} else {
|
|
||||||
imgDialog->close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
||||||
bool isNarrowView() const { return isNarrowView_; }
|
bool isNarrowView() const { return isNarrowView_; }
|
||||||
bool isWindowFocused() const { return isWindowFocused_; }
|
bool isWindowFocused() const { return isWindowFocused_; }
|
||||||
Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const;
|
Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId);
|
||||||
Q_INVOKABLE QColor userColor(QString id, QColor background);
|
Q_INVOKABLE QColor userColor(QString id, QColor background);
|
||||||
Q_INVOKABLE QString escapeEmoji(QString str) const;
|
Q_INVOKABLE QString escapeEmoji(QString str) const;
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ signals:
|
||||||
void narrowViewChanged();
|
void narrowViewChanged();
|
||||||
void focusChanged();
|
void focusChanged();
|
||||||
void focusInput();
|
void focusInput();
|
||||||
|
void openImageOverlayInternalCb(QString eventId, QImage img);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
||||||
|
@ -146,6 +147,9 @@ public slots:
|
||||||
void backToRooms() { emit showRoomList(); }
|
void backToRooms() { emit showRoomList(); }
|
||||||
QObject *completerFor(QString completerName, QString roomId = "");
|
QObject *completerFor(QString completerName, QString roomId = "");
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void openImageOverlayInternal(QString eventId, QImage img);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef USE_QUICK_VIEW
|
#ifdef USE_QUICK_VIEW
|
||||||
QQuickView *view;
|
QQuickView *view;
|
||||||
|
|
Loading…
Reference in a new issue