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

@ -11,14 +11,16 @@ QT += widgets
QT += network
HEADERS += $$PWD/src/qsimpleupdater.h \
$$PWD/src/dialogs/download_dialog.h
$$PWD/src/dialogs/download_dialog.h
SOURCES += $$PWD/src/qsimpleupdater.cpp \
$$PWD/src/dialogs/download_dialog.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

@ -18,33 +18,33 @@ class DownloadDialog;
}
class DownloadDialog : public QWidget {
Q_OBJECT
Q_OBJECT
public:
explicit DownloadDialog (QWidget *parent = 0);
~DownloadDialog();
public:
explicit DownloadDialog (QWidget *parent = 0);
~DownloadDialog();
void beginDownload (const QUrl &url);
void beginDownload (const QUrl& url);
private slots:
void openDownload();
void cancelDownload();
void downloadFinished();
void updateProgress (qint64 received, qint64 total);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error);
private slots:
void openDownload();
void cancelDownload();
void downloadFinished();
void updateProgress (qint64 received, qint64 total);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError>& error);
private:
Ui::DownloadDialog *ui;
private:
Ui::DownloadDialog *ui;
QString m_path;
bool m_download_paused;
QString m_path;
bool m_download_paused;
QNetworkReply *m_reply;
QNetworkAccessManager *m_manager;
QNetworkReply *m_reply;
QNetworkAccessManager *m_manager;
uint m_start_time;
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

@ -17,87 +17,87 @@
#include "dialogs/download_dialog.h"
class QSimpleUpdater : public QObject {
Q_OBJECT
Q_OBJECT
public:
QSimpleUpdater (QObject *parent = 0);
public:
QSimpleUpdater (QObject *parent = 0);
/// Returns the downloaded change log
QString changeLog() const;
/// Returns the downloaded change log
QString changeLog() const;
/// Returns the downloaded version string
QString latestVersion() const;
/// Returns the downloaded version string
QString latestVersion() const;
/// Returns the local version, referenced by
/// the setApplicationVersion() function
QString installedVersion() const;
/// Returns the local version, referenced by
/// the setApplicationVersion() function
QString installedVersion() const;
/// Returns \c true if there's a newer version available
bool newerVersionAvailable() const;
/// Returns \c true if there's a newer version available
bool newerVersionAvailable() const;
/// Checks for updates and calls the appropriate
/// signals when finished
void checkForUpdates();
/// Checks for updates and calls the appropriate
/// signals when finished
void checkForUpdates();
/// Opens the download URL in a a web browser.
/// The URL is referenced by the \c setDownloadUrl() function
void openDownloadLink();
/// Opens the download URL in a a web browser.
/// The URL is referenced by the \c setDownloadUrl() function
void openDownloadLink();
/// Shows a dialog that downloads the file in the
/// URL referenced by the \c setDownloadUrl() function
void downloadLatestVersion();
/// Shows a dialog that downloads the file in the
/// 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);
/// 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);
/// Changes the reference URL, which contains ONLY the latest
/// version of your application as a plain text file.
/// Examples include:
/// - 1.2.3
/// - 5.4.0
/// - 0.1.2
/// - etc.
void setReferenceUrl (const QString &url);
/// Changes the reference URL, which contains ONLY the latest
/// version of your application as a plain text file.
/// Examples include:
/// - 1.2.3
/// - 5.4.0
/// - 0.1.2
/// - etc.
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);
/// 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);
/// Tells the updater the version of the installed
/// copy of your application.
void setApplicationVersion (const QString &version);
/// Tells the updater the version of the installed
/// copy of your application.
void setApplicationVersion (const QString& version);
private slots:
void checkDownloadedVersion (QNetworkReply *reply);
void processDownloadedChangelog (QNetworkReply *reply);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error);
private slots:
void checkDownloadedVersion (QNetworkReply *reply);
void processDownloadedChangelog (QNetworkReply *reply);
void ignoreSslErrors (QNetworkReply *reply, const QList<QSslError>& error);
signals:
void checkingFinished();
void versionCheckFinished();
void changelogDownloadFinished();
signals:
void checkingFinished();
void versionCheckFinished();
void changelogDownloadFinished();
private:
QString m_changelog;
QString m_latest_version;
QString m_installed_version;
private:
QString m_changelog;
QString m_latest_version;
QString m_installed_version;
QUrl m_download_url;
QUrl m_reference_url;
QUrl m_changelog_url;
QUrl m_download_url;
QUrl m_reference_url;
QUrl m_changelog_url;
bool m_changelog_downloaded;
bool m_version_check_finished;
bool m_changelog_downloaded;
bool m_version_check_finished;
bool m_new_version_available;
bool m_new_version_available;
DownloadDialog *m_downloadDialog;
DownloadDialog *m_downloadDialog;
};
#endif