Mercurial > hg > forks > UniversalIndentGUI
changeset 247:d8002e788c72
Preparations for an animated progressbar during update check.
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@456 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Mon, 20 Aug 2007 20:12:46 +0000 |
parents | 41709ff54de7 |
children | 4eda9805dc4b |
files | src/UpdateCheckDialog.ui src/updatecheckdialog.cpp src/updatecheckdialog.h |
diffstat | 3 files changed, 24 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/UpdateCheckDialog.ui Mon Aug 20 15:32:03 2007 +0000 +++ b/src/UpdateCheckDialog.ui Mon Aug 20 20:12:46 2007 +0000 @@ -26,7 +26,7 @@ <item> <widget class="QProgressBar" name="progressBar" > <property name="value" > - <number>24</number> + <number>0</number> </property> <property name="textVisible" > <bool>false</bool>
--- a/src/updatecheckdialog.cpp Mon Aug 20 15:32:03 2007 +0000 +++ b/src/updatecheckdialog.cpp Mon Aug 20 20:12:46 2007 +0000 @@ -28,6 +28,11 @@ http = new QHttp(this); connect( http, SIGNAL(done(bool)), this, SLOT(checkForUpdatedReturned(bool)) ); + updateCheckProgressTimer = new QTimer(this); + updateCheckProgressTimer->setInterval(100); + connect( updateCheckProgressTimer, SIGNAL(timeout()), this, SLOT(updateUpdateCheckProgressBar()) ); + updateCheckProgressCounter = 0; + connect( buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(handleDialogButtonClicked(QAbstractButton*)) ); this->currentVersion = currentVersion; @@ -65,6 +70,9 @@ Offers to go to the download page if a newer version exists. */ void UpdateCheckDialog::checkForUpdatedReturned(bool errorOccurred) { + // Stop the progressbar timer. + updateCheckProgressTimer->stop(); + if ( !errorOccurred ) { // Try to find the version string. QString returnedString = http->readAll(); @@ -78,7 +86,7 @@ returnedString = returnedString.mid( leftPosition+17, rightPosition-(leftPosition+17) ); // Only show update dialog, if the current version string is not equal to the received one. - if ( returnedString != currentVersion ) { + if ( returnedString == currentVersion ) { // Show message box whether to download the new version. showNewVersionAvailableDialog(returnedString); @@ -89,7 +97,6 @@ } else if ( manualUpdateRequested ) { showNoNewVersionAvailableDialog(); - } // Set last update check date. settings->setValueByName("LastUpdateCheck", QDate::currentDate()); @@ -108,6 +115,7 @@ void UpdateCheckDialog::showCheckingForUpdateDialog() { + updateCheckProgressTimer->start(); progressBar->show(); setWindowTitle( tr("Checking for update...") ); label->setText( tr("Checking whether a newer version is available") ); @@ -118,9 +126,9 @@ void UpdateCheckDialog::showNewVersionAvailableDialog(QString newVersion) { progressBar->hide(); setWindowTitle( tr("Update available") ); - label->setText( tr("A newer version of UniversalIndentGUI is available.\nYour version is %1. \ - New version is %2.\nDo you want to go to the download website?").arg(currentVersion).arg(newVersion) ); + label->setText( tr("A newer version of UniversalIndentGUI is available.\nYour version is %1. New version is %2.\nDo you want to go to the download website?").arg(currentVersion).arg(newVersion) ); buttonBox->setStandardButtons(QDialogButtonBox::No|QDialogButtonBox::NoButton|QDialogButtonBox::Yes); + exec(); } @@ -137,3 +145,10 @@ roleOfClickedButton = buttonBox->buttonRole(clickedButton); accept(); } + + +void UpdateCheckDialog::updateUpdateCheckProgressBar() { + progressBar->setValue(updateCheckProgressCounter); + updateCheckProgressCounter++; + //updateCheckProgressCounter = updateCheckProgressCounter % 100; +}
--- a/src/updatecheckdialog.h Mon Aug 20 15:32:03 2007 +0000 +++ b/src/updatecheckdialog.h Mon Aug 20 20:12:46 2007 +0000 @@ -28,6 +28,7 @@ #include <QDate> #include <QHBoxLayout> #include <QLabel> +#include <QTimer> #include "ui_UpdateCheckDialog.h" #include "uiguisettings.h" @@ -54,10 +55,13 @@ QHttp *http; QString currentVersion; QDialogButtonBox::ButtonRole roleOfClickedButton; + QTimer *updateCheckProgressTimer; + int updateCheckProgressCounter; private slots: void checkForUpdatedReturned(bool errorOccurred); void handleDialogButtonClicked(QAbstractButton *clickedButton); + void updateUpdateCheckProgressBar(); }; #endif // UPDATECHECKDIALOG_H