Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs with preview widget #9170

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@
<source>Use DuckDuckGo service to download website icons</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hide TOTP in the entry preview panel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AutoType</name>
Expand Down
1 change: 1 addition & 0 deletions src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::Security_PasswordsHidden, {QS("Security/PasswordsHidden"), Roaming, true}},
{Config::Security_PasswordEmptyPlaceholder, {QS("Security/PasswordEmptyPlaceholder"), Roaming, false}},
{Config::Security_HidePasswordPreviewPanel, {QS("Security/HidePasswordPreviewPanel"), Roaming, true}},
{Config::Security_HideTotpPreviewPanel, {QS("Security/HideTotpPreviewPanel"), Roaming, false}},
{Config::Security_AutoTypeAsk, {QS("Security/AutotypeAsk"), Roaming, true}},
{Config::Security_IconDownloadFallback, {QS("Security/IconDownloadFallback"), Roaming, false}},
{Config::Security_NoConfirmMoveEntryToRecycleBin,{QS("Security/NoConfirmMoveEntryToRecycleBin"), Roaming, true}},
Expand Down
1 change: 1 addition & 0 deletions src/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class Config : public QObject
Security_PasswordsHidden,
Security_PasswordEmptyPlaceholder,
Security_HidePasswordPreviewPanel,
Security_HideTotpPreviewPanel,
Security_AutoTypeAsk,
Security_IconDownloadFallback,
Security_NoConfirmMoveEntryToRecycleBin,
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ApplicationSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ void ApplicationSettingsWidget::loadSettings()
m_secUi->passwordShowDotsCheckBox->setChecked(config()->get(Config::Security_PasswordEmptyPlaceholder).toBool());
m_secUi->passwordPreviewCleartextCheckBox->setChecked(
config()->get(Config::Security_HidePasswordPreviewPanel).toBool());
m_secUi->hideTotpCheckBox->setChecked(config()->get(Config::Security_HideTotpPreviewPanel).toBool());
m_secUi->passwordsRepeatVisibleCheckBox->setChecked(
config()->get(Config::Security_PasswordsRepeatVisible).toBool());
m_secUi->hideNotesCheckBox->setChecked(config()->get(Config::Security_HideNotes).toBool());
Expand Down Expand Up @@ -427,6 +428,7 @@ void ApplicationSettingsWidget::saveSettings()
config()->set(Config::Security_PasswordEmptyPlaceholder, m_secUi->passwordShowDotsCheckBox->isChecked());

config()->set(Config::Security_HidePasswordPreviewPanel, m_secUi->passwordPreviewCleartextCheckBox->isChecked());
config()->set(Config::Security_HideTotpPreviewPanel, m_secUi->hideTotpCheckBox->isChecked());
config()->set(Config::Security_PasswordsRepeatVisible, m_secUi->passwordsRepeatVisibleCheckBox->isChecked());
config()->set(Config::Security_HideNotes, m_secUi->hideNotesCheckBox->isChecked());
config()->set(Config::Security_NoConfirmMoveEntryToRecycleBin,
Expand Down
7 changes: 7 additions & 0 deletions src/gui/ApplicationSettingsWidgetSecurity.ui
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="hideTotpCheckBox">
<property name="text">
<string>Hide TOTP in the entry preview panel</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="hideNotesCheckBox">
<property name="text">
Expand Down
32 changes: 22 additions & 10 deletions src/gui/EntryPreviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,38 +119,50 @@ void EntryPreviewWidget::clear()

void EntryPreviewWidget::setEntry(Entry* selectedEntry)
{
if (m_currentEntry == selectedEntry) {
return;
}

if (m_currentEntry) {
disconnect(m_currentEntry);
disconnect(m_currentEntry, nullptr, this, nullptr);
}
if (m_currentGroup) {
disconnect(m_currentGroup);
disconnect(m_currentGroup, nullptr, this, nullptr);
}

m_currentEntry = selectedEntry;
m_currentGroup = nullptr;

if (!selectedEntry) {
if (!m_currentEntry) {
hide();
return;
}

connect(selectedEntry, &Entry::modified, this, &EntryPreviewWidget::refresh);
connect(m_currentEntry, &Entry::modified, this, &EntryPreviewWidget::refresh);
refresh();

if (m_currentEntry->hasTotp()) {
m_ui->entryTotpButton->setChecked(!config()->get(Config::Security_HideTotpPreviewPanel).toBool());
}
}

void EntryPreviewWidget::setGroup(Group* selectedGroup)
{
if (m_currentGroup == selectedGroup) {
return;
}

if (m_currentEntry) {
disconnect(m_currentEntry);
disconnect(m_currentEntry, nullptr, this, nullptr);
}
if (m_currentGroup) {
disconnect(m_currentGroup);
disconnect(m_currentGroup, nullptr, this, nullptr);
}

m_currentEntry = nullptr;
m_currentGroup = selectedGroup;

if (!selectedGroup) {
if (!m_currentGroup) {
hide();
return;
}
Expand Down Expand Up @@ -226,15 +238,15 @@ void EntryPreviewWidget::updateEntryTotp()
Q_ASSERT(m_currentEntry);
const bool hasTotp = m_currentEntry->hasTotp();
m_ui->entryTotpButton->setVisible(hasTotp);
m_ui->entryTotpLabel->hide();
m_ui->entryTotpProgress->hide();
m_ui->entryTotpButton->setChecked(false);

if (hasTotp) {
m_totpTimer.start(1000);
m_ui->entryTotpProgress->setMaximum(m_currentEntry->totpSettings()->step);
updateTotpLabel();
} else {
m_ui->entryTotpLabel->hide();
m_ui->entryTotpProgress->hide();
m_ui->entryTotpButton->setChecked(false);
m_ui->entryTotpLabel->clear();
m_totpTimer.stop();
}
Expand Down