2020-06-08 10:36:30 +02:00
|
|
|
package envoy.client.ui.controller;
|
2020-04-10 21:52:19 +02:00
|
|
|
|
2020-10-12 16:12:23 +02:00
|
|
|
import java.util.Map;
|
|
|
|
|
2020-04-18 11:03:06 +02:00
|
|
|
import javafx.fxml.FXML;
|
2020-09-25 14:29:23 +02:00
|
|
|
import javafx.scene.control.*;
|
2020-10-12 16:12:23 +02:00
|
|
|
import javafx.scene.input.*;
|
2020-04-18 11:03:06 +02:00
|
|
|
|
2020-09-01 20:14:02 +02:00
|
|
|
import envoy.client.data.Context;
|
2020-10-12 16:12:23 +02:00
|
|
|
import envoy.client.data.shortcuts.KeyboardMapping;
|
2020-09-25 14:29:23 +02:00
|
|
|
import envoy.client.ui.listcell.ListCellFactory;
|
2020-08-01 09:43:15 +02:00
|
|
|
import envoy.client.ui.settings.*;
|
2020-04-19 19:57:40 +02:00
|
|
|
|
2020-04-10 21:52:19 +02:00
|
|
|
/**
|
2020-09-25 14:29:23 +02:00
|
|
|
* Controller for the settings scene.
|
2020-04-18 19:46:04 +02:00
|
|
|
*
|
2020-04-10 21:52:19 +02:00
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Client v0.1-beta
|
|
|
|
*/
|
2020-10-12 16:12:23 +02:00
|
|
|
public final class SettingsScene implements KeyboardMapping {
|
2020-04-10 21:52:19 +02:00
|
|
|
|
2020-04-18 11:03:06 +02:00
|
|
|
@FXML
|
2020-06-06 18:30:09 +02:00
|
|
|
private ListView<SettingsPane> settingsList;
|
2020-04-18 11:03:06 +02:00
|
|
|
|
|
|
|
@FXML
|
|
|
|
private TitledPane titledPane;
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
private void initialize() {
|
2020-09-25 14:29:23 +02:00
|
|
|
settingsList.setCellFactory(new ListCellFactory<>(pane -> new Label(pane.getTitle())));
|
2020-10-19 18:17:51 +02:00
|
|
|
settingsList.getItems().addAll(new GeneralSettingsPane(), new UserSettingsPane(),
|
|
|
|
new DownloadSettingsPane(), new BugReportPane());
|
2020-04-18 11:03:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
private void settingsListClicked() {
|
|
|
|
final var pane = settingsList.getSelectionModel().getSelectedItem();
|
2020-04-18 21:37:44 +02:00
|
|
|
if (pane != null) {
|
|
|
|
titledPane.setText(pane.getTitle());
|
|
|
|
titledPane.setContent(pane);
|
|
|
|
}
|
2020-04-18 11:03:06 +02:00
|
|
|
}
|
2020-04-18 19:46:04 +02:00
|
|
|
|
|
|
|
@FXML
|
2020-10-19 18:17:51 +02:00
|
|
|
private void backButtonClicked() {
|
|
|
|
Context.getInstance().getSceneContext().pop();
|
|
|
|
}
|
2020-10-12 16:12:23 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<KeyCombination, Runnable> getKeyboardShortcuts() {
|
2020-10-19 18:17:51 +02:00
|
|
|
return Map.of(new KeyCodeCombination(KeyCode.B, KeyCombination.CONTROL_DOWN),
|
|
|
|
this::backButtonClicked);
|
2020-10-12 16:12:23 +02:00
|
|
|
}
|
2020-04-10 21:52:19 +02:00
|
|
|
}
|