mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-18 05:06:02 +00:00
fixes #387
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
package org.cryptomator.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -97,10 +98,19 @@ public class MainApplication extends Application {
|
||||
}
|
||||
|
||||
private void setupStylesheets() {
|
||||
Font.loadFont(getClass().getResourceAsStream("/css/ionicons.ttf"), 12.0);
|
||||
loadFont("/css/ionicons.ttf");
|
||||
loadFont("/css/fontawesome-webfont.ttf");
|
||||
chooseNativeStylesheet();
|
||||
}
|
||||
|
||||
private void loadFont(String resourcePath) {
|
||||
try (InputStream in = getClass().getResourceAsStream(resourcePath)) {
|
||||
Font.loadFont(in, 12.0);
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Error loading font from path: " + resourcePath, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeStage(Stage primaryStage, MainController mainCtrl) {
|
||||
mainCtrl.initStage(primaryStage);
|
||||
primaryStage.titleProperty().bind(mainCtrl.windowTitle());
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.cryptomator.ui.controls;
|
||||
|
||||
import org.cryptomator.ui.model.Vault;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.monadic.MonadicBinding;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
@@ -19,28 +20,14 @@ import javafx.scene.control.OverrunStyle;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
public class DirectoryListCell extends DraggableListCell<Vault> {
|
||||
|
||||
// fill: #FD4943, stroke: #E1443F
|
||||
private static final Color RED_FILL = Color.rgb(253, 73, 67);
|
||||
private static final Color RED_STROKE = Color.rgb(225, 68, 63);
|
||||
|
||||
// fill: #FFBF2F, stroke: #E4AC36
|
||||
// private static final Color YELLOW_FILL = Color.rgb(255, 191, 47);
|
||||
// private static final Color YELLOW_STROKE = Color.rgb(228, 172, 54);
|
||||
|
||||
// fill: #28CA40, stroke: #30B740
|
||||
private static final Color GREEN_FILL = Color.rgb(40, 202, 64);
|
||||
private static final Color GREEN_STROKE = Color.rgb(48, 183, 64);
|
||||
|
||||
private final Circle statusIndicator = new Circle(4.5);
|
||||
private final Label statusText = new Label();
|
||||
private final Label nameText = new Label();
|
||||
private final Label pathText = new Label();
|
||||
private final VBox vbox = new VBox(4.0, nameText, pathText);
|
||||
private final HBox hbox = new HBox(6.0, statusIndicator, vbox);
|
||||
private final HBox hbox = new HBox(6.0, statusText, vbox);
|
||||
private ContextMenu vaultContextMenu;
|
||||
|
||||
public DirectoryListCell() {
|
||||
@@ -56,25 +43,27 @@ public class DirectoryListCell extends DraggableListCell<Vault> {
|
||||
pathText.setTextOverrun(OverrunStyle.ELLIPSIS);
|
||||
pathText.getStyleClass().add("detail-label");
|
||||
|
||||
statusIndicator.fillProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).filter(Boolean.TRUE::equals).map(unlocked -> GREEN_FILL).orElse(RED_FILL));
|
||||
statusIndicator.strokeProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).filter(Boolean.TRUE::equals).map(unlocked -> GREEN_STROKE).orElse(RED_STROKE));
|
||||
MonadicBinding<Boolean> optionalItemIsUnlocked = EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty);
|
||||
statusText.textProperty().bind(optionalItemIsUnlocked.map(this::getStatusIconText));
|
||||
statusText.textFillProperty().bind(this.textFillProperty());
|
||||
statusText.setMinSize(16.0, 16.0);
|
||||
statusText.setAlignment(Pos.CENTER);
|
||||
statusText.getStyleClass().add("fontawesome");
|
||||
|
||||
tooltipProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::displayablePath).map(p -> new Tooltip(p.toString())));
|
||||
contextMenuProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).map(unlocked -> {
|
||||
return unlocked ? null : vaultContextMenu;
|
||||
}));
|
||||
contextMenuProperty().bind(optionalItemIsUnlocked.map(unlocked -> unlocked ? null : vaultContextMenu));
|
||||
|
||||
setGraphic(hbox);
|
||||
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(Vault item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item == null) {
|
||||
statusIndicator.setVisible(false);
|
||||
private String getStatusIconText(Boolean unlockedOrNull) {
|
||||
if (Boolean.TRUE.equals(unlockedOrNull)) {
|
||||
return "\uf09c";
|
||||
} else if (Boolean.FALSE.equals(unlockedOrNull)) {
|
||||
return "\uf023";
|
||||
} else {
|
||||
statusIndicator.setVisible(true);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -51,6 +51,9 @@
|
||||
-fx-font-family: Ionicons;
|
||||
}
|
||||
|
||||
.fontawesome {
|
||||
-fx-font-family: FontAwesome;
|
||||
}
|
||||
.caption-label {
|
||||
-fx-font-size: 0.9em;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
-fx-font-family: Ionicons;
|
||||
}
|
||||
|
||||
.fontawesome {
|
||||
-fx-font-family: FontAwesome;
|
||||
}
|
||||
|
||||
.caption-label {
|
||||
-fx-font-size: 0.9em;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
-fx-font-family: Ionicons;
|
||||
}
|
||||
|
||||
.fontawesome {
|
||||
-fx-font-family: FontAwesome;
|
||||
}
|
||||
|
||||
.caption-label {
|
||||
-fx-font-size: 0.9em;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user