UI: Rename Default theme to System
The system theme was named Default even though the default theme is Dark. This addresses that by renaming Default.qss to System.qss. I've made it backwards compatible so users already using this theme are not affected. The theme list now shows up as: -System -Dark (Default) -Acri -Rachni I have also made it so that you can specify the default theme in the UI config file.master
parent
b5cc26a918
commit
94b3f80305
|
@ -86,6 +86,7 @@ ShowInMultiview="Show in Multiview"
|
||||||
VerticalLayout="Vertical Layout"
|
VerticalLayout="Vertical Layout"
|
||||||
Group="Group"
|
Group="Group"
|
||||||
DoNotShowAgain="Do not show again"
|
DoNotShowAgain="Do not show again"
|
||||||
|
Default="(Default)"
|
||||||
|
|
||||||
# warning if program already open
|
# warning if program already open
|
||||||
AlreadyRunning.Title="OBS is already running"
|
AlreadyRunning.Title="OBS is already running"
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "ui-config.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static log_handler_t def_log_handler;
|
static log_handler_t def_log_handler;
|
||||||
|
@ -423,7 +425,7 @@ bool OBSApp::InitGlobalConfigDefaults()
|
||||||
|
|
||||||
if (!config_get_bool(globalConfig, "General", "Pre21Defaults")) {
|
if (!config_get_bool(globalConfig, "General", "Pre21Defaults")) {
|
||||||
config_set_default_string(globalConfig, "General",
|
config_set_default_string(globalConfig, "General",
|
||||||
"CurrentTheme", "Dark");
|
"CurrentTheme", DEFAULT_THEME);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_set_default_bool(globalConfig, "BasicWindow",
|
config_set_default_bool(globalConfig, "BasicWindow",
|
||||||
|
@ -1026,18 +1028,22 @@ bool OBSApp::InitTheme()
|
||||||
|
|
||||||
const char *themeName = config_get_string(globalConfig, "General",
|
const char *themeName = config_get_string(globalConfig, "General",
|
||||||
"CurrentTheme");
|
"CurrentTheme");
|
||||||
|
|
||||||
|
if (strcmp(themeName, "Default") == 0)
|
||||||
|
themeName = "System";
|
||||||
|
|
||||||
if (!themeName) {
|
if (!themeName) {
|
||||||
/* Use deprecated "Theme" value if available */
|
/* Use deprecated "Theme" value if available */
|
||||||
themeName = config_get_string(globalConfig,
|
themeName = config_get_string(globalConfig,
|
||||||
"General", "Theme");
|
"General", "Theme");
|
||||||
if (!themeName)
|
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 true;
|
||||||
|
|
||||||
return SetTheme("Default");
|
return SetTheme(DEFAULT_THEME);
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSApp::OBSApp(int &argc, char **argv, profiler_name_store_t *store)
|
OBSApp::OBSApp(int &argc, char **argv, profiler_name_store_t *store)
|
||||||
|
|
|
@ -27,3 +27,5 @@
|
||||||
#define RESTREAM_ENABLED @RESTREAM_ENABLED@
|
#define RESTREAM_ENABLED @RESTREAM_ENABLED@
|
||||||
#define RESTREAM_CLIENTID "@RESTREAM_CLIENTID@"
|
#define RESTREAM_CLIENTID "@RESTREAM_CLIENTID@"
|
||||||
#define RESTREAM_HASH 0x@RESTREAM_HASH@
|
#define RESTREAM_HASH 0x@RESTREAM_HASH@
|
||||||
|
|
||||||
|
#define DEFAULT_THEME "Dark"
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "window-projector.hpp"
|
#include "window-projector.hpp"
|
||||||
|
|
||||||
#include <util/platform.h>
|
#include <util/platform.h>
|
||||||
|
#include "ui-config.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -1003,17 +1004,31 @@ void OBSBasicSettings::LoadThemeList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString defaultTheme;
|
||||||
|
defaultTheme += DEFAULT_THEME;
|
||||||
|
defaultTheme += " ";
|
||||||
|
defaultTheme += QTStr("Default");
|
||||||
|
|
||||||
/* Check shipped themes. */
|
/* Check shipped themes. */
|
||||||
QDirIterator uIt(QString(themeDir.c_str()), QStringList() << "*.qss",
|
QDirIterator uIt(QString(themeDir.c_str()), QStringList() << "*.qss",
|
||||||
QDir::Files);
|
QDir::Files);
|
||||||
while (uIt.hasNext()) {
|
while (uIt.hasNext()) {
|
||||||
uIt.next();
|
uIt.next();
|
||||||
QString name = uIt.fileName().section(".",0,0);
|
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);
|
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)
|
if (idx != -1)
|
||||||
ui->theme->setCurrentIndex(idx);
|
ui->theme->setCurrentIndex(idx);
|
||||||
}
|
}
|
||||||
|
@ -2657,13 +2672,19 @@ void OBSBasicSettings::SaveGeneralSettings()
|
||||||
|
|
||||||
int themeIndex = ui->theme->currentIndex();
|
int themeIndex = ui->theme->currentIndex();
|
||||||
QString themeData = ui->theme->itemText(themeIndex);
|
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)) {
|
if (WidgetChanged(ui->theme)) {
|
||||||
config_set_string(GetGlobalConfig(), "General", "CurrentTheme",
|
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__)
|
#if defined(_WIN32) || defined(__APPLE__)
|
||||||
|
@ -3392,8 +3413,17 @@ void OBSBasicSettings::closeEvent(QCloseEvent *event)
|
||||||
|
|
||||||
void OBSBasicSettings::on_theme_activated(int idx)
|
void OBSBasicSettings::on_theme_activated(int idx)
|
||||||
{
|
{
|
||||||
string currT = ui->theme->itemText(idx).toStdString();
|
QString currT = ui->theme->itemText(idx);
|
||||||
App()->SetTheme(currT);
|
|
||||||
|
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()
|
void OBSBasicSettings::on_listWidget_itemSelectionChanged()
|
||||||
|
|
Loading…
Reference in New Issue