diff options
Diffstat (limited to 'lib/downloads/widgets/downloaditemwidget.cpp')
-rw-r--r-- | lib/downloads/widgets/downloaditemwidget.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp index 2790c5c..660d8a5 100644 --- a/lib/downloads/widgets/downloaditemwidget.cpp +++ b/lib/downloads/widgets/downloaditemwidget.cpp @@ -15,8 +15,8 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa : QWidget(parent) , ui(new Ui::DownloadItemForm) { - m_item = item; - + Q_CHECK_PTR(item); + this->item = item; ui->setupUi(this); { // pause/resume icons @@ -28,9 +28,7 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa ui->abort_toolButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); } - ui->url_label->setContent(item->url().toString()); - ui->detailsWidget->hide(); - + ui->url_label->setText(item->url().toString()); ui->path_label->setText(item->path()); connect(item, &QWebEngineDownloadItem::stateChanged, this, &DownloadItemWidget::updateState); @@ -52,21 +50,6 @@ DownloadItemWidget::~DownloadItemWidget() delete ui; } -void DownloadItemWidget::showDetails() -{ - ui->detailsWidget->show(); -} - -void DownloadItemWidget::hideDetails() -{ - ui->detailsWidget->hide(); -} - -QWebEngineDownloadItem *DownloadItemWidget::item() const -{ - return m_item; -} - QString DownloadItemWidget::sizeString(int size) const { if(size < 1024) { @@ -127,4 +110,25 @@ void DownloadItemWidget::updateProgress(qint64 value, qint64 total) void DownloadItemWidget::updateFinished() { ui->progressBar->setValue(ui->progressBar->maximum()); + QString tooltip = "<table>" + "<tr>" + "<th>Preview</th>" + "<th>Information</th>" + "</tr>" + "<tr>" + "<td>%1</td>" + "<td>" + "<p><b>URL</b>: %2</p>" + "<p><b>Path</b>: %3</p>" + "<p><b>MIME Type</b>: %4</p>" + "<p><b>Size</b>: %5</p>" + "</td>" + "</tr>" + "</table>"; + if(item->mimeType().startsWith("image")) + tooltip = tooltip.arg("<img src='file://" + item->path() + "' alt='not available'>"); + else + tooltip = tooltip.arg("not available"); + tooltip = tooltip.arg(item->url().toString(), item->path(), item->mimeType(), sizeString(item->totalBytes())); + setToolTip(tooltip); } |