ControlPasswordInputDialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "ControlPasswordInputDialog.h"
00019
00020 #include <QPushButton>
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 QString
00057 ControlPasswordInputDialog::password() const
00058 {
00059 return ui.linePassword->text();
00060 }
00061
00062 bool
00063 ControlPasswordInputDialog::isSavePasswordChecked() const
00064 {
00065 return ui.chkSavePassword->isChecked();
00066 }
00067
00068 void
00069 ControlPasswordInputDialog::passwordEdited(const QString &text)
00070 {
00071 QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok);
00072 if (okButton)
00073 okButton->setEnabled(! text.isEmpty());
00074 }
00075
00076 void
00077 ControlPasswordInputDialog::clicked(QAbstractButton *button)
00078 {
00079 QDialogButtonBox::StandardButton btn = ui.buttonBox->standardButton(button);
00080 switch (btn) {
00081 case QDialogButtonBox::Ok:
00082 case QDialogButtonBox::Reset:
00083 case QDialogButtonBox::Cancel:
00084 done(btn);
00085 break;
00086
00087 case QDialogButtonBox::Help:
00088 emit helpRequested("troubleshooting.password");
00089 break;
00090
00091 default:
00092 break;
00093 }
00094 }
00095
00096 void
00097 ControlPasswordInputDialog::setVisible(bool visible)
00098 {
00099 if (visible)
00100 resize(minimumSizeHint());
00101 QDialog::setVisible(visible);
00102 }
00103