Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## v0.2.1
- Improve Dialogs.getDefaultOwner() logic https://github.com/qupath/qupath-fxtras/pull/60

## v0.2.0
- Update gradle, version https://github.com/qupath/qupath-fxtras/pull/48
- FXUtils commands to get stages https://github.com/qupath/qupath-fxtras/pull/47
- Convert to kotlin https://github.com/qupath/qupath-fxtras/pull/49
- Make the use of country codes optional https://github.com/qupath/qupath-fxtras/pull/50
- Fix publishing https://github.com/qupath/qupath-fxtras/pull/51
- Update version https://github.com/qupath/qupath-fxtras/pull/52
- Improve file chooser behavior https://github.com/qupath/qupath-fxtras/pull/53

## v0.1.7
- Improve screen choice for input display https://github.com/qupath/qupath-fxtras/pull/44

## v0.1.6
- Allow default directory to be set when prompting for a file with FileChoosers (https://github.com/qupath/qupath-fxtras/issues/40)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

base {
group = "io.github.qupath"
version = "0.2.0"
version = "0.2.1"
description = "Extra classes built on JavaFX that are used to help create the QuPath user interface. " +
"These don't depend on other QuPath modules, so can be reused elsewhere."
}
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/qupath/fx/dialogs/Dialogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,27 @@ static Window getDefaultOwner() {
.thenComparing(w -> w.isFocused() ? -1 : 1) // Prefer focused windows
.thenComparing(w -> w == primaryWindow) // Prefer the primary window
.thenComparing(Dialogs::getTitle); // Finally sort by title
var owner = Window.getWindows().stream()
.filter(w -> !(w instanceof PopupWindow)) // Avoid popup windows (they don't work well as owners)
.sorted(comparator)
.findFirst()
// Avoid popup windows (they don't work well as owners)
return Window.getWindows().stream()
.filter(Dialogs::maybeOwner)
.min(comparator)
.orElse(primaryWindow);
return owner;
}

private static boolean maybeOwner(Window window) {
// Don't accept popup windows
if (window instanceof PopupWindow || !window.isShowing())
return false;
// Only accept 'normal', decorated, non-transparent stages
if (window instanceof Stage stage) {
return switch (stage.getStyle()) {
case UNDECORATED, TRANSPARENT, UTILITY -> false;
default -> true;
};
}
return true;
}

private static String getTitle(Window window) {
String title = null;
if (window instanceof Stage stage)
Expand Down