aboutsummaryrefslogtreecommitdiff
path: root/lib/downloads/downloadswidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/downloads/downloadswidget.cpp')
-rw-r--r--lib/downloads/downloadswidget.cpp15
1 files changed, 5 insertions, 10 deletions
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);
}