summaryrefslogtreecommitdiffstats
path: root/examples/network/http/httpwindow.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-09-26 16:08:55 +0200
committerLiang Qi <liang.qi@qt.io>2017-09-26 16:14:54 +0200
commitaadfe7d634de04519102c5827ca885dc2e2199c9 (patch)
treed92db346ca95332b177036a53f1f6beb2e24fb74 /examples/network/http/httpwindow.cpp
parent4b6c1448047362b8c38d265e6414f0e3e59b8d37 (diff)
parenta732e16d5fd9dbf8a0289fec9f948b12e9ba2c19 (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/gui/kernel/qguiapplication.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h src/plugins/platforms/cocoa/qcocoawindow.h src/testlib/qtestsystem.h Change-Id: I5975ffb3261c2dd82fe02ec4e57df7c0950226c5
Diffstat (limited to 'examples/network/http/httpwindow.cpp')
-rw-r--r--examples/network/http/httpwindow.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index 9640907673..ec90b8f7fe 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -55,12 +55,12 @@
#include "httpwindow.h"
#include "ui_authenticationdialog.h"
-#ifndef QT_NO_SSL
-static const char defaultUrl[] = "https://www.qt.io/";
+#if QT_CONFIG(ssl)
+const char defaultUrl[] = "https://www.qt.io/";
#else
-static const char defaultUrl[] = "http://www.qt.io/";
+const char defaultUrl[] = "http://www.qt.io/";
#endif
-static const char defaultFileName[] = "index.html";
+const char defaultFileName[] = "index.html";
ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent)
: QProgressDialog(parent)
@@ -71,6 +71,7 @@ ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent)
setMinimum(0);
setValue(0);
setMinimumDuration(0);
+ setMinimumSize(QSize(400, 75));
}
void ProgressDialog::networkReplyProgress(qint64 bytesRead, qint64 totalBytes)
@@ -174,15 +175,22 @@ void HttpWindow::downloadFile()
if (fileName.isEmpty())
fileName = defaultFileName;
QString downloadDirectory = QDir::cleanPath(downloadDirectoryLineEdit->text().trimmed());
- if (!downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir())
+ 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 in "
- "the current directory. Overwrite?").arg(fileName),
- QMessageBox::Yes|QMessageBox::No, QMessageBox::No)
- == QMessageBox::No)
+ 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) {
return;
+ }
QFile::remove(fileName);
}
@@ -252,7 +260,9 @@ void HttpWindow::httpFinished()
if (QMessageBox::question(this, tr("Redirect"),
tr("Redirect to %1 ?").arg(redirectedUrl.toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
+ QFile::remove(fi.absoluteFilePath());
downloadButton->setEnabled(true);
+ statusLabel->setText(tr("Download failed:\nRedirect rejected."));
return;
}
file = openFileForWrite(fi.absoluteFilePath());
@@ -286,7 +296,7 @@ void HttpWindow::enableDownloadButton()
downloadButton->setEnabled(!urlLineEdit->text().isEmpty());
}
-void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
+void HttpWindow::slotAuthenticationRequired(QNetworkReply *, QAuthenticator *authenticator)
{
QDialog authenticationDialog;
Ui::Dialog ui;
@@ -306,7 +316,7 @@ void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authe
}
#ifndef QT_NO_SSL
-void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
+void HttpWindow::sslErrors(QNetworkReply *, const QList<QSslError> &errors)
{
QString errorString;
foreach (const QSslError &error, errors) {