mirror of
https://github.com/rememberber/MooTool.git
synced 2026-08-30 18:02:12 +08:00
[global]opt:The tray icon is made transparent.
This commit is contained in:
@@ -1773,7 +1773,7 @@ function updateTray(settings: AppSettings): void {
|
||||
}
|
||||
|
||||
if (!tray) {
|
||||
const traySize = process.platform === 'darwin' ? 18 : 20
|
||||
const traySize = process.platform === 'darwin' ? 20 : 24
|
||||
const trayImage = nativeImage.createFromPath(getTrayIconPath()).resize({ width: traySize, height: traySize })
|
||||
if (trayImage.isEmpty()) return
|
||||
if (process.platform === 'darwin') trayImage.setTemplateImage(true)
|
||||
|
||||
@@ -62,6 +62,7 @@ public class App {
|
||||
|
||||
if (SystemInfo.isMacOS) {
|
||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||
System.setProperty("apple.awt.enableTemplateImages", "true");
|
||||
System.setProperty("apple.awt.application.name", "MooTool");
|
||||
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "MooTool");
|
||||
System.setProperty("apple.awt.application.appearance", "system");
|
||||
|
||||
@@ -299,8 +299,12 @@ public class Init {
|
||||
public static void initTray() {
|
||||
|
||||
try {
|
||||
if (SystemTray.isSupported() && App.tray == null) {
|
||||
App.tray = SystemTray.getSystemTray();
|
||||
if (!SystemTray.isSupported()) {
|
||||
logger.warn("System tray is not supported");
|
||||
return;
|
||||
}
|
||||
if (App.trayIcon == null) {
|
||||
SystemTray tray = App.tray != null ? App.tray : SystemTray.getSystemTray();
|
||||
|
||||
App.popupMenu = new JPopupMenu();
|
||||
// App.popupMenu.setFont(App.mainFrame.getContentPane().getFont());
|
||||
@@ -337,20 +341,23 @@ public class Init {
|
||||
App.popupMenu.addSeparator();
|
||||
App.popupMenu.add(exitItem);
|
||||
|
||||
App.trayIcon = new TrayIcon(UiConsts.IMAGE_TRAY_64, "MooTool");
|
||||
App.trayIcon.setImageAutoSize(true);
|
||||
TrayIcon trayIcon = new TrayIcon(UiConsts.IMAGE_TRAY_64, "MooTool");
|
||||
trayIcon.setImageAutoSize(true);
|
||||
|
||||
App.trayIcon.addActionListener(e -> {
|
||||
trayIcon.addActionListener(e -> {
|
||||
App.mainFrame.setVisible(true);
|
||||
App.mainFrame.setExtendedState(JFrame.NORMAL);
|
||||
App.mainFrame.requestFocus();
|
||||
});
|
||||
|
||||
JPopupMenuMouseAdapter jPopupMenuMouseAdapter = new JPopupMenuMouseAdapter(App.popupMenu);
|
||||
App.trayIcon.addMouseListener(jPopupMenuMouseAdapter);
|
||||
trayIcon.addMouseListener(jPopupMenuMouseAdapter);
|
||||
|
||||
try {
|
||||
App.tray.add(App.trayIcon);
|
||||
tray.add(trayIcon);
|
||||
App.tray = tray;
|
||||
App.trayIcon = trayIcon;
|
||||
logger.info("System tray icon initialized");
|
||||
} catch (AWTException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(ExceptionUtils.getStackTrace(e));
|
||||
|
||||
@@ -62,6 +62,7 @@ public final class StartupCoordinator {
|
||||
started = true;
|
||||
phase.set(StartupPhase.SHELL_VISIBLE);
|
||||
StartupMetrics.mark("mainFrame.visible");
|
||||
Init.initTray();
|
||||
|
||||
phase.set(StartupPhase.CRITICAL_LOADING);
|
||||
StartupMetrics.mark("critical.loading");
|
||||
|
||||
Reference in New Issue
Block a user