Small fixes

This commit is contained in:
crschnick 2024-10-04 00:21:38 +00:00
parent be464120fa
commit c72ed034d1
3 changed files with 32 additions and 20 deletions

View file

@ -1,5 +1,6 @@
package io.xpipe.app.comp.base; package io.xpipe.app.comp.base;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppFont; import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppLayoutModel; import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.Comp; 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.IconButtonComp;
import io.xpipe.app.fxcomps.impl.StackComp; import io.xpipe.app.fxcomps.impl.StackComp;
import io.xpipe.app.fxcomps.impl.TooltipAugment; 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.fxcomps.util.PlatformThread;
import io.xpipe.app.update.UpdateAvailableAlert; import io.xpipe.app.update.UpdateAvailableAlert;
import io.xpipe.app.update.XPipeDistributionType; import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.Hyperlinks;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.beans.property.Property; import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.css.PseudoClass; import javafx.css.PseudoClass;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
@ -22,6 +27,9 @@ import javafx.scene.control.Button;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
public class SideMenuBarComp extends Comp<CompStructure<VBox>> { public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
@ -133,6 +141,28 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
vbox.getChildren().add(b.createRegion()); 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(); var filler = new Button();
filler.setDisable(true); filler.setDisable(true);
filler.setMaxHeight(3000); filler.setMaxHeight(3000);

View file

@ -126,25 +126,6 @@ public class AppLayoutModel {
// () -> Hyperlinks.open(Hyperlinks.GITHUB_WEBTOP), // () -> Hyperlinks.open(Hyperlinks.GITHUB_WEBTOP),
// null) // 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; return l;
} }

View file

@ -76,8 +76,9 @@ public class TerminalLauncher {
type.launch(config); type.launch(config);
latch.await(); latch.await();
} catch (Exception ex) { } 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( throw ErrorEvent.expected(new IOException(
"Unable to launch terminal " + type.toTranslatedString().getValue() + ": " + ex.getMessage(), ex)); "Unable to launch terminal " + type.toTranslatedString().getValue() + ": " + modMsg, ex));
} }
} }
} }