diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2023-01-11 18:19:39 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2023-01-24 20:11:53 +0100 |
commit | c89c37b52f31e10a82cae2ecfac957184f9dab51 (patch) | |
tree | 2a6eaf6a8262bca31cdf3c6995a1f2cce9f7b235 /examples/network/http | |
parent | 7c90881a8e0402c6d6970539087c7b9632e51e23 (diff) |
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>
Diffstat (limited to 'examples/network/http')
-rw-r--r-- | examples/network/http/httpwindow.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp index 242c3df73e..5edc2838f6 100644 --- a/examples/network/http/httpwindow.cpp +++ b/examples/network/http/httpwindow.cpp @@ -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 #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)) , urlLineEdit(new QLineEdit(defaultUrl)) , downloadButton(new QPushButton(tr("Download"))) - , launchCheckBox(new QCheckBox("Launch file")) + , launchCheckBox(new QCheckBox(tr("Launch file"))) , defaultFileLineEdit(new QLineEdit(defaultFileName)) , downloadDirectoryLineEdit(new QLineEdit) { @@ -142,19 +142,18 @@ void HttpWindow::downloadFile() bool useDirectory = !downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir(); if (useDirectory) fileName.prepend(downloadDirectory + '/'); + if (QFile::exists(fileName)) { - if (QMessageBox::question(this, tr("Overwrite Existing File"), - tr("There already exists a file called %1%2." - " Overwrite?") - .arg(fileName, - useDirectory - ? QString() - : QStringLiteral(" in the current directory")), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No) - == QMessageBox::No) { + QString alreadyExists = useDirectory + ? tr("There already exists a file called %1. Overwrite?") + : tr("There already exists a file called %1 in the current directory. " + "Overwrite?"); + QMessageBox::StandardButton response = QMessageBox::question(this, + tr("Overwrite Existing File"), + alreadyExists.arg(QDir::toNativeSeparators(fileName)), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + if (response == QMessageBox::No) return; - } QFile::remove(fileName); } |