Make password and expiry information editable in EditEntryWidget.

This commit is contained in:
Felix Geyer 2012-01-07 16:18:21 +01:00
parent 2f5d110149
commit 40e96ad7b3
3 changed files with 85 additions and 6 deletions

View File

@ -54,6 +54,10 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
Q_ASSERT(m_ui->categoryList->model()->rowCount() == m_ui->stackedWidget->count()); 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_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(accepted()), SLOT(saveEntry()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel())); 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->titleEdit->setText(entry->title());
m_mainUi->usernameEdit->setText(entry->username()); m_mainUi->usernameEdit->setText(entry->username());
m_mainUi->urlEdit->setText(entry->url()); 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()); m_notesUi->notesEdit->setPlainText(entry->notes());
@ -87,6 +96,10 @@ void EditEntryWidget::saveEntry()
m_entry->setTitle(m_mainUi->titleEdit->text()); m_entry->setTitle(m_mainUi->titleEdit->text());
m_entry->setUsername(m_mainUi->usernameEdit->text()); m_entry->setUsername(m_mainUi->usernameEdit->text());
m_entry->setUrl(m_mainUi->urlEdit->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()); m_entry->setNotes(m_notesUi->notesEdit->toPlainText());
@ -99,3 +112,9 @@ void EditEntryWidget::cancel()
m_entry = 0; m_entry = 0;
Q_EMIT editFinished(false); 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);
}

View File

@ -47,6 +47,7 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void saveEntry(); void saveEntry();
void cancel(); void cancel();
void togglePassword(bool checked);
private: private:
Entry* m_entry; Entry* m_entry;

View File

@ -10,10 +10,10 @@
<height>301</height> <height>301</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="titleLabel"> <widget class="QLabel" name="titleLabel">
<property name="text"> <property name="text">
@ -34,9 +34,6 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="usernameEdit"/> <widget class="QLineEdit" name="usernameEdit"/>
</item> </item>
<item row="2" column="1">
<widget class="QLineEdit" name="urlEdit"/>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="urlLabel"> <widget class="QLabel" name="urlLabel">
<property name="text"> <property name="text">
@ -44,6 +41,68 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QLineEdit" name="urlEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="passwordRepeatLabel">
<property name="text">
<string>Repeat:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="passwordRepeatEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="expireCheck">
<property name="text">
<string>Expires</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDateTimeEdit" name="expireDatePicker">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="passwordEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="togglePasswordButton">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>