mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-04 21:17:43 +03:00
Fix bugs with preview widget
* Add configuration to hide TOTP in preview widget (shown by default). * Retain the visibility of TOTP and other fields when the same entry remains selected in the preview panel. * Fix disconnecting signals when switch entries / groups. This likely is going to fix crashes because we were compounding signals when focusing in on the main window.
This commit is contained in:
parent
c1720c3711
commit
58c4d1de1e
6 changed files with 37 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue