Skip to content

How does wiliwili detect system theme in ? #177

Answered by xfangfang
yuioto asked this question in Q&A
Discussion options

You must be logged in to vote

wiliwili目前还不支持运行时检测系统主题。

  1. 在窗口初始化时

读取环境变量:BOREALIS_THEME。若未设定,PC平台在 macOS 和 UWP 下自动获取系统主题,其他系统默认为白色主题

https://github.com/xfangfang/borealis/blob/a3e600e5e6f5b0e1bf7546fa47ff075296cf4357/library/lib/platforms/desktop/desktop_platform.cpp#L370-L401

BOREALIS_THEME 可能为的值是:DARK / LIGHT

  1. 在初始化之后
    读取配置目录,如果有应用内强制设定的主题,还会覆盖前面的设置

// 初始化主题
std::string themeData =
getSettingItem(SettingItem::APP_THEME, std::string{"auto"});
if (themeData == "light") {
brls::Application::getPlatform()->setThemeVariant(
brls::ThemeVariant::LIGHT);
} else if (themeData == "dark") {
brls::Applicatio…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by yuioto
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants