add support for multiple custom themes

also moved theme related code from Application.cpp to new ui/themes/ThemeManager.cpp, this class should cleanly isolate theme related functions and help avoid code duplication in future theme related additions.
Themes can now be just qss or css files, they won't have color pallette information with them in that case

Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
Tayou
2022-10-29 19:27:20 +02:00
parent 04b39294ba
commit fef60a9da0
8 changed files with 445 additions and 126 deletions

View File

@ -0,0 +1,44 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <QString>
#include "ui/themes/ITheme.h"
#include "ui/MainWindow.h"
#define themeDebugLog qDebug() << "[Themes]"
#define themeWarningLog qWarning() << "[Themes]"
class ThemeManager {
public:
ThemeManager(MainWindow* mainWindow);
void InitializeThemes();
std::vector<ITheme *> getValidApplicationThemes();
void setIconTheme(const QString& name);
void applyCurrentlySelectedTheme();
void setApplicationTheme(const QString& name, bool initial);
private:
std::map<QString, std::unique_ptr<ITheme>> m_themes;
MainWindow* m_mainWindow;
QString AddTheme(ITheme * theme);
ITheme* GetTheme(QString themeId);
};