diff --git a/client/src/main/java/ctbrec/ui/CamrecApplication.java b/client/src/main/java/ctbrec/ui/CamrecApplication.java index 9a4e3eb1..537eed29 100644 --- a/client/src/main/java/ctbrec/ui/CamrecApplication.java +++ b/client/src/main/java/ctbrec/ui/CamrecApplication.java @@ -21,6 +21,7 @@ import com.squareup.moshi.Moshi; import com.squareup.moshi.Types; import ctbrec.Config; +import ctbrec.StringUtil; import ctbrec.Version; import ctbrec.io.HttpClient; import ctbrec.recorder.LocalRecorder; @@ -110,9 +111,6 @@ public class CamrecApplication extends Application { rootPane.getTabs().add(siteTab); } } - try { - ((SiteTab)rootPane.getTabs().get(0)).selected(); - } catch(ClassCastException | IndexOutOfBoundsException e) {} RecordedModelsTab modelsTab = new RecordedModelsTab("Recording", recorder, sites); rootPane.getTabs().add(modelsTab); @@ -122,6 +120,8 @@ public class CamrecApplication extends Application { rootPane.getTabs().add(settingsTab); rootPane.getTabs().add(new DonateTabFx()); + switchToStartTab(); + primaryStage.getScene().getStylesheets().add("/ctbrec/ui/ThumbCell.css"); primaryStage.getScene().widthProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowWidth = newVal.intValue()); primaryStage.getScene().heightProperty() @@ -184,6 +184,21 @@ public class CamrecApplication extends Application { }); } + private void switchToStartTab() { + String startTab = Config.getInstance().getSettings().startTab; + if(StringUtil.isNotBlank(startTab)) { + for (Tab tab : rootPane.getTabs()) { + if(Objects.equals(startTab, tab.getText())) { + rootPane.getSelectionModel().select(tab); + break; + } + } + } + if(rootPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener) { + ((TabSelectionListener)rootPane.getSelectionModel().getSelectedItem()).selected(); + } + } + private void createRecorder() { if (config.getSettings().localRecording) { recorder = new LocalRecorder(config); diff --git a/client/src/main/java/ctbrec/ui/SettingsTab.java b/client/src/main/java/ctbrec/ui/SettingsTab.java index ea3b47ea..11287e82 100644 --- a/client/src/main/java/ctbrec/ui/SettingsTab.java +++ b/client/src/main/java/ctbrec/ui/SettingsTab.java @@ -15,6 +15,7 @@ import ctbrec.Config; import ctbrec.Hmac; import ctbrec.Settings; import ctbrec.Settings.DirectoryStructure; +import ctbrec.StringUtil; import ctbrec.sites.ConfigUI; import ctbrec.sites.Site; import javafx.beans.value.ChangeListener; @@ -75,6 +76,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { private ComboBox maxResolution; private ComboBox splitAfter; private ComboBox directoryStructure; + private ComboBox startTab; private List sites; private Label restartLabel; private Accordion credentialsAccordion = new Accordion(); @@ -373,7 +375,17 @@ public class SettingsTab extends Tab implements TabSelectionListener { splitAfter.setOnAction((e) -> Config.getInstance().getSettings().splitRecordings = splitAfter.getSelectionModel().getSelectedItem().getValue()); GridPane.setMargin(l, new Insets(0, 0, 0, 0)); GridPane.setMargin(splitAfter, new Insets(0, 0, 0, CHECKBOX_MARGIN)); - maxResolution.prefWidthProperty().bind(splitAfter.widthProperty()); + + l = new Label("Start Tab"); + layout.add(l, 0, row); + startTab = new ComboBox<>(); + layout.add(startTab, 1, row++); + startTab.setOnAction((e) -> Config.getInstance().getSettings().startTab = startTab.getSelectionModel().getSelectedItem()); + GridPane.setMargin(l, new Insets(0, 0, 0, 0)); + GridPane.setMargin(startTab, new Insets(0, 0, 0, CHECKBOX_MARGIN)); + + splitAfter.prefWidthProperty().bind(startTab.widthProperty()); + maxResolution.prefWidthProperty().bind(startTab.widthProperty()); TitledPane general = new TitledPane("General", layout); general.setCollapsible(false); @@ -589,6 +601,14 @@ public class SettingsTab extends Tab implements TabSelectionListener { @Override public void selected() { + startTab.getItems().clear(); + for(Tab tab : getTabPane().getTabs()) { + startTab.getItems().add(tab.getText()); + } + String startTabName = Config.getInstance().getSettings().startTab; + if(StringUtil.isNotBlank(startTabName)) { + startTab.getSelectionModel().select(startTabName); + } } @Override diff --git a/common/src/main/java/ctbrec/Settings.java b/common/src/main/java/ctbrec/Settings.java index d3895b3c..e7ff8ceb 100644 --- a/common/src/main/java/ctbrec/Settings.java +++ b/common/src/main/java/ctbrec/Settings.java @@ -62,6 +62,7 @@ public class Settings { public String proxyPort; public String proxyUser; public String proxyPassword; + public String startTab = "Settings"; public int thumbWidth = 180; public boolean updateThumbnails = true; public int windowWidth = 1340;