mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-25 22:16:01 -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) {
|
connect(m_mainUi->autoExtendExpire, &QCheckBox::toggled, [&](bool enabled) {
|
||||||
m_mainUi->extendByQuantity->setEnabled(enabled);
|
m_mainUi->extendByQuantity->setEnabled(enabled);
|
||||||
m_mainUi->extendByMagnitude->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, [&]() {
|
connect(m_mainUi->passwordEdit, &QLineEdit::textChanged, this, [&]() {
|
||||||
if (m_mainUi->autoExtendExpire->isEnabled()) {
|
if (m_mainUi->autoExtendExpire->isEnabled()) {
|
||||||
TimeDelta delta = std::get<1>(m_extensionOnPwUpdate) * std::get<0>(m_extensionOnPwUpdate);
|
TimeDelta delta = std::get<1>(m_extensionOnPwUpdate) * std::get<0>(m_extensionOnPwUpdate);
|
||||||
QDateTime now = Clock::currentDateTime();
|
QDateTime now = Clock::currentDateTime();
|
||||||
QDateTime expiryDateTime = now + delta;
|
QDateTime expiryDateTime = now + delta;
|
||||||
|
if (m_mainUi->randomizeExtensionDeadline->isEnabled()) {
|
||||||
|
expiryDateTime =
|
||||||
|
expiryDateTime.addDays(-QRandomGenerator::global()->bounded(0, m_daysRandomizeExtension));
|
||||||
|
}
|
||||||
m_mainUi->expireDatePicker->setDateTime(expiryDateTime);
|
m_mainUi->expireDatePicker->setDateTime(expiryDateTime);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -165,6 +165,8 @@ private:
|
|||||||
QSharedPointer<Database> m_db;
|
QSharedPointer<Database> m_db;
|
||||||
|
|
||||||
std::tuple<unsigned, TimeDelta> m_extensionOnPwUpdate;
|
std::tuple<unsigned, TimeDelta> m_extensionOnPwUpdate;
|
||||||
|
qint64 m_daysRandomizeExtension;
|
||||||
|
|
||||||
bool m_create;
|
bool m_create;
|
||||||
bool m_history;
|
bool m_history;
|
||||||
#ifdef WITH_XC_SSHAGENT
|
#ifdef WITH_XC_SSHAGENT
|
||||||
|
@ -336,6 +336,52 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user