Skip to content

Commit

Permalink
feat: Open file in file manager (e.g. Finder or Explorer) (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandmalfarbe authored Dec 29, 2023
1 parent 025096f commit 0543a4c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javafx.util.Pair;
import lombok.extern.slf4j.Slf4j;

import java.awt.Desktop;
import java.io.File;
import java.net.URL;
import java.util.List;
Expand Down Expand Up @@ -77,4 +78,12 @@ private void setCreator(String titleString) {
creator.getStyleClass().remove(Styles.TEXT_SUBTLE);
creator.setText(titleString);
}

public void openFile() {
String text = this.file.getText();
if (text == null || text.isEmpty()) {
return;
}
Desktop.getDesktop().browseFileDirectory(new File(text));
}
}
5 changes: 4 additions & 1 deletion src/main/resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
}

/**
* Workaround for large icons in the fxml files. The size there (iconSize="64") is not applied when using AtlantaFX.
* Workaround for small/large icons in the fxml files. The size there (iconSize="64") is not applied when using AtlantaFX.
*/
.icon-small {
-fx-icon-size: 16px;
}
.icon-large {
-fx-icon-size: 32px;
}
Expand Down
30 changes: 24 additions & 6 deletions src/main/resources/fxml/InfoPanel.fxml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<GridPane hgap="10.0" minWidth="200" prefWidth="300" fx:controller="de.pascalwagler.epubcheckfx.ui.controller.InfoPanelController"
<?import org.kordamp.ikonli.javafx.FontIcon?>
<GridPane hgap="10.0" minWidth="200" prefWidth="300"
fx:controller="de.pascalwagler.epubcheckfx.ui.controller.InfoPanelController"
xmlns="http://javafx.com/javafx/20.0.0" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="NEVER" minWidth="10.0" prefWidth="63.0"/>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS" minWidth="10.0" prefWidth="200.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="22" />
<RowConstraints minHeight="22" />
<RowConstraints minHeight="22" />
<RowConstraints valignment="CENTER" minHeight="22"/>
<RowConstraints valignment="CENTER" minHeight="22"/>
<RowConstraints valignment="CENTER" minHeight="22"/>
</rowConstraints>
<children>
<Label text="%info_panel.file" styleClass="font-bold">
Expand All @@ -32,7 +37,20 @@
<Font name="System Bold"/>
</font>
</Label>
<Label fx:id="file" GridPane.columnIndex="1"/>


<HBox alignment="CENTER_LEFT" prefHeight="0.0" prefWidth="200.0" GridPane.columnIndex="1"
GridPane.rowIndex="0" onMouseClicked="#openFile">
<Label fx:id="file"/>
<Button styleClass="button-icon,flat,small" mnemonicParsing="false" onAction="#openFile">
<graphic>
<FontIcon iconLiteral="mdmz-open_in_new" iconSize="16" styleClass="icon-small"/>
</graphic>
<HBox.margin>
<Insets left="5"/>
</HBox.margin>
</Button>
</HBox>
<Label fx:id="title" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label fx:id="creator" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
</children>
Expand Down

0 comments on commit 0543a4c

Please sign in to comment.