Explorar o código

changed dialog L&F on OS X

Sebastian Stenzel %!s(int64=9) %!d(string=hai) anos
pai
achega
92c87f7b84

+ 41 - 31
main/ui/src/main/java/org/cryptomator/ui/controllers/MainController.java

@@ -9,6 +9,33 @@
  ******************************************************************************/
 package org.cryptomator.ui.controllers;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.commons.lang3.SystemUtils;
+import org.cryptomator.ui.controls.DirectoryListCell;
+import org.cryptomator.ui.model.Vault;
+import org.cryptomator.ui.model.VaultFactory;
+import org.cryptomator.ui.settings.Localization;
+import org.cryptomator.ui.settings.Settings;
+import org.cryptomator.ui.util.DialogBuilderUtil;
+import org.fxmisc.easybind.EasyBind;
+import org.fxmisc.easybind.monadic.MonadicBinding;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import dagger.Lazy;
 import javafx.application.Platform;
 import javafx.beans.binding.Binding;
@@ -23,35 +50,17 @@ import javafx.event.ActionEvent;
 import javafx.fxml.FXML;
 import javafx.geometry.Side;
 import javafx.scene.Parent;
-import javafx.scene.control.*;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.ListCell;
+import javafx.scene.control.ListView;
+import javafx.scene.control.ToggleButton;
 import javafx.scene.layout.HBox;
 import javafx.scene.layout.Pane;
 import javafx.stage.FileChooser;
 import javafx.stage.Stage;
-import org.cryptomator.ui.controls.DirectoryListCell;
-import org.cryptomator.ui.model.Vault;
-import org.cryptomator.ui.model.VaultFactory;
-import org.cryptomator.ui.settings.Localization;
-import org.cryptomator.ui.settings.Settings;
-import org.cryptomator.ui.util.DialogBuilderUtil;
-import org.fxmisc.easybind.EasyBind;
-import org.fxmisc.easybind.monadic.MonadicBinding;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
 
 @Singleton
 public class MainController extends LocalizedFXMLViewController {
@@ -225,13 +234,14 @@ public class MainController extends LocalizedFXMLViewController {
 
 	@FXML
 	private void didClickRemoveSelectedEntry(ActionEvent e) {
-		Dialog confirmDialog = DialogBuilderUtil.buildConfirmationDialog(
-				localization.getString("main.directoryList.remove.confirmation.title"),
-				localization.getString("main.directoryList.remove.confirmation.header"),
-				localization.getString("main.directoryList.remove.confirmation.content")
-		);
+		Alert confirmDialog = DialogBuilderUtil.buildConfirmationDialog( //
+				localization.getString("main.directoryList.remove.confirmation.title"), //
+				localization.getString("main.directoryList.remove.confirmation.header"), //
+				localization.getString("main.directoryList.remove.confirmation.content"), //
+				SystemUtils.IS_OS_MAC_OSX ? ButtonType.CANCEL : ButtonType.OK);
+
 		Optional<ButtonType> choice = confirmDialog.showAndWait();
-		if (choice.get() == ButtonType.OK){
+		if (ButtonType.OK.equals(choice.get())) {
 			vaults.remove(selectedVault.get());
 			if (vaults.isEmpty()) {
 				activeController.set(welcomeController.get());

+ 33 - 20
main/ui/src/main/java/org/cryptomator/ui/util/DialogBuilderUtil.java

@@ -9,32 +9,45 @@
 package org.cryptomator.ui.util;
 
 import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.text.Text;
 
 public class DialogBuilderUtil {
 
-    public DialogBuilderUtil() {}
+	public DialogBuilderUtil() {
+	}
 
-    public static Alert buildInformationDialog(String title, String header, String content) {
-        return buildDialog(title, header, content,Alert.AlertType.INFORMATION);
-    }
+	public static Alert buildInformationDialog(String title, String header, String content, ButtonType defaultButton) {
+		return buildDialog(title, header, content, Alert.AlertType.INFORMATION, defaultButton);
+	}
 
-    public static Alert buildWarningDialog(String title, String header, String content) {
-        return buildDialog(title, header, content,Alert.AlertType.WARNING);
-    }
+	public static Alert buildWarningDialog(String title, String header, String content, ButtonType defaultButton) {
+		return buildDialog(title, header, content, Alert.AlertType.WARNING, defaultButton);
+	}
 
-    public static Alert buildErrorDialog(String title, String header, String content) {
-        return buildDialog(title, header, content,Alert.AlertType.ERROR);
-    }
+	public static Alert buildErrorDialog(String title, String header, String content, ButtonType defaultButton) {
+		return buildDialog(title, header, content, Alert.AlertType.ERROR, defaultButton);
+	}
 
-    public static Alert buildConfirmationDialog(String title, String header, String content) {
-        return buildDialog(title, header, content,Alert.AlertType.CONFIRMATION);
-    }
+	public static Alert buildConfirmationDialog(String title, String header, String content, ButtonType defaultButton) {
+		return buildDialog(title, header, content, Alert.AlertType.CONFIRMATION, defaultButton);
+	}
 
-    private static Alert buildDialog(String title, String header, String content, Alert.AlertType type) {
-        Alert alert = new Alert(type);
-        alert.setTitle(title);
-        alert.setHeaderText(header);
-        alert.setContentText(content);
-        return alert;
-    }
+	private static Alert buildDialog(String title, String header, String content, Alert.AlertType type, ButtonType defaultButton) {
+		Text contentText = new Text(content);
+		contentText.setWrappingWidth(360.0);
+
+		Alert alert = new Alert(type);
+		alert.setTitle(title);
+		alert.setHeaderText(header);
+		alert.getDialogPane().setContent(contentText);
+
+		alert.getDialogPane().getButtonTypes().stream().forEach(buttonType -> {
+			Button btn = (Button) alert.getDialogPane().lookupButton(buttonType);
+			btn.setDefaultButton(buttonType.equals(defaultButton));
+		});
+
+		return alert;
+	}
 }

+ 25 - 61
main/ui/src/main/resources/css/mac_theme.css

@@ -10,7 +10,7 @@
  */
  
 .root {
-	-fx-font-family: 'lucida-grande';
+	-fx-font-family: 'lucida-grande', sans-serif;
 	-fx-font-smoothing-type: lcd;
     -fx-font-size: 13px;
 	
@@ -541,79 +541,43 @@
 
 .dialog-pane {
     -fx-background-color: COLOR_BACKGROUND;
-    -fx-padding: 0;
-}
-
-.dialog-pane > .expandable-content {
-    -fx-padding: 0.666em; /* 8px */
-}
-
-.dialog-pane > .button-bar > .container {
-    -fx-padding: 0.833em; /* 10px */
-}
-
-.dialog-pane > .content.label {
-    -fx-alignment: top-left;
-    -fx-padding: 1.333em 0.833em 0 0.833em; /* 16px 10px 0px 10px */
-}
-
-.dialog-pane > .content {
-    -fx-padding: 0.833em; /* 10 */
-}
-
-.dialog-pane:no-header .graphic-container {
-    -fx-padding: 0.833em 0 0 0.833em; /* 10px 0px 0px 10px */
+    -fx-padding: 20px 20px 20px 96px;
+    
+    -fx-background-image: url("/img/dialog-icon.png");
+    -fx-background-repeat: no-repeat;
+    -fx-background-position: 20px 20px;
 }
 
+/* HEADER */
 .dialog-pane:header .header-panel {
-    /*-fx-padding: 0.833em 1.166em 0.833em 1.166em; *//* 10px 14px 10px 14px */
-    -fx-padding: 0.833em; /* 10px */
-    -fx-background-color: COLOR_BORDER, linear-gradient(COLOR_BACKGROUND, derive(COLOR_BACKGROUND, 30%));
-    -fx-background-insets: 0, 0 0 1 0;
+    -fx-padding: 0 0 12px 0;
 }
 
+/* TITLE */
 .dialog-pane:header .header-panel .label {
-    -fx-font-size: 1.167em; /* 14px */
+    -fx-font-weight: bold;
     -fx-wrap-text: true;
 }
 
-.dialog-pane:header .header-panel .graphic-container {
-    /* This prevents the text in the header running directly into the graphic */
-    -fx-padding: 0 0 0 0.833em; /* 0px 0px 0px 10px */
-}
-
-.dialog-pane > .button-bar > .container > .details-button {
-  -fx-alignment: baseline-left;
-  -fx-focus-traversable: false;
-  -fx-padding: 0.416em; /* 5px */
-}
-
-.dialog-pane > .button-bar > .container > .details-button.more {
-    -fx-graphic: url("dialog-more-details.png");
-}
-
-.dialog-pane > .button-bar > .container > .details-button.less {
-    -fx-graphic: url("dialog-fewer-details.png");
-}
-
-.dialog-pane > .button-bar > .container > .details-button:hover {
-    -fx-underline: true;
-}
-
-.alert.confirmation.dialog-pane,
-.text-input-dialog.dialog-pane,
-.choice-dialog.dialog-pane {
-    -fx-graphic: url("dialog-confirm.png");
+/* CONTENT LABEL */
+.dialog-pane > .content {
+	-fx-alignment: top-left;
+	-fx-wrap-text: true;
+	-fx-font-size: 11px;
+	-fx-line-spacing: 1.0;
 }
 
-.alert.information.dialog-pane {
-    -fx-graphic: url("dialog-information.png");
+/* BUTTONS */
+.dialog-pane > .button-bar > .container {
+    -fx-padding: 12px 0 0 0;
 }
 
-.alert.error.dialog-pane {
-    -fx-graphic: url("dialog-error.png");
+.dialog-pane > .button-bar .button:default {
+	-fx-background-color: COLOR_HGRAD_BTN_DEF_BORDER, COLOR_HGRAD_BTN_DEF_BACKGROUND;
+    -fx-text-fill: #FFF;
 }
 
-.alert.warning.dialog-pane {
-    -fx-graphic: url("dialog-warning.png");
+.dialog-pane > .button-bar .button:default:armed {
+    -fx-background-color: COLOR_HGRAD_BTN_ARMED_BORDER, COLOR_HGRAD_BTN_ARMED_BACKGROUND;
+    -fx-text-fill: #FFF;
 }

BIN=BIN
main/ui/src/main/resources/img/dialog-icon.png


BIN=BIN
main/ui/src/main/resources/img/dialog-icon@2x.png


+ 3 - 3
main/ui/src/main/resources/localization/en.txt

@@ -13,9 +13,9 @@ main.directoryList.contextMenu.remove=Remove from list
 main.directoryList.contextMenu.changePassword=Change password
 main.addDirectory.contextMenu.new=Create new vault
 main.addDirectory.contextMenu.open=Open existing vault
-main.directoryList.remove.confirmation.title=Vault removal
-main.directoryList.remove.confirmation.header=Do you really want to remove this vault ?
-main.directoryList.remove.confirmation.content=Every data it contains will be lost.
+main.directoryList.remove.confirmation.title=Remove Vault
+main.directoryList.remove.confirmation.header=Do you really want to remove this vault?
+main.directoryList.remove.confirmation.content=The vault will only be removed from the list. To permanently delete it, please delete the files from your filesystem. Lorem ipsum, wie das duftet, kräftig, deftig, würzig, gut. Pommersche aus dem Buchenrauch, naturgewürzt und das schmeckt man auch.
 
 # welcome.fxml
 welcome.checkForUpdates.label.currentlyChecking=Checking for Updates...