mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-02 18:51:01 +12:00
Set proper terminal default value
This commit is contained in:
parent
0a7741cb8c
commit
6c91639293
3 changed files with 18 additions and 30 deletions
|
@ -74,15 +74,6 @@ public class AppWindowHelper {
|
||||||
childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2);
|
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) {
|
public static void showAlert(Consumer<Alert> c, Consumer<Optional<ButtonType>> bt) {
|
||||||
ThreadHelper.runAsync(() -> {
|
ThreadHelper.runAsync(() -> {
|
||||||
var r = showBlockingAlert(c);
|
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<>();
|
AtomicReference<Optional<ButtonType>> result = new AtomicReference<>();
|
||||||
if (!Platform.isFxApplicationThread()) {
|
if (!Platform.isFxApplicationThread()) {
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
Alert a = AppWindowHelper.createEmptyAlert();
|
||||||
|
AppFont.normal(a.getDialogPane());
|
||||||
|
|
||||||
|
c.accept(a);
|
||||||
result.set(a.showAndWait());
|
result.set(a.showAndWait());
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
|
@ -121,6 +116,10 @@ public class AppWindowHelper {
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Alert a = createEmptyAlert();
|
||||||
|
AppFont.normal(a.getDialogPane());
|
||||||
|
c.accept(a);
|
||||||
|
|
||||||
Button button = (Button) a.getDialogPane().lookupButton(ButtonType.OK);
|
Button button = (Button) a.getDialogPane().lookupButton(ButtonType.OK);
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.getStyleClass().add("ok-button");
|
button.getStyleClass().add("ok-button");
|
||||||
|
@ -131,13 +130,6 @@ public class AppWindowHelper {
|
||||||
return result.get();
|
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() {
|
public static Alert createEmptyAlert() {
|
||||||
Alert alert = new Alert(Alert.AlertType.NONE);
|
Alert alert = new Alert(Alert.AlertType.NONE);
|
||||||
setIcon(alert);
|
setIcon(alert);
|
||||||
|
|
|
@ -12,16 +12,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class MacOsPermissions {
|
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 {
|
public static boolean waitForAccessibilityPermissions() throws Exception {
|
||||||
AtomicReference<Alert> alert = new AtomicReference<>();
|
AtomicReference<Alert> alert = new AtomicReference<>();
|
||||||
var state = new SimpleBooleanProperty(true);
|
var state = new SimpleBooleanProperty(true);
|
||||||
|
@ -42,8 +32,14 @@ public class MacOsPermissions {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alert.set(createAlert());
|
AppWindowHelper.showAlert(a -> {
|
||||||
AppWindowHelper.showAlert(alert.get(), buttonType -> {
|
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();
|
alert.get().close();
|
||||||
if (buttonType.isEmpty() || !buttonType.get().getButtonData().isDefaultButton()) {
|
if (buttonType.isEmpty() || !buttonType.get().getButtonData().isDefaultButton()) {
|
||||||
state.set(false);
|
state.set(false);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
return ALL.stream()
|
return ALL.stream()
|
||||||
.filter(terminalType -> terminalType.isAvailable())
|
.filter(terminalType -> terminalType.isAvailable())
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(CUSTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void launch(String name, String command) throws Exception;
|
public abstract void launch(String name, String command) throws Exception;
|
||||||
|
|
Loading…
Reference in a new issue