Fix: center unlock dialog on screen when triggered from system tray#13421
Open
yjdyamv wants to merge 2 commits into
Open
Fix: center unlock dialog on screen when triggered from system tray#13421yjdyamv wants to merge 2 commits into
yjdyamv wants to merge 2 commits into
Conversation
When KeePassXC is minimized to the system tray and the unlock dialog is shown (e.g. via global Auto-Type shortcut), the dialog appears in the top-left corner instead of centered because Qt has no valid parent window geometry to position against. Add centering logic to DatabaseOpenDialog::showEvent() using QApplication::screenAt(QCursor::pos()), consistent with the existing implementation in AutoTypeSelectDialog. Fixes the issue where popup windows appear in upper left of screen on Windows with Qt6.
droidmonkey
requested changes
Jun 10, 2026
Member
|
Nice! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes dialog positioning when KeePassXC is minimized to the system tray (notably on Windows with Qt6), ensuring unlock-related dialogs are centered on the screen under the mouse cursor rather than appearing at (0,0) due to missing/invalid parent window geometry.
Changes:
- Adds a shared helper (
GuiTools::centerWidgetOnActiveScreen) to center a widget on the screen at the current cursor position (fallback: primary screen). - Uses the helper in
DatabaseOpenDialog::showEvent()to center the unlock dialog when shown from the tray/global shortcut flows. - Refactors existing centering logic in Auto-Type dialogs to reuse the shared helper.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/gui/GuiTools.h |
Declares a new helper for centering widgets on the active (cursor) screen. |
src/gui/GuiTools.cpp |
Implements the new centering helper using screenAt(QCursor::pos()) with a fallback. |
src/gui/DatabaseOpenDialog.cpp |
Centers the unlock dialog on show to avoid top-left placement when triggered from tray. |
src/autotype/PickcharsDialog.cpp |
Replaces inline centering code with the shared helper. |
src/autotype/AutoTypeSelectDialog.cpp |
Reuses the shared helper after restoring/clamping dialog size. |
…reen Move screen detection and widget centering into a shared GuiTools helper to avoid duplication across dialogs. Apply code review suggestions: add null guards and use frameGeometry().moveCenter() for accurate positioning with window decorations.
Contributor
Author
|
Ok, I just revised to follow copilot' s robust advice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When KeePassXC is minimized to the system tray and the unlock dialog is shown (e.g. via global Auto-Type shortcut), the dialog appears in the top-left corner instead of centered because Qt has no valid parent window geometry to position against.
Add centering logic to DatabaseOpenDialog::showEvent() using QApplication::screenAt(QCursor::pos()), consistent with the existing implementation in AutoTypeSelectDialog.
Fixes the issue where popup windows appear in upper left of screen on Windows with Qt6.
Fixes #13375
Screenshots
Testing strategy
Type of change