From eca5159e12288e1b4ee7d2d52f0475ca6433a0eb Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 24 Aug 2018 15:13:47 +0200 Subject: Downloads: prevent download widget width from exceeding download list width Downloads: add open button --- lib/downloads/downloadswidget.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/downloads/downloadswidget.cpp') diff --git a/lib/downloads/downloadswidget.cpp b/lib/downloads/downloadswidget.cpp index 2a8fe56..340ef93 100644 --- a/lib/downloads/downloadswidget.cpp +++ b/lib/downloads/downloadswidget.cpp @@ -14,14 +14,13 @@ DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) : QDialog(parent) , ui(new Ui::DownloadDialog) + , m_downloadPath(downloadPath) { // make sure this dialog does not get deleted on close setAttribute(Qt::WA_DeleteOnClose, false); setWindowTitle(tr("Downloads")); ui->setupUi(this); - - m_downloadPath = downloadPath; } DownloadsWidget::~DownloadsWidget() @@ -31,9 +30,7 @@ DownloadsWidget::~DownloadsWidget() void DownloadsWidget::addDownload(QWebEngineDownloadItem *item) { - QString filepath = QFileDialog::getSaveFileName(this, - tr("Save"), - m_downloadPath + "/" + QFileInfo(item->path()).fileName()); + const QString filepath = QFileDialog::getSaveFileName(this, tr("Save File"), m_downloadPath + "/" + QFileInfo(item->path()).fileName()); if(filepath.isEmpty()) { // user cancelled the save dialog @@ -43,15 +40,13 @@ void DownloadsWidget::addDownload(QWebEngineDownloadItem *item) item->setPath(filepath); - auto *listItem = new QListWidgetItem(); - int rowIndex = ui->listWidget->count(); - ui->listWidget->insertItem(rowIndex, listItem); + auto *listItem = new QListWidgetItem(ui->listWidget); auto *form = new DownloadItemWidget(item, this); ui->listWidget->setItemWidget(listItem, form); - listItem->setSizeHint(form->sizeHint()); + listItem->setSizeHint(QSize(listItem->sizeHint().width(), form->size().height())); item->accept(); - ui->listWidget->setCurrentRow(rowIndex); + ui->listWidget->setCurrentItem(listItem); } -- cgit v1.2.1