From 40e96ad7b3c131327ddead6c0d6488aba45b206d Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 7 Jan 2012 16:18:21 +0100 Subject: [PATCH] Make password and expiry information editable in EditEntryWidget. --- src/gui/EditEntryWidget.cpp | 19 +++++++++ src/gui/EditEntryWidget.h | 1 + src/gui/EditEntryWidgetMain.ui | 71 +++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/gui/EditEntryWidget.cpp b/src/gui/EditEntryWidget.cpp index 57a19c5e9..a2393683d 100644 --- a/src/gui/EditEntryWidget.cpp +++ b/src/gui/EditEntryWidget.cpp @@ -54,6 +54,10 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) Q_ASSERT(m_ui->categoryList->model()->rowCount() == m_ui->stackedWidget->count()); connect(m_ui->categoryList, SIGNAL(currentRowChanged(int)), m_ui->stackedWidget, SLOT(setCurrentIndex(int))); + + connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePassword(bool))); + connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool))); + connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(saveEntry())); connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel())); } @@ -76,6 +80,11 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupN m_mainUi->titleEdit->setText(entry->title()); m_mainUi->usernameEdit->setText(entry->username()); m_mainUi->urlEdit->setText(entry->url()); + m_mainUi->passwordEdit->setText(entry->password()); + m_mainUi->passwordRepeatEdit->setText(entry->password()); + m_mainUi->expireCheck->setChecked(entry->timeInfo().expires()); + m_mainUi->expireDatePicker->setDateTime(entry->timeInfo().expiryTime()); + m_mainUi->togglePasswordButton->setChecked(true); m_notesUi->notesEdit->setPlainText(entry->notes()); @@ -87,6 +96,10 @@ void EditEntryWidget::saveEntry() m_entry->setTitle(m_mainUi->titleEdit->text()); m_entry->setUsername(m_mainUi->usernameEdit->text()); m_entry->setUrl(m_mainUi->urlEdit->text()); + // TODO check password repeat field + m_entry->setPassword(m_mainUi->passwordEdit->text()); + m_entry->timeInfo().setExpires(m_mainUi->expireCheck->isChecked()); + m_entry->timeInfo().setExpiryTime(m_mainUi->expireDatePicker->dateTime()); m_entry->setNotes(m_notesUi->notesEdit->toPlainText()); @@ -99,3 +112,9 @@ void EditEntryWidget::cancel() m_entry = 0; Q_EMIT editFinished(false); } + +void EditEntryWidget::togglePassword(bool checked) +{ + m_mainUi->passwordEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal); + m_mainUi->passwordRepeatEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal); +} diff --git a/src/gui/EditEntryWidget.h b/src/gui/EditEntryWidget.h index 9ee32a65d..0e066ac0f 100644 --- a/src/gui/EditEntryWidget.h +++ b/src/gui/EditEntryWidget.h @@ -47,6 +47,7 @@ Q_SIGNALS: private Q_SLOTS: void saveEntry(); void cancel(); + void togglePassword(bool checked); private: Entry* m_entry; diff --git a/src/gui/EditEntryWidgetMain.ui b/src/gui/EditEntryWidgetMain.ui index 26ec53968..ca6792d2c 100644 --- a/src/gui/EditEntryWidgetMain.ui +++ b/src/gui/EditEntryWidgetMain.ui @@ -10,10 +10,10 @@ 301 - - Form - + + QFormLayout::ExpandingFieldsGrow + @@ -34,9 +34,6 @@ - - - @@ -44,6 +41,68 @@ + + + + + + + Password: + + + + + + + Repeat: + + + + + + + QLineEdit::Password + + + + + + + Expires + + + + + + + false + + + + + + + + + QLineEdit::Password + + + + + + + ... + + + true + + + true + + + + +