Split about page in settings

This commit is contained in:
crschnick 2023-06-22 17:47:31 +00:00
parent 29de7cddd2
commit 8261f6f7ec
9 changed files with 163 additions and 120 deletions

View file

@ -38,7 +38,7 @@ public class BrowserWelcomeComp extends SimpleComp {
vbox.setPadding(new Insets(40, 40, 40, 50));
vbox.setSpacing(18);
if (state == null) {
var header = new Label("Have fun with the file browser!");
var header = new Label("Here you will be able to see were you left off last time you exited XPipe.");
AppFont.header(header);
vbox.getChildren().add(header);
return vbox;

View file

@ -2,19 +2,12 @@ package io.xpipe.app.prefs;
import io.xpipe.app.comp.base.TileButtonComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLogs;
import io.xpipe.app.core.AppWindowHelper;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.impl.VerticalComp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.UserReportComp;
import io.xpipe.app.util.*;
import io.xpipe.core.impl.FileNames;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.util.XPipeInstallation;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.OptionsBuilder;
import javafx.geometry.Insets;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Region;
@ -28,73 +21,6 @@ public class AboutComp extends Comp<CompStructure<?>> {
return deps;
}
private Comp<?> createActions() {
return new OptionsBuilder()
.addComp(
new TileButtonComp("reportIssue", "reportIssueDescription", "mdal-bug_report", e -> {
var event = ErrorEvent.fromMessage("User Report");
if (AppLogs.get().isWriteToFile()) {
event.attachment(AppLogs.get().getSessionLogsDirectory());
}
UserReportComp.show(event.build());
e.consume();
})
.grow(true, false),
null)
.addComp(
new TileButtonComp(
"launchDebugMode", "launchDebugModeDescription", "mdmz-refresh", e -> {
OperationMode.executeAfterShutdown(() -> {
try (var sc = ShellStore.createLocal()
.control()
.start()) {
var script = FileNames.join(
XPipeInstallation.getCurrentInstallationBasePath()
.toString(),
XPipeInstallation.getDaemonDebugScriptPath(sc.getOsType()));
if (sc.getOsType().equals(OsType.WINDOWS)) {
sc.executeSimpleCommand(ScriptHelper.createDetachCommand(
sc, "\"" + script + "\""));
} else {
TerminalHelper.open("XPipe Debug", "\"" + script + "\"");
}
}
});
DesktopHelper.browsePath(
AppLogs.get().getSessionLogsDirectory());
e.consume();
})
.grow(true, false),
null)
.addComp(
new TileButtonComp(
"openCurrentLogFile",
"openCurrentLogFileDescription",
"mdmz-text_snippet",
e -> {
FileOpener.openInTextEditor(AppLogs.get()
.getSessionLogsDirectory()
.resolve("xpipe.log")
.toString());
e.consume();
})
.grow(true, false),
null)
.addComp(
new TileButtonComp(
"openInstallationDirectory",
"openInstallationDirectoryDescription",
"mdomz-snippet_folder",
e -> {
DesktopHelper.browsePath(
XPipeInstallation.getCurrentInstallationBasePath());
e.consume();
})
.grow(true, false),
null)
.buildComp();
}
private Comp<?> createLinks() {
return new OptionsBuilder()
.addComp(
@ -119,31 +45,29 @@ public class AboutComp extends Comp<CompStructure<?>> {
.grow(true, false),
null)
.addComp(
new TileButtonComp(
"securityPolicy", "securityPolicyDescription", "mdrmz-security", e -> {
Hyperlinks.open(Hyperlinks.SECURITY);
e.consume();
})
new TileButtonComp("securityPolicy", "securityPolicyDescription", "mdrmz-security", e -> {
Hyperlinks.open(Hyperlinks.SECURITY);
e.consume();
})
.grow(true, false),
null)
.addComp(
new TileButtonComp("privacy", "privacyDescription", "mdomz-privacy_tip", e -> {
Hyperlinks.open(Hyperlinks.PRIVACY);
e.consume();
})
Hyperlinks.open(Hyperlinks.PRIVACY);
e.consume();
})
.grow(true, false),
null)
.addComp(
new TileButtonComp(
"thirdParty", "thirdPartyDescription", "mdi2o-open-source-initiative", e -> {
AppWindowHelper.sideWindow(
AppI18n.get("openSourceNotices"),
stage -> Comp.of(() -> createThirdPartyDeps()),
true,
null)
.show();
e.consume();
})
new TileButtonComp("thirdParty", "thirdPartyDescription", "mdi2o-open-source-initiative", e -> {
AppWindowHelper.sideWindow(
AppI18n.get("openSourceNotices"),
stage -> Comp.of(() -> createThirdPartyDeps()),
true,
null)
.show();
e.consume();
})
.grow(true, false),
null)
.buildComp();
@ -163,7 +87,7 @@ public class AboutComp extends Comp<CompStructure<?>> {
public CompStructure<?> createBase() {
var props = new PropertiesComp().padding(new Insets(0, 0, 0, 15));
var update = new UpdateCheckComp().grow(true, false);
var box = new VerticalComp(List.of(props, Comp.separator(), update, Comp.separator(), createLinks(), Comp.separator(), createActions()))
var box = new VerticalComp(List.of(props, Comp.separator(), update, Comp.separator(), createLinks()))
.apply(s -> s.get().setFillWidth(true))
.apply(struc -> struc.get().setSpacing(15))
.styleClass("information")

View file

@ -497,10 +497,12 @@ public class AppPrefs {
private AppPreferencesFx createPreferences() {
var ctr = Setting.class.getDeclaredConstructor(String.class, Element.class, Property.class);
ctr.setAccessible(true);
var s = ctr.newInstance(null, new LazyNodeElement<>(() -> new AboutComp().createRegion()), null);
var about = ctr.newInstance(null, new LazyNodeElement<>(() -> new AboutComp().createRegion()), null);
var troubleshoot = ctr.newInstance(null, new LazyNodeElement<>(() -> new TroubleshootComp().createRegion()), null);
var categories = new ArrayList<>(List.of(
Category.of("application", Group.of(s)),
Category.of("about", Group.of(about)),
Category.of("troubleshoot", Group.of(troubleshoot)),
Category.of(
"system",
Group.of(

View file

@ -1,13 +1,8 @@
package io.xpipe.app.prefs;
import io.xpipe.app.comp.AppLayoutComp;
import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.fxcomps.SimpleComp;
import javafx.geometry.Pos;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import org.controlsfx.control.MasterDetailPane;
@ -31,18 +26,7 @@ public class PrefsComp extends SimpleComp {
MasterDetailPane p = (MasterDetailPane) pfx.getCenter();
p.dividerPositionProperty().setValue(0.27);
var clearCaches = new ButtonComp(AppI18n.observable("clearCaches"), null, ClearCacheAlert::show).createRegion();
// var reload = new ButtonComp(AppI18n.observable("reload"), null, () -> OperationMode.reload()).createRegion();
var leftButtons = new HBox(clearCaches);
leftButtons.setAlignment(Pos.CENTER);
leftButtons.prefWidthProperty().bind(((Region) p.getDetailNode()).widthProperty());
var leftPane = new AnchorPane(leftButtons);
leftPane.setPickOnBounds(false);
AnchorPane.setBottomAnchor(leftButtons, 15.0);
AnchorPane.setLeftAnchor(leftButtons, 15.0);
var stack = new StackPane(pfx, leftPane);
var stack = new StackPane(pfx);
stack.setPickOnBounds(false);
AppFont.medium(stack);

View file

@ -0,0 +1,126 @@
package io.xpipe.app.prefs;
import io.xpipe.app.comp.base.TileButtonComp;
import io.xpipe.app.core.AppLogs;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.impl.VerticalComp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.UserReportComp;
import io.xpipe.app.util.*;
import io.xpipe.core.impl.FileNames;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.util.XPipeInstallation;
import java.util.List;
public class TroubleshootComp extends Comp<CompStructure<?>> {
private Comp<?> createActions() {
return new OptionsBuilder()
.addTitle("troubleshootingOptions")
.spacer(13)
.addComp(
new TileButtonComp("reportIssue", "reportIssueDescription", "mdal-bug_report", e -> {
var event = ErrorEvent.fromMessage("User Report");
if (AppLogs.get().isWriteToFile()) {
event.attachment(AppLogs.get().getSessionLogsDirectory());
}
UserReportComp.show(event.build());
e.consume();
})
.grow(true, false),
null)
.separator()
.addComp(
new TileButtonComp("restart", "restartDescription", "mdmz-refresh", e -> {
OperationMode.executeAfterShutdown(() -> {
try (var sc = ShellStore.createLocal()
.control()
.start()) {
var script = FileNames.join(
XPipeInstallation.getCurrentInstallationBasePath()
.toString(),
XPipeInstallation.getDaemonExecutablePath(sc.getOsType()));
sc.executeSimpleCommand(
ScriptHelper.createDetachCommand(sc, "\"" + script + "\""));
}
});
e.consume();
})
.grow(true, false),
null)
.separator()
.addComp(
new TileButtonComp("launchDebugMode", "launchDebugModeDescription", "mdmz-refresh", e -> {
OperationMode.executeAfterShutdown(() -> {
try (var sc = ShellStore.createLocal()
.control()
.start()) {
var script = FileNames.join(
XPipeInstallation.getCurrentInstallationBasePath()
.toString(),
XPipeInstallation.getDaemonDebugScriptPath(sc.getOsType()));
if (sc.getOsType().equals(OsType.WINDOWS)) {
sc.executeSimpleCommand(
ScriptHelper.createDetachCommand(sc, "\"" + script + "\""));
} else {
TerminalHelper.open("XPipe Debug", "\"" + script + "\"");
}
}
});
e.consume();
})
.grow(true, false),
null)
.separator()
.addComp(
new TileButtonComp(
"openCurrentLogFile",
"openCurrentLogFileDescription",
"mdmz-text_snippet",
e -> {
FileOpener.openInTextEditor(AppLogs.get()
.getSessionLogsDirectory()
.resolve("xpipe.log")
.toString());
e.consume();
})
.grow(true, false),
null)
.separator()
.addComp(
new TileButtonComp(
"openInstallationDirectory",
"openInstallationDirectoryDescription",
"mdomz-snippet_folder",
e -> {
DesktopHelper.browsePath(
XPipeInstallation.getCurrentInstallationBasePath());
e.consume();
})
.grow(true, false),
null)
.separator()
.addComp(
new TileButtonComp("clearCaches", "clearCachesDescription", "mdi2t-trash-can-outline", e -> {
ClearCacheAlert.show();
e.consume();
})
.grow(true, false),
null)
.buildComp();
}
@Override
public CompStructure<?> createBase() {
var box = new VerticalComp(List.of(createActions()))
.apply(s -> s.get().setFillWidth(true))
.apply(struc -> struc.get().setSpacing(15))
.styleClass("troubleshoot-tab")
.apply(struc -> struc.get().setPrefWidth(600));
return box.createStructure();
}
}

View file

@ -114,6 +114,11 @@ public class OptionsBuilder {
return addComp(Comp.of(() -> new Spacer(size, Orientation.VERTICAL)));
}
public OptionsBuilder separator() {
return addComp(Comp.separator());
}
public OptionsBuilder name(String nameKey) {
finishCurrent();
name = AppI18n.observable(nameKey);

View file

@ -23,10 +23,14 @@ anyStream=Any Stream Type
noMatchingStoreFound=No suitable saved store was found
addStore=Add Store
anyStreamDescription=Or choose specific type
restart=Restart XPipe
restartDescription=A restart can often be a quick fix
reportIssue=Report Issue
reportIssueDescription=Open the integrated issue reporter
usefulActions=Useful actions
stored=Saved
troubleshootingOptions=Troubleshooting options
troubleshoot=Troubleshoot
other=Other
remote=Remote File
addShellStore=Add Shell ...

View file

@ -44,6 +44,7 @@ startGui=Start GUI
startInTray=Start in tray
startInBackground=Start in background
clearCaches=Clear caches ...
clearCachesDescription=Delete all cache data
ok=OK
apply=Apply
cancel=Cancel

View file

@ -20,12 +20,9 @@
-fx-padding: 0.6em 0 0.6em 0;
}
.about-tab .information {
-fx-spacing: 2em;
}
.about-tab {
-fx-padding: 1.3em;
.troubleshoot-tab .separator {
-fx-padding: 0.3em 0 0.3em 0;
}
.about-tab .update-check {