Skip to content

Commit

Permalink
Improve about window
Browse files Browse the repository at this point in the history
Cleanup the hyperlinks.

Add margins in the license.

New DisclosedHyperlink class that shows the URL in the tooltip.
  • Loading branch information
zapek committed Nov 15, 2023
1 parent 5670e2a commit 20b2047
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

package io.xeres.ui.controller.about;

import io.xeres.ui.JavaFxApplication;
import io.xeres.ui.controller.WindowController;
import io.xeres.ui.support.util.UiUtils;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.TabPane;
import javafx.scene.text.Text;
Expand Down Expand Up @@ -58,12 +56,6 @@ public class AboutWindowController implements WindowController
@FXML
private Label profile;

@FXML
private Hyperlink twemoji;

@FXML
private Hyperlink twemojiLicense;

private final BuildProperties buildProperties;
private final Environment environment;
private final ResourceBundle bundle;
Expand All @@ -89,9 +81,6 @@ public void initialize() throws IOException
}
license.setText(UiUtils.getResourceFileAsString(getClass().getResourceAsStream("/LICENSE")));

twemoji.setOnAction(event -> JavaFxApplication.openUrl("https://github.com/twitter/twemoji"));
twemojiLicense.setOnAction(event -> JavaFxApplication.openUrl("https://creativecommons.org/licenses/by/4.0/"));

closeWindow.setOnAction(UiUtils::closeWindow);
UiUtils.linkify(infoPane);

Expand Down
49 changes: 49 additions & 0 deletions ui/src/main/java/io/xeres/ui/custom/DisclosedHyperlink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2023 by David Gerber - https://zapek.com
*
* This file is part of Xeres.
*
* Xeres is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xeres is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xeres. If not, see <http://www.gnu.org/licenses/>.
*/

package io.xeres.ui.custom;

import io.xeres.ui.support.util.TooltipUtils;
import javafx.scene.control.Hyperlink;

public class DisclosedHyperlink extends Hyperlink
{
private String uri;

public DisclosedHyperlink()
{
}

public DisclosedHyperlink(String text, String uri)
{
super(text);
setUri(uri);
}

public String getUri()
{
return uri;
}

public void setUri(String uri)
{
this.uri = uri;
TooltipUtils.install(this, uri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package io.xeres.ui.support.contentline;

import io.xeres.ui.JavaFxApplication;
import io.xeres.ui.support.util.TooltipUtils;
import io.xeres.ui.custom.DisclosedHyperlink;
import javafx.scene.Node;
import javafx.scene.control.Hyperlink;

Expand All @@ -38,15 +38,13 @@ public ContentUri(String uri)

public ContentUri(String uri, String description)
{
node = new Hyperlink(description);
TooltipUtils.install(node, uri);
node = new DisclosedHyperlink(description, uri);
node.setOnAction(event -> JavaFxApplication.openUrl(appendMailToIfNeeded(uri)));
}

public ContentUri(String uri, String description, Consumer<String> action)
{
node = new Hyperlink(description);
TooltipUtils.install(node, uri);
node = new DisclosedHyperlink(description, uri);
node.setOnAction(event -> action.accept(uri));
}

Expand Down
10 changes: 9 additions & 1 deletion ui/src/main/java/io/xeres/ui/support/util/UiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import io.xeres.common.rest.ErrorResponseEntity;
import io.xeres.ui.JavaFxApplication;
import io.xeres.ui.custom.DisclosedHyperlink;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.css.PseudoClass;
Expand Down Expand Up @@ -245,7 +246,14 @@ else if (rootNode instanceof Parent parent)
parent.getChildrenUnmodifiable().forEach(UiUtils::linkify);
}

if (rootNode instanceof Hyperlink hyperlink)
if (rootNode instanceof DisclosedHyperlink disclosedHyperlink)
{
if (disclosedHyperlink.getOnAction() == null)
{
disclosedHyperlink.setOnAction(event -> JavaFxApplication.openUrl(disclosedHyperlink.getUri()));
}
}
else if (rootNode instanceof Hyperlink hyperlink)
{
if (hyperlink.getOnAction() == null)
{
Expand Down
74 changes: 32 additions & 42 deletions ui/src/main/resources/view/about/about.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
~ along with Xeres. If not, see <http://www.gnu.org/licenses/>.
-->

<?import io.xeres.ui.custom.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
Expand All @@ -29,21 +30,21 @@
<HBox VBox.vgrow="NEVER">
<ImageView fitHeight="78.0" fitWidth="71.0" pickOnBounds="true" preserveRatio="true">
<HBox.margin>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
</HBox.margin>
<Image url="@../../image/icon.png" />
<Image url="@../../image/icon.png"/>
</ImageView>
<VBox>
<Label text="Xeres" styleClass="title-2"/>
<HBox>
<Label text="%about.version"/>
<Label fx:id="version" />
<Label fx:id="version"/>
</HBox>
<Label fx:id="profile">
<VBox.margin>
<Insets top="4.0" />
</VBox.margin>
</Label>
<Label fx:id="profile">
<VBox.margin>
<Insets top="4.0"/>
</VBox.margin>
</Label>
</VBox>
</HBox>
<TabPane fx:id="infoPane" prefHeight="256.0" prefWidth="560.0" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="ALWAYS">
Expand All @@ -53,17 +54,15 @@
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="%about.slogan" styleClass="text-caption"/>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="&#10;&#10;©2019-2023 by David Gerber, All Rights Reserved&#10;"/>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="&#10;&#10;Use " />
<Hyperlink text="https://github.com/zapek/Xeres/issues/new/choose" />
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text=" to report bugs or suggest improvements." />
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="&#10;&#10;Website: " />
<Hyperlink text="https://xeres.io" />
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="&#10;Wiki: " />
<Hyperlink text="https://github.com/zapek/Xeres/wiki" />
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="&#10;Source code: " />
<Hyperlink text="https://github.com/zapek/Xeres" />
<Text text="%about.slogan" styleClass="text-caption"/>
<Text text="&#10;&#10;©2019-2023 by David Gerber, All Rights Reserved&#10;&#10;"/>
<DisclosedHyperlink text="Report bugs or suggest improvements." uri="https://github.com/zapek/Xeres/issues/new/choose"/>
<Text text="&#10;&#10;"/>
<DisclosedHyperlink text="Website" uri="https://xeres.io"/>
<Text text="&#10;"/>
<DisclosedHyperlink text="Wiki" uri="https://github.com/zapek/Xeres/wiki"/>
<Text text="&#10;"/>
<DisclosedHyperlink text="Source code" uri="https://github.com/zapek/Xeres"/>
</TextFlow>
</ScrollPane>
</Tab>
Expand All @@ -73,19 +72,9 @@
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="David Gerber (Zapek)&#10;" styleClass="text-caption"/>
<Hyperlink text="dg@zapek.com" />
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="&#10;Benevolent dictator, lead developer" styleClass="text-italic"/>
</TextFlow>
</ScrollPane>
</Tab>
<Tab text="%about.contributors">
<ScrollPane fitToWidth="true">
<TextFlow>
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="(None yet)"/>
<Text text="David Gerber (Zapek)&#10;" styleClass="text-caption"/>
<DisclosedHyperlink text="dg@zapek.com" uri="mailto:dg@zapek.com"/>
<Text text="&#10;Benevolent dictator, lead developer" styleClass="text-italic"/>
</TextFlow>
</ScrollPane>
</Tab>
Expand All @@ -95,10 +84,9 @@
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="Please visit "/>
<Hyperlink text="https://xeres.io"/>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text=" to make a donation.&#10;"/>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="All sponsors will be listed here (opt-in)."/>
<Text text="Please "/>
<DisclosedHyperlink text="make a donation." uri="https://xeres.io/donate"/>
<Text text="&#10;All sponsors will be listed here (opt-in)."/>
</TextFlow>
</ScrollPane>
</Tab>
Expand All @@ -108,14 +96,16 @@
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0"
text="Olivier Piras&#10;for coming up with the name&#10;&#10;Nicolas Dirand&#10;for raising a statue in my image in his village&#10;&#10;Cyril Soler&#10;for answering my silly questions&#10;&#10;Adrien Gerber&#10;for testing the emojis&#10;&#10;The Retroshare developers&#10;for coming up with the most interesting P2P concepts"/>
<Text text="Olivier Piras&#10;for coming up with the name&#10;&#10;Nicolas Dirand&#10;for raising a statue in my image in his village&#10;&#10;Cyril Soler&#10;for answering my silly questions&#10;&#10;Adrien Gerber&#10;for testing the emojis&#10;&#10;The Retroshare developers&#10;for coming up with the most interesting P2P concepts"/>
</TextFlow>
</ScrollPane>
</Tab>
<Tab text="%about.license">
<ScrollPane fitToWidth="true">
<TextFlow>
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Text fx:id="license" styleClass="fixed-font"/>
</TextFlow>
</ScrollPane>
Expand All @@ -126,16 +116,16 @@
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0"/>
</padding>
<Hyperlink fx:id="twemoji" text="Twemoji"/>
<Text fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text=" © 2020 Twitter, Inc and other contributors. Graphics licensed under "/>
<Hyperlink fx:id="twemojiLicense" text="CC-BY 4.0"/>
<DisclosedHyperlink text="Twemoji" uri="https://github.com/twitter/twemoji"/>
<Text text=" © 2020 Twitter, Inc and other contributors. Graphics licensed under "/>
<DisclosedHyperlink text="CC-BY 4.0" uri="https://creativecommons.org/licenses/by/4.0/"/>
</TextFlow>
</ScrollPane>
</Tab>
</TabPane>
<HBox alignment="TOP_RIGHT">
<VBox.margin>
<Insets top="8.0" />
<Insets top="8.0"/>
</VBox.margin>
<Button fx:id="closeWindow" minWidth="72.0" mnemonicParsing="false" text="%button.close"/>
</HBox>
Expand Down

0 comments on commit 20b2047

Please sign in to comment.