Code format changes

This commit is contained in:
Alex Spataru 2014-12-16 18:04:55 -06:00
parent 0104c18332
commit df6feef57f
5 changed files with 110 additions and 108 deletions

View File

@ -12,13 +12,15 @@ QT += network
HEADERS += $$PWD/src/qsimpleupdater.h \ HEADERS += $$PWD/src/qsimpleupdater.h \
$$PWD/src/dialogs/download_dialog.h $$PWD/src/dialogs/download_dialog.h
SOURCES += $$PWD/src/qsimpleupdater.cpp \ SOURCES += $$PWD/src/qsimpleupdater.cpp \
$$PWD/src/dialogs/download_dialog.cpp $$PWD/src/dialogs/download_dialog.cpp
OTHER_FILES += $$PWD/src/QSimpleUpdater OTHER_FILES += $$PWD/src/QSimpleUpdater
INCLUDEPATH += $$PWD/src INCLUDEPATH += $$PWD/src
macx || linux:!android { unix:!android {
LIBS += -lcrypto -lssl LIBS += -lcrypto -lssl
} }
@ -28,5 +30,4 @@ win32* {
RESOURCES += $$PWD/res/qsu_resources.qrc RESOURCES += $$PWD/res/qsu_resources.qrc
FORMS += \ FORMS += $$PWD/src/dialogs/download_dialog.ui
$$PWD/src/dialogs/download_dialog.ui

View File

@ -9,9 +9,9 @@
#include "download_dialog.h" #include "download_dialog.h"
#include "ui_download_dialog.h" #include "ui_download_dialog.h"
DownloadDialog::DownloadDialog (QWidget *parent) : DownloadDialog::DownloadDialog (QWidget *parent)
QWidget (parent), : QWidget (parent)
ui (new Ui::DownloadDialog) { , ui (new Ui::DownloadDialog) {
// Setup the UI // Setup the UI
ui->setupUi (this); ui->setupUi (this);
@ -22,8 +22,8 @@ DownloadDialog::DownloadDialog (QWidget *parent) :
m_manager = new QNetworkAccessManager (this); m_manager = new QNetworkAccessManager (this);
// Avoid SSL issues // Avoid SSL issues
connect (m_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)), connect (m_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)), this,
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>))); SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
} }
DownloadDialog::~DownloadDialog() { DownloadDialog::~DownloadDialog() {
@ -44,8 +44,8 @@ void DownloadDialog::beginDownload (const QUrl &url) {
m_start_time = QDateTime::currentDateTime().toTime_t(); m_start_time = QDateTime::currentDateTime().toTime_t();
// Update the progress bar value automatically // Update the progress bar value automatically
connect (m_reply, SIGNAL (downloadProgress (qint64, qint64)), connect (m_reply, SIGNAL (downloadProgress (qint64, qint64)), this,
this, SLOT (updateProgress (qint64, qint64))); SLOT (updateProgress (qint64, qint64)));
// Write the file to the hard disk once the download is finished // Write the file to the hard disk once the download is finished
connect (m_reply, SIGNAL (finished()), this, SLOT (downloadFinished())); connect (m_reply, SIGNAL (finished()), this, SLOT (downloadFinished()));
@ -157,9 +157,7 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
_received_string = tr ("%1 MB").arg (_received); _received_string = tr ("%1 MB").arg (_received);
} }
ui->downloadLabel->setText (tr ("Downloading updates") + " (" + ui->downloadLabel->setText (tr ("Downloading updates") + " (" + _received_string + " " + tr ("of") + " " + _total_string + ")");
_received_string + " " + tr ("of") + " " +
_total_string + ")");
uint _diff = QDateTime::currentDateTime().toTime_t() - m_start_time; uint _diff = QDateTime::currentDateTime().toTime_t() - m_start_time;
@ -184,7 +182,8 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
} }
} }
// We do not know the size of the download, so we improvise... // We do not know the size of the download, so we avoid scaring the shit out
// of the user
else { else {
ui->progressBar->setValue (-1); ui->progressBar->setValue (-1);
ui->progressBar->setMinimum (0); ui->progressBar->setMinimum (0);
@ -194,7 +193,8 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
} }
} }
void DownloadDialog::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error) { void DownloadDialog::ignoreSslErrors (QNetworkReply *reply,
const QList<QSslError>& error) {
#ifndef Q_OS_IOS #ifndef Q_OS_IOS
reply->ignoreSslErrors (error); reply->ignoreSslErrors (error);
#else #else

View File

@ -29,8 +29,8 @@ void QSimpleUpdater::checkForUpdates() {
if (!m_reference_url.isEmpty()) { if (!m_reference_url.isEmpty()) {
QNetworkAccessManager *_manager = new QNetworkAccessManager (this); QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
connect (_manager, SIGNAL (finished (QNetworkReply *)), connect (_manager, SIGNAL (finished (QNetworkReply *)), this,
this, SLOT (checkDownloadedVersion (QNetworkReply *))); SLOT (checkDownloadedVersion (QNetworkReply *)));
connect (_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)), connect (_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)),
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>))); this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
@ -165,8 +165,8 @@ void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply) {
if (!m_changelog_url.isEmpty() && newerVersionAvailable()) { if (!m_changelog_url.isEmpty() && newerVersionAvailable()) {
QNetworkAccessManager *_manager = new QNetworkAccessManager (this); QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
connect (_manager, SIGNAL (finished (QNetworkReply *)), connect (_manager, SIGNAL (finished (QNetworkReply *)), this,
this, SLOT (processDownloadedChangelog (QNetworkReply *))); SLOT (processDownloadedChangelog (QNetworkReply *)));
connect (_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)), connect (_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)),
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>))); this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
@ -192,7 +192,8 @@ void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply) {
emit checkingFinished(); emit checkingFinished();
} }
void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error) { void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply,
const QList<QSslError>& error) {
#ifndef Q_OS_IOS #ifndef Q_OS_IOS
reply->ignoreSslErrors (error); reply->ignoreSslErrors (error);
#else #else