forked from j62/ctbrec
1
0
Fork 0

Make main tabs rearrangable

This commit is contained in:
0xb00bface 2021-08-21 18:49:30 +02:00
parent 74e70074ba
commit 8517b7e8ad
3 changed files with 28 additions and 2 deletions

View File

@ -1,3 +1,7 @@
4.5.1
========================
* Main tabs can now be rearranged
4.5.0 4.5.0
======================== ========================
* Added portrait column to Recording tab. The image to show can be selected in * Added portrait column to Recording tab. The image to show can be selected in

View File

@ -81,6 +81,7 @@ import javafx.scene.control.ButtonType;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
import javafx.scene.control.TabPane.TabDragPolicy;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
@ -243,7 +244,8 @@ public class CamrecApplication extends Application {
tabPane.getTabs().add(new DonateTabFx()); tabPane.getTabs().add(new DonateTabFx());
tabPane.getTabs().add(new HelpTab()); tabPane.getTabs().add(new HelpTab());
tabPane.getTabs().add(new LoggingTab()); tabPane.getTabs().add(new LoggingTab());
tabPane.setTabDragPolicy(TabDragPolicy.REORDER);
restoreTabOrder();
switchToStartTab(); switchToStartTab();
writeColorSchemeStyleSheet(); writeColorSchemeStyleSheet();
var base = Color.web(Config.getInstance().getSettings().colorBase); var base = Color.web(Config.getInstance().getSettings().colorBase);
@ -346,10 +348,12 @@ public class CamrecApplication extends Application {
shutdownInfo.setTitle("Shutdown"); shutdownInfo.setTitle("Shutdown");
shutdownInfo.setContentText("Shutting down. Please wait while recordings are finished..."); shutdownInfo.setContentText("Shutting down. Please wait while recordings are finished...");
shutdownInfo.show(); shutdownInfo.show();
final boolean immediately = shutdownNow; final boolean immediately = shutdownNow;
new Thread(() -> { new Thread(() -> {
List<String> tabOrder = Config.getInstance().getSettings().tabOrder;
tabOrder.clear();
for (Tab tab : tabPane.getTabs()) { for (Tab tab : tabPane.getTabs()) {
tabOrder.add(tab.getText());
if (tab instanceof ShutdownListener) { if (tab instanceof ShutdownListener) {
((ShutdownListener) tab).onShutdown(); ((ShutdownListener) tab).onShutdown();
} }
@ -469,6 +473,23 @@ public class CamrecApplication extends Application {
} }
} }
private void restoreTabOrder() {
List<String> tabOrder = Config.getInstance().getSettings().tabOrder;
for (int i = 0; i < tabOrder.size(); i++) {
Tab matched = null;
for (Tab tab : tabPane.getTabs()) {
if (Objects.equals(tabOrder.get(i), tab.getText())) {
matched = tab;
}
}
if (matched != null) {
tabPane.getTabs().remove(matched);
int max = tabPane.getTabs().size();
tabPane.getTabs().add(Math.min(i, max), matched);
}
}
}
private void switchToStartTab() { private void switchToStartTab() {
String startTab = Config.getInstance().getSettings().startTab; String startTab = Config.getInstance().getSettings().startTab;
if (StringUtil.isNotBlank(startTab)) { if (StringUtil.isNotBlank(startTab)) {

View File

@ -172,6 +172,7 @@ public class Settings {
public String stripchatUsername = ""; public String stripchatUsername = "";
public String stripchatPassword = ""; public String stripchatPassword = "";
public boolean stripchatUseXhamster = false; public boolean stripchatUseXhamster = false;
public List<String> tabOrder = new ArrayList<>();
public boolean totalModelCountInTitle = false; public boolean totalModelCountInTitle = false;
public boolean transportLayerSecurity = true; public boolean transportLayerSecurity = true;
public int thumbWidth = 180; public int thumbWidth = 180;