Skip to content

Fix pre-release issues with attachment viewer#12244

Merged
droidmonkey merged 8 commits intodevelopfrom
copilot/fix-12243
Sep 8, 2025
Merged

Fix pre-release issues with attachment viewer#12244
droidmonkey merged 8 commits intodevelopfrom
copilot/fix-12243

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 29, 2025

This PR fixes two translation issues in the attachment editor that prevented proper localization:

Issues Fixed

1. "FIT" translation not working in image attachment zoom controls

The "Fit" text in the image attachment widget zoom dropdown was not being translated because QObject::tr("Fit") was called in an anonymous namespace, causing the translation context to be lost.

Before: Translation system couldn't find the proper context for "Fit"
After: tr("Fit") is called directly in the ImageAttachmentsWidget class methods where the translation context is properly available

2. "New Attachment" string not marked for translation

The default name for new attachments was hardcoded as a string literal and never marked for translation.

Before:

constexpr const char* DefaultName = "New Attachment";
auto newFileName = generateUniqueName(DefaultName, m_entryAttachments->keys());

After:

auto newFileName = generateUniqueName(tr("New Attachment"), m_entryAttachments->keys());

Technical Details

  • Moved tr("Fit") calls from anonymous namespace to proper class methods in ImageAttachmentsWidget
  • Replaced hardcoded "New Attachment" string with tr("New Attachment") call in EntryAttachmentsWidget::newAttachments()
  • Updated translation files to include both new translatable strings
  • Removed unused DefaultName constant to keep code clean

The changes are minimal and surgical, following existing code patterns in the project. Both strings now appear correctly in the translation files and will be available for localization.

Fixes #12243.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Several issues in the attachment editor Fix translation issues for "FIT" and "New Attachment" strings in attachment editor Jun 29, 2025
Copilot AI requested a review from droidmonkey June 29, 2025 14:41
@droidmonkey
Copy link
Copy Markdown
Member

Fix the other problems mentioned in the comments of the source issue.

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 29, 2025

Codecov Report

❌ Patch coverage is 73.21429% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.20%. Comparing base (ad2f951) to head (d80fadb).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
...entry/attachments/TextAttachmentsPreviewWidget.cpp 61.11% 7 Missing ⚠️
...rc/gui/entry/attachments/TextAttachmentsWidget.cpp 86.21% 4 Missing ⚠️
...ui/entry/attachments/TextAttachmentsEditWidget.cpp 25.00% 3 Missing ⚠️
src/gui/entry/EntryAttachmentsWidget.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12244      +/-   ##
===========================================
- Coverage    64.22%   64.20%   -0.03%     
===========================================
  Files          377      377              
  Lines        39403    39436      +33     
===========================================
+ Hits         25305    25316      +11     
- Misses       14098    14120      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 29, 2025

Fix the other problems mentioned in the comments of the source issue.

Fixed the remaining attachment editor issues mentioned in the source issue comments. The changes address:

  1. Markdown preview switching to plaintext: Added state tracking so manual format selection persists during content updates
  2. Links not working: Enabled external links in QTextBrowser so HTML/Markdown links open with Ctrl+click

All existing tests pass and the fixes are minimal surgical changes. Fixed in commit f6c6321.

@droidmonkey droidmonkey marked this pull request as ready for review June 29, 2025 17:45
Copilot AI review requested due to automatic review settings June 29, 2025 17:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures proper localization for the attachment editor by moving translation calls into the correct context and marking all hardcoded strings for translation.

  • Use tr("Fit") within ImageAttachmentsWidget methods instead of an anonymous namespace
  • Replace hardcoded "New Attachment" with tr("New Attachment") and remove the unused constant
  • Introduce and reset a manual‐selection flag in TextAttachmentsPreviewWidget, and enable external link opening in its preview browser

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/entry/attachments/TextAttachmentsPreviewWidget.h Added m_userManuallySelectedType member
src/gui/entry/attachments/TextAttachmentsPreviewWidget.cpp Initialized and reset manual‐selection flag; enabled external links
src/gui/entry/attachments/ImageAttachmentsWidget.cpp Replaced anonymous‐namespace FitText with tr("Fit")
src/gui/entry/EntryAttachmentsWidget.cpp Swapped hardcoded default name for tr("New Attachment")
share/translations/keepassxc_en.ts Added entries for "New Attachment" and "Fit" translations
Comments suppressed due to low confidence (3)

src/gui/entry/attachments/TextAttachmentsPreviewWidget.h:61

  • Add a brief comment explaining the purpose of m_userManuallySelectedType to improve code readability.
    bool m_userManuallySelectedType;

src/gui/entry/attachments/TextAttachmentsPreviewWidget.cpp:67

  • Consider adding a unit test to verify that the manual type selection flag is correctly reset when opening a new attachment.
    // Reset manual selection flag when opening a new attachment

src/gui/entry/attachments/TextAttachmentsPreviewWidget.cpp:100

  • Add a GUI test to confirm that the previewTextBrowser indeed opens external links as expected.
    m_ui->previewTextBrowser->setOpenExternalLinks(true);

@droidmonkey droidmonkey changed the title Fix translation issues for "FIT" and "New Attachment" strings in attachment editor Fix pre-release issues with attachment viewer Jun 29, 2025
@phoerious phoerious added the pr: ai-assisted Pull request contains significant contributions by generative AI label Jun 30, 2025
@droidmonkey droidmonkey added this to the v2.7.11 milestone Jul 4, 2025
@droidmonkey
Copy link
Copy Markdown
Member

Fixed a bunch of scrolling issues with the preview:

2025-07-04_08-42-52.mp4

@droidmonkey
Copy link
Copy Markdown
Member

@varjolintu ready for your review/testing

@varjolintu
Copy link
Copy Markdown
Member

@varjolintu ready for your review/testing

The main text in the PR could've just been "Fixed a few missing translations with.." or something equally compact :)

@droidmonkey
Copy link
Copy Markdown
Member

Our intern coder gets a little verbose sometimes

@droidmonkey droidmonkey force-pushed the copilot/fix-12243 branch 3 times, most recently from 511bad8 to 1e6766d Compare August 5, 2025 11:09
@droidmonkey
Copy link
Copy Markdown
Member

@varjolintu fixed remaining issues noted, give this a once over and approve if ready. I tested everything manually and works well.

Copilot AI and others added 8 commits September 7, 2025 23:42
…ditor

Co-authored-by: droidmonkey <2809491+droidmonkey@users.noreply.github.com>
…ent editor

Co-authored-by: droidmonkey <2809491+droidmonkey@users.noreply.github.com>
* Update preview panel if manually moved from collapsed position
* Preview is now only updated once on first show instead of three times
* Match edit view scroll position (by percentage) when changed. This ensures the preview remains in relative sync with the edited document, for example when a large amount of HTML reduces down to a short preview document.
* Reset the preview scroll back to it's previous position after re-rendering a change.
* Fix default preview size to be half the width of the edit widget.
@droidmonkey droidmonkey merged commit dd023ca into develop Sep 8, 2025
11 checks passed
@droidmonkey droidmonkey deleted the copilot/fix-12243 branch September 8, 2025 10:22
pull bot pushed a commit to gburkhow/keepassxc that referenced this pull request Sep 26, 2025
* Fix translation issues for "FIT" and "New Attachment" in attachment editor

* Fix markdown preview persistence and enable external links in attachment editor

* Update preview panel if manually moved from collapsed position

* Match edit view scroll position (by percentage) when changed. This ensures the preview remains in relative sync with the edited document, for example when a large amount of HTML reduces down to a short preview document.

* Fix default preview size to be half the width of the edit widget.

* Set tab stop to 10 and remove base ui file

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonathan White <support@dmapps.us>
@droidmonkey droidmonkey added the pr: backported Pull request backported to previous release label Oct 25, 2025
droidmonkey added a commit that referenced this pull request Oct 26, 2025
* Fix translation issues for "FIT" and "New Attachment" in attachment editor

* Fix markdown preview persistence and enable external links in attachment editor

* Update preview panel if manually moved from collapsed position

* Match edit view scroll position (by percentage) when changed. This ensures the preview remains in relative sync with the edited document, for example when a large amount of HTML reduces down to a short preview document.

* Fix default preview size to be half the width of the edit widget.

* Set tab stop to 10 and remove base ui file

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jonathan White <support@dmapps.us>
dragonekii pushed a commit to dragonekii/keepassxc-custom that referenced this pull request Dec 8, 2025
Release 2.7.11 (2025-11-23)

- Add image, HTML, Markdown preview, and text editing support to inline attachment viewer [keepassxreboot#12085, keepassxreboot#12244, keepassxreboot#12654]
- Add database merge confirmation dialog [keepassxreboot#10173]
- Add option to auto-generate a password for new entries [keepassxreboot#12593]
- Add support for group sync in KeeShare [keepassxreboot#11593]
- Add {UUID} placeholder for use in references [keepassxreboot#12511]
- Add “Wait for Enter” search option [keepassxreboot#12263]
- Add keyboard shortcut to “Jump to Group” from search results [keepassxreboot#12225]
- Add predefined search for TOTP entries [keepassxreboot#12199]
- Add confirmation when closing database via ESC key [keepassxreboot#11963]
- Add support for escaping placeholder expressions [keepassxreboot#11904]
- Reduce tab indentation width in notes fields [keepassxreboot#11919]
- Cap default Argon2 parallelism when creating a new database [keepassxreboot#11853]
- Database lock after inactivity now enabled by default and set to 900 seconds [keepassxreboot#12689, keepassxreboot#12609]
- Copying TOTP now opens setup dialog if none is configured for entry [keepassxreboot#12584]
- Make double click action configurable [keepassxreboot#12322]
- Remove unused “Last Accessed” from GUI [keepassxreboot#12602]
- Auto-Type: Add more granular confirmation settings [keepassxreboot#12370]
- Auto-Type: Add URL typing preset and add copy options to menu [keepassxreboot#12341]
- Browser: Do not allow sites automatically if entry added from browser extension [keepassxreboot#12413]
- Browser: Add options to restrict exposed groups [keepassxreboot#9852, keepassxreboot#12119]
- Bitwarden Import: Add support for timestamps and password history [keepassxreboot#12588]
- macOS: Add Liquid Glass icon [keepassxreboot#12642]
- macOS: Remove theme-based menubar icon toggle [keepassxreboot#12685]
- macOS: Add Window and Help menus [keepassxreboot#12357]
- Windows: Add option to add KeePassXC to PATH during installation [keepassxreboot#12171]

- Fix window geometry not being restored properly when KeePassXC starts in tray [keepassxreboot#12683]
- Fix potential database truncation when using direct write save method with YubiKeys [keepassxreboot#11841]
- Fix issue with database backup saving [keepassxreboot#11874]
- Fix UI lockups during startup with multiple tabs [keepassxreboot#12053]
- Fix keyboard shortcuts when menubar is hidden [keepassxreboot#12431]
- Fix clipboard being cleared on exit even if no password was copied [keepassxreboot#12603]
- Fix single-instance detection when username contains invalid filename characters [keepassxreboot#12559]
- Fix “Search Wait for Enter” setting not being save [keepassxreboot#12614]
- Fix hotkey accelerators not being escaped properly on database tabs [keepassxreboot#12630]
- Fix confusing error if user cancels out of key file edit dialog [keepassxreboot#12639]
- Fix issues with saved searches and “Press Enter to Search” option [keepassxreboot#12314]
- Fix URL wildcard matching [keepassxreboot#12257]
- Fix TOTP visibility on unlock and settings change [keepassxreboot#12220]
- Fix KeeShare entries with reference attributes not updating [keepassxreboot#11809]
- Fix sort order not being maintained when toggling filters in database reports [keepassxreboot#11849]
- Fix several UI font and layout issues [keepassxreboot#11967,  keepassxreboot#12102]
- Prevent mouse wheel scroll on edit username field [keepassxreboot#12398]
- Improve base translation consistency [keepassxreboot#12432]
- Improve inactivity timer [keepassxreboot#12246]
- Documentation improvements [keepassxreboot#12373, keepassxreboot#12506]
- Browser: Fix ordering of clientDataJSON in Passkey response object [keepassxreboot#12120]
- Browser: Fix URL matching for additional URLs [keepassxreboot#12196]
- Browser: Fix group settings inheritance [keepassxreboot#12368]
- Browser: Allow read-only native messaging config files [keepassxreboot#12236]
- Browser: Optimise entry iteration in browser access control dialog [keepassxreboot#11817]
- Browser: Fix “Do not ask permission for HTTP Basic Auth” option [keepassxreboot#11871]
- Browser: Fix native messaging path for Tor Browser launcher on Linux [keepassxreboot#12005]
- Auto-Type: Fix empty window behaviour [keepassxreboot#12622]
- Auto-Type: Take delays into account when typing TOTP [keepassxreboot#12691]
- SSH Agent: Fix out-of-memory crash with malformed SSH keys [keepassxreboot#12606]
- CSV Import: Fix modified and creation time import [keepassxreboot#12379]
- CSV Import: Fix duplication of root groups on import [keepassxreboot#12240]
- Proton Pass Import: Fix email addresses not being imported when no username set [keepassxreboot#11888]
- macOS: Fix secure input getting stuck [keepassxreboot#11928]
- Windows: Prevent launch as SYSTEM user from MSI installer [keepassxreboot#12705]
- Windows: Remove broken check for MSVC Redistributable from MSI installer [keepassxreboot#11950]
- Linux: Fix startup delay due to StartupNotify setting in desktop file [keepassxreboot#12306]
- Linux: Fix memory initialisation when --pw-stdin is used with a pipe [keepassxreboot#12050]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n pr: ai-assisted Pull request contains significant contributions by generative AI pr: backported Pull request backported to previous release PRE-RELEASE BUG

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Several issues in the attachment editor

7 participants