UI: Set Twitch Panel Dark Mode using OBS theme
Check if the current OBS theme is "Dark Mode"-esque and use that to determine if the Twitch browser panel docks should use Twitch's Dark Mode or not.
This commit is contained in:
parent
079e6cebee
commit
54a808c34a
@ -229,7 +229,11 @@ void TwitchAuth::LoadUI()
|
||||
chat->SetWidget(browser);
|
||||
cef->add_force_popup_url(moderation_tools_url, chat.data());
|
||||
|
||||
script = "localStorage.setItem('twilight.theme', 1);";
|
||||
if (App()->IsThemeDark()) {
|
||||
script = "localStorage.setItem('twilight.theme', 1);";
|
||||
} else {
|
||||
script = "localStorage.setItem('twilight.theme', 0);";
|
||||
}
|
||||
|
||||
const int twAddonChoice =
|
||||
config_get_int(main->Config(), service(), "AddonChoice");
|
||||
@ -276,7 +280,11 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
||||
QSize size = main->frameSize();
|
||||
QPoint pos = main->pos();
|
||||
|
||||
script = "localStorage.setItem('twilight.theme', 1);";
|
||||
if (App()->IsThemeDark()) {
|
||||
script = "localStorage.setItem('twilight.theme', 1);";
|
||||
} else {
|
||||
script = "localStorage.setItem('twilight.theme', 0);";
|
||||
}
|
||||
script += referrer_script1;
|
||||
script += "https://www.twitch.tv/";
|
||||
script += name;
|
||||
|
@ -1121,6 +1121,8 @@ bool OBSApp::SetTheme(std::string name, std::string path)
|
||||
setPalette(defaultPalette);
|
||||
ParseExtraThemeData(path.c_str());
|
||||
setStyleSheet(mpath);
|
||||
QColor color = palette().text().color();
|
||||
themeDarkMode = !(color.redF() < 0.5);
|
||||
|
||||
emit StyleChanged();
|
||||
return true;
|
||||
|
@ -74,6 +74,7 @@ class OBSApp : public QApplication {
|
||||
private:
|
||||
std::string locale;
|
||||
std::string theme;
|
||||
bool themeDarkMode = true;
|
||||
ConfigFile globalConfig;
|
||||
TextLookup textLookup;
|
||||
QPointer<OBSMainWindow> mainWindow;
|
||||
@ -127,6 +128,7 @@ public:
|
||||
|
||||
inline const char *GetTheme() const { return theme.c_str(); }
|
||||
bool SetTheme(std::string name, std::string path = "");
|
||||
inline bool IsThemeDark() const { return themeDarkMode; };
|
||||
|
||||
inline lookup_t *GetTextLookup() const { return textLookup; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user