fix: add menu item to reload all gamelist views (shift+F5)

This commit is contained in:
lantzelot-swe 2022-10-24 20:22:26 +02:00
parent 9a58494d2f
commit c5c426a34f
1 changed files with 23 additions and 3 deletions

View File

@ -85,6 +85,7 @@ public class MenuManager
private JMenuItem exportFLItem; private JMenuItem exportFLItem;
private JMenuItem exportSavedStatesItem; private JMenuItem exportSavedStatesItem;
private JMenuItem refreshItem; private JMenuItem refreshItem;
private JMenuItem refreshAllItem;
private JMenuItem toggleFavorite1Item; private JMenuItem toggleFavorite1Item;
private JMenuItem toggleFavorite2Item; private JMenuItem toggleFavorite2Item;
@ -199,6 +200,7 @@ public class MenuManager
fileMenu.add(exportMenu); fileMenu.add(exportMenu);
fileMenu.addSeparator(); fileMenu.addSeparator();
fileMenu.add(getRefreshItem()); fileMenu.add(getRefreshItem());
fileMenu.add(getRefreshAllItem());
fileMenu.addSeparator(); fileMenu.addSeparator();
fileMenu.add(getPreferencesMenuItem()); fileMenu.add(getPreferencesMenuItem());
fileMenu.addSeparator(); fileMenu.addSeparator();
@ -481,6 +483,16 @@ public class MenuManager
return refreshItem; return refreshItem;
} }
private JMenuItem getRefreshAllItem()
{
refreshAllItem = new JMenuItem("Reload all gamelist views");
KeyStroke keyStrokeToReloadGameViews = KeyStroke.getKeyStroke(KeyEvent.VK_F5, InputEvent.SHIFT_DOWN_MASK);
refreshAllItem.setAccelerator(keyStrokeToReloadGameViews);
refreshAllItem.setMnemonic('g');
refreshAllItem.addActionListener(e -> reloadAll());
return refreshAllItem;
}
private JMenuItem getExitItem() private JMenuItem getExitItem()
{ {
exitItem = new JMenuItem("Exit"); exitItem = new JMenuItem("Exit");
@ -776,7 +788,8 @@ public class MenuManager
editViewTagItem.addActionListener(e -> { editViewTagItem.addActionListener(e -> {
if (!mainWindow.getMainPanel().isNoGameSelected()) if (!mainWindow.getMainPanel().isNoGameSelected())
{ {
String initialValue = mainWindow.getMainPanel().isSingleGameSelected() ? uiModel.getInfoModel().getViewTag() : ""; String initialValue =
mainWindow.getMainPanel().isSingleGameSelected() ? uiModel.getInfoModel().getViewTag() : "";
String message = mainWindow.getMainPanel().isSingleGameSelected() String message = mainWindow.getMainPanel().isSingleGameSelected()
? "Enter the view tag to set for " + uiModel.getInfoModel().getTitle() ? "Enter the view tag to set for " + uiModel.getInfoModel().getTitle()
: "Enter the view tag to set for the selected games"; : "Enter the view tag to set for the selected games";
@ -815,7 +828,7 @@ public class MenuManager
deleteAllGamesItem.addActionListener(e -> deleteAllGames()); deleteAllGamesItem.addActionListener(e -> deleteAllGames());
return deleteAllGamesItem; return deleteAllGamesItem;
} }
private JMenuItem getDeleteAllGameViewsItem() private JMenuItem getDeleteAllGameViewsItem()
{ {
deleteAllGameViewsItem = new JMenuItem("Delete all gamelist views in database"); deleteAllGameViewsItem = new JMenuItem("Delete all gamelist views in database");
@ -1201,6 +1214,13 @@ public class MenuManager
this.mainWindow.reloadCurrentGameView(); this.mainWindow.reloadCurrentGameView();
} }
private void reloadAll()
{
//Refresh game views
uiModel.reloadGameViews();
this.mainWindow.refreshMenuAndUI();
}
private void backupDb() private void backupDb()
{ {
BackupProgressDialog dialog = new BackupProgressDialog(this.mainWindow); BackupProgressDialog dialog = new BackupProgressDialog(this.mainWindow);
@ -1241,7 +1261,7 @@ public class MenuManager
startDeleteProgress(TYPE_OF_DELETE.ALL); startDeleteProgress(TYPE_OF_DELETE.ALL);
} }
} }
private void deleteAllGamelistViews() private void deleteAllGamelistViews()
{ {
DeleteDialog dialog = new DeleteDialog(TYPE_OF_DELETE.ALL_VIEWS); DeleteDialog dialog = new DeleteDialog(TYPE_OF_DELETE.ALL_VIEWS);