Skip to content

Commit

Permalink
allow automatic expiration date extension on pwd modification
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xvallspl committed Apr 27, 2021
1 parent 91e7494 commit 3a31a80
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/core/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ void Entry::setExpires(const bool& value)
}
}

// Aqui
void Entry::setExpiryTime(const QDateTime& dateTime)
{
if (m_data.timeInfo.expiryTime() != dateTime) {
Expand Down
19 changes: 18 additions & 1 deletion src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -178,6 +178,23 @@ 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());
// Canviar aixo
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);
});
// Canviar aixo
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()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/entry/EditEntryWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QTimer>

#include "config-keepassx.h"
#include "core/TimeDelta.h"
#include "gui/EditWidget.h"

class AutoTypeAssociations;
Expand Down Expand Up @@ -162,6 +163,7 @@ private slots:
QPointer<Entry> m_entry;
QSharedPointer<Database> m_db;

TimeDelta m_extensionOnPwUpdate;
bool m_create;
bool m_history;
#ifdef WITH_XC_SSHAGENT
Expand Down
164 changes: 106 additions & 58 deletions src/gui/entry/EditEntryWidgetMain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -252,25 +213,112 @@
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
<item row="5" column="1">
<widget class="QCheckBox" name="expireCheck">
<property name="toolTip">
<string>Toggle expiration</string>
</property>
<item>
<widget class="QCheckBox" name="expireCheck">
<property name="toolTip">
<string>Toggle expiration</string>
</property>
<property name="accessibleName">
<string>Toggle expiration</string>
</property>
<property name="text">
<string>Expires:</string>
</property>
</widget>
<property name="accessibleName">
<string>Toggle expiration</string>
</property>
<property name="text">
<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>
</layout>
</widget>
</item>
</layout>
</widget>
Expand Down

0 comments on commit 3a31a80

Please sign in to comment.