UX tweak + formatting + added cat to wizard
Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
@ -167,8 +167,6 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
|
||||
|
||||
if (!FS::ensureFolderPathExists(path) || !FS::ensureFolderPathExists(pathResources)) {
|
||||
themeWarningLog() << "couldn't create folder for theme!";
|
||||
m_palette = baseTheme->colorScheme();
|
||||
m_styleSheet = baseTheme->appStyleSheet();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -177,18 +175,15 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
|
||||
bool jsonDataIncomplete = false;
|
||||
|
||||
m_palette = baseTheme->colorScheme();
|
||||
if (!readThemeJson(themeFilePath, m_palette, m_fadeAmount, m_fadeColor, m_name, m_widgets, m_qssFilePath, jsonDataIncomplete)) {
|
||||
themeDebugLog() << "Did not read theme json file correctly, writing new one to: " << themeFilePath;
|
||||
m_name = "Custom";
|
||||
m_palette = baseTheme->colorScheme();
|
||||
m_fadeColor = baseTheme->fadeColor();
|
||||
m_fadeAmount = baseTheme->fadeAmount();
|
||||
m_widgets = baseTheme->qtTheme();
|
||||
m_qssFilePath = "themeStyle.css";
|
||||
} else {
|
||||
if (readThemeJson(themeFilePath, m_palette, m_fadeAmount, m_fadeColor, m_name, m_widgets, m_qssFilePath, jsonDataIncomplete)) {
|
||||
// If theme data was found, fade "Disabled" color of each role according to FadeAmount
|
||||
m_palette = fadeInactive(m_palette, m_fadeAmount, m_fadeColor);
|
||||
} else {
|
||||
themeDebugLog() << "Did not read theme json file correctly, not changing theme, keeping previous.";
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: This is kinda jank, it only actually checks if the qss file path is not present. It should actually check for any relevant missing data (e.g. name, colors)
|
||||
if (jsonDataIncomplete) {
|
||||
writeThemeJson(fileInfo.absoluteFilePath(), m_palette, m_fadeAmount, m_fadeColor, m_name, m_widgets, m_qssFilePath);
|
||||
}
|
||||
@ -197,20 +192,14 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
|
||||
QFileInfo info(qssFilePath);
|
||||
if (info.isFile()) {
|
||||
try {
|
||||
// TODO: validate css?
|
||||
// TODO: validate qss?
|
||||
m_styleSheet = QString::fromUtf8(FS::read(qssFilePath));
|
||||
} catch (const Exception& e) {
|
||||
themeWarningLog() << "Couldn't load css:" << e.cause() << "from" << qssFilePath;
|
||||
m_styleSheet = baseTheme->appStyleSheet();
|
||||
themeWarningLog() << "Couldn't load qss:" << e.cause() << "from" << qssFilePath;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
themeDebugLog() << "No theme css present.";
|
||||
m_styleSheet = baseTheme->appStyleSheet();
|
||||
try {
|
||||
FS::write(qssFilePath, m_styleSheet.toUtf8());
|
||||
} catch (const Exception& e) {
|
||||
themeWarningLog() << "Couldn't write css:" << e.cause() << "to" << qssFilePath;
|
||||
}
|
||||
themeDebugLog() << "No theme qss present.";
|
||||
}
|
||||
} else {
|
||||
m_id = fileInfo.fileName();
|
||||
|
@ -33,14 +33,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <QPalette>
|
||||
#include <QString>
|
||||
|
||||
class QStyle;
|
||||
|
||||
class ITheme
|
||||
{
|
||||
public:
|
||||
class ITheme {
|
||||
public:
|
||||
virtual ~ITheme() {}
|
||||
virtual void apply();
|
||||
virtual QString id() = 0;
|
||||
@ -52,10 +51,7 @@ public:
|
||||
virtual QPalette colorScheme() = 0;
|
||||
virtual QColor fadeColor() = 0;
|
||||
virtual double fadeAmount() = 0;
|
||||
virtual QStringList searchPaths()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual QStringList searchPaths() { return {}; }
|
||||
|
||||
static QPalette fadeInactive(QPalette in, qreal bias, QColor color);
|
||||
};
|
||||
|
@ -34,24 +34,22 @@
|
||||
*/
|
||||
#include "SystemTheme.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QStyle>
|
||||
#include <QStyleFactory>
|
||||
#include <QDebug>
|
||||
#include "ThemeManager.h"
|
||||
|
||||
SystemTheme::SystemTheme()
|
||||
{
|
||||
themeDebugLog() << "Determining System Theme...";
|
||||
const auto & style = QApplication::style();
|
||||
const auto& style = QApplication::style();
|
||||
systemPalette = style->standardPalette();
|
||||
QString lowerThemeName = style->objectName();
|
||||
themeDebugLog() << "System theme seems to be:" << lowerThemeName;
|
||||
QStringList styles = QStyleFactory::keys();
|
||||
for(auto &st: styles)
|
||||
{
|
||||
for (auto& st : styles) {
|
||||
themeDebugLog() << "Considering theme from theme factory:" << st.toLower();
|
||||
if(st.toLower() == lowerThemeName)
|
||||
{
|
||||
if (st.toLower() == lowerThemeName) {
|
||||
systemTheme = st;
|
||||
themeDebugLog() << "System theme has been determined to be:" << systemTheme;
|
||||
return;
|
||||
@ -99,7 +97,7 @@ double SystemTheme::fadeAmount()
|
||||
|
||||
QColor SystemTheme::fadeColor()
|
||||
{
|
||||
return QColor(128,128,128);
|
||||
return QColor(128, 128, 128);
|
||||
}
|
||||
|
||||
bool SystemTheme::hasStyleSheet()
|
||||
|
@ -36,9 +36,8 @@
|
||||
|
||||
#include "ITheme.h"
|
||||
|
||||
class SystemTheme: public ITheme
|
||||
{
|
||||
public:
|
||||
class SystemTheme : public ITheme {
|
||||
public:
|
||||
SystemTheme();
|
||||
virtual ~SystemTheme() {}
|
||||
void apply() override;
|
||||
@ -52,7 +51,8 @@ public:
|
||||
QPalette colorScheme() override;
|
||||
double fadeAmount() override;
|
||||
QColor fadeColor() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
QPalette systemPalette;
|
||||
QString systemTheme;
|
||||
};
|
||||
|
@ -35,9 +35,6 @@ class ThemeManager {
|
||||
public:
|
||||
ThemeManager(MainWindow* mainWindow);
|
||||
|
||||
// maybe make private? Or put in ctor?
|
||||
void InitializeThemes();
|
||||
|
||||
QList<ITheme*> getValidApplicationThemes();
|
||||
void setIconTheme(const QString& name);
|
||||
void applyCurrentlySelectedTheme();
|
||||
@ -48,6 +45,7 @@ class ThemeManager {
|
||||
MainWindow* m_mainWindow;
|
||||
bool m_firstThemeInitialized;
|
||||
|
||||
void InitializeThemes();
|
||||
QString AddTheme(std::unique_ptr<ITheme> theme);
|
||||
ITheme* GetTheme(QString themeId);
|
||||
};
|
||||
|
Reference in New Issue
Block a user