Various fixes

This commit is contained in:
crschnick 2024-07-06 17:28:42 +00:00
parent 1af837b02e
commit ddac4cd402
5 changed files with 38 additions and 88 deletions

View file

@ -1,20 +1,16 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.augment.Augment;
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.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;
@ -65,7 +61,14 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
var selected = PseudoClass.getPseudoClass("selected");
for (int i = 0; i < entries.size(); i++) {
var e = entries.get(i);
var b = new IconButtonComp(e.icon(), () -> value.setValue(e));
var b = new IconButtonComp(e.icon(), () -> {
if (e.action() != null) {
e.action().run();
return;
}
value.setValue(e);
});
var shortcut = e.combination();
if (shortcut != null) {
b.apply(struc -> struc.get().getProperties().put("shortcut", shortcut));
@ -85,7 +88,7 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
var indicator = Comp.empty().styleClass("indicator");
var stack = new StackComp(List.of(indicator, b)).apply(struc -> struc.get().setAlignment(Pos.CENTER_RIGHT));
stack.apply(struc -> {
var indicatorRegion = (Region) struc.get().getChildren().get(0);
var indicatorRegion = (Region) struc.get().getChildren().getFirst();
indicatorRegion.setMaxWidth(7);
indicatorRegion
.backgroundProperty()
@ -110,71 +113,6 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
vbox.getChildren().add(stack.createRegion());
}
Augment<CompStructure<Button>> simpleBorders = struc -> {
struc.get()
.backgroundProperty()
.bind(Bindings.createObjectBinding(
() -> {
if (struc.get().isHover()) {
return hoverBorder.get();
}
return noneBorder.get();
},
struc.get().hoverProperty(),
value,
hoverBorder,
selectedBorder,
noneBorder));
};
{
var b = new IconButtonComp("mdi2g-github", () -> Hyperlinks.open(Hyperlinks.GITHUB))
.tooltipKey("visitGithubRepository")
.apply(simpleBorders)
.accessibleTextKey("visitGithubRepository");
b.apply(struc -> {
AppFont.setSize(struc.get(), 2);
});
vbox.getChildren().add(b.createRegion());
}
{
var b = new IconButtonComp("mdi2d-discord", () -> Hyperlinks.open(Hyperlinks.DISCORD))
.tooltipKey("discord")
.apply(simpleBorders)
.accessibleTextKey("discord");
b.apply(struc -> {
AppFont.setSize(struc.get(), 2);
});
vbox.getChildren().add(b.createRegion());
}
// {
// var b = new IconButtonComp("mdi2t-translate", () -> Hyperlinks.open(Hyperlinks.TRANSLATE))
// .tooltipKey("translate")
// .apply(simpleBorders)
// .accessibleTextKey("translate");
// b.apply(struc -> {
// AppFont.setSize(struc.get(), 2);
// });
// vbox.getChildren().add(b.createRegion());
// }
{
var b = new IconButtonComp(
"mdi2c-code-json",
() -> Hyperlinks.open(
"http://localhost:" + AppBeaconServer.get().getPort()))
.tooltipKey("api")
.apply(simpleBorders)
.accessibleTextKey("api");
b.apply(struc -> {
AppFont.setSize(struc.get(), 2);
});
vbox.getChildren().add(b.createRegion());
}
{
var b = new IconButtonComp("mdi2u-update", () -> UpdateAvailableAlert.showIfNeeded())
.tooltipKey("updateAvailableTooltip")

View file

@ -1,10 +1,12 @@
package io.xpipe.app.core;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.browser.session.BrowserSessionComp;
import io.xpipe.app.browser.session.BrowserSessionModel;
import io.xpipe.app.comp.store.StoreLayoutComp;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.prefs.AppPrefsComp;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.LicenseProvider;
import javafx.beans.property.Property;
@ -75,22 +77,45 @@ public class AppLayoutModel {
AppI18n.observable("browser"),
"mdi2f-file-cabinet",
new BrowserSessionComp(BrowserSessionModel.DEFAULT),
null,
new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("connections"),
"mdi2c-connection",
new StoreLayoutComp(),
null,
new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("settings"),
"mdsmz-miscellaneous_services",
new AppPrefsComp(),
null,
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("explorePlans"),
"mdi2p-professional-hexagon",
LicenseProvider.get().overviewPage(),
null)));
null,
null),
new Entry(
AppI18n.observable("visitGithubRepository"),
"mdi2g-github",
new AppPrefsComp(),
() -> Hyperlinks.open(Hyperlinks.GITHUB),
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("discord"),
"mdi2d-discord",
new AppPrefsComp(),
() -> Hyperlinks.open(Hyperlinks.DISCORD),
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN)),
new Entry(
AppI18n.observable("api"),
"mdi2c-code-json",
new AppPrefsComp(),
() -> Hyperlinks.open(
"http://localhost:" + AppBeaconServer.get().getPort()),
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN))));
return l;
}
@ -103,5 +128,5 @@ public class AppLayoutModel {
double browserConnectionsWidth;
}
public record Entry(ObservableValue<String> name, String icon, Comp<?> comp, KeyCombination combination) {}
public record Entry(ObservableValue<String> name, String icon, Comp<?> comp, Runnable action, KeyCombination combination) {}
}

View file

@ -32,10 +32,6 @@
-fx-padding: 1 0 9 9;
}
.root:pretty .bookmarks-container {
-fx-effect: dropshadow(three-pass-box, -color-shadow-default, 2px, 0.25, 0, 1);
}
.bookmarks-header {
-fx-min-height: 3.5em;
-fx-pref-height: 3.5em;

View file

@ -15,10 +15,6 @@
-fx-padding: 0 6 8 8;
}
.root:pretty .browser .transfer {
-fx-effect: dropshadow(three-pass-box, -color-shadow-default, 2px, 0.25, 0, 1);
}
.transfer > * {
-fx-border-radius: 4;
-fx-background-radius: 4;
@ -239,11 +235,6 @@
-fx-border-color: -color-border-default;
}
.root:pretty .browser .browser-content {
-fx-effect: dropshadow(three-pass-box, -color-shadow-default, 2px, 0.25, 0, 1);
}
.browser .browser-content-container {
-fx-padding: 0 10 7 0;
}

View file

@ -1,6 +1,6 @@
.scroll-bar:vertical {
-fx-min-width: 6px;
-fx-pref-width: 6px;
-fx-min-width: 7px;
-fx-pref-width: 7px;
-fx-padding: 1;
-fx-background-color: transparent;
}