Skip to content

Commit

Permalink
"UI refactoring", preparation for #73
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Mar 2, 2016
1 parent e57ee67 commit 890a0c4
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 105 deletions.
Expand Up @@ -72,7 +72,9 @@ public void start(final Stage primaryStage) throws IOException {
final ResourceBundle rb = ResourceBundle.getBundle("localization");
primaryStage.titleProperty().bind(mainCtrl.windowTitle());
primaryStage.setResizable(false);
primaryStage.getIcons().add(new Image(MainApplication.class.getResourceAsStream("/window_icon.png")));
if (SystemUtils.IS_OS_WINDOWS) {
primaryStage.getIcons().add(new Image(MainApplication.class.getResourceAsStream("/window_icon.png")));
}
primaryStage.show();

ActiveWindowStyleSupport.startObservingFocus(primaryStage);
Expand Down
Expand Up @@ -161,7 +161,7 @@ private void didClickAddVault(ActionEvent event) {
if (addVaultContextMenu.isShowing()) {
addVaultContextMenu.hide();
} else {
addVaultContextMenu.show(addVaultButton, Side.RIGHT, 0.0, 0.0);
addVaultContextMenu.show(addVaultButton, Side.BOTTOM, 0.0, 0.0);
}
}

Expand Down
Expand Up @@ -293,13 +293,11 @@ private void unlock(CharSequence password) {
messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
}
});
} catch (FrontendCreationFailedException e) {
} catch (FrontendCreationFailedException | CommandFailedException e) {
LOG.error("Decryption failed for technical reasons.", e);
Platform.runLater(() -> {
messageText.setText(resourceBundle.getString("unlock.errorMessage.decryptionFailed"));
messageText.setText(resourceBundle.getString("unlock.errorMessage.mountingFailed"));
});
} catch (CommandFailedException e) {
LOG.error("Failed to reveal mounted vault", e);
} finally {
Platform.runLater(() -> {
passwordField.swipe();
Expand Down
Expand Up @@ -31,11 +31,15 @@
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.geometry.Side;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.ToggleButton;
import javafx.stage.PopupWindow.AnchorLocation;
import javafx.stage.Stage;
import javafx.util.Duration;

Expand Down Expand Up @@ -68,12 +72,19 @@ public UnlockedController(Provider<MacWarningsController> macWarningsControllerP
@FXML
private NumberAxis xAxis;

@FXML
private ToggleButton moreOptionsButton;

@FXML
private ContextMenu moreOptionsMenu;

@Override
public void initialize() {
macWarningsController.initStage(macWarningsWindow);
ActiveWindowStyleSupport.startObservingFocus(macWarningsWindow);

EasyBind.subscribe(vault, this::vaultChanged);
EasyBind.subscribe(moreOptionsMenu.showingProperty(), moreOptionsButton::setSelected);
}

@Override
Expand Down Expand Up @@ -106,31 +117,41 @@ private void vaultChanged(Vault newVault) {
}

@FXML
private void didClickRevealVault(ActionEvent event) {
private void didClickLockVault(ActionEvent event) {
exec.submit(() -> {
try {
vault.get().reveal();
vault.get().unmount();
} catch (CommandFailedException e) {
Platform.runLater(() -> {
messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
messageLabel.setText(resourceBundle.getString("unlocked.label.unmountFailed"));
});
return;
}
vault.get().deactivateFrontend();
listener.ifPresent(this::invokeListenerLater);
});
}

@FXML
private void didClickCloseVault(ActionEvent event) {
private void didClickMoreOptions(ActionEvent event) {
if (moreOptionsMenu.isShowing()) {
moreOptionsMenu.hide();
} else {
moreOptionsMenu.setAnchorLocation(AnchorLocation.CONTENT_TOP_RIGHT);
moreOptionsMenu.show(moreOptionsButton, Side.BOTTOM, moreOptionsButton.getWidth(), 0.0);
}
}

@FXML
private void didClickRevealVault(ActionEvent event) {
exec.submit(() -> {
try {
vault.get().unmount();
vault.get().reveal();
} catch (CommandFailedException e) {
Platform.runLater(() -> {
messageLabel.setText(resourceBundle.getString("unlocked.label.unmountFailed"));
messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
});
return;
}
vault.get().deactivateFrontend();
listener.ifPresent(this::invokeListenerLater);
});
}

Expand Down
Expand Up @@ -53,6 +53,19 @@ public class WelcomeController extends AbstractFXMLViewController {

private static final Logger LOG = LoggerFactory.getLogger(WelcomeController.class);

private final Application app;
private final Settings settings;
private final Comparator<String> semVerComparator;
private final ExecutorService executor;

@Inject
public WelcomeController(Application app, Settings settings, @Named("SemVer") Comparator<String> semVerComparator, ExecutorService executor) {
this.app = app;
this.settings = settings;
this.semVerComparator = semVerComparator;
this.executor = executor;
}

@FXML
private ImageView botImageView;

Expand All @@ -68,17 +81,15 @@ public class WelcomeController extends AbstractFXMLViewController {
@FXML
private Hyperlink updateLink;

private final Application app;
private final Settings settings;
private final Comparator<String> semVerComparator;
private final ExecutorService executor;

@Inject
public WelcomeController(Application app, Settings settings, @Named("SemVer") Comparator<String> semVerComparator, ExecutorService executor) {
this.app = app;
this.settings = settings;
this.semVerComparator = semVerComparator;
this.executor = executor;
@Override
public void initialize() {
botImageView.setImage(new Image(getClass().getResource("/bot_welcome.png").toString()));
if (areUpdatesManagedExternally()) {
checkForUpdatesContainer.setVisible(false);
checkForUpdatesContainer.setManaged(false);
} else if (settings.isCheckForUpdatesEnabled()) {
executor.execute(this::checkForUpdates);
}
}

@Override
Expand All @@ -91,17 +102,6 @@ protected ResourceBundle getFxmlResourceBundle() {
return ResourceBundle.getBundle("localization");
}

@Override
public void initialize() {
botImageView.setImage(new Image(getClass().getResource("/bot_welcome.png").toString()));
if (areUpdatesManagedExternally()) {
checkForUpdatesContainer.setVisible(false);
checkForUpdatesContainer.setManaged(false);
} else if (settings.isCheckForUpdatesEnabled()) {
executor.execute(this::checkForUpdates);
}
}

// ****************************************
// Check for updates
// ****************************************
Expand Down
39 changes: 32 additions & 7 deletions main/ui/src/main/resources/css/linux_theme.css
Expand Up @@ -38,14 +38,18 @@

/****************************************************************************
* *
* Labels *
* Labels & Fonts *
* *
****************************************************************************/

.label {
-fx-text-fill: COLOR_TEXT;
}

.ionicons {
-fx-font-family: Ionicons;
}

/****************************************************************************
* *
* Hyperlinks *
Expand All @@ -67,30 +71,51 @@
* *
****************************************************************************/

.button {
.button,
.toggle-button {
-fx-pref-height: 25px;
-fx-background-color: COLOR_BORDER, COLOR_VGRAD_LIGHT;
-fx-background-insets: 0, 1;
-fx-padding: 0.4em 0.8em 0.4em 0.8em;
-fx-padding: 4px 8px 4px 8px;
-fx-text-fill: COLOR_TEXT;
-fx-alignment: CENTER;
}

.button:hover,
.button:default:hover {
.button:default:hover,
.toggle-button:hover {
-fx-background-color: COLOR_BORDER, COLOR_VGRAD_MEDIUM;
}

.button:armed,
.button:default:armed {
.button:default:armed,
.toggle-button:armed {
-fx-background-color: COLOR_BORDER_DARK, COLOR_VGRAD_DARK;
}

.button:disabled,
.button:default:disabled {
.button:default:disabled,
.toggle-button:disabled {
-fx-background-color: COLOR_BORDER, COLOR_VGRAD_LIGHT;
-fx-text-fill: COLOR_TEXT_DISABLED;
}

/****************************************************************************
* *
* Segmented Buttons *
* *
****************************************************************************/

.segmented-button-bar .button,
.segmented-button-bar .toggle-button {
-fx-background-insets: 0, 1;
}

.segmented-button-bar .button.last,
.segmented-button-bar .toggle-button.last {
-fx-background-insets: 0, 1 1 1 0;
}

/****************************************************************************
* *
* Text Fields *
Expand Down Expand Up @@ -179,7 +204,7 @@

.tool-bar.list-related-toolbar .toggle-button,
.tool-bar.list-related-toolbar .button {
-fx-font-family: Ionicons;
-fx-pref-height: 30px;
-fx-font-size: 1.8em;
-fx-text-fill: COLOR_TEXT;
-fx-padding: 0.2em 0.8em 0.2em 0.8em;
Expand Down
45 changes: 40 additions & 5 deletions main/ui/src/main/resources/css/mac_theme.css
Expand Up @@ -37,14 +37,18 @@

/****************************************************************************
* *
* Labels *
* Labels & Fonts *
* *
****************************************************************************/

.label {
-fx-text-fill: COLOR_TEXT;
}

.ionicons {
-fx-font-family: Ionicons;
}

/****************************************************************************
* *
* Hyperlinks *
Expand All @@ -66,11 +70,13 @@
* *
****************************************************************************/

.button {
.button,
.toggle-button {
-fx-pref-height: 21px;
-fx-background-color: COLOR_HGRAD_BTN_BORDER, #FFF;
-fx-background-insets: 0, 1;
-fx-background-radius: 4;
-fx-padding: 0.2em 0.8em 0.2em 0.8em;
-fx-padding: 2px 12px 3px 12px;
-fx-text-fill: COLOR_TEXT;
-fx-alignment: CENTER;
-fx-focus-traversable: false;
Expand All @@ -84,6 +90,7 @@

.button:disabled,
.button:default:disabled,
.toggle-button:disabled,
.root.active-window .button:default:disabled {
-fx-background-color: COLOR_HGRAD_BTN_BORDER_DIS, #F2F2F2;
-fx-background-insets: 0, 1;
Expand All @@ -97,6 +104,34 @@
-fx-text-fill: #FFF;
}

.toggle-button:armed,
.toggle-button:selected {
-fx-background-color: linear-gradient(to bottom, #C0C0C0 0%, #ADADAD 100%);
}

/****************************************************************************
* *
* Segmented Buttons *
* *
****************************************************************************/

.segmented-button-bar .button,
.segmented-button-bar .toggle-button {
-fx-background-radius: 0;
-fx-background-insets: 0, 1 1 1 0;
}

.segmented-button-bar .button.first,
.segmented-button-bar .toggle-button.first {
-fx-background-radius: 4 0 0 4;
-fx-background-insets: 0, 1;
}

.segmented-button-bar .button.last,
.segmented-button-bar .toggle-button.last {
-fx-background-radius: 0 4 4 0;
}

/****************************************************************************
* *
* Text Fields *
Expand Down Expand Up @@ -227,6 +262,7 @@
****************************************************************************/

.tool-bar.list-related-toolbar {
-fx-font-size: 1.4em;
-fx-background-color: COLOR_BORDER, #F7F7F7;
-fx-background-insets: 0, 0 1 1 1;
-fx-padding: 0;
Expand All @@ -241,8 +277,7 @@

.tool-bar.list-related-toolbar .toggle-button,
.tool-bar.list-related-toolbar .button {
-fx-font-family: Ionicons;
-fx-font-size: 1.4em;
-fx-pref-height: 25px;
-fx-text-fill: COLOR_TEXT;
-fx-background-color: transparent;
-fx-padding: 0.1em 0.6em 0.1em 0.6em;
Expand Down

0 comments on commit 890a0c4

Please sign in to comment.