From 686f58c997dce499ab90c7ba035e2c387ab96ec4 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 13 May 2018 16:58:53 +0200 Subject: Download widget item tooltip Simplified ElidedLabel --- lib/downloads/widgets/downloaditemwidget.cpp | 44 +++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'lib/downloads/widgets/downloaditemwidget.cpp') 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 = "" + "" + "" + "" + "" + "" + "" + "" + "" + "
PreviewInformation
%1" + "

URL: %2

" + "

Path: %3

" + "

MIME Type: %4

" + "

Size: %5

" + "
"; + if(item->mimeType().startsWith("image")) + tooltip = tooltip.arg("not available"); + else + tooltip = tooltip.arg("not available"); + tooltip = tooltip.arg(item->url().toString(), item->path(), item->mimeType(), sizeString(item->totalBytes())); + setToolTip(tooltip); } -- cgit v1.2.1