00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <QPushButton>
00019
00020 #include "controlpasswordinputdialog.h"
00021
00022
00023 ControlPasswordInputDialog::ControlPasswordInputDialog(QWidget *parent)
00024 : QDialog(parent)
00025 {
00026 ui.setupUi(this);
00027 setSizeGripEnabled(false);
00028 setAttribute(Qt::WA_DeleteOnClose, false);
00029
00030 ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok
00031 | QDialogButtonBox::Cancel
00032 | QDialogButtonBox::Reset
00033 | QDialogButtonBox::Help);
00034
00035 connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)),
00036 this, SLOT(clicked(QAbstractButton*)));
00037 connect(ui.linePassword, SIGNAL(textEdited(QString)),
00038 this, SLOT(passwordEdited(QString)));
00039
00040
00041 passwordEdited(QString());
00042 }
00043
00044 void
00045 ControlPasswordInputDialog::setResetEnabled(bool enabled)
00046 {
00047 if (enabled) {
00048 ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons()
00049 | QDialogButtonBox::Reset);
00050 } else {
00051 ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons()
00052 & ~QDialogButtonBox::Reset);
00053
00054 }
00055 }
00056
00057 QString
00058 ControlPasswordInputDialog::password() const
00059 {
00060 return ui.linePassword->text();
00061 }
00062
00063 bool
00064 ControlPasswordInputDialog::isSavePasswordChecked() const
00065 {
00066 return ui.chkSavePassword->isChecked();
00067 }
00068
00069 void
00070 ControlPasswordInputDialog::passwordEdited(const QString &text)
00071 {
00072 QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok);
00073 if (okButton)
00074 okButton->setEnabled(! text.isEmpty());
00075 }
00076
00077 void
00078 ControlPasswordInputDialog::clicked(QAbstractButton *button)
00079 {
00080 QDialogButtonBox::StandardButton btn = ui.buttonBox->standardButton(button);
00081 switch (btn) {
00082 case QDialogButtonBox::Ok:
00083 case QDialogButtonBox::Reset:
00084 case QDialogButtonBox::Cancel:
00085 done(btn);
00086 break;
00087
00088 case QDialogButtonBox::Help:
00089 emit helpRequested("troubleshooting.password");
00090 break;
00091
00092 default:
00093 break;
00094 }
00095 }
00096
00097 void
00098 ControlPasswordInputDialog::setVisible(bool visible)
00099 {
00100 if (visible)
00101 resize(minimumSizeHint());
00102 QDialog::setVisible(visible);
00103 }
00104