feat: New menu option to reload current game view with F5
Useful when adding a game to get the view sorted properly afterwards.
This commit is contained in:
parent
3cdc01c922
commit
88c96d5625
|
@ -421,4 +421,14 @@ public class ListPanel extends JPanel
|
|||
mainPanel.repaintAfterModifications();
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadCurrentGameView()
|
||||
{
|
||||
GameListData selectedData = getList().getSelectedValue();
|
||||
getList().clearSelection();
|
||||
uiModel.reloadCurrentGameView();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
getList().setSelectedValue(selectedData, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,4 +167,9 @@ public class MainPanel extends JPanel
|
|||
{
|
||||
getGameDetailsBackgroundPanel().getInfoBackgroundPanel().selectEnDescriptionTab();
|
||||
}
|
||||
|
||||
public void reloadCurrentGameView()
|
||||
{
|
||||
getListPanel().reloadCurrentGameView();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,11 @@ public final class MainWindow extends JFrame
|
|||
return menuBar;
|
||||
}
|
||||
|
||||
public void reloadCurrentGameView()
|
||||
{
|
||||
getMainPanel().reloadCurrentGameView();
|
||||
}
|
||||
|
||||
public void repaintAfterModifications()
|
||||
{
|
||||
getMainPanel().repaintAfterModifications();
|
||||
|
|
|
@ -50,7 +50,8 @@ public class MenuManager
|
|||
private JMenuItem runGameItem;
|
||||
private JMenuItem importItem;
|
||||
private JMenuItem exportItem;
|
||||
|
||||
private JMenuItem refreshItem;
|
||||
|
||||
private JMenuItem toggleFavoriteItem;
|
||||
private JMenuItem clearFavoritesItem;
|
||||
|
||||
|
@ -100,6 +101,8 @@ public class MenuManager
|
|||
fileMenu.add(getImportItem());
|
||||
fileMenu.add(getExportItem());
|
||||
fileMenu.addSeparator();
|
||||
fileMenu.add(getRefreshItem());
|
||||
fileMenu.addSeparator();
|
||||
fileMenu.add(getExitItem());
|
||||
editMenu = new JMenu("Edit");
|
||||
editMenu.add(getToggleFavoriteItem());
|
||||
|
@ -127,6 +130,7 @@ public class MenuManager
|
|||
exportItem.setEnabled(okToEnable);
|
||||
toggleFavoriteItem.setEnabled(okToEnable);
|
||||
runGameItem.setEnabled(!uiModel.getInfoModel().getGamesFile().isEmpty());
|
||||
refreshItem.setEnabled(okToEnable);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -200,6 +204,16 @@ public class MenuManager
|
|||
exportItem.addActionListener(e -> exportGames());
|
||||
return exportItem;
|
||||
}
|
||||
|
||||
private JMenuItem getRefreshItem()
|
||||
{
|
||||
refreshItem = new JMenuItem("Reload current game view");
|
||||
KeyStroke keyStrokeToReloadGameView = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0);
|
||||
refreshItem.setAccelerator(keyStrokeToReloadGameView);
|
||||
refreshItem.setMnemonic('G');
|
||||
refreshItem.addActionListener(e -> reloadView());
|
||||
return refreshItem;
|
||||
}
|
||||
|
||||
private JMenuItem getExitItem()
|
||||
{
|
||||
|
@ -363,6 +377,11 @@ public class MenuManager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadView()
|
||||
{
|
||||
this.mainWindow.reloadCurrentGameView();
|
||||
}
|
||||
|
||||
private void backupDb()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue