Files
qt-creator/tests/manual/tasking/imagescaling/downloaddialog.cpp
Jarek Kobus c3344c740a Tasking: Import imagescaling example
It's an initial copy of the
qtbase/examples/qtconcurrent/imagescaling.

The goal is to implement it using TaskTree and
compare both implementations.

Change-Id: I92953a70a3330ac679823060e75e5f39971ae444
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2023-06-06 08:05:39 +00:00

42 lines
1.3 KiB
C++

// Copyright (C) 2023 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;
}