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

Restore ability to do quick single exports #1173

Closed

Conversation

lisham2000
Copy link
Contributor

No description provided.

@lisham2000 lisham2000 requested review from Ion-e and Tiomat85 and removed request for Ion-e September 20, 2024 13:07
Adjust unit test to adhere to new menu dropdowns
Copy link
Collaborator

@cmeyer cmeyer left a comment

Choose a reason for hiding this comment

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

I know this is still draft, but I happened to be looking at it so thought I throw in some comments now.

"action_id": "file.export_svg"
"type": "sub_menu",
"menu_id": "file_export",
"title": "Export...",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sub-menus should not have "..." on them. But I don't think these should go into a sub-menu, at least for now.

As part of this change, though, we could update the context menu to supply "single export" and "export svg". That's done here:

self.add_action_to_menu_if_enabled(menu, "file.export", action_context)

Copy link
Contributor Author

@lisham2000 lisham2000 Oct 1, 2024

Choose a reason for hiding this comment

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

Hi Chris, Can I ask why we wouldn't want to group these in a sub menu? The spec in #1134 James talks about a sub menu with items so i may have interpreted this wrong

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% opposed to it, but the File menu is relatively short, so adding an item isn't a big change. The downside of the sub menu is it is (a) less visible to users exploring the menus (b) one extra click/mouse-motion to select.

I actually think it might be nice to have them all visible with a separator between the 'Import' items and the 'Export' items. This would be the addition of two lines in the menu.

If your group has a strong opinion, it's fine. But if not, let's go with no sub-menu with the option of putting them in a sub-menu in another PR.

action_id = "file.export"
action_name = _("Export...")
class SingleExportAction(Window.Action):
action_id = "export.single_export"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The old action_id should not change. It's unlikely that it is used, but the action id's are meant to be stable over long periods of time. Likewise, I'd like to use consistent identifiers, even though your identifier names are better. That means using file.batch_export or maybe file.export_batch to make it easily distinguishable in an alphabetized list.

Along those same lines, the classes should be in alphabetical order in the file. This is to make it easier to locate them, which is a problem in the huge file. To that end, I'd keep the original name along with the original identifier (for the reasons above): ExportAction or perhaps ExportSingleAction.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can I ask the silly question of why do classes need to be alphabetical in a file? Most modern IDEs (including PyCharm) can list classes/functions in a file in alphabetical order anyway. If a file has enough classes in it that that list isn't enough surely that is indicative that the file could do with being broken down into smaller chunks rather than trying to use the first few letters of a class name to create pseudo-structure - potentially leading to names that are less descriptive of the actual function and instead are named just to keep them together.

Copy link
Collaborator

Choose a reason for hiding this comment

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

They're not really totally alphabetical - only within each major section. It's simply something to make it easier when searching for commands. This file should definitely be broken down into more manageable pieces and now might be a sensible time to do that (just before a release). Or maybe just after. Either way, when a file gets split, it's more difficult to get a history of that file for regressions, so I tend not to do it for that reason.

Copy link
Collaborator

Choose a reason for hiding this comment

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

NOTE: the important part of my comment is to not rename the existing command.

@@ -3080,13 +3099,13 @@ def invoke(self, context: Window.ActionContext) -> Window.ActionResult:

Window.register_action(DeleteItemAction())
Window.register_action(DeleteDataItemAction())
Window.register_action(ExportAction())
Window.register_action(SingleExportAction())
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should appear in alphabetical order within their group.

return len(context.display_items) == 1 and context.display_item is not None


class BatchExportAction(Window.Action):
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should appear in alphabetical order, and I'd rename it to ExportBatchAction to make sure it's located in the same area of the code as ExportAction when alphabetized.

@lisham2000 lisham2000 marked this pull request as ready for review October 4, 2024 13:55
@cmeyer
Copy link
Collaborator

cmeyer commented Oct 4, 2024

Merged with minor edits 3e084a5

@cmeyer cmeyer closed this Oct 4, 2024
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