aboutsummaryrefslogtreecommitdiff
path: root/src/lib/downloads/downloadswidget.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-12-27 17:06:33 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-12-27 17:06:33 +0100
commitbdc239d1f827308c0fc1e4c202ed0e3f5c71da0b (patch)
treee743885fcdfc92a85eb46b075cf65e6b7c0c8a8e /src/lib/downloads/downloadswidget.cpp
parentUrlRequestInterceptor fixes (diff)
downloadsmolbote-bdc239d1f827308c0fc1e4c202ed0e3f5c71da0b.tar.xz
Download manager fixes
DownloadsWidget - Download widget now in landscape - Download widget no longer docks in the main window, but is a dialog DownloadItemWidget - Download item widget looks more compact - Download details are now a part of the item widgets instead - Download details: save path
Diffstat (limited to 'src/lib/downloads/downloadswidget.cpp')
-rw-r--r--src/lib/downloads/downloadswidget.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/lib/downloads/downloadswidget.cpp b/src/lib/downloads/downloadswidget.cpp
index af41397..dc7d5e2 100644
--- a/src/lib/downloads/downloadswidget.cpp
+++ b/src/lib/downloads/downloadswidget.cpp
@@ -17,7 +17,7 @@
#include "widgets/downloaditemwidget.h"
DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) :
- QWidget(parent),
+ QDialog(parent),
ui(new Ui::DownloadDialog)
{
// make sure this dialog does not get deleted on close
@@ -25,11 +25,22 @@ DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) :
setWindowTitle(tr("Downloads"));
ui->setupUi(this);
- ui->filePath->setWordWrap(true);
m_downloadPath = downloadPath;
- connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showItemDetails(int)));
+ connect(ui->listWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous) {
+ DownloadItemWidget *currentWidget = qobject_cast<DownloadItemWidget*>(ui->listWidget->itemWidget(current));
+ currentWidget->showDetails();
+ currentWidget->adjustSize();
+ current->setSizeHint(currentWidget->size());
+
+ DownloadItemWidget *previousWidget = qobject_cast<DownloadItemWidget*>(ui->listWidget->itemWidget(previous));
+ if(previousWidget != nullptr) {
+ previousWidget->hideDetails();
+ previousWidget->adjustSize();
+ previous->setSizeHint(previousWidget->size());
+ }
+ });
}
DownloadsWidget::~DownloadsWidget()
@@ -60,13 +71,8 @@ void DownloadsWidget::addDownload(QWebEngineDownloadItem *item)
ui->listWidget->setItemWidget(listItem, form);
item->accept();
- this->show();
-}
-void DownloadsWidget::showItemDetails(int index)
-{
- DownloadItemWidget *form = qobject_cast<DownloadItemWidget *>(ui->listWidget->itemWidget(ui->listWidget->item(index)));
- ui->mimeType_label->setText(form->item()->mimeType());
- ui->filePath_label->setText(form->item()->path());
- ui->fileSize_label->setText(QString("%1 bytes").arg(form->item()->totalBytes()));
+ ui->listWidget->setCurrentRow(rowIndex);
+
+ this->show();
}