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 issues with Entry Editing #10667

Merged
merged 2 commits into from
May 5, 2024
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
14 changes: 11 additions & 3 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1755,9 +1755,17 @@ bool DatabaseWidget::lock()

emit databaseLockRequested();

// ignore event if we are active and a modal dialog is still open (such as a message box or file dialog)
if (isVisible() && QApplication::activeModalWidget()) {
return false;
// Force close any modal widgets associated with this widget
auto modalWidget = QApplication::activeModalWidget();
if (modalWidget) {
auto parent = modalWidget->parentWidget();
while (parent) {
if (parent == this) {
modalWidget->close();
break;
}
parent = parent->parentWidget();
}
}

clipboard()->clearCopiedText();
Expand Down
11 changes: 7 additions & 4 deletions src/gui/EditWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,19 @@ void EditWidget::setPageHidden(QWidget* widget, bool hidden)
}
}

if (index != -1) {
m_ui->categoryList->setCategoryHidden(index, hidden);
if (index == -1) {
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;
if (newIndex < 0) {
newIndex = m_ui->stackedWidget->count() - 1;
}
m_ui->stackedWidget->setCurrentIndex(newIndex);
m_ui->categoryList->setCurrentCategory(newIndex);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,9 @@ void MainWindow::closeModalWindow()

void MainWindow::lockDatabasesAfterInactivity()
{
m_ui->tabWidget->lockDatabases();
if (!m_ui->tabWidget->lockDatabases()) {
m_inactivityTimer->activate();
}
}

bool MainWindow::isTrayIconEnabled() const
Expand Down
13 changes: 9 additions & 4 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,28 +1173,33 @@ bool EditEntryWidget::commitEntry()
toKeeAgentSettings(m_sshAgentSettings);
#endif

// Begin entry update
if (!m_create) {
m_entry->beginUpdate();
}

#ifdef WITH_XC_BROWSER
if (config()->get(Config::Browser_Enabled).toBool()) {
updateBrowser();
}
#endif

if (!m_create) {
m_entry->beginUpdate();
}

updateEntryData(m_entry);

if (!m_create) {
m_entry->endUpdate();
}
// End entry update

m_historyModel->setEntries(m_entry->historyItems(), m_entry);
setPageHidden(m_historyWidget, m_history || m_entry->historyItems().count() < 1);
m_advancedUi->attachmentsWidget->linkAttachments(m_entry->attachments());

showMessage(tr("Entry updated successfully."), MessageWidget::Positive);
setModified(false);
// Prevent a reload due to entry modified signals
m_entryModifiedTimer.stop();

return true;
}

Expand Down
11 changes: 11 additions & 0 deletions src/gui/wizard/ImportWizardPageSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ void ImportWizardPageSelect::updateDatabaseChoices() const
auto mainWindow = getMainWindow();
if (mainWindow) {
for (auto dbWidget : mainWindow->getOpenDatabases()) {
// Remove all connections
disconnect(dbWidget, nullptr, nullptr, nullptr);

// Skip over locked databases
if (dbWidget->isLocked()) {
continue;
}

connect(dbWidget, &DatabaseWidget::databaseLocked, this, &ImportWizardPageSelect::updateDatabaseChoices);
connect(dbWidget, &DatabaseWidget::databaseModified, this, &ImportWizardPageSelect::updateDatabaseChoices);

// Enable the selection of an existing database
m_ui->existingDatabaseRadio->setEnabled(true);
m_ui->existingDatabaseRadio->setToolTip("");
Expand Down Expand Up @@ -161,6 +167,11 @@ void ImportWizardPageSelect::updateDatabaseChoices() const
}
}
}

if (m_ui->existingDatabaseChoice->count() == 0) {
m_ui->existingDatabaseRadio->setEnabled(false);
m_ui->newDatabaseRadio->setChecked(true);
}
}

void ImportWizardPageSelect::chooseImportFile()
Expand Down
Loading