refactor: remove ensureConnection method and update MediaPreviewDialog for image loading

This commit is contained in:
uncor3
2025-09-14 00:36:32 +00:00
parent 9fbe1b5f45
commit ef6ad480a0
6 changed files with 74 additions and 96 deletions
+15 -19
View File
@@ -174,26 +174,22 @@ void MediaPreviewDialog::loadMedia()
void MediaPreviewDialog::loadImage()
{
// TODO
// // Load image asynchronously
// auto future = QtConcurrent::run([this]() {
// return PhotoModel::loadThumbnailFromDevice(m_device, m_filePath,
// QSize(4096, 4096), "");
// });
auto future = QtConcurrent::run(
[this]() { return PhotoModel::loadImage(m_device, m_filePath, ""); });
// auto *watcher = new QFutureWatcher<QPixmap>(this);
// connect(watcher, &QFutureWatcher<QPixmap>::finished, this,
// [this, watcher]() {
// QPixmap pixmap = watcher->result();
// if (!pixmap.isNull()) {
// m_originalPixmap = pixmap;
// onImageLoaded();
// } else {
// onImageLoadFailed();
// }
// watcher->deleteLater();
// });
// watcher->setFuture(future);
auto *watcher = new QFutureWatcher<QPixmap>(this);
connect(watcher, &QFutureWatcher<QPixmap>::finished, this,
[this, watcher]() {
QPixmap pixmap = watcher->result();
if (!pixmap.isNull()) {
m_originalPixmap = pixmap;
onImageLoaded();
} else {
onImageLoadFailed();
}
watcher->deleteLater();
});
watcher->setFuture(future);
}
void MediaPreviewDialog::loadVideo()