allow automatic expiration date extension on pwd modification

Addressed issue #2010

Creates a new Expiration Settings area in the Edit Entry widget, composed
of the expiration date settings and a new optional feature that allows for
automatic extension of the expiration date on password modification.
This commit is contained in:
Xavier Valls 2021-04-27 17:56:39 +02:00
parent fd0bdaae80
commit fa785e1745
3 changed files with 124 additions and 59 deletions

View File

@ -168,7 +168,7 @@ void EditEntryWidget::setupMain()
m_mainUi->urlEdit->enableVerifyMode();
#endif
connect(m_mainUi->expireCheck, &QCheckBox::toggled, [&](bool enabled) {
m_mainUi->expireDatePicker->setEnabled(enabled);
m_mainUi->expirationBox->setEnabled(enabled);
if (enabled) {
m_mainUi->expireDatePicker->setDateTime(Clock::currentDateTime());
}
@ -178,6 +178,21 @@ void EditEntryWidget::setupMain()
m_mainUi->expirePresets->setMenu(createPresetsMenu());
connect(m_mainUi->expirePresets->menu(), SIGNAL(triggered(QAction*)), this, SLOT(useExpiryPreset(QAction*)));
m_mainUi->extendPresets->setMenu(createPresetsMenu());
connect(m_mainUi->extendPresets->menu(), &QMenu::triggered, this, [&](QAction* action) {
m_extensionOnPwUpdate = action->data().value<TimeDelta>();
});
connect(m_mainUi->autoExtendExpire, &QCheckBox::toggled, [&](bool enabled) {
m_mainUi->extendPresets->setEnabled(enabled);
});
connect(m_mainUi->passwordEdit, &QLineEdit::textChanged, this, [&]() {
if (m_mainUi->extendPresets->isEnabled()) {
TimeDelta delta = m_extensionOnPwUpdate;
QDateTime now = Clock::currentDateTime();
QDateTime expiryDateTime = now + delta;
m_mainUi->expireDatePicker->setDateTime(expiryDateTime);
}
});
}
void EditEntryWidget::setupAdvanced()

View File

@ -28,6 +28,7 @@
#include <QTimer>
#include "config-keepassx.h"
#include "core/TimeDelta.h"
#include "gui/EditWidget.h"
class AutoTypeAssociations;
@ -162,6 +163,7 @@ private:
QPointer<Entry> m_entry;
QSharedPointer<Database> m_db;
TimeDelta m_extensionOnPwUpdate;
bool m_create;
bool m_history;
#ifdef WITH_XC_SSHAGENT

View File

@ -56,7 +56,7 @@
<property name="verticalSpacing">
<number>8</number>
</property>
<item row="6" column="1">
<item row="7" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPlainTextEdit" name="notesEdit">
@ -99,7 +99,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="notesEnabled">
@ -129,45 +129,6 @@
</item>
</layout>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QDateTimeEdit" name="expireDatePicker">
<property name="enabled">
<bool>false</bool>
</property>
<property name="accessibleName">
<string>Expiration field</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expirePresets">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expiration Presets</string>
</property>
<property name="accessibleName">
<string>Expiration presets</string>
</property>
<property name="text">
<string>Presets</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
@ -252,12 +213,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<item row="5" column="1">
<widget class="QCheckBox" name="expireCheck">
<property name="toolTip">
<string>Toggle expiration</string>
@ -266,12 +222,104 @@
<string>Toggle expiration</string>
</property>
<property name="text">
<string>Expires:</string>
<string>Configure an expiration date</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QGroupBox" name="expirationBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Expiration settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_expiration">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_expiration">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QDateTimeEdit" name="expireDatePicker">
<property name="accessibleName">
<string>Expiration field</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expirePresets">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expiration Presets</string>
</property>
<property name="accessibleName">
<string>Expiration presets</string>
</property>
<property name="text">
<string>Presets</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalautoUpdate">
<item>
<widget class="QCheckBox" name="autoExtendExpire">
<property name="toolTip">
<string>Toggle auto updating expiration</string>
</property>
<property name="accessibleName">
<string>Toggle auto updating expiration date</string>
</property>
<property name="text">
<string>Automatically extend expiration date on password modification by</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="extendPresets">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expiration extension Presets</string>
</property>
<property name="accessibleName">
<string>Expiration extension presets</string>
</property>
<property name="text">
<string>Time</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>