Skip to content

Refactor attachment handling and UI components#12085

Merged
droidmonkey merged 32 commits intokeepassxreboot:developfrom
w15eacre:feature/improve_editor
Jun 19, 2025
Merged

Refactor attachment handling and UI components#12085
droidmonkey merged 32 commits intokeepassxreboot:developfrom
w15eacre:feature/improve_editor

Conversation

@w15eacre
Copy link
Copy Markdown
Contributor

@w15eacre w15eacre commented May 11, 2025

Refactor attachment editor to support editing files.

  • Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
  • Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
  • Added functionality to edit attachments in EntryAttachmentsWidget.
  • Created AbstractAttachmentWidget interface for different attachment types.
  • Implemented TextAttachmentsWidget for handling plain text attachments.
  • Added UnknownAttachmentTypeWidget for unsupported attachment types.
  • Updated PreviewEntryAttachmentsDialog to utilize the new attachment widget factory.
  • Enhanced EntryAttachmentsModel with rowByKey method for better key management.
  • Updated UI files for new and existing dialogs to reflect changes.
  • Introduced IAttachmentWidgetFactory interface for creating attachment widgets based on MIME type.
  • Add image attachment support with zoom functionality
  • Fix editing a empty file
  • Add the preview button on the Edit widget.
  • The text preview was changed
  • Add html and markdown detection

Screenshots

edit_text_and_preview
edit_text
new buttons
new_file
preview_image_zoom
preview html

preview_plain_text
preview_text_html
Preview
previw_image_fit
unknown_type

Testing strategy

manually testing and unit tests

Type of change

  • ✅ New feature (change that adds functionality)
  • ✅ Refactor (significant modification to existing code)

@w15eacre
Copy link
Copy Markdown
Contributor Author

Hello @droidmonkey. I've started refactoring the attachment handling code to make it easier to add new features (like PDF support and text file editing). Do we need to support rich text files as well?

@droidmonkey
Copy link
Copy Markdown
Member

RichText, maybe, I'm more inclined to support markdown rendering instead

@w15eacre
Copy link
Copy Markdown
Contributor Author

RichText, maybe, I'm more inclined to support markdown rendering instead

I hadn’t thought about using Markdown before, but it seems interesting.

@w15eacre w15eacre force-pushed the feature/improve_editor branch from 0ba1270 to 689cb85 Compare May 11, 2025 00:57
- Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
- Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
- Added functionality to edit attachments in EntryAttachmentsWidget.
- Created AbstractAttachmentWidget interface for different attachment types.
- Implemented TextAttachmentsWidget for handling plain text attachments.
- Added UnknownAttachmentTypeWidget for unsupported attachment types.
- Updated PreviewEntryAttachmentsDialog to utilize the new attachment widget factory.
- Enhanced EntryAttachmentsModel with rowByKey method for better key management.
- Updated UI files for new and existing dialogs to reflect changes.
- Introduced IAttachmentWidgetFactory interface for creating attachment widgets based on MIME type.
@w15eacre w15eacre force-pushed the feature/improve_editor branch from 689cb85 to 3d9c99a Compare May 11, 2025 01:24
@w15eacre
Copy link
Copy Markdown
Contributor Author

w15eacre commented May 12, 2025

@xboxones1 This PR addresses your issue. I separated the widgets by file type to enhance the editor. Now, when you press the ‘Add’ button, it generates the name “New Attachment_{index}.txt”. You can change the name and/or press the ‘Edit’ button to modify the file.

@w15eacre
Copy link
Copy Markdown
Contributor Author

@xboxones1
It’s related to the MIME type. I haven’t pushed the fix yet

@w15eacre w15eacre force-pushed the feature/improve_editor branch from 54ab847 to e2c53c5 Compare May 18, 2025 11:26
@droidmonkey
Copy link
Copy Markdown
Member

@w15eacre do you think you can have this review ready this week? I'd like to push this out with 2.7.11

@droidmonkey droidmonkey added this to the v2.7.11 milestone May 18, 2025
@droidmonkey droidmonkey added pr: new feature Pull request adds a new feature pr: bugfix Pull request fixes a bug labels May 18, 2025
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 pull request refactors attachment handling and the related UI components to better support editing, previewing, and handling various attachment types. Key changes include renaming dialogs (to EditEntryAttachmentsDialog), introducing an abstract widget interface with corresponding implementations, and enhancing the attachments model with new key management functionality.

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/gui/entry/attachments/AttachmentWidgetFactory.* Introduces a factory for creating attachment widgets.
src/gui/entry/attachments/AbstractAttachmentWidget.h Defines the abstract widget interface for attachments.
src/gui/entry/PreviewEntryAttachmentsDialog.* Updates preview dialog to use the new widget factory and attachment struct.
src/gui/entry/EntryAttachmentsWidget.* Modifies attachment widget behavior, including edit functionality.
src/gui/entry/EditEntryAttachmentsDialog.* Introduces a dedicated dialog for editing existing attachments.
src/gui/entry/EntryAttachmentsModel.* Adds a method to retrieve row index by key for better key management.
src/core/Tools.* Adds getMimeType helper method using QMimeDatabase.
CMakeLists.txt Updates the build files to remove the old dialog and add new attachment widget source files.

@w15eacre
Copy link
Copy Markdown
Contributor Author

image fit
image zoom

@w15eacre
Copy link
Copy Markdown
Contributor Author

Md file

@w15eacre
Copy link
Copy Markdown
Contributor Author

edit and preview

Introduces a new `TextAttachmentsPreviewWidget` to enable previewing attachments in plain text, HTML, and Markdown formats.

Integrates the preview widget into `TextAttachmentsWidget` using a splitter for better attachment editing and viewing. Updates the attachment-handling logic to synchronize edits and previews dynamically.

Also expands MIME type detection by adding support for zero-size text files.
@w15eacre
Copy link
Copy Markdown
Contributor Author

@

@w15eacre do you think you can have this review ready this week? I'd like to push this out with 2.7.11

I’ll finish it in 2–3 days.
Feel free to check my screen — and if you have any suggestions to improve the editor UI, just let me know.

@w15eacre
Copy link
Copy Markdown
Contributor Author

@xboxones1 I fixed the Edit button.

@droidmonkey
Copy link
Copy Markdown
Member

wow I am really into this, awesome work!

@michaelk83
Copy link
Copy Markdown

if you have any suggestions to improve the editor UI

Maybe move the type dropdown to the left end of the buttons row? This way, it won't take up vertical space from the editor. And you can probably skip the label, as it's clear enough from the context. Just add it as a tooltip of the dropdown:
[ Html ▼ ] [ OK ] [ Cancel ]

Not sure if it's a good idea, but just something to consider.

@w15eacre
Copy link
Copy Markdown
Contributor Author

if you have any suggestions to improve the editor UI

Maybe move the type dropdown to the left end of the buttons row? This way, it won't take up vertical space from the editor. And you can probably skip the label, as it's clear enough from the context. Just add it as a tooltip of the dropdown:

[ Html ▼ ] [ OK ] [ Cancel ]

Not sure if it's a good idea, but just something to consider.

Not sure, but aligning the text editor and preview is a good idea

Replaces deprecated SIGNAL-SLOT syntax with modern signal-slot syntax for better readability and maintenance.

Enhances attachment selection handling by adding a check for empty selections and providing a warning message, preventing potential crashes or undefined behavior when no attachment is selected.
@w15eacre w15eacre force-pushed the feature/improve_editor branch from 5d1e977 to 95cfb6d Compare May 20, 2025 21:53
@w15eacre
Copy link
Copy Markdown
Contributor Author

A new button "Add file..."
image
Screenshot_20250531_162003

@droidmonkey
Copy link
Copy Markdown
Member

Oh I love that

w15eacre added 2 commits May 31, 2025 22:01
- Removed the AbstractAttachmentWidget class and its associated files.
- Introduced AttachmentTypes.h to define Attachment structure and OpenMode enum.
- Created AttachmentWidget class to manage attachments, replacing the abstract class.
- Updated ImageAttachmentsWidget, TextAttachmentsWidget, and related classes to inherit from QWidget instead of AbstractAttachmentWidget.
- Removed the AttachmentWidgetFactory and its tests, simplifying attachment widget creation.
- Added tests for AttachmentWidget to ensure proper functionality with text and image attachments.
- Cleaned up unused code and adjusted tests to reflect the new structure.
@w15eacre w15eacre force-pushed the feature/improve_editor branch from 7cc4ec0 to a6e6049 Compare May 31, 2025 23:52
@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented Jun 1, 2025

Just tested the latest, this is an awesome upgrade.

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented Jun 1, 2025

@w15eacre I pushed some code standards cleanup and a couple fixes. Edited attachments were not saved (I fixed that) so might need to add a gui test for that.

* Fix editing attachment not saving the edits
* Fix preview being updated even if not visible and adding a delay to update to reduce typing lockups
@droidmonkey droidmonkey force-pushed the feature/improve_editor branch from 084726d to d6d8399 Compare June 1, 2025 14:20
…ndling tests

Add a returning text attachment test
@w15eacre
Copy link
Copy Markdown
Contributor Author

w15eacre commented Jun 1, 2025

@droidmonkey I’ve fixed the tests. Thanks!

@w15eacre
Copy link
Copy Markdown
Contributor Author

w15eacre commented Jun 2, 2025

@droidmonkey Is MacOs working ok?

@droidmonkey
Copy link
Copy Markdown
Member

It needs to be fixed, a brew update caused builds to fail

@w15eacre w15eacre force-pushed the feature/improve_editor branch from b710fb7 to 055de1c Compare June 5, 2025 07:04
@w15eacre
Copy link
Copy Markdown
Contributor Author

w15eacre commented Jun 5, 2025

@droidmonkey Does MacOs work?

@droidmonkey
Copy link
Copy Markdown
Member

Got it working again

@droidmonkey droidmonkey merged commit f2a4cc7 into keepassxreboot:develop Jun 19, 2025
11 checks passed
@droidmonkey
Copy link
Copy Markdown
Member

@w15eacre thank you for this PR, great work!

pull bot pushed a commit to surkin/keepassxc that referenced this pull request Jun 19, 2025
…12085)

* Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
* Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
* Added functionality to preview attachments while editing them.
* Enhanced EntryAttachmentsModel with rowByKey method for better key management.
* Add image attachment support with zoom functionality.
* Add html and markdown detection.
* Improve button layout on the attachment section when editing an entry
@droidmonkey droidmonkey added the pr: backported Pull request backported to previous release label Jun 19, 2025
pull bot pushed a commit to blog2i2j/keepassxreboot.._..keepassxc that referenced this pull request Jun 19, 2025
…12085)

* Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
* Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
* Added functionality to preview attachments while editing them.
* Enhanced EntryAttachmentsModel with rowByKey method for better key management.
* Add image attachment support with zoom functionality.
* Add html and markdown detection.
* Improve button layout on the attachment section when editing an entry
droidmonkey pushed a commit that referenced this pull request Jun 21, 2025
* Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
* Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
* Added functionality to preview attachments while editing them.
* Enhanced EntryAttachmentsModel with rowByKey method for better key management.
* Add image attachment support with zoom functionality.
* Add html and markdown detection.
* Improve button layout on the attachment section when editing an entry
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

pr: backported Pull request backported to previous release pr: bugfix Pull request fixes a bug pr: new feature Pull request adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants