summaryrefslogtreecommitdiffstats
path: root/examples/network/http/httpwindow.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-09-17 15:56:30 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-11-05 13:54:13 +0000
commitd482a92858f181c76229dc977ee9c159ba36515f (patch)
tree429e985974655f5e2ebb2f2738ed54bd1fec682e /examples/network/http/httpwindow.h
parentf13d8163ec80afdb0051897dc705598ea2691725 (diff)
Polish the HTTP example.
- Remove unneeded member variables. - Use new connection syntax. - Streamline code. - Add a QCheckBox for launching the file after download and make the default file name and download directory configureable. - Make status messages more verbose. - Set Password echo mode on authentication dialog. - Extract the progress dialog to a separate class that is directly connected to the QNetworkReply, which is created on demand. Set set minimum and duration on it. This fixes a crash that currently occurs when clicking "Abort" on the SSL error dialog and "Cancel" on the progress dialog that is then re-shown due to its internal force timer/minimum duration handling. - Resize according to screen size. Task-number: QTBUG-48332 Change-Id: Ia2611e63fe96d6f49e4cdd06049a206ddb2c2864 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'examples/network/http/httpwindow.h')
-rw-r--r--examples/network/http/httpwindow.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h
index f1dc2e1f80..cc632e5bab 100644
--- a/examples/network/http/httpwindow.h
+++ b/examples/network/http/httpwindow.h
@@ -41,39 +41,46 @@
#ifndef HTTPWINDOW_H
#define HTTPWINDOW_H
-#include <QDialog>
+#include <QProgressDialog>
#include <QNetworkAccessManager>
#include <QUrl>
QT_BEGIN_NAMESPACE
-class QDialogButtonBox;
class QFile;
class QLabel;
class QLineEdit;
-class QProgressDialog;
class QPushButton;
class QSslError;
class QAuthenticator;
class QNetworkReply;
-
+class QCheckBox;
QT_END_NAMESPACE
+class ProgressDialog : public QProgressDialog {
+ Q_OBJECT
+
+public:
+ explicit ProgressDialog(const QUrl &url, QWidget *parent = Q_NULLPTR);
+
+public slots:
+ void networkReplyProgress(qint64 bytesRead, qint64 totalBytes);
+};
+
class HttpWindow : public QDialog
{
Q_OBJECT
public:
- HttpWindow(QWidget *parent = 0);
+ explicit HttpWindow(QWidget *parent = Q_NULLPTR);
- void startRequest(QUrl url);
+ void startRequest(const QUrl &requestedUrl);
private slots:
void downloadFile();
void cancelDownload();
void httpFinished();
void httpReadyRead();
- void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
void enableDownloadButton();
void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
#ifndef QT_NO_SSL
@@ -81,19 +88,19 @@ private slots:
#endif
private:
+ QFile *openFileForWrite(const QString &fileName);
+
QLabel *statusLabel;
- QLabel *urlLabel;
QLineEdit *urlLineEdit;
- QProgressDialog *progressDialog;
QPushButton *downloadButton;
- QPushButton *quitButton;
- QDialogButtonBox *buttonBox;
+ QCheckBox *launchCheckBox;
+ QLineEdit *defaultFileLineEdit;
+ QLineEdit *downloadDirectoryLineEdit;
QUrl url;
QNetworkAccessManager qnam;
QNetworkReply *reply;
QFile *file;
- int httpGetId;
bool httpRequestAborted;
};