Vidalia  0.3.1
BridgeDownloaderProgressDialog.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 /*
12 ** \file BridgeDownloaderProgressDialog.cpp
13 ** \brief Displays the progress of a request for bridge addresses
14 */
15 
17 
18 #include <QTimer>
19 
20 
22  : QDialog(parent)
23 {
24  ui.setupUi(this);
25 
26  connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)),
27  this, SLOT(buttonClicked(QAbstractButton *)));
28 
29  setModal(true);
30 }
31 
32 void
34 {
35  if (visible) {
36  ui.progressBar->setRange(0, 0);
37  ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
38  }
39  QDialog::setVisible(visible);
40 }
41 
42 void
44 {
45  ui.lblStatus->setText(status);
46 }
47 
48 void
50 {
51  ui.progressBar->setRange(0, total);
52  ui.progressBar->setValue(done);
53 }
54 
55 void
57 {
58  Q_UNUSED(bridges);
59 
60  accept();
61 }
62 
63 void
65 {
66  ui.lblStatus->setText(tr("Unable to download bridges: %1").arg(error));
67 
68  ui.progressBar->setRange(0, 1);
69  ui.progressBar->setValue(1);
70 
71  ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel
72  | QDialogButtonBox::Retry
73  | QDialogButtonBox::Help);
74 }
75 
76 void
78 {
79  int standardButton = ui.buttonBox->standardButton(button);
80  if (standardButton == QDialogButtonBox::Retry) {
81  setStatus(tr("Retrying bridge request..."));
82  setDownloadProgress(0, 0);
83  ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
84 
85  QTimer::singleShot(1000, this, SIGNAL(retry()));
86  } else {
87  done(standardButton);
88  }
89 }
90