keyboard shortcuts

This commit is contained in:
aj 2019-05-23 14:12:52 +01:00
parent 4ff50048e0
commit 2ca1930615
2 changed files with 55 additions and 12 deletions

View File

@ -193,10 +193,18 @@ public class RootController {
refresh(); refresh();
} }
// if (event.getCode() == KeyCode.Q && event.isControlDown()) { if (event.getCode() == KeyCode.W && event.isControlDown()) {
// System.out.println("control q"); closeCurrentTab();
// }
// }
if (event.getCode() == KeyCode.TAB && event.isControlDown()) {
if (event.isShiftDown()) {
tabPane.getSelectionModel().selectPrevious();
} else {
tabPane.getSelectionModel().selectNext();
}
}
} }
@FXML @FXML
@ -453,6 +461,22 @@ public class RootController {
addTab(new ConsoleTab()); addTab(new ConsoleTab());
} }
public void closeCurrentTab() {
SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
Tab tab = selectionModel.getSelectedItem();
if (tab.isClosable()) {
EventHandler<Event> handler = tab.getOnClosed();
if (handler != null) {
handler.handle(null);
} else {
tabPane.getTabs().remove(tab);
}
}
}
@FXML @FXML
protected void handleGenrePieTab(ActionEvent event) { protected void handleGenrePieTab(ActionEvent event) {
addTab(new GenrePieChartTab()); addTab(new GenrePieChartTab());

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.input.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?> <?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
@ -12,16 +13,31 @@
<menus> <menus>
<Menu fx:id="menuFile" mnemonicParsing="false" text="file"> <Menu fx:id="menuFile" mnemonicParsing="false" text="file">
<items> <items>
<MenuItem fx:id="menuItemCreateList" mnemonicParsing="false" onAction="#handleCreateList" text="new list" /> <MenuItem fx:id="menuItemCreateList" mnemonicParsing="false" onAction="#handleCreateList" text="new list">
<MenuItem fx:id="menuItemListEdit" mnemonicParsing="false" onAction="#handleListEdit" text="open list" /> <accelerator>
<KeyCodeCombination alt="UP" code="N" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
<MenuItem fx:id="menuItemListEdit" mnemonicParsing="false" onAction="#handleListEdit" text="open list">
<accelerator>
<KeyCodeCombination alt="UP" code="O" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
</items> </items>
</Menu> </Menu>
<Menu fx:id="menuLookup" mnemonicParsing="false" text="lookup"> <Menu fx:id="menuLookup" mnemonicParsing="false" text="lookup">
<items> <items>
<MenuItem fx:id="menuItemCurrentTrack" mnemonicParsing="false" onAction="#handleCurrentTrack" text="current track" /> <MenuItem fx:id="menuItemCurrentTrack" mnemonicParsing="false" onAction="#handleCurrentTrack" text="current track" />
<MenuItem fx:id="menuItemTrack" mnemonicParsing="false" onAction="#handleLookupTrack" text="track" /> <MenuItem fx:id="menuItemTrack" mnemonicParsing="false" onAction="#handleLookupTrack" text="track">
<MenuItem fx:id="menuItemAlbum" mnemonicParsing="false" onAction="#handleLookupAlbum" text="album" /> <accelerator>
<MenuItem fx:id="menuItemArtist" mnemonicParsing="false" onAction="#handleLookupArtist" text="artist" /> <KeyCodeCombination alt="DOWN" code="T" control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
<MenuItem fx:id="menuItemAlbum" mnemonicParsing="false" onAction="#handleLookupAlbum" text="album">
<accelerator>
<KeyCodeCombination alt="DOWN" code="A" control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
<MenuItem fx:id="menuItemArtist" mnemonicParsing="false" onAction="#handleLookupArtist" text="artist">
<accelerator>
<KeyCodeCombination alt="DOWN" code="R" control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
</items> </items>
</Menu> </Menu>
<Menu fx:id="menuChart" mnemonicParsing="false" text="chart"> <Menu fx:id="menuChart" mnemonicParsing="false" text="chart">
@ -35,7 +51,10 @@
<items> <items>
<MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" /> <MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" />
<MenuItem fx:id="menuItemAuth" mnemonicParsing="false" onAction="#handleAuth" text="authenticate" /> <MenuItem fx:id="menuItemAuth" mnemonicParsing="false" onAction="#handleAuth" text="authenticate" />
<MenuItem fx:id="menuItemOpenConsole" mnemonicParsing="false" onAction="#handleOpenConsole" text="open console" /> <MenuItem fx:id="menuItemOpenConsole" mnemonicParsing="false" onAction="#handleOpenConsole" text="open console">
<accelerator>
<KeyCodeCombination alt="DOWN" code="C" control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
<MenuItem mnemonicParsing="false" onAction="#handleChangeUsername" text="set username" /> <MenuItem mnemonicParsing="false" onAction="#handleChangeUsername" text="set username" />
<MenuItem fx:id="menuItemPrintConfig" mnemonicParsing="false" onAction="#handlePrintConfig" text="print config" /> <MenuItem fx:id="menuItemPrintConfig" mnemonicParsing="false" onAction="#handlePrintConfig" text="print config" />
<MenuItem fx:id="menuItemDumpCache" mnemonicParsing="false" onAction="#handleDumpCache" text="dump cache" /> <MenuItem fx:id="menuItemDumpCache" mnemonicParsing="false" onAction="#handleDumpCache" text="dump cache" />