mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 23:39:50 -05:00
add an option for randomizing the extension deadline
Proposed in Issue #6451
This commit is contained in:
parent
626f592c98
commit
c669765256
@ -200,12 +200,25 @@ void EditEntryWidget::setupMain()
|
||||
connect(m_mainUi->autoExtendExpire, &QCheckBox::toggled, [&](bool enabled) {
|
||||
m_mainUi->extendByQuantity->setEnabled(enabled);
|
||||
m_mainUi->extendByMagnitude->setEnabled(enabled);
|
||||
m_mainUi->randomizeExtensionDeadline->setEnabled(enabled);
|
||||
});
|
||||
|
||||
connect(m_mainUi->randomizeExtensionDeadline, &QCheckBox::toggled, [&](bool enabled) {
|
||||
m_mainUi->randomizeByQuantity->setEnabled(enabled);
|
||||
});
|
||||
|
||||
connect(m_mainUi->randomizeByQuantity, QOverload<int>::of(&QSpinBox::valueChanged), this, [&](int n) {
|
||||
m_daysRandomizeExtension = static_cast<qint64>(n);
|
||||
});
|
||||
connect(m_mainUi->passwordEdit, &QLineEdit::textChanged, this, [&]() {
|
||||
if (m_mainUi->autoExtendExpire->isEnabled()) {
|
||||
TimeDelta delta = std::get<1>(m_extensionOnPwUpdate) * std::get<0>(m_extensionOnPwUpdate);
|
||||
QDateTime now = Clock::currentDateTime();
|
||||
QDateTime expiryDateTime = now + delta;
|
||||
if (m_mainUi->randomizeExtensionDeadline->isEnabled()) {
|
||||
expiryDateTime =
|
||||
expiryDateTime.addDays(-QRandomGenerator::global()->bounded(0, m_daysRandomizeExtension));
|
||||
}
|
||||
m_mainUi->expireDatePicker->setDateTime(expiryDateTime);
|
||||
}
|
||||
});
|
||||
|
@ -165,6 +165,8 @@ private:
|
||||
QSharedPointer<Database> m_db;
|
||||
|
||||
std::tuple<unsigned, TimeDelta> m_extensionOnPwUpdate;
|
||||
qint64 m_daysRandomizeExtension;
|
||||
|
||||
bool m_create;
|
||||
bool m_history;
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
|
@ -336,6 +336,52 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalRandomize">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="randomizeExtensionDeadline">
|
||||
<property name="toolTip">
|
||||
<string>Toggle randomizing expiration date</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Toggle randomizing expiration date</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Randomize the extension deadline within the last </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="randomizeByQuantity">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="FixedWidth">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel">
|
||||
<property name="visible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> days</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user