mirror of
https://github.com/octopusYan/alist-gui.git
synced 2025-12-08 17:21:56 +08:00
Compare commits
3 Commits
alpha/v1.0
...
alpha/v1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b3a4f5569 | |||
| be7e17665f | |||
| 654b13e150 |
@ -1,6 +1,5 @@
|
|||||||
package cn.octopusyan.alistgui.config;
|
package cn.octopusyan.alistgui.config;
|
||||||
|
|
||||||
import atlantafx.base.theme.Theme;
|
|
||||||
import cn.octopusyan.alistgui.Application;
|
import cn.octopusyan.alistgui.Application;
|
||||||
import cn.octopusyan.alistgui.base.BaseController;
|
import cn.octopusyan.alistgui.base.BaseController;
|
||||||
import cn.octopusyan.alistgui.controller.AboutController;
|
import cn.octopusyan.alistgui.controller.AboutController;
|
||||||
@ -41,7 +40,6 @@ public class Context {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(Context.class);
|
private static final Logger log = LoggerFactory.getLogger(Context.class);
|
||||||
private static Scene scene;
|
private static Scene scene;
|
||||||
private static final IntegerProperty currentViewIndex = new SimpleIntegerProperty(0);
|
private static final IntegerProperty currentViewIndex = new SimpleIntegerProperty(0);
|
||||||
private static final ObjectProperty<Theme> theme = new SimpleObjectProperty<>(ConfigManager.theme());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制器集合
|
* 控制器集合
|
||||||
@ -92,10 +90,6 @@ public class Context {
|
|||||||
Context.application = application;
|
Context.application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectProperty<Theme> themeProperty() {
|
|
||||||
return theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前所选时区属性
|
// 获取当前所选时区属性
|
||||||
public static ObjectProperty<Locale> currentLocaleProperty() {
|
public static ObjectProperty<Locale> currentLocaleProperty() {
|
||||||
return currentLocale;
|
return currentLocale;
|
||||||
@ -150,12 +144,6 @@ public class Context {
|
|||||||
return LANGUAGE_RESOURCE_FACTORY.getResourceBundleProperty();
|
return LANGUAGE_RESOURCE_FACTORY.getResourceBundleProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化 语言
|
|
||||||
*/
|
|
||||||
private static void initI18n() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有此类所在路径决定相对路径
|
* 有此类所在路径决定相对路径
|
||||||
*
|
*
|
||||||
@ -183,7 +171,6 @@ public class Context {
|
|||||||
private static void loadScene() {
|
private static void loadScene() {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = FxmlUtil.load("root-view");
|
FXMLLoader loader = FxmlUtil.load("root-view");
|
||||||
loader.setControllerFactory(Context.getControlFactory());
|
|
||||||
//底层面板
|
//底层面板
|
||||||
Pane root = loader.load();
|
Pane root = loader.load();
|
||||||
Optional.ofNullable(scene).ifPresentOrElse(
|
Optional.ofNullable(scene).ifPresentOrElse(
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class SystemTrayManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
initTrayIcon();
|
initTrayIcon(AListManager.isRunning());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isShowing())
|
if (!isShowing())
|
||||||
@ -95,11 +95,12 @@ public class SystemTrayManager {
|
|||||||
|
|
||||||
//========================================={ private }===========================================
|
//========================================={ private }===========================================
|
||||||
|
|
||||||
private static void initTrayIcon() {
|
private static void initTrayIcon(boolean running) {
|
||||||
if (trayIcon != null) return;
|
if (trayIcon != null) return;
|
||||||
|
|
||||||
// 系统托盘图标
|
// 系统托盘图标
|
||||||
Image image = Toolkit.getDefaultToolkit().getImage(WindowsUtil.class.getResource("/assets/logo-disabled.png"));
|
URL resource = WindowsUtil.class.getResource(STR."/assets/logo\{running ? "" : "-disabled"}.png");
|
||||||
|
Image image = Toolkit.getDefaultToolkit().getImage(resource);
|
||||||
trayIcon = new TrayIcon(image);
|
trayIcon = new TrayIcon(image);
|
||||||
|
|
||||||
// 设置图标尺寸自动适应
|
// 设置图标尺寸自动适应
|
||||||
@ -129,7 +130,7 @@ public class SystemTrayManager {
|
|||||||
if (event.isPopupTrigger()) {
|
if (event.isPopupTrigger()) {
|
||||||
// 弹出菜单
|
// 弹出菜单
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
initPopupMenu();
|
initPopupMenu(running);
|
||||||
popupMenu.show(event);
|
popupMenu.show(event);
|
||||||
});
|
});
|
||||||
} else if (event.getButton() == MouseEvent.BUTTON1) {
|
} else if (event.getButton() == MouseEvent.BUTTON1) {
|
||||||
@ -143,12 +144,15 @@ public class SystemTrayManager {
|
|||||||
/**
|
/**
|
||||||
* 构建托盘菜单
|
* 构建托盘菜单
|
||||||
*/
|
*/
|
||||||
private static void initPopupMenu() {
|
private static void initPopupMenu(boolean running) {
|
||||||
if (popupMenu != null) return;
|
if (popupMenu != null) return;
|
||||||
|
|
||||||
MenuItem start = PopupMenu.menuItem(getString("main.control.start"), _ -> AListManager.openScheme());
|
MenuItem start = PopupMenu.menuItem(
|
||||||
|
getString(STR."main.control.\{running ? "stop" : "start"}"),
|
||||||
|
_ -> AListManager.openScheme()
|
||||||
|
);
|
||||||
MenuItem browser = PopupMenu.menuItem(getString("main.more.browser"), _ -> AListManager.openScheme());
|
MenuItem browser = PopupMenu.menuItem(getString("main.more.browser"), _ -> AListManager.openScheme());
|
||||||
browser.setDisable(true);
|
browser.setDisable(!running);
|
||||||
|
|
||||||
AListManager.runningProperty().addListener((_, _, newValue) -> {
|
AListManager.runningProperty().addListener((_, _, newValue) -> {
|
||||||
start.setText(getString(STR."main.control.\{newValue ? "stop" : "start"}"));
|
start.setText(getString(STR."main.control.\{newValue ? "stop" : "start"}"));
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class FxmlUtil {
|
|||||||
FxmlUtil.class.getResource(prefix + name + suffix),
|
FxmlUtil.class.getResource(prefix + name + suffix),
|
||||||
bundle,
|
bundle,
|
||||||
new JavaFXBuilderFactory(),
|
new JavaFXBuilderFactory(),
|
||||||
null,
|
Context.getControlFactory(),
|
||||||
StandardCharsets.UTF_8
|
StandardCharsets.UTF_8
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,6 @@ public class Registry {
|
|||||||
RESTORE,
|
RESTORE,
|
||||||
SAVE,
|
SAVE,
|
||||||
UNLOAD,
|
UNLOAD,
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Root {
|
public enum Root {
|
||||||
@ -75,6 +74,5 @@ public class Registry {
|
|||||||
REG_LINK,
|
REG_LINK,
|
||||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||||
REG_EXPAND_SZ,
|
REG_EXPAND_SZ,
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ public class SetupViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
|
|
||||||
public SetupViewModel() {
|
public SetupViewModel() {
|
||||||
theme.bindBidirectional(Context.themeProperty());
|
|
||||||
theme.addListener((_, _, newValue) -> ConfigManager.theme(newValue));
|
theme.addListener((_, _, newValue) -> ConfigManager.theme(newValue));
|
||||||
silentStartup.addListener((_, _, newValue) -> ConfigManager.silentStartup(newValue));
|
silentStartup.addListener((_, _, newValue) -> ConfigManager.silentStartup(newValue));
|
||||||
autoStart.addListener((_, _, newValue) -> {
|
autoStart.addListener((_, _, newValue) -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user