diff options
Diffstat (limited to 'lib/downloads/widgets')
-rw-r--r-- | lib/downloads/widgets/downloaditemwidget.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp index 4096751..241b90b 100644 --- a/lib/downloads/widgets/downloaditemwidget.cpp +++ b/lib/downloads/widgets/downloaditemwidget.cpp @@ -48,7 +48,7 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa } ui->url_label->setText(item->url().toString()); - ui->path_label->setText(item->path()); + ui->path_label->setText(QString("%1<br>%2").arg(item->downloadDirectory(), item->downloadFileName())); this->updateState(item->state()); connect(item, &QWebEngineDownloadItem::stateChanged, this, &DownloadItemWidget::updateState); @@ -64,7 +64,7 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa } }); connect(ui->open_toolButton, &QToolButton::clicked, item, [item]() { - QDesktopServices::openUrl(QUrl::fromLocalFile(item->path())); + QDesktopServices::openUrl(QUrl::fromLocalFile(item->downloadDirectory()+'/'+item->downloadFileName())); }); } @@ -125,28 +125,17 @@ void DownloadItemWidget::updateFinished() ui->abort_toolButton->hide(); ui->open_toolButton->show(); - // generate a useful tooltip - QString tooltip = "<p><b>URL</b>: %1</p>" - "<p><b>Path</b>: %2</p>" - "<p><b>MIME Type</b>: %3</p>" - "<p><b>Size</b>: %4</p>"; - tooltip = tooltip.arg(item->url().toString(), item->path(), item->mimeType(), sizeString(item->totalBytes())); - + // generate a preview tooltip if(item->mimeType().startsWith("image")) { - const QPixmap pixmap(item->path()); + const QPixmap pixmap(item->downloadDirectory()+'/'+item->downloadFileName()); const QPixmap thumbnail = pixmap.scaledToWidth(qMax(400, pixmap.width()), Qt::SmoothTransformation); QByteArray imageData; QBuffer buffer(&imageData); thumbnail.save(&buffer, "PNG"); - tooltip = QString("<table>" - "<tr><th>Preview</th><th>Information</th></tr>" - "<tr><td>%1</td><td>%2</td></tr>" - "</table>").arg(QString("<img src='data:image/png;base64," + imageData.toBase64() + "' width='400' alt='preview'>"), - tooltip); - + const auto tooltip = QString("<img src='data:image/png;base64," + imageData.toBase64() + "' width='400' alt='preview'>"); + setToolTip(tooltip); } - setToolTip(tooltip); } |