Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bound archive buttons enable/disable to context menu actions #1793

Merged
merged 5 commits into from
Sep 19, 2023

Conversation

bigtedde
Copy link
Collaborator

@bigtedde bigtedde commented Sep 1, 2023

Description

The context menu that appears when you right click on an archive has its own rules for when actions are enabled or disabled, separate from the rules for the buttons in the archive tab, even though they perform the same actions. I do not believe there is a reason for these buttons to ever be enabled in the context menu and disabled on the archive tab or vise versa.

In this PR, I have bound the "enabled" or "disabled" state of the actions in the archive right-click context menu to the state of their button equivalent in the archive tab. This will improve consistency, and prevent issues like the one I encountered here.

Related Issue

#1792

Motivation and Context

Improve consistency and prevent errors

How Has This Been Tested?

Tested locally, and passes Github test workflow

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

menu.addSeparator()
diff_action = QAction(self.bDiff.icon(), self.bDiff.text(), menu)
diff_action.triggered.connect(self.diff_action)
menu.addAction(diff_action)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess, ideally, we would have the action menu mimic the layout of the button menu, with a separator before 'diff' and moving 'delete' to the end?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would make sense although we should review the current button layout. I initialls designed it so that it distinguishes between single and multi archive options. But maybe there is a better button order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I initially designed it so that it distinguishes between single and multi archive options

Let's run with that idea. Maybe list them by number of archives required for the action?

  • Single archive only actions: 'mount', 'extract', 'rename'
  • two archive only actions: 'diff'
  • any number archive actions: 'recalculate', 'delete'

Separators between each of these sections, maybe?

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Categorizing by impact would also be possible.

  1. Recalculate
  2. Diff

Those only extract data of vorta.

  1. mount
  2. extract

Those do not alter the repo but modify the filesystem

  1. rename

This is reversible.

  1. delete

This deletes data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can wrap these changes into this PR. Would we like separators between those categories, or just ordered in a list as you outlined?

Same list order for the context menu as well?

Copy link
Collaborator

@real-yfprojects real-yfprojects Sep 1, 2023

Choose a reason for hiding this comment

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

Which of these two options do you prefer?

Would we like separators between those categories, or just ordered in a list as you outlined?

I feel like separators or increased spacing would clutter the ui too much.

Same list order for the context menu as well?

Recognisable patterns repeated throughout the application usually improve the UX.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Which of these two options do you prefer?

Categorizing by impact as you suggest makes logical sense, and I like 'delete' being the last option as that is intuitive.

I will remove the serparators and match the ordering for both button and context menu 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, the requested changes have been made. The only difference now between the context menu and the buttons is the 'copy' context menu action. Would you like there to be a 'copy' button as well, or leave it as it is?

@bigtedde
Copy link
Collaborator Author

bigtedde commented Sep 5, 2023

I have tested this locally and everything works as intended. This solves the issue of mismatched available actions in the context menu vs the archive buttons. The buttons are categorized by impact as discussed, and the separators have have been cleaned up.

Copy link
Collaborator

@real-yfprojects real-yfprojects left a comment

Choose a reason for hiding this comment

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

Can you align the archive actions buttons to the top?

Comment on lines +190 to +201
button_connection_pairs = [
(self.bRefreshArchive, self.refresh_archive_info),
(self.bDiff, self.diff_action),
(self.bMountArchive, self.bmountarchive_clicked),
(self.bExtract, self.extract_action),
(self.bRename, self.cell_double_clicked),
(self.bDelete, self.delete_action),
]

for button, connection in button_connection_pairs:
action = menu.addAction(button.icon(), button.text(), connection)
action.setEnabled(button.isEnabled())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clever rewrite!

@m3nu m3nu merged commit 43140be into borgbase:master Sep 19, 2023
11 checks passed
@bigtedde bigtedde deleted the delete branch September 21, 2023 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants