Add setting to toggle draggable tabs

Draggable tabs in conjunction with alerts can cause tabs to freeze.
See https://bugs.openjdk.java.net/browse/JDK-8254676
This commit is contained in:
0xb00bface 2022-05-07 15:11:49 +02:00
parent 5c2c7f3477
commit 14f2626492
4 changed files with 24 additions and 14 deletions

View File

@ -2,6 +2,9 @@
======================== ========================
* Fix minimize to tray * Fix minimize to tray
* Save coonfig in a sub-directory for each version. * Save coonfig in a sub-directory for each version.
* Add setting to disable tab dragging, because that might be the cause for tab
freezes
* Fix thumbnails for Stripchat
4.7.5 4.7.5
======================== ========================

View File

@ -51,7 +51,6 @@ import javafx.geometry.Insets;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.*; import javafx.scene.control.*;
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;
@ -78,6 +77,8 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static ctbrec.event.Event.Type.*; import static ctbrec.event.Event.Type.*;
import static javafx.scene.control.TabPane.TabDragPolicy.FIXED;
import static javafx.scene.control.TabPane.TabDragPolicy.REORDER;
public class CamrecApplication extends Application { public class CamrecApplication extends Application {
@ -145,8 +146,8 @@ public class CamrecApplication extends Application {
if (Objects.equals("stage_restored", evt.get("event"))) { if (Objects.equals("stage_restored", evt.get("event"))) {
LOG.debug("Main stage restored"); LOG.debug("Main stage restored");
Platform.runLater(() -> { Platform.runLater(() -> {
if (tabPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener) { if (tabPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener listener) {
((TabSelectionListener) tabPane.getSelectionModel().getSelectedItem()).selected(); listener.selected();
} }
}); });
} }
@ -240,7 +241,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); tabPane.setTabDragPolicy(config.getSettings().tabsSortable ? REORDER : FIXED);
restoreTabOrder(); restoreTabOrder();
switchToStartTab(); switchToStartTab();
writeColorSchemeStyleSheet(); writeColorSchemeStyleSheet();
@ -289,7 +291,7 @@ public class CamrecApplication extends Application {
private void setWindowMinimizeListener(Stage primaryStage) { private void setWindowMinimizeListener(Stage primaryStage) {
primaryStage.iconifiedProperty().addListener((obs, oldV, newV) -> { primaryStage.iconifiedProperty().addListener((obs, oldV, newV) -> {
if (newV.booleanValue() && Config.getInstance().getSettings().minimizeToTray && primaryStage.isShowing()) { if (Boolean.TRUE.equals(newV) && Config.getInstance().getSettings().minimizeToTray && primaryStage.isShowing()) {
DesktopIntegration.minimizeToTray(primaryStage); DesktopIntegration.minimizeToTray(primaryStage);
suspendTabUpdates(); suspendTabUpdates();
} }
@ -299,11 +301,11 @@ public class CamrecApplication extends Application {
private void tabChanged(ObservableValue<?> ov, Tab from, Tab to) { private void tabChanged(ObservableValue<?> ov, Tab from, Tab to) {
try { try {
if (from instanceof TabSelectionListener) { if (from instanceof TabSelectionListener l) {
((TabSelectionListener) from).deselected(); l.deselected();
} }
if (to instanceof TabSelectionListener) { if (to instanceof TabSelectionListener l) {
((TabSelectionListener) to).selected(); l.selected();
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error switching tabs", e); LOG.error("Error switching tabs", e);
@ -359,8 +361,8 @@ public class CamrecApplication extends Application {
tabOrder.clear(); tabOrder.clear();
for (Tab tab : tabPane.getTabs()) { for (Tab tab : tabPane.getTabs()) {
tabOrder.add(tab.getText()); tabOrder.add(tab.getText());
if (tab instanceof ShutdownListener) { if (tab instanceof ShutdownListener l) {
((ShutdownListener) tab).onShutdown(); l.onShutdown();
} }
} }
onlineMonitor.shutdown(); onlineMonitor.shutdown();
@ -506,8 +508,8 @@ public class CamrecApplication extends Application {
} }
} }
} }
if (tabPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener) { if (tabPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener l) {
((TabSelectionListener) tabPane.getSelectionModel().getSelectedItem()).selected(); l.selected();
} }
} }
@ -611,6 +613,7 @@ public class CamrecApplication extends Application {
return html_url; return html_url;
} }
@SuppressWarnings("unused")
public void setHtmlUrl(String htmlUrl) { public void setHtmlUrl(String htmlUrl) {
this.html_url = htmlUrl; this.html_url = htmlUrl;
} }

View File

@ -116,6 +116,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private SimpleIntegerProperty playlistRequestTimeout; private SimpleIntegerProperty playlistRequestTimeout;
private SimpleBooleanProperty minimizeToTray; private SimpleBooleanProperty minimizeToTray;
private SimpleBooleanProperty showGridLinesInTables; private SimpleBooleanProperty showGridLinesInTables;
private SimpleBooleanProperty tabsSortable;
private SimpleIntegerProperty defaultPriority; private SimpleIntegerProperty defaultPriority;
private LocalTimeProperty timeoutRecordingStartingAt; private LocalTimeProperty timeoutRecordingStartingAt;
private LocalTimeProperty timeoutRecordingEndingAt; private LocalTimeProperty timeoutRecordingEndingAt;
@ -193,6 +194,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
timeoutRecordingEndingAt = new LocalTimeProperty(null, "timeoutRecordingEndingAt", settings.timeoutRecordingEndingAt); timeoutRecordingEndingAt = new LocalTimeProperty(null, "timeoutRecordingEndingAt", settings.timeoutRecordingEndingAt);
recordUntilDefaultDurationInMinutes = new SimpleLongProperty(null, "recordUntilDefaultDurationInMinutes", settings.recordUntilDefaultDurationInMinutes); recordUntilDefaultDurationInMinutes = new SimpleLongProperty(null, "recordUntilDefaultDurationInMinutes", settings.recordUntilDefaultDurationInMinutes);
dateTimeFormat = new SimpleStringProperty(null, "dateTimeFormat", settings.dateTimeFormat); dateTimeFormat = new SimpleStringProperty(null, "dateTimeFormat", settings.dateTimeFormat);
tabsSortable = new SimpleBooleanProperty(null, "tabsSortable", settings.tabsSortable);
} }
private void createGui() { private void createGui() {
@ -238,7 +240,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("Total model count in title", totalModelCountInTitle, "Show the total number of models in the title bar"), Setting.of("Total model count in title", totalModelCountInTitle, "Show the total number of models in the title bar"),
Setting.of("Show active recordings counter in tray", showActiveRecordingsInTray, "Show the number of running recorings in the tray icon"), Setting.of("Show active recordings counter in tray", showActiveRecordingsInTray, "Show the number of running recorings in the tray icon"),
Setting.of("Show grid lines in tables", showGridLinesInTables, "Show grid lines in tables").needsRestart(), Setting.of("Show grid lines in tables", showGridLinesInTables, "Show grid lines in tables").needsRestart(),
Setting.of("Fast scroll speed", fastScrollSpeed, "Makes the thumbnail overviews scroll faster with the mouse wheel").needsRestart())), Setting.of("Fast scroll speed", fastScrollSpeed, "Makes the thumbnail overviews scroll faster with the mouse wheel").needsRestart(),
Setting.of("Draggable tabs", tabsSortable, "Main tabs can be reordered").needsRestart())),
Category.of("Recorder", Category.of("Recorder",
Group.of("Recorder", Group.of("Recorder",
Setting.of("Recordings Directory", recordingsDir), Setting.of("Recordings Directory", recordingsDir),

View File

@ -185,6 +185,7 @@ public class Settings {
public String stripchatPassword = ""; public String stripchatPassword = "";
public boolean stripchatUseXhamster = false; public boolean stripchatUseXhamster = false;
public List<String> tabOrder = new ArrayList<>(); public List<String> tabOrder = new ArrayList<>();
public boolean tabsSortable = true;
public LocalTime timeoutRecordingStartingAt = LocalTime.of(0, 0); public LocalTime timeoutRecordingStartingAt = LocalTime.of(0, 0);
public LocalTime timeoutRecordingEndingAt = LocalTime.of(0, 0); public LocalTime timeoutRecordingEndingAt = LocalTime.of(0, 0);
public boolean totalModelCountInTitle = false; public boolean totalModelCountInTitle = false;