forked from dorkbox/SystemTray
Code polish
This commit is contained in:
parent
bb03e870c7
commit
9fdee240f8
@ -59,8 +59,7 @@ class ImageUtils {
|
||||
*/
|
||||
public static
|
||||
void determineIconSize(int trayType) {
|
||||
int trayScale;
|
||||
int menuScale;
|
||||
int scalingFactor = 0;
|
||||
|
||||
if (SystemTray.AUTO_TRAY_SIZE) {
|
||||
if (OS.isWindows()) {
|
||||
@ -96,7 +95,6 @@ class ImageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
int scalingFactor;
|
||||
if (windowsVersion.startsWith("5.1")) {
|
||||
// Windows XP 5.1.2600
|
||||
scalingFactor = 1;
|
||||
@ -144,25 +142,9 @@ class ImageUtils {
|
||||
if (SystemTray.DEBUG) {
|
||||
SystemTray.logger.error("Windows version (partial): '{}'", windowsVersion);
|
||||
}
|
||||
|
||||
// windows will automatically scale the tray size BUT NOT the menu entry icon size
|
||||
// we want to make sure our "scaled" size is appropriate for the OS.
|
||||
trayScale = SystemTray.DEFAULT_TRAY_SIZE * scalingFactor;
|
||||
menuScale = SystemTray.DEFAULT_MENU_SIZE;
|
||||
} else {
|
||||
// GtkStatusIcon will USUALLY automatically scale the icon
|
||||
// AppIndicator will NOT scale the icon
|
||||
if (trayType == SystemTray.TYPE_SWING || trayType == SystemTray.TYPE_GTK_STATUSICON) {
|
||||
// swing or GtkStatusIcon on linux/mac? use the default settings
|
||||
trayScale = SystemTray.DEFAULT_TRAY_SIZE;
|
||||
menuScale = SystemTray.DEFAULT_MENU_SIZE;
|
||||
} else {
|
||||
if (SystemTray.DEBUG) {
|
||||
SystemTray.logger.error("Auto detecting UI scale");
|
||||
}
|
||||
|
||||
int uiScalingFactor = 0;
|
||||
|
||||
// AppIndicator MIGHT scale the icon (depends on the OS)
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
|
||||
PrintStream outputStream = new PrintStream(byteArrayOutputStream);
|
||||
@ -186,7 +168,7 @@ class ImageUtils {
|
||||
// should be: uint32 0 or something
|
||||
if (output.contains("uint32")) {
|
||||
String value = output.substring(output.indexOf("uint")+7, output.length()-1);
|
||||
uiScalingFactor = Integer.parseInt(value);
|
||||
scalingFactor = Integer.parseInt(value);
|
||||
|
||||
// 0 is disabled (no scaling)
|
||||
// 1 is enabled (default scale)
|
||||
@ -205,35 +187,27 @@ class ImageUtils {
|
||||
SystemTray.logger.error("Cannot check scaling factor", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// windows, mac, linux(GtkStatusIcon) will automatically scale the tray size
|
||||
// the menu entry icon size will NOT get scaled (it will show whatever we specify)
|
||||
// we want to make sure our "scaled" size is appropriate for the OS.
|
||||
|
||||
// the DEFAULT scale is 16
|
||||
if (uiScalingFactor > 1) {
|
||||
trayScale = SystemTray.DEFAULT_TRAY_SIZE * uiScalingFactor;
|
||||
menuScale = SystemTray.DEFAULT_MENU_SIZE * uiScalingFactor;
|
||||
} else {
|
||||
trayScale = SystemTray.DEFAULT_TRAY_SIZE;
|
||||
menuScale = SystemTray.DEFAULT_MENU_SIZE;
|
||||
}
|
||||
if (scalingFactor > 1) {
|
||||
TRAY_SIZE = SystemTray.DEFAULT_TRAY_SIZE * scalingFactor;
|
||||
ENTRY_SIZE = SystemTray.DEFAULT_MENU_SIZE;
|
||||
|
||||
if (SystemTray.DEBUG) {
|
||||
SystemTray.logger.debug("uiScaling factor is '{}', auto tray size is '{}'.", uiScalingFactor, trayScale);
|
||||
}
|
||||
}
|
||||
SystemTray.logger.debug("Scaling Factor factor is '{}', tray size is '{}'.", scalingFactor, TRAY_SIZE);
|
||||
}
|
||||
} else {
|
||||
if (OS.isWindows()) {
|
||||
trayScale = SystemTray.DEFAULT_TRAY_SIZE;
|
||||
menuScale = SystemTray.DEFAULT_MENU_SIZE;
|
||||
} else {
|
||||
trayScale = SystemTray.DEFAULT_TRAY_SIZE;
|
||||
menuScale = SystemTray.DEFAULT_MENU_SIZE;
|
||||
TRAY_SIZE = SystemTray.DEFAULT_TRAY_SIZE;
|
||||
ENTRY_SIZE = SystemTray.DEFAULT_MENU_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
TRAY_SIZE = trayScale;
|
||||
ENTRY_SIZE = menuScale;
|
||||
}
|
||||
|
||||
|
||||
public static
|
||||
File getTransparentImage(final int size) {
|
||||
|
Loading…
Reference in New Issue
Block a user