Automatically check password checkbox and make toggle password button work.

This commit is contained in:
Felix Geyer 2011-11-16 18:46:09 +01:00
parent c7ed5f8421
commit 0ba03920df
3 changed files with 26 additions and 2 deletions

View file

@ -26,6 +26,8 @@ KeyOpenDialog::KeyOpenDialog(QWidget* parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
connect(m_ui->buttonTogglePassword, SIGNAL(toggled(bool)), SLOT(togglePassword(bool)));
connect(m_ui->editPassword, SIGNAL(textChanged(QString)), SLOT(activatePassword()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(createKey())); connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(createKey()));
} }
@ -48,3 +50,13 @@ void KeyOpenDialog::createKey()
// TODO read key file // TODO read key file
} }
} }
void KeyOpenDialog::togglePassword(bool checked)
{
m_ui->editPassword->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal);
}
void KeyOpenDialog::activatePassword()
{
m_ui->checkPassword->setChecked(true);
}

View file

@ -38,6 +38,8 @@ public:
private Q_SLOTS: private Q_SLOTS:
void createKey(); void createKey();
void togglePassword(bool checked);
void activatePassword();
private: private:
QScopedPointer<Ui::KeyOpenDialog> m_ui; QScopedPointer<Ui::KeyOpenDialog> m_ui;

View file

@ -24,13 +24,23 @@
<item row="0" column="1"> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLineEdit" name="editPassword"/> <widget class="QLineEdit" name="editPassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="buttonTogglePassword"> <widget class="QToolButton" name="buttonTogglePassword">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>