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 \
$$PWD/src/dialogs/download_dialog.h
SOURCES += $$PWD/src/qsimpleupdater.cpp \
$$PWD/src/dialogs/download_dialog.cpp
OTHER_FILES += $$PWD/src/QSimpleUpdater
INCLUDEPATH += $$PWD/src
macx || linux:!android {
unix:!android {
LIBS += -lcrypto -lssl
}
@ -28,5 +30,4 @@ win32* {
RESOURCES += $$PWD/res/qsu_resources.qrc
FORMS += \
$$PWD/src/dialogs/download_dialog.ui
FORMS += $$PWD/src/dialogs/download_dialog.ui

View File

@ -9,9 +9,9 @@
#include "download_dialog.h"
#include "ui_download_dialog.h"
DownloadDialog::DownloadDialog (QWidget *parent) :
QWidget (parent),
ui (new Ui::DownloadDialog) {
DownloadDialog::DownloadDialog (QWidget *parent)
: QWidget (parent)
, ui (new Ui::DownloadDialog) {
// Setup the UI
ui->setupUi (this);
@ -22,15 +22,15 @@ DownloadDialog::DownloadDialog (QWidget *parent) :
m_manager = new QNetworkAccessManager (this);
// Avoid SSL issues
connect (m_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)),
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
connect (m_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)), this,
SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
}
DownloadDialog::~DownloadDialog() {
delete ui;
}
void DownloadDialog::beginDownload (const QUrl &url) {
void DownloadDialog::beginDownload (const QUrl& url) {
Q_ASSERT (!url.isEmpty());
// Reset the UI
@ -44,8 +44,8 @@ void DownloadDialog::beginDownload (const QUrl &url) {
m_start_time = QDateTime::currentDateTime().toTime_t();
// Update the progress bar value automatically
connect (m_reply, SIGNAL (downloadProgress (qint64, qint64)),
this, SLOT (updateProgress (qint64, qint64)));
connect (m_reply, SIGNAL (downloadProgress (qint64, qint64)), this,
SLOT (updateProgress (qint64, qint64)));
// Write the file to the hard disk once the download is finished
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);
}
ui->downloadLabel->setText (tr ("Downloading updates") + " (" +
_received_string + " " + tr ("of") + " " +
_total_string + ")");
ui->downloadLabel->setText (tr ("Downloading updates") + " (" + _received_string + " " + tr ("of") + " " + _total_string + ")");
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 {
ui->progressBar->setValue (-1);
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
reply->ignoreSslErrors (error);
#else
@ -203,6 +203,6 @@ void DownloadDialog::ignoreSslErrors (QNetworkReply *reply, const QList<QSslErro
#endif
}
float DownloadDialog::roundNumber (const float &input) {
float DownloadDialog::roundNumber (const float& input) {
return roundf (input * 100) / 100;
}

View File

@ -20,20 +20,20 @@ class DownloadDialog;
class DownloadDialog : public QWidget {
Q_OBJECT
public:
public:
explicit DownloadDialog (QWidget *parent = 0);
~DownloadDialog();
void beginDownload (const QUrl &url);
void beginDownload (const QUrl& url);
private slots:
private slots:
void openDownload();
void cancelDownload();
void downloadFinished();
void updateProgress (qint64 received, qint64 total);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError>& error);
private:
private:
Ui::DownloadDialog *ui;
QString m_path;
@ -44,7 +44,7 @@ class DownloadDialog : public QWidget {
uint m_start_time;
float roundNumber (const float &input);
float roundNumber (const float& input);
};
#endif

View File

@ -29,8 +29,8 @@ void QSimpleUpdater::checkForUpdates() {
if (!m_reference_url.isEmpty()) {
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
connect (_manager, SIGNAL (finished (QNetworkReply *)),
this, SLOT (checkDownloadedVersion (QNetworkReply *)));
connect (_manager, SIGNAL (finished (QNetworkReply *)), this,
SLOT (checkDownloadedVersion (QNetworkReply *)));
connect (_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)),
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
@ -84,7 +84,7 @@ bool QSimpleUpdater::newerVersionAvailable() const {
return m_new_version_available;
}
void QSimpleUpdater::setDownloadUrl (const QString &url) {
void QSimpleUpdater::setDownloadUrl (const QString& url) {
Q_ASSERT (!url.isEmpty());
if (!url.isEmpty())
@ -94,7 +94,7 @@ void QSimpleUpdater::setDownloadUrl (const QString &url) {
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
}
void QSimpleUpdater::setReferenceUrl (const QString &url) {
void QSimpleUpdater::setReferenceUrl (const QString& url) {
Q_ASSERT (!url.isEmpty());
if (!url.isEmpty())
@ -104,7 +104,7 @@ void QSimpleUpdater::setReferenceUrl (const QString &url) {
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
}
void QSimpleUpdater::setChangelogUrl (const QString &url) {
void QSimpleUpdater::setChangelogUrl (const QString& url) {
Q_ASSERT (!url.isEmpty());
if (!url.isEmpty())
@ -114,7 +114,7 @@ void QSimpleUpdater::setChangelogUrl (const QString &url) {
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
}
void QSimpleUpdater::setApplicationVersion (const QString &version) {
void QSimpleUpdater::setApplicationVersion (const QString& version) {
Q_ASSERT (!version.isEmpty());
if (!version.isEmpty())
@ -165,8 +165,8 @@ void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply) {
if (!m_changelog_url.isEmpty() && newerVersionAvailable()) {
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
connect (_manager, SIGNAL (finished (QNetworkReply *)),
this, SLOT (processDownloadedChangelog (QNetworkReply *)));
connect (_manager, SIGNAL (finished (QNetworkReply *)), this,
SLOT (processDownloadedChangelog (QNetworkReply *)));
connect (_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)),
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
@ -192,7 +192,8 @@ void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply) {
emit checkingFinished();
}
void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error) {
void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply,
const QList<QSslError>& error) {
#ifndef Q_OS_IOS
reply->ignoreSslErrors (error);
#else

View File

@ -19,7 +19,7 @@
class QSimpleUpdater : public QObject {
Q_OBJECT
public:
public:
QSimpleUpdater (QObject *parent = 0);
/// Returns the downloaded change log
@ -47,12 +47,12 @@ class QSimpleUpdater : public QObject {
/// URL referenced by the \c setDownloadUrl() function
void downloadLatestVersion();
public slots:
public slots:
/// Changes the URL that we can open in a web browser or
/// download. Its recommended to use fixed URLs if you
/// want to automatically download and install your updates
void setDownloadUrl (const QString &url);
void setDownloadUrl (const QString& url);
/// Changes the reference URL, which contains ONLY the latest
/// version of your application as a plain text file.
@ -61,29 +61,29 @@ class QSimpleUpdater : public QObject {
/// - 5.4.0
/// - 0.1.2
/// - etc.
void setReferenceUrl (const QString &url);
void setReferenceUrl (const QString& url);
/// Changes the change log URL, which contains the change log
/// of your application. The change log can be any file you
/// like, however, its recommended to write it in plain text,
/// such as TXT, HTML and RTF files.
void setChangelogUrl (const QString &url);
void setChangelogUrl (const QString& url);
/// Tells the updater the version of the installed
/// copy of your application.
void setApplicationVersion (const QString &version);
void setApplicationVersion (const QString& version);
private slots:
private slots:
void checkDownloadedVersion (QNetworkReply *reply);
void processDownloadedChangelog (QNetworkReply *reply);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError>& error);
signals:
signals:
void checkingFinished();
void versionCheckFinished();
void changelogDownloadFinished();
private:
private:
QString m_changelog;
QString m_latest_version;
QString m_installed_version;