Make log colours themeable

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2024-08-21 22:11:43 +01:00
parent 1edfbeec8d
commit 2ad34c724e
No known key found for this signature in database
GPG key ID: 5E39D70B4C93C38E
18 changed files with 230 additions and 356 deletions

View file

@ -123,11 +123,11 @@ void ThemeManager::initializeWidgets()
{
themeDebugLog() << "Determining System Widget Theme...";
const auto& style = QApplication::style();
currentlySelectedSystemTheme = style->objectName();
themeDebugLog() << "System theme seems to be:" << currentlySelectedSystemTheme;
m_currentlySelectedSystemTheme = style->objectName();
themeDebugLog() << "System theme seems to be:" << m_currentlySelectedSystemTheme;
themeDebugLog() << "<> Initializing Widget Themes";
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>(currentlySelectedSystemTheme, true));
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>(m_currentlySelectedSystemTheme, true));
auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
@ -196,8 +196,8 @@ QList<ITheme*> ThemeManager::getValidApplicationThemes()
QList<CatPack*> ThemeManager::getValidCatPacks()
{
QList<CatPack*> ret;
ret.reserve(m_cat_packs.size());
for (auto&& [id, theme] : m_cat_packs) {
ret.reserve(m_catPacks.size());
for (auto&& [id, theme] : m_catPacks) {
ret.append(theme.get());
}
return ret;
@ -246,6 +246,8 @@ void ThemeManager::setApplicationTheme(const QString& name, bool initial)
auto& theme = themeIter->second;
themeDebugLog() << "applying theme" << theme->name();
theme->apply(initial);
m_logColors = theme->logColorScheme();
} else {
themeWarningLog() << "Tried to set invalid theme:" << name;
}
@ -258,7 +260,7 @@ void ThemeManager::applyCurrentlySelectedTheme(bool initial)
themeDebugLog() << "<> Icon theme set.";
auto applicationTheme = settings->get("ApplicationTheme").toString();
if (applicationTheme == "") {
applicationTheme = currentlySelectedSystemTheme;
applicationTheme = m_currentlySelectedSystemTheme;
}
setApplicationTheme(applicationTheme, initial);
themeDebugLog() << "<> Application theme set.";
@ -266,8 +268,8 @@ void ThemeManager::applyCurrentlySelectedTheme(bool initial)
QString ThemeManager::getCatPack(QString catName)
{
auto catIter = m_cat_packs.find(!catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString());
if (catIter != m_cat_packs.end()) {
auto catIter = m_catPacks.find(!catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString());
if (catIter != m_catPacks.end()) {
auto& catPack = catIter->second;
themeDebugLog() << "applying catpack" << catPack->id();
return catPack->path();
@ -275,14 +277,14 @@ QString ThemeManager::getCatPack(QString catName)
themeWarningLog() << "Tried to get invalid catPack:" << catName;
}
return m_cat_packs.begin()->second->path();
return m_catPacks.begin()->second->path();
}
QString ThemeManager::addCatPack(std::unique_ptr<CatPack> catPack)
{
QString id = catPack->id();
if (m_cat_packs.find(id) == m_cat_packs.end())
m_cat_packs.emplace(id, std::move(catPack));
if (m_catPacks.find(id) == m_catPacks.end())
m_catPacks.emplace(id, std::move(catPack));
else
themeWarningLog() << "CatPack(" << id << ") not added to prevent id duplication";
return id;
@ -340,8 +342,8 @@ void ThemeManager::refresh()
{
m_themes.clear();
m_icons.clear();
m_cat_packs.clear();
m_catPacks.clear();
initializeThemes();
initializeCatPacks();
};
}