Skip to content

Commit

Permalink
Fix default printer searching on 2.1.6 (qzind#945)
Browse files Browse the repository at this point in the history
Fixes the default printer missing on MacOS
Closes qzind#944
  • Loading branch information
tresf authored Mar 24, 2022
1 parent 988a07d commit 914f6c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/qz/printer/PrintServiceMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static NativePrinter getDefaultPrinter() {
printers.putAll(defaultService);
}

return printers.get(defaultService.getName());
return printers.get(defaultService);
}

public static String findPrinterName(String query) throws JSONException {
Expand Down
10 changes: 10 additions & 0 deletions src/qz/printer/info/NativePrinterMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import qz.utils.SystemUtilities;

import javax.print.PrintService;
import java.lang.annotation.Native;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
Expand Down Expand Up @@ -68,4 +69,13 @@ public boolean contains(PrintService service) {
}
return false;
}

public NativePrinter get(PrintService service) {
for (NativePrinter printer : values()) {
if (printer.getPrintService().equals(service)) {
return printer;
}
}
return null;
}
}

0 comments on commit 914f6c0

Please sign in to comment.