Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ void DatabaseWidget::onDatabaseNonDataChanged()
{
// Force mark the database modified if we are not auto-saving non-data changes
if (!config()->get(Config::AutoSaveNonDataChanges).toBool()) {
m_db->markAsModified();
emit databaseNonDataChanged();
}
Comment on lines 1903 to 1906
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DatabaseWidget already relays Database::databaseNonDataChanged to its own databaseNonDataChanged signal in connectDatabaseSignals(). Emitting databaseNonDataChanged() again here will fire the signal twice for the same underlying change (and therefore call MainWindow::updateMenuActionState() twice via the action multiplexer). Consider removing this extra emit, or alternatively stop relaying the database signal and emit conditionally only from this slot.

Also, the comment above no longer matches the behavior (it mentions marking the DB modified, but the code now only emits a signal).

Copilot uses AI. Check for mistakes.
}

Expand Down
28 changes: 25 additions & 3 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,11 @@ void MainWindow::updateMenuActionState()
m_ui->actionGroupDownloadFavicons->setEnabled(groupSelected && groupHasEntries && !inRecycleBin);

// Database Menu
m_ui->actionDatabaseSave->setEnabled(databaseUnlocked && m_ui->tabWidget->canSave());
bool enableSave = databaseUnlocked
&& (m_ui->tabWidget->canSave()
|| (dbWidget && dbWidget->database() && dbWidget->database()->hasNonDataChanges()
&& !config()->get(Config::AutoSaveNonDataChanges).toBool()));
m_ui->actionDatabaseSave->setEnabled(enableSave);
m_ui->actionDatabaseSaveAs->setEnabled(databaseUnlocked);
m_ui->actionDatabaseSaveBackup->setEnabled(databaseUnlocked);
m_ui->actionDatabaseClose->setEnabled(dbWidget);
Expand Down Expand Up @@ -1091,7 +1095,12 @@ void MainWindow::updateWindowTitle()
if (isModified && customWindowTitlePart.endsWith("*")) {
customWindowTitlePart.remove(customWindowTitlePart.size() - 1, 1);
}
m_ui->actionDatabaseSave->setEnabled(m_ui->tabWidget->canSave(tabWidgetIndex));
auto dbWidget = m_ui->tabWidget->databaseWidgetFromIndex(tabWidgetIndex);
bool enableSave = (dbWidget && !dbWidget->isLocked())
&& (m_ui->tabWidget->canSave(tabWidgetIndex)
|| (dbWidget->database() && dbWidget->database()->hasNonDataChanges()
&& !config()->get(Config::AutoSaveNonDataChanges).toBool()));
m_ui->actionDatabaseSave->setEnabled(enableSave);
} else if (stackedWidgetIndex == StackedWidgetIndex::SettingsScreen) {
customWindowTitlePart = tr("Settings");
} else if (stackedWidgetIndex == StackedWidgetIndex::PasswordGeneratorScreen) {
Expand Down Expand Up @@ -2269,12 +2278,25 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
}
}
#endif
} else if (eventType == QEvent::KeyPress) {
auto keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Alt) {
m_altKeyAlone = (keyEvent->modifiers() == Qt::AltModifier);
} else {
m_altKeyAlone = false;
}
return QObject::eventFilter(watched, event);
} else if (eventType == QEvent::KeyRelease && watched == mainWindow) {
#ifdef Q_OS_MACOS
// On macOS, the menubar is always visible, so no need to toggle it
return false;
#endif
auto keyEvent = dynamic_cast<QKeyEvent*>(event);

if (keyEvent->key() != Qt::Key_Alt) {
m_altKeyAlone = false;
return QObject::eventFilter(watched, event);
}
#ifdef Q_OS_WIN
// Windows translates AltGr into CTRL + ALT, this breaks using AltGr when the menubar is hidden
// Prevent this by activating the ALT cooldown to ignore the next key event which will be an ALT key
Expand All @@ -2284,7 +2306,7 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
return false;
}
#endif
if (keyEvent->key() == Qt::Key_Alt && !keyEvent->modifiers() && config()->get(Config::GUI_HideMenubar).toBool()
if (keyEvent->key() == Qt::Key_Alt && m_altKeyAlone && config()->get(Config::GUI_HideMenubar).toBool()
&& !m_altCoolDown.isActive()) {
auto menubar = mainWindow->m_ui->menubar;
menubar->setMaximumHeight(menubar->maximumHeight() > 0 ? 0 : QWIDGETSIZE_MAX);
Expand Down
1 change: 1 addition & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class MainWindowEventFilter : public QObject
private:
QTimer m_menubarTimer;
QTimer m_altCoolDown;
bool m_altKeyAlone = false;
};

/**
Expand Down
Loading