UpdateProgressDialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "UpdateProgressDialog.h"
00012
00013
00014 UpdateProgressDialog::UpdateProgressDialog(QWidget *parent)
00015 : QDialog(parent)
00016 {
00017 ui.setupUi(this);
00018
00019 connect(ui.btnHide, SIGNAL(clicked()), this, SLOT(onHide()));
00020 connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(onCancel()));
00021
00022 setModal(true);
00023 }
00024
00025 void
00026 UpdateProgressDialog::setStatus(UpdateProgressDialog::Status status)
00027 {
00028 switch (status) {
00029 case CheckingForUpdates:
00030 ui.lblCurrentAction->setText(tr("Checking for available updates..."));
00031
00032 ui.progressBar->setMinimum(0);
00033 ui.progressBar->setMaximum(0);
00034
00035 ui.btnHide->setText(tr("Hide"));
00036 ui.btnCancel->setVisible(true);
00037 ui.btnCancel->setEnabled(true);
00038 break;
00039
00040 case DownloadingUpdates:
00041 ui.lblCurrentAction->setText(tr("Downloading updates..."));
00042 break;
00043
00044 case InstallingUpdates:
00045 ui.lblCurrentAction->setText(tr("Installing updated software..."));
00046
00047 ui.progressBar->setMinimum(0);
00048 ui.progressBar->setMaximum(0);
00049
00050 ui.btnCancel->setEnabled(false);
00051 break;
00052
00053 case UpdatesInstalled:
00054 ui.lblCurrentAction->setText(tr("Done! Your software is now up to date."));
00055
00056 ui.progressBar->setMinimum(0);
00057 ui.progressBar->setMaximum(1);
00058 ui.progressBar->setValue(1);
00059
00060 ui.btnHide->setText(tr("OK"));
00061 ui.btnCancel->setVisible(false);
00062 break;
00063
00064 default:
00065 break;
00066 }
00067 }
00068
00069 void
00070 UpdateProgressDialog::setDownloadProgress(const QString &url,
00071 int bytesReceived, int bytesTotal)
00072 {
00073 Q_UNUSED(url);
00074
00075 setStatus(DownloadingUpdates);
00076 ui.progressBar->setMaximum(bytesTotal);
00077 ui.progressBar->setValue(bytesReceived);
00078 }
00079
00080 void
00081 UpdateProgressDialog::onHide()
00082 {
00083 setVisible(false);
00084 }
00085
00086 void
00087 UpdateProgressDialog::onCancel()
00088 {
00089 emit cancelUpdate();
00090 hide();
00091 }
00092