Vidalia  0.3.1
ControlPasswordInputDialog.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 ControlPasswordInputDialog.cpp
13 ** \brief Prompts the user to enter their control port password, and gives
14 ** them the option to save or attempt to reset it.
15 */
16 
18 
19 #include <QPushButton>
20 
21 
23  : QDialog(parent)
24 {
25  ui.setupUi(this);
26  setSizeGripEnabled(false);
27  setAttribute(Qt::WA_DeleteOnClose, false);
28 
29  ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok
30  | QDialogButtonBox::Reset
31  | QDialogButtonBox::Help);
32 
33  connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)),
34  this, SLOT(clicked(QAbstractButton*)));
35 }
36 
37 void
39 {
40  if (enabled) {
41  ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons()
42  | QDialogButtonBox::Reset);
43  ui.lblOptionOne->setVisible(false);
44  ui.lblOptionTwo->setVisible(true);
45  } else {
46  ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons()
47  & ~QDialogButtonBox::Reset);
48  ui.lblOptionOne->setVisible(true);
49  ui.lblOptionTwo->setVisible(false);
50  }
51 }
52 
53 void
54 ControlPasswordInputDialog::clicked(QAbstractButton *button)
55 {
56  QDialogButtonBox::StandardButton btn = ui.buttonBox->standardButton(button);
57  switch (btn) {
58  case QDialogButtonBox::Ok:
59  case QDialogButtonBox::Reset:
60  case QDialogButtonBox::Cancel:
61  done(btn);
62  break;
63 
64  case QDialogButtonBox::Help:
65  emit helpRequested("troubleshooting.password");
66  break;
67 
68  default:
69  break;
70  }
71 }
72 
73 void
75 {
76  if (visible)
77  adjustSize();
78  QDialog::setVisible(visible);
79 }
80 
void helpRequested(const QString &topic)
Ui::ControlPasswordInputDialog ui
virtual void setVisible(bool visible)
stop errmsg connect(const QHostAddress &address, quint16 port)
void clicked(QAbstractButton *button)