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);
|
chat->SetWidget(browser);
|
||||||
cef->add_force_popup_url(moderation_tools_url, chat.data());
|
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 =
|
const int twAddonChoice =
|
||||||
config_get_int(main->Config(), service(), "AddonChoice");
|
config_get_int(main->Config(), service(), "AddonChoice");
|
||||||
@ -276,7 +280,11 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
|||||||
QSize size = main->frameSize();
|
QSize size = main->frameSize();
|
||||||
QPoint pos = main->pos();
|
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 += referrer_script1;
|
||||||
script += "https://www.twitch.tv/";
|
script += "https://www.twitch.tv/";
|
||||||
script += name;
|
script += name;
|
||||||
|
@ -1121,6 +1121,8 @@ bool OBSApp::SetTheme(std::string name, std::string path)
|
|||||||
setPalette(defaultPalette);
|
setPalette(defaultPalette);
|
||||||
ParseExtraThemeData(path.c_str());
|
ParseExtraThemeData(path.c_str());
|
||||||
setStyleSheet(mpath);
|
setStyleSheet(mpath);
|
||||||
|
QColor color = palette().text().color();
|
||||||
|
themeDarkMode = !(color.redF() < 0.5);
|
||||||
|
|
||||||
emit StyleChanged();
|
emit StyleChanged();
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,6 +74,7 @@ class OBSApp : public QApplication {
|
|||||||
private:
|
private:
|
||||||
std::string locale;
|
std::string locale;
|
||||||
std::string theme;
|
std::string theme;
|
||||||
|
bool themeDarkMode = true;
|
||||||
ConfigFile globalConfig;
|
ConfigFile globalConfig;
|
||||||
TextLookup textLookup;
|
TextLookup textLookup;
|
||||||
QPointer<OBSMainWindow> mainWindow;
|
QPointer<OBSMainWindow> mainWindow;
|
||||||
@ -127,6 +128,7 @@ public:
|
|||||||
|
|
||||||
inline const char *GetTheme() const { return theme.c_str(); }
|
inline const char *GetTheme() const { return theme.c_str(); }
|
||||||
bool SetTheme(std::string name, std::string path = "");
|
bool SetTheme(std::string name, std::string path = "");
|
||||||
|
inline bool IsThemeDark() const { return themeDarkMode; };
|
||||||
|
|
||||||
inline lookup_t *GetTextLookup() const { return textLookup; }
|
inline lookup_t *GetTextLookup() const { return textLookup; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user