Move Help/Donate to Settings side menu
This commit is contained in:
parent
d2fc18faf1
commit
97c6d5d915
|
@ -256,8 +256,6 @@ public class CamrecApplication extends Application {
|
||||||
tabPane.getTabs().add(new RecentlyWatchedTab(recorder, sites));
|
tabPane.getTabs().add(new RecentlyWatchedTab(recorder, sites));
|
||||||
}
|
}
|
||||||
tabPane.getTabs().add(new SettingsTab(sites, recorder));
|
tabPane.getTabs().add(new SettingsTab(sites, recorder));
|
||||||
tabPane.getTabs().add(new DonateTabFx());
|
|
||||||
tabPane.getTabs().add(new HelpTab());
|
|
||||||
tabPane.setTabDragPolicy(config.getSettings().tabsSortable ? REORDER : FIXED);
|
tabPane.setTabDragPolicy(config.getSettings().tabsSortable ? REORDER : FIXED);
|
||||||
|
|
||||||
restoreTabOrder();
|
restoreTabOrder();
|
||||||
|
|
|
@ -15,6 +15,8 @@ import ctbrec.ui.SiteUiFactory;
|
||||||
import ctbrec.ui.controls.range.DiscreteRange;
|
import ctbrec.ui.controls.range.DiscreteRange;
|
||||||
import ctbrec.ui.settings.api.*;
|
import ctbrec.ui.settings.api.*;
|
||||||
import ctbrec.ui.sites.ConfigUI;
|
import ctbrec.ui.sites.ConfigUI;
|
||||||
|
import ctbrec.ui.tabs.HelpTab;
|
||||||
|
import ctbrec.ui.tabs.DonateTabFx;
|
||||||
import ctbrec.ui.tabs.TabSelectionListener;
|
import ctbrec.ui.tabs.TabSelectionListener;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.animation.PauseTransition;
|
import javafx.animation.PauseTransition;
|
||||||
|
@ -332,7 +334,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
Setting.of("", ignoreList)),
|
Setting.of("", ignoreList)),
|
||||||
Group.of("Text Filters",
|
Group.of("Text Filters",
|
||||||
Setting.of("Blacklist", filterBlacklist, "Default list of blacklist filters for site views, space seperated"),
|
Setting.of("Blacklist", filterBlacklist, "Default list of blacklist filters for site views, space seperated"),
|
||||||
Setting.of("Whitelist", filterWhitelist, "Default list of whitelist filters for site views, space seperated"))), Category.of("Sites", siteCategories.toArray(new Category[0])),
|
Setting.of("Whitelist", filterWhitelist, "Default list of whitelist filters for site views, space seperated"))),
|
||||||
|
Category.of("Sites", siteCategories.toArray(new Category[0])),
|
||||||
Category.of("Proxy",
|
Category.of("Proxy",
|
||||||
Group.of("Proxy",
|
Group.of("Proxy",
|
||||||
Setting.of("Type", proxyType).needsRestart(),
|
Setting.of("Type", proxyType).needsRestart(),
|
||||||
|
@ -364,7 +367,9 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
Setting.of("Log hlsdl output", loghlsdlOutput, "Log hlsdl output to files in the system's temp directory")),
|
Setting.of("Log hlsdl output", loghlsdlOutput, "Log hlsdl output to files in the system's temp directory")),
|
||||||
Group.of("Miscelaneous",
|
Group.of("Miscelaneous",
|
||||||
Setting.of("Config file saving delay (ms)", configSavingDelayMs,
|
Setting.of("Config file saving delay (ms)", configSavingDelayMs,
|
||||||
"Wait specified number of milliseconds before actually writing config to disk"))));
|
"Wait specified number of milliseconds before actually writing config to disk"))),
|
||||||
|
Category.of("Donate", (new DonateTabFx()).getContent()),
|
||||||
|
Category.of("Help", (new HelpTab()).getContent()));
|
||||||
Region preferencesView = prefs.getView();
|
Region preferencesView = prefs.getView();
|
||||||
prefs.onRestartRequired(this::showRestartRequired);
|
prefs.onRestartRequired(this::showRestartRequired);
|
||||||
storage.setPreferences(prefs);
|
storage.setPreferences(prefs);
|
||||||
|
|
|
@ -4,46 +4,91 @@ import ctbrec.docs.DocServer;
|
||||||
import ctbrec.ui.DesktopIntegration;
|
import ctbrec.ui.DesktopIntegration;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.awt.Desktop;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class HelpTab extends Tab {
|
public class HelpTab extends Tab {
|
||||||
|
|
||||||
|
private boolean serverStarted = false;
|
||||||
|
|
||||||
public HelpTab() {
|
public HelpTab() {
|
||||||
setClosable(true);
|
setClosable(false);
|
||||||
setText("Help");
|
setText("Help");
|
||||||
|
|
||||||
var openHelp = new Button("Open Help");
|
Button openHelp = new Button("Open Help");
|
||||||
|
Button openLog = new Button("Open Log File");
|
||||||
openHelp.setPadding(new Insets(20));
|
openHelp.setPadding(new Insets(20));
|
||||||
var layout = new BorderPane(openHelp);
|
openLog.setPadding(new Insets(20));
|
||||||
BorderPane.setMargin(openHelp, new Insets(20));
|
Label logFilePathLabel = new Label("Log: " + new File("ctbrec.log").getAbsolutePath());
|
||||||
|
|
||||||
|
VBox vbox = new VBox();
|
||||||
|
vbox.setAlignment(Pos.CENTER); // Center align the buttons
|
||||||
|
vbox.setSpacing(20); // Set a 20 pixel gap between the buttons
|
||||||
|
vbox.getChildren().addAll(openHelp, openLog, logFilePathLabel);
|
||||||
|
|
||||||
|
BorderPane layout = new BorderPane();
|
||||||
|
|
||||||
|
// Add the VBox to the center region of the BorderPane
|
||||||
|
layout.setCenter(vbox);
|
||||||
|
|
||||||
setContent(layout);
|
setContent(layout);
|
||||||
AtomicBoolean started = new AtomicBoolean(false);
|
|
||||||
openHelp.setOnAction(e -> {
|
openHelp.setOnAction(e -> {
|
||||||
synchronized (started) {
|
if (!serverStarted) {
|
||||||
if (!started.get()) {
|
startDocumentationServer();
|
||||||
|
} else {
|
||||||
|
openDocumentationPage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
openLog.setOnAction(e -> {
|
||||||
|
File logFile = new File("ctbrec.log");
|
||||||
|
if (logFile.exists()) {
|
||||||
|
try {
|
||||||
|
// Use Runtime.getRuntime().exec() to open the file in a separate process
|
||||||
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
|
ProcessBuilder pb = null;
|
||||||
|
if (osName.contains("mac")) {
|
||||||
|
pb = new ProcessBuilder("open", logFile.getAbsolutePath());
|
||||||
|
} else if (osName.contains("win")) {
|
||||||
|
pb = new ProcessBuilder("explorer.exe", logFile.getAbsolutePath());
|
||||||
|
} else { // Assume it's a Unix/Linux system
|
||||||
|
pb = new ProcessBuilder("xdg-open", logFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
pb.start();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.error("Couldn't open log file", ex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("Log file doesn't exist: {}", logFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startDocumentationServer() {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
DocServer.start(() ->
|
DocServer.start(() -> Platform.runLater(() -> {
|
||||||
Platform.runLater(() -> {
|
serverStarted = true;
|
||||||
started.set(true);
|
openDocumentationPage();
|
||||||
DesktopIntegration.open("http://localhost:5689/docs/index.md");
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Couldn't start documentation server", ex);
|
log.error("Couldn't start documentation server", ex);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
private void openDocumentationPage() {
|
||||||
DesktopIntegration.open("http://localhost:5689/docs/index.md");
|
DesktopIntegration.open("http://localhost:5689/docs/index.md");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue