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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public enum ThemeColorType {
/// Uses the built-in launcher default theme color.
DEFAULT,

/// Follows the accent color provided by the operating system.
SYSTEM,

/// Uses the custom launcher theme color selected by the user.
CUSTOM,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ private static ThemeColorSource currentThemeColorSource() throws IOException {
if (themeColorType == ThemeColorType.DEFAULT) {
return ThemeColorSource.DEFAULT;
}
if (themeColorType == ThemeColorType.SYSTEM) {
return ThemeColorSource.custom(Themes.getSystemThemeColor());
}
if (themeColorType == ThemeColorType.BACKGROUND) {
if (backgroundType == BackgroundType.THEME_COLOR) {
return ThemeColorSource.DEFAULT;
Expand Down
13 changes: 13 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/theme/Themes.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public final class Themes {
if (FXUtils.DARK_MODE != null) {
observables.add(FXUtils.DARK_MODE);
}
if (FXUtils.ACCENT_COLOR != null) {
observables.add(FXUtils.ACCENT_COLOR);
}
bind(observables.toArray(new Observable[0]));
}

Expand Down Expand Up @@ -195,6 +198,7 @@ static ThemeColor resolveThemeColor(
}
return switch (themeColorType) {
case DEFAULT -> ThemeColor.DEFAULT;
case SYSTEM -> getSystemThemeColor();
case CUSTOM -> fallback;
case BACKGROUND -> resolveWallpaperThemeColor(fallback, backgroundType);
};
Expand Down Expand Up @@ -528,6 +532,15 @@ private static Brightness getDefaultBrightness() {
return defaultBrightness = brightness;
}

/// Returns the current operating system accent color, or the launcher default when unavailable.
public static ThemeColor getSystemThemeColor() {
if (FXUtils.ACCENT_COLOR == null) {
return ThemeColor.DEFAULT;
}
@Nullable Color accentColor = FXUtils.ACCENT_COLOR.get();
return accentColor != null ? ThemeColor.of(accentColor) : ThemeColor.DEFAULT;
}

/// Returns the current resolved launcher theme.
public static ResolvedTheme getTheme() {
return theme.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ public PersonalizationPage() {
i18n("settings.launcher.theme_color_type.default"),
ThemeColorType.DEFAULT);

var systemColorChoice = new RadioChoiceList.Choice<ThemeColorType>(
i18n("settings.launcher.theme_color_type.system"),
ThemeColorType.SYSTEM);

var customColorChoice = new RadioChoiceList.Choice<ThemeColorType>(
i18n("settings.launcher.theme_color_type.custom"),
ThemeColorType.CUSTOM) {
Expand All @@ -461,7 +465,11 @@ protected Node createRightNode() {

RadioChoiceList<ThemeColorType> themeColorChoiceList = new RadioChoiceList<>();
themeColorChoiceList.setFallbackValue(ThemeColorType.DEFAULT);
themeColorChoiceList.setChoices(Arrays.asList(defaultColorChoice, customColorChoice, backgroundColorChoice));
themeColorChoiceList.setChoices(Arrays.asList(
defaultColorChoice,
systemColorChoice,
customColorChoice,
backgroundColorChoice));

JFXButton themeColorOverrideButton = createThemeAppearanceOverrideButton();
themeColorSublist.setTitleRight(themeColorOverrideButton);
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ settings.launcher.theme_color_type.background=Follow Background Wallpaper
settings.launcher.theme_color_type.custom=Custom Color
settings.launcher.theme_color_type.custom.description=Use the color selected above.
settings.launcher.theme_color_type.default=Default
settings.launcher.theme_color_type.system=Follow System
settings.launcher.title_transparent=Transparent Titlebar
settings.launcher.turn_off_animations=Disable Animation
settings.launcher.version_list_source=Version List
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ settings.launcher.theme_color_type.background=跟隨背景圖片
settings.launcher.theme_color_type.custom=自訂顏色
settings.launcher.theme_color_type.custom.description=使用上方選擇的顏色。
settings.launcher.theme_color_type.default=預設
settings.launcher.theme_color_type.system=跟隨系統
settings.launcher.title_transparent=標題欄透明
settings.launcher.turn_off_animations=關閉動畫
settings.launcher.version_list_source=版本清單來源
Expand Down
1 change: 1 addition & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,7 @@ settings.launcher.theme_color_type.background=跟随背景壁纸
settings.launcher.theme_color_type.custom=自定义颜色
settings.launcher.theme_color_type.custom.description=使用上方选择的颜色。
settings.launcher.theme_color_type.default=默认
settings.launcher.theme_color_type.system=跟随系统
settings.launcher.title_transparent=标题栏透明
settings.launcher.turn_off_animations=关闭动画
settings.launcher.version_list_source=版本列表源
Expand Down