mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Set proper terminal default value
This commit is contained in:
parent
4b30bed0a8
commit
49de9b8a97
2 changed files with 17 additions and 29 deletions
|
@ -74,15 +74,6 @@ public class AppWindowHelper {
|
|||
childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2);
|
||||
}
|
||||
|
||||
public static void showAlert(Alert a, Consumer<Optional<ButtonType>> bt) {
|
||||
ThreadHelper.runAsync(() -> {
|
||||
var r = showBlockingAlert(a);
|
||||
if (bt != null) {
|
||||
bt.accept(r);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showAlert(Consumer<Alert> c, Consumer<Optional<ButtonType>> bt) {
|
||||
ThreadHelper.runAsync(() -> {
|
||||
var r = showBlockingAlert(c);
|
||||
|
@ -108,11 +99,15 @@ public class AppWindowHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static Optional<ButtonType> showBlockingAlert(Alert a) {
|
||||
public static Optional<ButtonType> showBlockingAlert(Consumer<Alert> c) {
|
||||
AtomicReference<Optional<ButtonType>> result = new AtomicReference<>();
|
||||
if (!Platform.isFxApplicationThread()) {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
Platform.runLater(() -> {
|
||||
Alert a = AppWindowHelper.createEmptyAlert();
|
||||
AppFont.normal(a.getDialogPane());
|
||||
|
||||
c.accept(a);
|
||||
result.set(a.showAndWait());
|
||||
latch.countDown();
|
||||
});
|
||||
|
@ -121,6 +116,10 @@ public class AppWindowHelper {
|
|||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
} else {
|
||||
Alert a = createEmptyAlert();
|
||||
AppFont.normal(a.getDialogPane());
|
||||
c.accept(a);
|
||||
|
||||
Button button = (Button) a.getDialogPane().lookupButton(ButtonType.OK);
|
||||
if (button != null) {
|
||||
button.getStyleClass().add("ok-button");
|
||||
|
@ -131,13 +130,6 @@ public class AppWindowHelper {
|
|||
return result.get();
|
||||
}
|
||||
|
||||
public static Optional<ButtonType> showBlockingAlert(Consumer<Alert> c) {
|
||||
Alert a = AppWindowHelper.createEmptyAlert();
|
||||
AppFont.normal(a.getDialogPane());
|
||||
c.accept(a);
|
||||
return showBlockingAlert(a);
|
||||
}
|
||||
|
||||
public static Alert createEmptyAlert() {
|
||||
Alert alert = new Alert(Alert.AlertType.NONE);
|
||||
setIcon(alert);
|
||||
|
|
|
@ -12,16 +12,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
|
||||
public class MacOsPermissions {
|
||||
|
||||
private static Alert createAlert() {
|
||||
var alert = AppWindowHelper.createEmptyAlert();
|
||||
alert.setAlertType(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle(I18n.get("permissionsAlertTitle"));
|
||||
alert.setHeaderText(I18n.get("permissionsAlertTitleHeader"));
|
||||
alert.getDialogPane().setContent(AppWindowHelper.alertContentText(I18n.get("permissionsAlertTitleContent")));
|
||||
alert.getButtonTypes().clear();
|
||||
return alert;
|
||||
}
|
||||
|
||||
public static boolean waitForAccessibilityPermissions() throws Exception {
|
||||
AtomicReference<Alert> alert = new AtomicReference<>();
|
||||
var state = new SimpleBooleanProperty(true);
|
||||
|
@ -42,8 +32,14 @@ public class MacOsPermissions {
|
|||
return;
|
||||
}
|
||||
|
||||
alert.set(createAlert());
|
||||
AppWindowHelper.showAlert(alert.get(), buttonType -> {
|
||||
AppWindowHelper.showAlert(a -> {
|
||||
a.setAlertType(Alert.AlertType.INFORMATION);
|
||||
a.setTitle(I18n.get("permissionsAlertTitle"));
|
||||
a.setHeaderText(I18n.get("permissionsAlertTitleHeader"));
|
||||
a.getDialogPane().setContent(AppWindowHelper.alertContentText(I18n.get("permissionsAlertTitleContent")));
|
||||
a.getButtonTypes().clear();
|
||||
alert.set(a);
|
||||
}, buttonType -> {
|
||||
alert.get().close();
|
||||
if (buttonType.isEmpty() || !buttonType.get().getButtonData().isDefaultButton()) {
|
||||
state.set(false);
|
||||
|
|
Loading…
Reference in a new issue