05fc3aef53
Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright (C) 2020 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
#include "downloaddialog.h"
|
|
#include "ui_downloaddialog.h"
|
|
|
|
#include <QUrl>
|
|
|
|
DownloadDialog::DownloadDialog(QWidget *parent) : QDialog(parent), ui(new Ui::DownloadDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
ui->urlLineEdit->setPlaceholderText(tr("Enter the URL of an image to download"));
|
|
|
|
connect(ui->addUrlButton, &QPushButton::clicked, this, [this] {
|
|
const auto text = ui->urlLineEdit->text();
|
|
if (!text.isEmpty()) {
|
|
ui->urlListWidget->addItem(text);
|
|
ui->urlLineEdit->clear();
|
|
}
|
|
});
|
|
connect(ui->urlListWidget, &QListWidget::itemSelectionChanged, this, [this] {
|
|
ui->removeUrlButton->setEnabled(!ui->urlListWidget->selectedItems().empty());
|
|
});
|
|
connect(ui->clearUrlsButton, &QPushButton::clicked, ui->urlListWidget, &QListWidget::clear);
|
|
connect(ui->removeUrlButton, &QPushButton::clicked, this,
|
|
[this] { qDeleteAll(ui->urlListWidget->selectedItems()); });
|
|
}
|
|
|
|
DownloadDialog::~DownloadDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
QList<QUrl> DownloadDialog::getUrls() const
|
|
{
|
|
QList<QUrl> urls;
|
|
for (auto row = 0; row < ui->urlListWidget->count(); ++row)
|
|
urls.push_back(QUrl(ui->urlListWidget->item(row)->text()));
|
|
return urls;
|
|
}
|