make about dialog a page
This commit is contained in:
parent
f20b29a02e
commit
525a25769b
7 changed files with 94 additions and 24 deletions
|
@ -17,5 +17,6 @@ module dev.nuculabs.imagetagger.ui {
|
|||
|
||||
opens dev.nuculabs.imagetagger.ui to javafx.fxml, javafx.graphics;
|
||||
opens dev.nuculabs.imagetagger.ui.controls to javafx.fxml, javafx.graphics;
|
||||
opens dev.nuculabs.imagetagger.ui.pages to javafx.fxml, javafx.graphics;
|
||||
exports dev.nuculabs.imagetagger.ui;
|
||||
}
|
|
@ -3,6 +3,7 @@ package dev.nuculabs.imagetagger.ui
|
|||
import dev.nuculabs.imagetagger.ai.ImageTagsPrediction
|
||||
import dev.nuculabs.imagetagger.ui.controls.programatic.ApplicationMenuBar
|
||||
import javafx.application.Application
|
||||
import javafx.application.Platform
|
||||
import javafx.fxml.FXMLLoader
|
||||
import javafx.scene.Scene
|
||||
import javafx.scene.image.Image
|
||||
|
@ -40,6 +41,10 @@ class MainPage : Application() {
|
|||
stage.scene = scene
|
||||
stage.minWidth = 640.0
|
||||
stage.minHeight = 760.0
|
||||
// Whe the main window is hidden we exit the application.
|
||||
stage.setOnHidden {
|
||||
Platform.exit()
|
||||
}
|
||||
|
||||
// Add menu bar
|
||||
(scene.root as BorderPane).children.add(ApplicationMenuBar(mainPageController))
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package dev.nuculabs.imagetagger.ui.alerts
|
||||
|
||||
import javafx.scene.control.Alert
|
||||
import javafx.scene.layout.Region
|
||||
|
||||
/**
|
||||
* Represents the alert shown when the user clicks on About.
|
||||
* // TODO: Move this into a panel to make links clickable.
|
||||
*/
|
||||
class AboutAlert : Alert(AlertType.INFORMATION) {
|
||||
init {
|
||||
title = "About ImageTagger"
|
||||
headerText = ""
|
||||
contentText = "Image Tagger is an application that predicts an image's tags using deep-learning. " +
|
||||
"It is useful for photographers who want to improve their workflow by auto-tagging images.\n\n" +
|
||||
"Author: Denis-Cosmin Nutiu\n\n" +
|
||||
"Website: blog.nuculabs.dev\n" +
|
||||
"Github: https://github.com/dnutiu/ImageTagger"
|
||||
dialogPane.minHeight = Region.USE_PREF_SIZE
|
||||
show()
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package dev.nuculabs.imagetagger.ui.controls.programatic
|
||||
|
||||
import dev.nuculabs.imagetagger.ui.MainPageController
|
||||
import dev.nuculabs.imagetagger.ui.alerts.AboutAlert
|
||||
import dev.nuculabs.imagetagger.ui.pages.AboutPage
|
||||
import javafx.scene.control.Menu
|
||||
import javafx.scene.control.MenuBar
|
||||
import javafx.scene.control.MenuItem
|
||||
|
@ -23,7 +23,7 @@ class ApplicationMenuBar(private val mainPageController: MainPageController) : M
|
|||
private fun setupAboutMenu() {
|
||||
val aboutMenuItem = MenuItem("About")
|
||||
aboutMenuItem.setOnAction {
|
||||
AboutAlert()
|
||||
AboutPage.show()
|
||||
}
|
||||
aboutMenu.items.add(aboutMenuItem)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package dev.nuculabs.imagetagger.ui.pages
|
||||
|
||||
import javafx.fxml.FXML
|
||||
import javafx.fxml.FXMLLoader
|
||||
import javafx.scene.Parent
|
||||
import javafx.scene.Scene
|
||||
import javafx.stage.Stage
|
||||
import java.awt.Desktop
|
||||
import java.net.URL
|
||||
|
||||
|
||||
class AboutPage {
|
||||
|
||||
@FXML
|
||||
fun openBlog() {
|
||||
Desktop.getDesktop().browse(URL("https://blog.nuculabs.dev").toURI());
|
||||
}
|
||||
|
||||
@FXML
|
||||
fun openGithub() {
|
||||
Desktop.getDesktop().browse(URL("https://github.com/dnutiu/ImageTagger").toURI());
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun show() {
|
||||
val fxmlLoader = FXMLLoader(AboutPage::class.java.getResource("about-page.fxml"))
|
||||
val root = fxmlLoader.load<Any>() as Parent
|
||||
val newStage = Stage()
|
||||
newStage.title = "About ImageTagger"
|
||||
newStage.scene = Scene(root)
|
||||
newStage.isResizable = false
|
||||
newStage.show()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
.hyperlink {
|
||||
-fx-underline: false;
|
||||
-fx-border-color: transparent;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="dev.nuculabs.imagetagger.ui.pages.AboutPage"
|
||||
stylesheets="@about-page.css"
|
||||
>
|
||||
<VBox prefHeight="250.0" maxWidth="350" spacing="10">
|
||||
<padding>
|
||||
<Insets top="25" bottom="25" right="15" left="15"/>
|
||||
</padding>
|
||||
<HBox>
|
||||
<HBox>
|
||||
<padding>
|
||||
<Insets right="25"/>
|
||||
</padding>
|
||||
<ImageView>
|
||||
<Image
|
||||
url="@../image-analysis.png"
|
||||
backgroundLoading="true"
|
||||
/>
|
||||
</ImageView>
|
||||
</HBox>
|
||||
<Label wrapText="true"
|
||||
text="Image Tagger is an application that predicts an image's tags using deep-learning. It is useful for photographers who want to improve their workflow by auto-tagging images."/>
|
||||
</HBox>
|
||||
<Label text="Author: Denis-Cosmin Nutiu"/>
|
||||
<Hyperlink text="Website: blog.nuculabs.dev" onAction="#openBlog">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-blog" iconSize="16"/>
|
||||
</graphic>
|
||||
</Hyperlink>
|
||||
<Hyperlink text="Github: github.com/dnutiu/ImageTagger" onAction="#openGithub">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fab-github" iconSize="16"/>
|
||||
</graphic>
|
||||
</Hyperlink>
|
||||
|
||||
</VBox>
|
||||
</AnchorPane>
|
Loading…
Reference in a new issue