Skip to content

feat: add re-encrypt context menu for directories#1009

Merged
nogeenharrie merged 1 commit into
mainfrom
feature/reencrypt-button
Apr 15, 2026
Merged

feat: add re-encrypt context menu for directories#1009
nogeenharrie merged 1 commit into
mainfrom
feature/reencrypt-button

Conversation

@nogeenharrie
Copy link
Copy Markdown
Contributor

@nogeenharrie nogeenharrie commented Apr 15, 2026

Fixes: #269

This pull request introduces a new "Re-encrypt" context menu option for directories within the main application's tree view.

Key changes include:

  • Context Menu Integration: When a directory is right-clicked, a "Re-encrypt" action is now available in the context menu.
  • Re-encryption Functionality: A new reencryptPath function handles the re-encryption process.
    • It first validates the directory path.
    • It presents a confirmation dialog to the user, explaining that all password files within the selected directory will be re-encrypted using the current GPG recipients defined in .gpg-id, and that this action is not easily reversible.
    • Upon user confirmation, the main window is temporarily disabled to prevent further interaction, and the re-encryption operation is delegated to the ImitatePass backend for the specified directory.

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai Bot commented Apr 15, 2026

CodeAnt AI is reviewing your PR.

@kody-ai

This comment has been minimized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

Added a "Re-encrypt" directory context-menu action in MainWindow that validates the selected folder, prompts the user for confirmation, disables UI interaction, and calls ImitatePass::reencryptPath() with the folder's absolute path to re-encrypt contained password files.

Changes

Cohort / File(s) Summary
Directory Context Menu
src/mainwindow.cpp
Added MainWindow::reencryptPath(QString) and a conditional "Re-encrypt" action in the tree view context menu. The handler validates the directory exists, shows a confirmation dialog, disables relevant UI/tree view on confirm, and delegates to QtPassSettings::getImitatePass()->reencryptPath() with a cleaned absolute path.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant MW as MainWindow
    participant Dlg as ConfirmationDialog
    participant IP as ImitatePass
    participant FS as FileSystem

    User->>MW: Right-click folder + select "Re-encrypt"
    MW->>FS: verify directory exists
    alt not exists
        MW->>User: show critical error
    else exists
        MW->>Dlg: show confirmation (warn about .gpg-id recipients)
        User->>Dlg: confirm
        MW->>MW: disable UI / tree
        MW->>IP: reencryptPath(cleanedAbsoluteDir)
        IP->>FS: re-encrypt files using .gpg-id recipients
        IP-->>MW: completion
        MW->>MW: re-enable UI / tree
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I nudge a folder, click anew,

Recipients set, the files pass through,
A warning hopped, confirm the night,
UI rests quiet, then springs to light,
Freshly wrapped secrets, snug and true.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a re-encrypt context menu action for directories in the tree view.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/reencrypt-button

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Apr 15, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/mainwindow.cpp`:
- Around line 1347-1351: The code currently disables the entire MainWindow with
this->setEnabled(false) before calling
QtPassSettings::getImitatePass()->reencryptPath(...), but the re-enable path
uses setUiElementsEnabled(true), leaving the window permanently unresponsive;
change the disable call to setUiElementsEnabled(false) so the disable/enable
operations are symmetric with setUiElementsEnabled and match the re-enabling
done in endReencryptPath()/related completion handlers.
- Around line 1058-1059: The code captures a folder path into QString dirPath
via Util::getDir but does not normalize it before use; fix by calling
QDir::cleanPath(dirPath) immediately after assignment (mirroring the existing
pattern around QDir::cleanPath used elsewhere) and use that cleaned QString when
invoking the backend re-encryption call that consumes the folder path; update
references to dirPath in both the local scope and the function/method that sends
the path to the backend so the cleaned path is always passed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: ba61c2d0-b6f9-4f0f-820d-99d5d0ad14f9

📥 Commits

Reviewing files that changed from the base of the PR and between e1590fe and c44e3d4.

📒 Files selected for processing (1)
  • src/mainwindow.cpp

Comment thread src/mainwindow.cpp Outdated
Comment thread src/mainwindow.cpp Outdated
Comment thread src/mainwindow.cpp Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 15, 2026

Coverage Status

Coverage is 21.015%feature/reencrypt-button into main. No base build found for main.

Comment thread src/mainwindow.cpp Outdated
@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai Bot commented Apr 15, 2026

CodeAnt AI finished reviewing your PR.

@nogeenharrie nogeenharrie force-pushed the feature/reencrypt-button branch from c44e3d4 to bf68e80 Compare April 15, 2026 10:43
@kody-ai

This comment has been minimized.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.11%. Comparing base (8f1eab1) to head (5001365).
⚠️ Report is 18 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/mainwindow.cpp 0.00% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1009      +/-   ##
==========================================
- Coverage   27.27%   27.11%   -0.17%     
==========================================
  Files          39       39              
  Lines        3314     3334      +20     
==========================================
  Hits          904      904              
- Misses       2410     2430      +20     
Flag Coverage Δ
qtpass 27.11% <0.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Implements feature request #269:
- Add 'Re-encrypt' option to right-click context menu on folders
- Show confirmation dialog with warning before re-encrypting
- Use existing ImitatePass::reencryptPath() CLI implementation
- Disable UI during operation to prevent double execution
- Show status messages for progress feedback

Fixes:
- Use setUiElementsEnabled() instead of setEnabled() for symmetry
- Normalize path with QDir::cleanPath() for cross-platform consistency

Tests:
- Add reencryptPathNormalization test
- Add reencryptPathAbsolutePath test
@nogeenharrie nogeenharrie force-pushed the feature/reencrypt-button branch from bf68e80 to 5001365 Compare April 15, 2026 11:25
@kody-ai
Copy link
Copy Markdown

kody-ai Bot commented Apr 15, 2026

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Cross File
Business Logic

Access your configuration settings here.

Copy link
Copy Markdown
Member

@annejan annejan left a comment

Choose a reason for hiding this comment

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

I have tested this locally and it seems to work pretty well 👍🏼

@nogeenharrie nogeenharrie merged commit bfbcdb6 into main Apr 15, 2026
24 of 26 checks passed
@nogeenharrie nogeenharrie deleted the feature/reencrypt-button branch April 15, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Re-encrypt button

3 participants