HTTP example: Fix missing translation and improve others
As a drive-by: print the path with native separators Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I73164acb159d1a45960e16d5f57996e8c27257f7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
7c90881a8e
commit
c89c37b52f
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2020 The Qt Company Ltd.
|
// Copyright (C) 2023 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
#include "httpwindow.h"
|
#include "httpwindow.h"
|
||||||
@ -42,7 +42,7 @@ HttpWindow::HttpWindow(QWidget *parent)
|
|||||||
, statusLabel(new QLabel(tr("Please enter the URL of a file you want to download.\n\n"), this))
|
, statusLabel(new QLabel(tr("Please enter the URL of a file you want to download.\n\n"), this))
|
||||||
, urlLineEdit(new QLineEdit(defaultUrl))
|
, urlLineEdit(new QLineEdit(defaultUrl))
|
||||||
, downloadButton(new QPushButton(tr("Download")))
|
, downloadButton(new QPushButton(tr("Download")))
|
||||||
, launchCheckBox(new QCheckBox("Launch file"))
|
, launchCheckBox(new QCheckBox(tr("Launch file")))
|
||||||
, defaultFileLineEdit(new QLineEdit(defaultFileName))
|
, defaultFileLineEdit(new QLineEdit(defaultFileName))
|
||||||
, downloadDirectoryLineEdit(new QLineEdit)
|
, downloadDirectoryLineEdit(new QLineEdit)
|
||||||
{
|
{
|
||||||
@ -142,19 +142,18 @@ void HttpWindow::downloadFile()
|
|||||||
bool useDirectory = !downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir();
|
bool useDirectory = !downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir();
|
||||||
if (useDirectory)
|
if (useDirectory)
|
||||||
fileName.prepend(downloadDirectory + '/');
|
fileName.prepend(downloadDirectory + '/');
|
||||||
|
|
||||||
if (QFile::exists(fileName)) {
|
if (QFile::exists(fileName)) {
|
||||||
if (QMessageBox::question(this, tr("Overwrite Existing File"),
|
QString alreadyExists = useDirectory
|
||||||
tr("There already exists a file called %1%2."
|
? tr("There already exists a file called %1. Overwrite?")
|
||||||
" Overwrite?")
|
: tr("There already exists a file called %1 in the current directory. "
|
||||||
.arg(fileName,
|
"Overwrite?");
|
||||||
useDirectory
|
QMessageBox::StandardButton response = QMessageBox::question(this,
|
||||||
? QString()
|
tr("Overwrite Existing File"),
|
||||||
: QStringLiteral(" in the current directory")),
|
alreadyExists.arg(QDir::toNativeSeparators(fileName)),
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||||
QMessageBox::No)
|
if (response == QMessageBox::No)
|
||||||
== QMessageBox::No) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
QFile::remove(fileName);
|
QFile::remove(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user