Vidalia  0.3.1
UpdateProgressDialog.cpp
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 #include "UpdateProgressDialog.h"
12 
13 
15  : QDialog(parent)
16 {
17  ui.setupUi(this);
18 
19  connect(ui.btnHide, SIGNAL(clicked()), this, SLOT(onHide()));
20  connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(onCancel()));
21 
22  setModal(true);
23 }
24 
25 void
27 {
28  switch (status) {
29  case CheckingForUpdates:
30  ui.lblCurrentAction->setText(tr("Checking for available updates..."));
31 
32  ui.progressBar->setMinimum(0);
33  ui.progressBar->setMaximum(0);
34 
35  ui.btnHide->setText(tr("Hide"));
36  ui.btnCancel->setVisible(true);
37  ui.btnCancel->setEnabled(true);
38  break;
39 
40  case DownloadingUpdates:
41  ui.lblCurrentAction->setText(tr("Downloading updates..."));
42  break;
43 
44  case InstallingUpdates:
45  ui.lblCurrentAction->setText(tr("Installing updated software..."));
46 
47  ui.progressBar->setMinimum(0);
48  ui.progressBar->setMaximum(0);
49 
50  ui.btnCancel->setEnabled(false);
51  break;
52 
53  case UpdatesInstalled:
54  ui.lblCurrentAction->setText(tr("Done! Your software is now up to date."));
55 
56  ui.progressBar->setMinimum(0);
57  ui.progressBar->setMaximum(1);
58  ui.progressBar->setValue(1);
59 
60  ui.btnHide->setText(tr("OK"));
61  ui.btnCancel->setVisible(false);
62  break;
63 
64  default:
65  break;
66  }
67 }
68 
69 void
71  int bytesReceived, int bytesTotal)
72 {
73  Q_UNUSED(url);
74 
76  ui.progressBar->setMaximum(bytesTotal);
77  ui.progressBar->setValue(bytesReceived);
78 }
79 
80 void
82 {
83  setVisible(false);
84 }
85 
86 void
88 {
89  emit cancelUpdate();
90  hide();
91 }
92 
UpdateProgressDialog(QWidget *parent=0)
void setStatus(UpdateProgressDialog::Status status)
stop errmsg connect(const QHostAddress &address, quint16 port)
void setDownloadProgress(const QString &url, int bytesReceived, int bytesTotal)
Ui::UpdateProgressDialog ui