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

Add per-session recently used boards list #8607

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
buttonGroupsMap,
board, board.getContainerPlatform(), board.getContainerPlatform().getContainerPackage());
boardMenu.insert(item, 3);
item.setAccelerator(KeyStroke.getKeyStroke('0' + index,
item.setAccelerator(KeyStroke.getKeyStroke('1' + index,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems an unrelated off-by-one bugfix that should have been squashed into the previous commit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not an off by one really but a different shortcut, so I'd leave it as a separate commit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean that this shortcut is introduced in the previous commit and changed in this commit, so there is not really a point in separating them? You might as well introduce the shortcut correctly in the first commit? Also, this change (short 0 to 1) is currently in the " Fix concurrent access to menuItemsToClickAfterStartup" commit, where it does not belong at all AFAICS? So it should at least be moved into its own commit then.

Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() |
ActionEvent.SHIFT_MASK));
recentBoardsButtonGroup.add(item);
Expand Down Expand Up @@ -1513,18 +1513,14 @@ public void actionPerformed(ActionEvent actionevent) {
boardsCustomMenus.add(customMenu);
}

menuItemsToClickAfterStartup = new LinkedList<>();
List<JMenuItem> _menuItemsToClickAfterStartup = new LinkedList<>();
boardsButtonGroup = new ButtonGroup();
recentBoardsButtonGroup = new ButtonGroup();
buttonGroupsMap = new HashMap<>();

if (BaseNoGui.getRecentlyUsedBoards() != null) {
JMenuItem recentLabel = new JMenuItem(tr("Recently used boards"));
recentLabel.setEnabled(false);
boardMenu.add(recentLabel);
rebuildRecentBoardsMenu();
//rebuildRecentBoardsMenu(null);
}
JMenuItem recentLabel = new JMenuItem(tr("Recently used boards"));
recentLabel.setEnabled(false);
boardMenu.add(recentLabel);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This also seems like a change unrelated to the click after startup commit that is better squashed into the previous commit.


// Cycle through all packages
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
Expand All @@ -1546,7 +1542,7 @@ public void actionPerformed(ActionEvent actionevent) {
for (TargetBoard board : targetPlatform.getBoards().values()) {
if (board.getPreferences().get("hide") != null)
continue;
JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup,
JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, _menuItemsToClickAfterStartup,
buttonGroupsMap,
board, targetPlatform, targetPackage);
boardMenu.add(item);
Expand All @@ -1555,14 +1551,16 @@ public void actionPerformed(ActionEvent actionevent) {
}
}

if (menuItemsToClickAfterStartup.isEmpty()) {
menuItemsToClickAfterStartup.add(selectFirstEnabledMenuItem(boardMenu));
if (_menuItemsToClickAfterStartup.isEmpty()) {
_menuItemsToClickAfterStartup.add(selectFirstEnabledMenuItem(boardMenu));
}

for (JMenuItem menuItemToClick : menuItemsToClickAfterStartup) {
for (JMenuItem menuItemToClick : _menuItemsToClickAfterStartup) {
menuItemToClick.setSelected(true);
menuItemToClick.getAction().actionPerformed(new ActionEvent(this, -1, ""));
}

menuItemsToClickAfterStartup = _menuItemsToClickAfterStartup;
}

private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
Expand Down