mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Add option to auto-generate a password for new entries (#12593)
* Closes #626 --------- Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
@@ -577,6 +577,10 @@
|
||||
<source>Skip confirmation for main window Auto-Type actions</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Auto-generate password for new entries</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ApplicationSettingsWidgetSecurity</name>
|
||||
|
||||
@@ -69,6 +69,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||
{Config::OpenURLOnDoubleClick, {QS("OpenURLOnDoubleClick"), Roaming, true}},
|
||||
{Config::HideWindowOnCopy,{QS("HideWindowOnCopy"), Roaming, false}},
|
||||
{Config::MinimizeOnCopy,{QS("MinimizeOnCopy"), Roaming, true}},
|
||||
{Config::AutoGeneratePasswordForNewEntries,{QS("AutoGeneratePasswordForNewEntries"), Roaming, false}},
|
||||
{Config::MinimizeAfterUnlock,{QS("MinimizeAfterUnlock"), Roaming, false}},
|
||||
{Config::DropToBackgroundOnCopy,{QS("DropToBackgroundOnCopy"), Roaming, false}},
|
||||
{Config::UseGroupIconOnEntryCreation,{QS("UseGroupIconOnEntryCreation"), Roaming, true}},
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
HideWindowOnCopy,
|
||||
MinimizeOnCopy,
|
||||
MinimizeAfterUnlock,
|
||||
AutoGeneratePasswordForNewEntries,
|
||||
DropToBackgroundOnCopy,
|
||||
UseGroupIconOnEntryCreation,
|
||||
AutoTypeEntryTitleMatch,
|
||||
|
||||
@@ -226,6 +226,8 @@ void ApplicationSettingsWidget::loadSettings()
|
||||
!config()->get(Config::Security_NoConfirmMoveEntryToRecycleBin).toBool());
|
||||
m_generalUi->EnableCopyOnDoubleClickCheckBox->setChecked(
|
||||
config()->get(Config::Security_EnableCopyOnDoubleClick).toBool());
|
||||
m_generalUi->autoGeneratePasswordForNewEntriesCheckBox->setChecked(
|
||||
config()->get(Config::AutoGeneratePasswordForNewEntries).toBool());
|
||||
|
||||
m_generalUi->languageComboBox->clear();
|
||||
QList<QPair<QString, QString>> languages = Translator::availableLanguages();
|
||||
@@ -399,6 +401,8 @@ void ApplicationSettingsWidget::saveSettings()
|
||||
config()->set(Config::Security_NoConfirmMoveEntryToRecycleBin,
|
||||
!m_generalUi->ConfirmMoveEntryToRecycleBinCheckBox->isChecked());
|
||||
config()->set(Config::Security_EnableCopyOnDoubleClick, m_generalUi->EnableCopyOnDoubleClickCheckBox->isChecked());
|
||||
config()->set(Config::AutoGeneratePasswordForNewEntries,
|
||||
m_generalUi->autoGeneratePasswordForNewEntriesCheckBox->isChecked());
|
||||
|
||||
auto language = m_generalUi->languageComboBox->currentData().toString();
|
||||
if (config()->get(Config::GUI_Language) != language) {
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>568</width>
|
||||
<height>1202</height>
|
||||
<height>1226</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
@@ -539,6 +539,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoGeneratePasswordForNewEntriesCheckBox">
|
||||
<property name="text">
|
||||
<string>Auto-generate password for new entries</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="EnableCopyOnDoubleClickCheckBox">
|
||||
<property name="text">
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "core/EntryAttributes.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "core/PasswordGenerator.h"
|
||||
#include "core/TimeDelta.h"
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
#include "sshagent/OpenSSHKey.h"
|
||||
@@ -948,6 +949,12 @@ void EditEntryWidget::loadEntry(Entry* entry,
|
||||
// Force the user to Save/Discard new entries
|
||||
showApplyButton(!m_create);
|
||||
|
||||
// Set an initial password for new entries if the option is enabled
|
||||
if (create && config()->get(Config::AutoGeneratePasswordForNewEntries).toBool()) {
|
||||
PasswordGenerator generator;
|
||||
m_mainUi->passwordEdit->setText(generator.generatePassword());
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user