From 8261f6f7eca8a95517ccfbf13ddd940c1e9b0f14 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 22 Jun 2023 17:47:31 +0000 Subject: [PATCH] Split about page in settings --- .../xpipe/app/browser/BrowserWelcomeComp.java | 2 +- .../java/io/xpipe/app/prefs/AboutComp.java | 114 +++------------- .../java/io/xpipe/app/prefs/AppPrefs.java | 6 +- .../java/io/xpipe/app/prefs/PrefsComp.java | 18 +-- .../io/xpipe/app/prefs/TroubleshootComp.java | 126 ++++++++++++++++++ .../io/xpipe/app/util/OptionsBuilder.java | 5 + .../resources/lang/dscreation_en.properties | 4 + .../resources/lang/preferences_en.properties | 1 + .../io/xpipe/app/resources/style/about.css | 7 +- 9 files changed, 163 insertions(+), 120 deletions(-) create mode 100644 app/src/main/java/io/xpipe/app/prefs/TroubleshootComp.java diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java index bf0954b70..6890c4565 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java @@ -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; diff --git a/app/src/main/java/io/xpipe/app/prefs/AboutComp.java b/app/src/main/java/io/xpipe/app/prefs/AboutComp.java index 1ecfae966..369b7daa1 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AboutComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/AboutComp.java @@ -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> { 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> { .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> { 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") diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index 863150576..21e4fa084 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -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( diff --git a/app/src/main/java/io/xpipe/app/prefs/PrefsComp.java b/app/src/main/java/io/xpipe/app/prefs/PrefsComp.java index e87dd599c..7b0ad5090 100644 --- a/app/src/main/java/io/xpipe/app/prefs/PrefsComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/PrefsComp.java @@ -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); diff --git a/app/src/main/java/io/xpipe/app/prefs/TroubleshootComp.java b/app/src/main/java/io/xpipe/app/prefs/TroubleshootComp.java new file mode 100644 index 000000000..7c01dff37 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/prefs/TroubleshootComp.java @@ -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> { + + 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(); + } +} diff --git a/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java b/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java index 43907ad59..51d2f5fa1 100644 --- a/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java +++ b/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java @@ -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); diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/dscreation_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/dscreation_en.properties index f5c81b207..a0ee771b6 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/dscreation_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/dscreation_en.properties @@ -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 ... diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties index 8bf579b05..575aef422 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties @@ -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 diff --git a/app/src/main/resources/io/xpipe/app/resources/style/about.css b/app/src/main/resources/io/xpipe/app/resources/style/about.css index a94cdabfa..e69a6f378 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/about.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/about.css @@ -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 {