Various fixes

This commit is contained in:
crschnick
2024-12-31 01:31:14 +00:00
parent 4d150abc00
commit 63d043c0be
12 changed files with 34 additions and 19 deletions
@@ -20,6 +20,10 @@ public class LabelComp extends Comp<CompStructure<Label>> {
private final ObservableValue<String> text;
private final ObservableValue<LabelGraphic> graphic;
public LabelComp(String text, LabelGraphic graphic) {
this(new SimpleStringProperty(text), new SimpleObjectProperty<>(graphic));
}
public LabelComp(String text) {
this(new SimpleStringProperty(text));
}
@@ -162,7 +162,7 @@ public class ModalOverlayComp extends SimpleComp {
});
content.setSpacing(25);
content.setPadding(new Insets(13, 27, 20, 27));
if (newValue.getTitleKey() != null) {
var l = new Label(
AppI18n.get(newValue.getTitleKey()),
@@ -17,7 +17,7 @@ public class StoreIconChoiceDialog {
public static void show(DataStoreEntry entry) {
var dialog = new StoreIconChoiceDialog(entry);
dialog.getOverlay().showAndWait();
dialog.getOverlay().show();
}
private final ObjectProperty<SystemIcon> selected = new SimpleObjectProperty<>();
@@ -101,7 +101,7 @@ public class BaseMode extends OperationMode {
});
imagesLoaded.await();
browserLoaded.await();
AppDialog.waitForClose();
AppDialog.waitForAllDialogsClose();
PlatformThread.runLaterIfNeededBlocking(() -> {
AppMainWindow.initContent();
});
@@ -7,6 +7,7 @@ import io.xpipe.app.core.check.AppTempCheck;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.issue.*;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.CloseBehaviour;
import io.xpipe.app.util.*;
import io.xpipe.core.process.OsType;
import io.xpipe.core.util.FailableRunnable;
@@ -273,21 +274,21 @@ public abstract class OperationMode {
}
public static void onWindowClose() {
if (AppPrefs.get() == null) {
return;
CloseBehaviour action;
if (AppPrefs.get() != null && !isInStartup() && !isInShutdown()) {
action = AppPrefs.get().closeBehaviour().getValue();
} else {
action = CloseBehaviour.QUIT;
}
var action = AppPrefs.get().closeBehaviour().getValue();
ThreadHelper.runAsync(() -> {
action.run();
});
}
public static void shutdown(boolean inShutdownHook, boolean hasError) {
// We can receive shutdown events while we are still starting up
// In that case ignore them until we are finished
if (isInStartup()) {
return;
TrackEvent.info("Received shutdown request while in startup. Halting ...");
OperationMode.halt(1);
}
// In case we are stuck while in shutdown, instantly exit this application
@@ -38,12 +38,22 @@ public class AppDialog {
});
}
public static void waitForClose() {
public static void waitForAllDialogsClose() {
while (!modalOverlay.isEmpty()) {
ThreadHelper.sleep(10);
}
}
private static void waitForDialogClose(ModalOverlay overlay) {
while (modalOverlay.contains(overlay)) {
ThreadHelper.sleep(10);
}
}
public static void show(ModalOverlay o) {
show(o, false);
}
public static void showAndWait(ModalOverlay o) {
show(o, true);
}
@@ -54,7 +64,7 @@ public class AppDialog {
PlatformThread.runLaterIfNeededBlocking(() -> {
modalOverlay.add(o);
});
waitForClose();
waitForDialogClose(o);
ThreadHelper.sleep(200);
} else {
var key = new Object();
@@ -78,7 +88,7 @@ public class AppDialog {
});
if (wait) {
Platform.enterNestedEventLoop(key);
waitForClose();
waitForDialogClose(o);
}
}
}
@@ -262,7 +262,7 @@ public class AppMainWindow {
});
stage.setOnCloseRequest(e -> {
if (!CloseBehaviourDialog.showIfNeeded()) {
if (!OperationMode.isInStartup() && !OperationMode.isInShutdown() && !CloseBehaviourDialog.showIfNeeded()) {
e.consume();
return;
}
@@ -57,6 +57,6 @@ public class ErrorHandlerDialog {
}
});
AppDialog.show(modal.get(), true);
AppDialog.showAndWait(modal.get());
}
}
@@ -32,7 +32,7 @@ public class SyncCategory extends AppPrefsCategory {
var markdown = new MarkdownComp(md, s -> s).prefWidth(600);
var modal = ModalOverlay.of(null, markdown);
modal.addButton(ModalButton.ok());
AppDialog.showAndWait(modal);
AppDialog.show(modal);
}
public Comp<?> create() {
@@ -65,6 +65,6 @@ public class UpdateAvailableAlert {
},
false,
true));
AppDialog.showAndWait(modal);
AppDialog.show(modal);
}
}
@@ -42,6 +42,6 @@ public class UpdateChangelogAlert {
});
var modal = ModalOverlay.of("updateChangelogAlertTitle", comp.prefWidth(600), null);
modal.addButton(ModalButton.ok());
AppDialog.showAndWait(modal);
AppDialog.show(modal);
}
}
@@ -77,6 +77,6 @@ public class ScanDialog {
modal.addButton(ModalButton.ok(() -> {
comp.finish();
}));
modal.showAndWait();
modal.show();
}
}