Fix issues with Entry Editing

* Fix #10653 - prevent category switching if no category was actually hidden/visible. Also properly select a new category when a change is made instead of just changing the widget page.

* Fix apply button still being enabled after it is pressed and successfully committed
This commit is contained in:
Jonathan White 2024-05-05 09:41:59 -04:00
parent 8c91836038
commit ffc72c896c
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
2 changed files with 16 additions and 8 deletions

View File

@ -96,16 +96,19 @@ void EditWidget::setPageHidden(QWidget* widget, bool hidden)
} }
} }
if (index != -1) { if (index == -1) {
m_ui->categoryList->setCategoryHidden(index, hidden); return;
} }
if (index == m_ui->stackedWidget->currentIndex()) { bool changed = m_ui->categoryList->isCategoryHidden(index) != hidden;
m_ui->categoryList->setCategoryHidden(index, hidden);
if (changed && index == m_ui->stackedWidget->currentIndex()) {
int newIndex = m_ui->stackedWidget->currentIndex() - 1; int newIndex = m_ui->stackedWidget->currentIndex() - 1;
if (newIndex < 0) { if (newIndex < 0) {
newIndex = m_ui->stackedWidget->count() - 1; newIndex = m_ui->stackedWidget->count() - 1;
} }
m_ui->stackedWidget->setCurrentIndex(newIndex); m_ui->categoryList->setCurrentCategory(newIndex);
} }
} }

View File

@ -1134,21 +1134,23 @@ bool EditEntryWidget::commitEntry()
toKeeAgentSettings(m_sshAgentSettings); toKeeAgentSettings(m_sshAgentSettings);
#endif #endif
// Begin entry update
if (!m_create) {
m_entry->beginUpdate();
}
#ifdef WITH_XC_BROWSER #ifdef WITH_XC_BROWSER
if (config()->get(Config::Browser_Enabled).toBool()) { if (config()->get(Config::Browser_Enabled).toBool()) {
updateBrowser(); updateBrowser();
} }
#endif #endif
if (!m_create) {
m_entry->beginUpdate();
}
updateEntryData(m_entry); updateEntryData(m_entry);
if (!m_create) { if (!m_create) {
m_entry->endUpdate(); m_entry->endUpdate();
} }
// End entry update
m_historyModel->setEntries(m_entry->historyItems(), m_entry); m_historyModel->setEntries(m_entry->historyItems(), m_entry);
setPageHidden(m_historyWidget, m_history || m_entry->historyItems().count() < 1); setPageHidden(m_historyWidget, m_history || m_entry->historyItems().count() < 1);
@ -1156,6 +1158,9 @@ bool EditEntryWidget::commitEntry()
showMessage(tr("Entry updated successfully."), MessageWidget::Positive); showMessage(tr("Entry updated successfully."), MessageWidget::Positive);
setModified(false); setModified(false);
// Prevent a reload due to entry modified signals
m_entryModifiedTimer.stop();
return true; return true;
} }