Added developer documentation links in readme file

- Added developer documentation links in read me
- Added aytostyle scripts
This commit is contained in:
Alex Spataru 2015-01-25 17:27:18 -06:00
parent 14ad5b9db9
commit 23999faf4e
12 changed files with 266 additions and 148 deletions

View File

@ -1,9 +1,10 @@
#include "example.h"
#include "ui_example.h"
int main (int argc, char *argv[]) {
QApplication app(argc, argv);
app.setApplicationName("QSimpleUpdater Example");
int main (int argc, char *argv[])
{
QApplication app (argc, argv);
app.setApplicationName ("QSimpleUpdater Example");
// Create the dialog and show it
Example example;
@ -13,74 +14,76 @@ int main (int argc, char *argv[]) {
return app.exec();
}
Example::Example (QWidget *parent) : QDialog(parent), ui(new Ui::Example) {
Example::Example (QWidget *parent) : QDialog (parent), ui (new Ui::Example)
{
// Create and configure the user interface
ui->setupUi(this);
ui->versionLineEdit->setText("0.1");
ui->versionLineEdit->setPlaceholderText("0.1");
ui->changelogTextEdit->setPlainText("Click the \"Check for updates\" button to download the change log");
ui->setupUi (this);
ui->versionLineEdit->setText ("0.1");
ui->versionLineEdit->setPlaceholderText ("0.1");
ui->changelogTextEdit->setPlainText ("Click the \"Check for updates\" button to download the change log");
// Close the dialog when the close button is clicked
connect (ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect (ui->closeButton, SIGNAL (clicked()), this, SLOT (close()));
// Check for updates when the updates button is clicked
connect (ui->updatesButton, SIGNAL(clicked()), this, SLOT(checkForUpdates()));
connect (ui->updatesButton, SIGNAL (clicked()), this, SLOT (checkForUpdates()));
// Initialize the updater
updater = new QSimpleUpdater(this);
updater = new QSimpleUpdater (this);
// When the updater finishes checking for updates, show a message box
// and show the change log of the latest version
connect (updater, SIGNAL(checkingFinished()), this, SLOT(onCheckingFinished()));
connect (updater, SIGNAL (checkingFinished()), this, SLOT (onCheckingFinished()));
}
Example::~Example() {
Example::~Example()
{
delete ui;
}
void Example::checkForUpdates() {
void Example::checkForUpdates()
{
// Disable the check for updates button while the updater
// is checking for updates
ui->updatesButton->setEnabled(false);
ui->updatesButton->setText("Checking for updates...");
ui->updatesButton->setEnabled (false);
ui->updatesButton->setText ("Checking for updates...");
// If the user changed the text of the versionLineEdit, then change the
// application version in the updater too
if (!ui->versionLineEdit->text().isEmpty()) {
updater->setApplicationVersion(ui->versionLineEdit->text());
}
if (!ui->versionLineEdit->text().isEmpty())
updater->setApplicationVersion (ui->versionLineEdit->text());
// If the versionLineEdit is empty, then set the application version
// to "0.1"
else {
updater->setApplicationVersion("0.1");
}
else
updater->setApplicationVersion ("0.1");
// Tell the updater where we should download the changelog, note that
// the changelog can be any file you want,
// such as an HTML page or (as in this example), a text file
updater->setChangelogUrl("https://raw.githubusercontent.com/alex-97/"
"QSimpleUpdater/Files-for-example-project/changelog.txt");
updater->setChangelogUrl ("https://raw.githubusercontent.com/alex-97/"
"QSimpleUpdater/Files-for-example-project/changelog.txt");
// Tell the updater where we can find the file that tells us the latest version
// of the application
updater->setReferenceUrl("https://raw.githubusercontent.com/alex-97/"
"QSimpleUpdater/Files-for-example-project/current_version.txt");
updater->setReferenceUrl ("https://raw.githubusercontent.com/alex-97/"
"QSimpleUpdater/Files-for-example-project/current_version.txt");
// Tell the updater where to download the update, its recommended to use direct links
updater->setDownloadUrl("https://codeload.github.com/alex-97/QSimpleUpdater/zip/master");
updater->setDownloadUrl ("https://codeload.github.com/alex-97/QSimpleUpdater/zip/master");
// Show the progress dialog and show messages when checking is finished
updater->setSilent(false);
updater->setShowNewestVersionMessage(true);
updater->setSilent (false);
updater->setShowNewestVersionMessage (true);
// Finally, check for updates...
updater->checkForUpdates();
}
void Example::onCheckingFinished() {
void Example::onCheckingFinished()
{
// Enable the updatesButton and change its text to let the user know
// that he/she can check for updates again
ui->updatesButton->setEnabled(true);
ui->updatesButton->setText("Check for updates");
ui->updatesButton->setEnabled (true);
ui->updatesButton->setText ("Check for updates");
}

View File

@ -5,27 +5,28 @@
#include <QMessageBox>
#include <QSimpleUpdater>
namespace Ui {
namespace Ui
{
class Example;
}
class Example : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit Example(QWidget *parent = 0);
~Example();
public:
explicit Example (QWidget *parent = 0);
~Example();
public slots:
void checkForUpdates();
void onCheckingFinished();
public slots:
void checkForUpdates();
void onCheckingFinished();
private:
Ui::Example *ui;
private:
Ui::Example *ui;
QString m_installed_version;
QSimpleUpdater *updater;
QString m_installed_version;
QSimpleUpdater *updater;
};
#endif

View File

@ -18,7 +18,8 @@
DownloadDialog::DownloadDialog (QWidget *parent)
: QWidget (parent)
, ui (new Ui::DownloadDialog) {
, ui (new Ui::DownloadDialog)
{
// Setup the UI
ui->setupUi (this);
@ -45,11 +46,13 @@ DownloadDialog::DownloadDialog (QWidget *parent)
SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
}
DownloadDialog::~DownloadDialog (void) {
DownloadDialog::~DownloadDialog (void)
{
delete ui;
}
void DownloadDialog::beginDownload (const QUrl& url) {
void DownloadDialog::beginDownload (const QUrl& url)
{
Q_ASSERT (!url.isEmpty());
// Reset the UI
@ -73,7 +76,8 @@ void DownloadDialog::beginDownload (const QUrl& url) {
showNormal();
}
void DownloadDialog::installUpdate (void) {
void DownloadDialog::installUpdate (void)
{
QMessageBox msg;
msg.setIcon (QMessageBox::Question);
msg.setText ("<b>" +
@ -83,20 +87,24 @@ void DownloadDialog::installUpdate (void) {
msg.setInformativeText (tr ("Do you want to quit %1 now?").arg (qApp->applicationName()));
msg.setStandardButtons (QMessageBox::Yes | QMessageBox::No);
if (msg.exec() == QMessageBox::Yes) {
if (msg.exec() == QMessageBox::Yes)
{
openDownload();
qApp->closeAllWindows();
}
else {
else
{
ui->openButton->setEnabled (true);
ui->openButton->setVisible (true);
ui->timeLabel->setText (tr ("Click the \"Open\" button to apply the update"));
}
}
void DownloadDialog::openDownload (void) {
if (!m_path.isEmpty()) {
void DownloadDialog::openDownload (void)
{
if (!m_path.isEmpty())
{
QString url = m_path;
if (url.startsWith ("/"))
@ -109,15 +117,18 @@ void DownloadDialog::openDownload (void) {
}
}
void DownloadDialog::cancelDownload (void) {
if (!m_reply->isFinished()) {
void DownloadDialog::cancelDownload (void)
{
if (!m_reply->isFinished())
{
QMessageBox _message;
_message.setWindowTitle (tr ("Updater"));
_message.setIcon (QMessageBox::Question);
_message.setStandardButtons (QMessageBox::Yes | QMessageBox::No);
_message.setText (tr ("Are you sure you want to cancel the download?"));
if (_message.exec() == QMessageBox::Yes) {
if (_message.exec() == QMessageBox::Yes)
{
hide();
m_reply->abort();
}
@ -127,18 +138,21 @@ void DownloadDialog::cancelDownload (void) {
hide();
}
void DownloadDialog::downloadFinished (void) {
void DownloadDialog::downloadFinished (void)
{
ui->stopButton->setText (tr ("Close"));
ui->downloadLabel->setText (tr ("Download complete!"));
ui->timeLabel->setText (tr ("The installer will open in a separate window..."));
QByteArray data = m_reply->readAll();
if (!data.isEmpty()) {
if (!data.isEmpty())
{
QStringList list = m_reply->url().toString().split ("/");
QFile file (QDir::tempPath() + "/" + list.at (list.count() - 1));
if (file.open (QIODevice::WriteOnly)) {
if (file.open (QIODevice::WriteOnly))
{
file.write (data);
m_path = file.fileName();
}
@ -148,9 +162,11 @@ void DownloadDialog::downloadFinished (void) {
}
}
void DownloadDialog::updateProgress (qint64 received, qint64 total) {
void DownloadDialog::updateProgress (qint64 received, qint64 total)
{
// We know the size of the download, so we can calculate the progress....
if (total > 0 && received > 0) {
if (total > 0 && received > 0)
{
ui->progressBar->setMinimum (0);
ui->progressBar->setMaximum (100);
@ -166,12 +182,14 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
if (_total < 1024)
_total_string = tr ("%1 bytes").arg (_total);
else if (_total < 1024 * 1024) {
else if (_total < 1024 * 1024)
{
_total = roundNumber (_total / 1024);
_total_string = tr ("%1 KB").arg (_total);
}
else {
else
{
_total = roundNumber (_total / (1024 * 1024));
_total_string = tr ("%1 MB").arg (_total);
}
@ -179,12 +197,14 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
if (_received < 1024)
_received_string = tr ("%1 bytes").arg (_received);
else if (received < 1024 * 1024) {
else if (received < 1024 * 1024)
{
_received = roundNumber (_received / 1024);
_received_string = tr ("%1 KB").arg (_received);
}
else {
else
{
_received = roundNumber (_received / (1024 * 1024));
_received_string = tr ("%1 MB").arg (_received);
}
@ -193,16 +213,19 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
uint _diff = QDateTime::currentDateTime().toTime_t() - m_start_time;
if (_diff > 0) {
if (_diff > 0)
{
QString _time_string;
float _time_remaining = total / (received / _diff);
if (_time_remaining > 7200) {
if (_time_remaining > 7200)
{
_time_remaining /= 3600;
_time_string = tr ("About %1 hours").arg (int (_time_remaining + 0.5));
}
else if (_time_remaining > 60) {
else if (_time_remaining > 60)
{
_time_remaining /= 60;
_time_string = tr ("About %1 minutes").arg (int (_time_remaining + 0.5));
}
@ -216,7 +239,8 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
// 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->setMinimum (0);
ui->progressBar->setMaximum (0);
@ -226,7 +250,8 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total) {
}
void DownloadDialog::ignoreSslErrors (QNetworkReply *reply,
const QList<QSslError>& error) {
const QList<QSslError>& error)
{
#ifndef Q_OS_IOS
reply->ignoreSslErrors (error);
#else
@ -235,6 +260,7 @@ void DownloadDialog::ignoreSslErrors (QNetworkReply *reply,
#endif
}
float DownloadDialog::roundNumber (const float& input) {
float DownloadDialog::roundNumber (const float& input)
{
return roundf (input * 100) / 100;
}

View File

@ -26,11 +26,13 @@
#include <math.h>
namespace Ui {
namespace Ui
{
class DownloadDialog;
}
class DownloadDialog : public QWidget {
class DownloadDialog : public QWidget
{
Q_OBJECT
public:

View File

@ -15,10 +15,10 @@
#include "progress_dialog.h"
#include "ui_progress_dialog.h"
ProgressDialog::ProgressDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ProgressDialog)
ProgressDialog::ProgressDialog (QWidget *parent) : QDialog (parent), ui (new Ui::ProgressDialog)
{
// Create and configure UI
ui->setupUi(this);
ui->setupUi (this);
// Make the window look like a dialog
QIcon _blank;
@ -27,7 +27,7 @@ ProgressDialog::ProgressDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Pr
setWindowFlags (Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
// Close dialog when cancel button is clicked
connect(ui->ui_cancel_button, SIGNAL(clicked()), this, SLOT(cancel()));
connect (ui->ui_cancel_button, SIGNAL (clicked()), this, SLOT (cancel()));
}
ProgressDialog::~ProgressDialog()
@ -35,7 +35,8 @@ ProgressDialog::~ProgressDialog()
delete ui;
}
void ProgressDialog::cancel(void) {
void ProgressDialog::cancel (void)
{
hide();
emit cancelClicked();
}

View File

@ -17,26 +17,27 @@
#include <QDialog>
namespace Ui {
namespace Ui
{
class ProgressDialog;
}
class ProgressDialog : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit ProgressDialog(QWidget *parent = 0);
~ProgressDialog();
public:
explicit ProgressDialog (QWidget *parent = 0);
~ProgressDialog();
signals:
void cancelClicked();
signals:
void cancelClicked();
private slots:
void cancel (void);
private slots:
void cancel (void);
private:
Ui::ProgressDialog *ui;
private:
Ui::ProgressDialog *ui;
};
#endif // PROGRESS_DIALOG_H

View File

@ -14,9 +14,9 @@
/*! \class QSimpleUpdater
* \brief A simple auto-updater system for Qt
*
* QSimpleUpdater is an implementation of an auto-updating system to be used with Qt projects.
* Aside from notifying you if there's a newer version, it allows you to download the change log in any
*
* QSimpleUpdater is an implementation of an auto-updating system to be used with Qt projects.
* Aside from notifying you if there's a newer version, it allows you to download the change log in any
* format (such as HTML or RTF) and download the updates directly from your application using a dialog.
* QSimpleUpdater is free and open source LGPL software,
* which means that you can use it for both open source and proprietary applications.
@ -88,7 +88,8 @@ QSimpleUpdater::QSimpleUpdater (QObject *parent)
, m_silent (false)
, m_show_newest_version (true)
, m_show_update_available (true)
, m_new_version_available (false) {
, m_new_version_available (false)
{
m_progressDialog = new ProgressDialog();
m_downloadDialog = new DownloadDialog();
@ -99,17 +100,18 @@ QSimpleUpdater::QSimpleUpdater (QObject *parent)
connect (m_manager, SIGNAL (sslErrors (QNetworkReply *, QList<QSslError>)),
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
connect (m_progressDialog, SIGNAL(cancelClicked()), this, SLOT(cancel()));
connect (m_progressDialog, SIGNAL (cancelClicked()), this, SLOT (cancel()));
connect (this, SIGNAL (checkingFinished()), this, SLOT (onCheckingFinished()));
}
/*!
* Returns the downloaded change log as a \c QString.
*
*
* \sa setChangelogUrl()
*/
QString QSimpleUpdater::changeLog() const {
QString QSimpleUpdater::changeLog() const
{
return m_changelog;
}
@ -120,8 +122,10 @@ QString QSimpleUpdater::changeLog() const {
* \sa setDownloadUrl(), setReferenceUrl()
*/
void QSimpleUpdater::checkForUpdates (void) {
if (!m_reference_url.isEmpty()) {
void QSimpleUpdater::checkForUpdates (void)
{
if (!m_reference_url.isEmpty())
{
m_manager->get (QNetworkRequest (m_reference_url));
if (!silent())
@ -138,7 +142,8 @@ void QSimpleUpdater::checkForUpdates (void) {
* \sa setDownloadUrl()
*/
void QSimpleUpdater::openDownloadLink (void) {
void QSimpleUpdater::openDownloadLink (void)
{
if (!m_download_url.isEmpty())
QDesktopServices::openUrl (m_download_url);
}
@ -149,7 +154,8 @@ void QSimpleUpdater::openDownloadLink (void) {
* \sa setReferenceUrl(), checkForUpdates()
*/
QString QSimpleUpdater::latestVersion() const {
QString QSimpleUpdater::latestVersion() const
{
return m_latest_version;
}
@ -159,7 +165,8 @@ QString QSimpleUpdater::latestVersion() const {
* \sa setApplicationVersion()
*/
QString QSimpleUpdater::installedVersion() const {
QString QSimpleUpdater::installedVersion() const
{
return m_installed_version;
}
@ -170,7 +177,8 @@ QString QSimpleUpdater::installedVersion() const {
* \sa setDownloadUrl(), checkForUpdates()
*/
void QSimpleUpdater::downloadLatestVersion (void) {
void QSimpleUpdater::downloadLatestVersion (void)
{
if (!m_download_url.isEmpty())
m_downloadDialog->beginDownload (m_download_url);
}
@ -182,7 +190,8 @@ void QSimpleUpdater::downloadLatestVersion (void) {
* \sa setReferenceUrl(), checkForUpdates()
*/
bool QSimpleUpdater::newerVersionAvailable() const {
bool QSimpleUpdater::newerVersionAvailable() const
{
return m_new_version_available;
}
@ -193,7 +202,8 @@ bool QSimpleUpdater::newerVersionAvailable() const {
* \sa setSilent()
*/
bool QSimpleUpdater::silent() const {
bool QSimpleUpdater::silent() const
{
return m_silent;
}
@ -208,13 +218,14 @@ bool QSimpleUpdater::silent() const {
* \sa downloadLatestVersion(), openDownloadLink()
*/
void QSimpleUpdater::setDownloadUrl (const QString& url) {
void QSimpleUpdater::setDownloadUrl (const QString& url)
{
Q_ASSERT (!url.isEmpty());
m_download_url.setUrl (url);
}
/*!
* Tells the updater system from where to download the file
* Tells the updater system from where to download the file
* that indicates the latest version using the \a url parameter.
*
* The reference file should contain \bold {ONLY} the latest version
@ -231,15 +242,16 @@ void QSimpleUpdater::setDownloadUrl (const QString& url) {
* \sa latestVersion()
*/
void QSimpleUpdater::setReferenceUrl (const QString& url) {
void QSimpleUpdater::setReferenceUrl (const QString& url)
{
Q_ASSERT (!url.isEmpty());
m_reference_url.setUrl (url);
}
/*!
* Tells the updater system from where to download the
* Tells the updater system from where to download the
* change log using the \a url parameter.
* The change log can be any file you like, however,
* 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.
*
@ -247,7 +259,8 @@ void QSimpleUpdater::setReferenceUrl (const QString& url) {
*/
void QSimpleUpdater::setChangelogUrl (const QString& url) {
void QSimpleUpdater::setChangelogUrl (const QString& url)
{
Q_ASSERT (!url.isEmpty());
m_changelog_url.setUrl (url);
}
@ -263,13 +276,14 @@ void QSimpleUpdater::setChangelogUrl (const QString& url) {
*/
void QSimpleUpdater::setApplicationVersion (const QString& version) {
void QSimpleUpdater::setApplicationVersion (const QString& version)
{
Q_ASSERT (!version.isEmpty());
m_installed_version = version;
}
/*!
*
*
* \list
* \o If \a silent is set to \c true, no dialogs will be shown while checking
* for updates or when a newer version of the application is found.
@ -280,11 +294,12 @@ void QSimpleUpdater::setApplicationVersion (const QString& version) {
* \sa silent()
*/
void QSimpleUpdater::setSilent (bool silent) {
void QSimpleUpdater::setSilent (bool silent)
{
m_silent = silent;
if (m_silent)
setShowNewestVersionMessage(false);
setShowNewestVersionMessage (false);
}
/*!
@ -294,7 +309,8 @@ void QSimpleUpdater::setSilent (bool silent) {
* \sa checkForUpdates()
*/
void QSimpleUpdater::setShowUpdateAvailableMessage(bool show) {
void QSimpleUpdater::setShowUpdateAvailableMessage (bool show)
{
m_show_update_available = show;
}
@ -308,7 +324,8 @@ void QSimpleUpdater::setShowUpdateAvailableMessage(bool show) {
* \sa checkForUpdates()
*/
void QSimpleUpdater::setShowNewestVersionMessage(bool show) {
void QSimpleUpdater::setShowNewestVersionMessage (bool show)
{
m_show_newest_version = show;
}
@ -317,7 +334,8 @@ void QSimpleUpdater::setShowNewestVersionMessage(bool show) {
* clicks on the "cancel" button in the progress dialog.
*/
void QSimpleUpdater::cancel(void) {
void QSimpleUpdater::cancel (void)
{
m_manager->disconnect();
}
@ -328,10 +346,14 @@ void QSimpleUpdater::cancel(void) {
* \sa checkDownloadedVersion()
*/
void QSimpleUpdater::showErrorMessage (void) {
void QSimpleUpdater::showErrorMessage (void)
{
if (!silent())
QMessageBox::warning(NULL, tr("Software Updater"),
tr("An unknown error occured while checking for updates"));
{
m_progressDialog->hide();
QMessageBox::warning (NULL, tr ("Software Updater"),
tr ("An unknown error occured while checking for updates"));
}
}
/*! \internal
@ -341,41 +363,47 @@ void QSimpleUpdater::showErrorMessage (void) {
* \sa checkDownloadedVersion()
*/
void QSimpleUpdater::onCheckingFinished (void) {
void QSimpleUpdater::onCheckingFinished (void)
{
// Hide the progress dialog
m_progressDialog->hide();
// Get the application icon as a pixmap
QPixmap _icon = qApp->windowIcon().pixmap(
qApp->windowIcon().actualSize(QSize(96, 96)));
QPixmap _icon = qApp->windowIcon().pixmap (
qApp->windowIcon().actualSize (QSize (96, 96)));
// If the icon is invalid, use default icon
if (_icon.isNull())
_icon = QPixmap(":/icons/update.png");
_icon = QPixmap (":/icons/update.png");
QMessageBox _message;
_message.setIconPixmap (_icon);
// Ask user if he/she wants to download newer version
if (newerVersionAvailable() && m_show_update_available) {
if (newerVersionAvailable() && m_show_update_available)
{
_message.setDetailedText (changeLog());
_message.setStandardButtons (QMessageBox::Yes | QMessageBox::No);
_message.setText ("<b>" + tr ("A new version of %1 is available!").arg(qApp->applicationName()) + "</b>");
_message.setInformativeText (tr("%1 %2 is available - you have %3. Would you like to download it now?")
.arg(qApp->applicationName())
.arg(latestVersion())
.arg(installedVersion()));
_message.setText ("<b>" + tr ("A new version of %1 is available!").arg (qApp->applicationName()) + "</b>");
_message.setInformativeText (tr ("%1 %2 is available - you have %3. Would you like to download it now?")
.arg (qApp->applicationName())
.arg (latestVersion())
.arg (installedVersion()));
if (_message.exec() == QMessageBox::Yes)
downloadLatestVersion();
}
// Tell user that he/she is up to date (only if necessary)
else if (!silent() && m_show_newest_version && !m_latest_version.isEmpty()) {
else if (!silent() && m_show_newest_version && !m_latest_version.isEmpty())
{
_message.setStandardButtons (QMessageBox::Ok);
_message.setText ("<b>" + tr ("You're up-to-date!") +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>");
_message.setInformativeText (
tr ("%1 %2 is currently the newest version available")
.arg (qApp->applicationName())
.arg (installedVersion()));
tr ("%1 %2 is currently the newest version available")
.arg (qApp->applicationName())
.arg (installedVersion()));
_message.exec();
}
@ -391,34 +419,41 @@ void QSimpleUpdater::onCheckingFinished (void) {
* \sa checkForUpdates()
*/
void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply) {
void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply)
{
bool _new_update = false;
m_progressDialog->hide();
QString _reply = QString::fromUtf8 (reply->readAll());
_reply.replace (" ", "");
_reply.replace ("\n", "");
if (!_reply.isEmpty()) {
if (!_reply.isEmpty())
{
m_latest_version = _reply;
QStringList _download = m_latest_version.split (".");
QStringList _installed = m_installed_version.split (".");
for (int i = 0; i <= _download.count() - 1; ++i) {
if (_download.count() - 1 >= i && _installed.count() - 1 >= i) {
if (_download.at (i) > _installed.at (i)) {
for (int i = 0; i <= _download.count() - 1; ++i)
{
if (_download.count() - 1 >= i && _installed.count() - 1 >= i)
{
if (_download.at (i) > _installed.at (i))
{
_new_update = true;
break;
}
}
else {
if (_installed.count() < _download.count()) {
else
{
if (_installed.count() < _download.count())
{
if (_installed.at (i - 1) == _download.at (i - 1))
break;
else {
else
{
_new_update = true;
break;
}
@ -426,13 +461,14 @@ void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply) {
}
}
}
else
showErrorMessage();
m_new_version_available = _new_update;
if (!m_changelog_url.isEmpty() && newerVersionAvailable()) {
if (!m_changelog_url.isEmpty() && newerVersionAvailable())
{
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
connect (_manager, SIGNAL (finished (QNetworkReply *)), this,
@ -454,7 +490,8 @@ void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply) {
* \sa setChangelogUrl(), changeLog()
*/
void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply) {
void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply)
{
QString _reply = QString::fromUtf8 (reply->readAll());
if (!_reply.isEmpty())
@ -470,7 +507,8 @@ void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply) {
*/
void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply,
const QList<QSslError>& error) {
const QList<QSslError>& error)
{
#if SUPPORTS_SSL
reply->ignoreSslErrors (error);
#else

View File

@ -37,7 +37,8 @@
#include "dialogs/download_dialog.h"
#include "dialogs/progress_dialog.h"
class QSimpleUpdater : public QObject {
class QSimpleUpdater : public QObject
{
Q_OBJECT
public:
@ -59,8 +60,8 @@ class QSimpleUpdater : public QObject {
void setDownloadUrl (const QString& url);
void setReferenceUrl (const QString& url);
void setChangelogUrl (const QString& url);
void setShowNewestVersionMessage(bool show);
void setShowUpdateAvailableMessage(bool show);
void setShowNewestVersionMessage (bool show);
void setShowUpdateAvailableMessage (bool show);
void setApplicationVersion (const QString& version);
signals:

View File

@ -6,6 +6,10 @@ QSimpleUpdater is an implementation of an auto-updating system to be used with Q
QSimpleUpdater is **free and open source [LGPL software](https://www.gnu.org/licenses/lgpl.html)**, which means that you can use it for both open source and proprietary applications.
## Developer Documentation
You can find the developer documentation for QSimpleUpdater [here](http://qsimpleupdater.sourceforge.net/doc/).
## Using QSimpleUpdater
1. Copy the *QSimpleUpdater* folder in your "3rd-party" folder.

21
bin/autostyle.cmd Normal file
View File

@ -0,0 +1,21 @@
:: Description: This script changes the style format of
:: all the source code of the project.
:: Setup the command line
@echo off
title Autostyle
:: Go to the directory where the script is run
cd /d %~dp0
:: Style and format the source code recursively
astyle --style=allman -C -S -xG -Y -XW -w -f -F -p -xd -k3 -y -xj -c -K -L --suffix=none --recursive ../*.cpp ../*.h ../*.hxx ../*.cxx
:: Notify the user that we have finished
echo.
echo Code styling complete!
echo.
:: Let the user see the output
pause

19
bin/autostyle.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Description: This script changes the style format of
# all the source code of the project.
# Run only on the directory of the script
cd "$(dirname ${BASH_SOURCE[0]})"
# Style and format recursively
astyle --style=allman -C -S -xG -Y -XW -w -f -F -p -xd -k3 -y -xj -c -K -L --suffix=none --recursive ../*.cpp ../*.h ../*.hxx ../*.cxx
# Notify the user that we are done
echo
echo "Code styling complete!"
echo
# Let the user see the output
read -n1 -r -p "Press any key to continue..." key
clear

1
bin/readme.txt Normal file
View File

@ -0,0 +1 @@
The scripts contained in this folder will require you to install the [astyle](http://astyle.sf.net) source code styler.