diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index f5198c78e83d68ec012b149b28124439112cf824..de6be7a08543fc9dcbbdb32fd5649297b7e2db04 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -86,6 +86,7 @@ ShowInMultiview="Show in Multiview" VerticalLayout="Vertical Layout" Group="Group" DoNotShowAgain="Do not show again" +Default="(Default)" # warning if program already open AlreadyRunning.Title="OBS is already running" diff --git a/UI/data/themes/Default.qss b/UI/data/themes/System.qss similarity index 100% rename from UI/data/themes/Default.qss rename to UI/data/themes/System.qss diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index a58b2833513dd237a29d23fa2a81e1707b0ed92f..f271d0450ce19c4d310b931cdc3caba84969a688 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -54,6 +54,8 @@ #include +#include "ui-config.h" + using namespace std; static log_handler_t def_log_handler; @@ -423,7 +425,7 @@ bool OBSApp::InitGlobalConfigDefaults() if (!config_get_bool(globalConfig, "General", "Pre21Defaults")) { config_set_default_string(globalConfig, "General", - "CurrentTheme", "Dark"); + "CurrentTheme", DEFAULT_THEME); } config_set_default_bool(globalConfig, "BasicWindow", @@ -1026,18 +1028,22 @@ bool OBSApp::InitTheme() const char *themeName = config_get_string(globalConfig, "General", "CurrentTheme"); + + if (strcmp(themeName, "Default") == 0) + themeName = "System"; + if (!themeName) { /* Use deprecated "Theme" value if available */ themeName = config_get_string(globalConfig, "General", "Theme"); if (!themeName) - themeName = "Default"; + themeName = DEFAULT_THEME; } - if (strcmp(themeName, "Default") != 0 && SetTheme(themeName)) + if (strcmp(themeName, DEFAULT_THEME) != 0 && SetTheme(themeName)) return true; - return SetTheme("Default"); + return SetTheme(DEFAULT_THEME); } OBSApp::OBSApp(int &argc, char **argv, profiler_name_store_t *store) diff --git a/UI/ui-config.h.in b/UI/ui-config.h.in index d2c7dd5fe4934e2a8b36756ba1c4670523d8f828..fe31138bb003e2fa34ce36155271605bcf4e0a01 100644 --- a/UI/ui-config.h.in +++ b/UI/ui-config.h.in @@ -27,3 +27,5 @@ #define RESTREAM_ENABLED @RESTREAM_ENABLED@ #define RESTREAM_CLIENTID "@RESTREAM_CLIENTID@" #define RESTREAM_HASH 0x@RESTREAM_HASH@ + +#define DEFAULT_THEME "Dark" diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index c34c5988e90563c0c662191d906fdefec1b01c55..19077ed105d7bc3568948ce90f12c875001108ca 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -48,6 +48,7 @@ #include "window-projector.hpp" #include +#include "ui-config.h" using namespace std; @@ -1003,17 +1004,31 @@ void OBSBasicSettings::LoadThemeList() } } + QString defaultTheme; + defaultTheme += DEFAULT_THEME; + defaultTheme += " "; + defaultTheme += QTStr("Default"); + /* Check shipped themes. */ QDirIterator uIt(QString(themeDir.c_str()), QStringList() << "*.qss", QDir::Files); while (uIt.hasNext()) { uIt.next(); QString name = uIt.fileName().section(".",0,0); - if (!uniqueSet.contains(name)) + + if (name == DEFAULT_THEME) + name = defaultTheme; + + if (!uniqueSet.contains(name) && name != "Default") ui->theme->addItem(name); } - int idx = ui->theme->findText(App()->GetTheme()); + const char *themeName = App()->GetTheme(); + + if (strcmp(themeName, DEFAULT_THEME) == 0) + themeName = QT_TO_UTF8(defaultTheme); + + int idx = ui->theme->findText(themeName); if (idx != -1) ui->theme->setCurrentIndex(idx); } @@ -2657,13 +2672,19 @@ void OBSBasicSettings::SaveGeneralSettings() int themeIndex = ui->theme->currentIndex(); QString themeData = ui->theme->itemText(themeIndex); - string theme = themeData.toStdString(); + QString defaultTheme; + defaultTheme += DEFAULT_THEME; + defaultTheme += " "; + defaultTheme += QTStr("Default"); + + if (themeData == defaultTheme) + themeData = DEFAULT_THEME; if (WidgetChanged(ui->theme)) { config_set_string(GetGlobalConfig(), "General", "CurrentTheme", - theme.c_str()); + QT_TO_UTF8(themeData)); - App()->SetTheme(theme); + App()->SetTheme(themeData.toUtf8().constData()); } #if defined(_WIN32) || defined(__APPLE__) @@ -3392,8 +3413,17 @@ void OBSBasicSettings::closeEvent(QCloseEvent *event) void OBSBasicSettings::on_theme_activated(int idx) { - string currT = ui->theme->itemText(idx).toStdString(); - App()->SetTheme(currT); + QString currT = ui->theme->itemText(idx); + + QString defaultTheme; + defaultTheme += DEFAULT_THEME; + defaultTheme += " "; + defaultTheme += QTStr("Default"); + + if (currT == defaultTheme) + currT = DEFAULT_THEME; + + App()->SetTheme(currT.toUtf8().constData()); } void OBSBasicSettings::on_listWidget_itemSelectionChanged()