aboutsummaryrefslogtreecommitdiff
path: root/lib/downloads/widgets/downloaditemwidget.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-05-13 16:58:53 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-05-13 16:58:53 +0200
commit686f58c997dce499ab90c7ba035e2c387ab96ec4 (patch)
tree579e80a5d6dd5dfee16aa15e7ff511c29c42464a /lib/downloads/widgets/downloaditemwidget.cpp
parentNew window action (diff)
downloadsmolbote-686f58c997dce499ab90c7ba035e2c387ab96ec4.tar.xz
Download widget item tooltip
Simplified ElidedLabel
Diffstat (limited to 'lib/downloads/widgets/downloaditemwidget.cpp')
-rw-r--r--lib/downloads/widgets/downloaditemwidget.cpp44
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);
}