diff --git a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java index 73811eb87..e60dcf12c 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java @@ -1,5 +1,6 @@ package io.xpipe.app.comp.base; +import io.xpipe.app.core.AppCache; import io.xpipe.app.core.AppFont; import io.xpipe.app.core.AppLayoutModel; import io.xpipe.app.fxcomps.Comp; @@ -8,13 +9,17 @@ import io.xpipe.app.fxcomps.SimpleCompStructure; import io.xpipe.app.fxcomps.impl.IconButtonComp; import io.xpipe.app.fxcomps.impl.StackComp; import io.xpipe.app.fxcomps.impl.TooltipAugment; +import io.xpipe.app.fxcomps.util.LabelGraphic; import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.update.UpdateAvailableAlert; import io.xpipe.app.update.XPipeDistributionType; +import io.xpipe.app.util.Hyperlinks; import javafx.application.Platform; import javafx.beans.binding.Bindings; import javafx.beans.property.Property; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleStringProperty; import javafx.css.PseudoClass; import javafx.geometry.Insets; import javafx.geometry.Pos; @@ -22,6 +27,9 @@ import javafx.scene.control.Button; import javafx.scene.layout.*; import javafx.scene.paint.Color; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.List; public class SideMenuBarComp extends Comp> { @@ -133,6 +141,28 @@ public class SideMenuBarComp extends Comp> { vbox.getChildren().add(b.createRegion()); } + { + var zone = ZoneId.of(ZoneId.SHORT_IDS.get("PST")); + var now = Instant.now(); + var phStart = ZonedDateTime.of(2024, 10, 22, 0, 1, 0, 0, zone).toInstant(); + var phEnd = ZonedDateTime.of(2024, 10, 23, 0, 1, 0, 0, zone).toInstant(); + var clicked = AppCache.get("phClicked",Boolean.class,() -> false); + var phShow = now.isAfter(phStart) && now.isBefore(phEnd) && !clicked; + if (phShow) { + var hide = new SimpleBooleanProperty(false); + var b = new IconButtonComp(new LabelGraphic.ImageGraphic("app:producthunt-color.png", 24), () -> { + AppCache.update("phClicked", true); + Hyperlinks.open(Hyperlinks.PRODUCT_HUNT); + hide.set(true); + }).tooltip(new SimpleStringProperty("Product Hunt")); + b.apply(struc -> { + AppFont.setSize(struc.get(), 1); + }); + b.hide(hide); + vbox.getChildren().add(b.createRegion()); + } + } + var filler = new Button(); filler.setDisable(true); filler.setMaxHeight(3000); diff --git a/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java b/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java index 702070429..db8d52c1f 100644 --- a/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java +++ b/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java @@ -126,25 +126,6 @@ public class AppLayoutModel { // () -> Hyperlinks.open(Hyperlinks.GITHUB_WEBTOP), // null) )); - - - var zone = ZoneId.of(ZoneId.SHORT_IDS.get("PST")); - var now = Instant.now(); - var phStart = ZonedDateTime.of(2024, 10, 22, 0, 1, 0, 0, zone).toInstant(); - var phEnd = ZonedDateTime.of(2024, 10, 29, 0, 1, 0, 0, zone).toInstant(); - var clicked = AppCache.get("phClicked",Boolean.class,() -> false); - var phShow = now.isAfter(phStart) && now.isBefore(phEnd) && !clicked; - if (phShow) { - l.add(new Entry( - new SimpleStringProperty("Product Hunt"), - new LabelGraphic.ImageGraphic("app:producthunt-color.png", 24), - null, - () -> { - AppCache.update("phClicked", true); - Hyperlinks.open(Hyperlinks.PRODUCT_HUNT); - }, - null)); - } return l; } diff --git a/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java b/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java index 10c681d69..6d5a12a0a 100644 --- a/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java +++ b/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java @@ -76,8 +76,9 @@ public class TerminalLauncher { type.launch(config); latch.await(); } catch (Exception ex) { + var modMsg = ex.getMessage() != null && ex.getMessage().contains("Unable to find application named") ? ex.getMessage() + " in installed Applications on this system" : ex; throw ErrorEvent.expected(new IOException( - "Unable to launch terminal " + type.toTranslatedString().getValue() + ": " + ex.getMessage(), ex)); + "Unable to launch terminal " + type.toTranslatedString().getValue() + ": " + modMsg, ex)); } } }