mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: edit variables for themes
This commit is contained in:
parent
d35dbcc870
commit
827e3b734c
|
@ -89,11 +89,28 @@ static QMap<QString, QString> dictColor;
|
||||||
static QMap<QString, QString> dictFont;
|
static QMap<QString, QString> dictFont;
|
||||||
static QMap<QString, QString> dictTheme;
|
static QMap<QString, QString> dictTheme;
|
||||||
|
|
||||||
|
QList<Style::ThemeNameColor> Style::themeNameColors = {
|
||||||
|
{Style::Light, QObject::tr("Default"), QColor()},
|
||||||
|
{Style::Light, QObject::tr("Blue"), QColor("#004aa4")},
|
||||||
|
{Style::Light, QObject::tr("Olive"), QColor("#97ba00")},
|
||||||
|
{Style::Light, QObject::tr("Red"), QColor("#c23716")},
|
||||||
|
{Style::Light, QObject::tr("Violet"), QColor("#4617b5")},
|
||||||
|
{Style::Dark, QObject::tr("Dark"), QColor()},
|
||||||
|
{Style::Dark, QObject::tr("Dark blue"), QColor("#00336d")},
|
||||||
|
{Style::Dark, QObject::tr("Dark olive"), QColor("#4d5f00")},
|
||||||
|
{Style::Dark, QObject::tr("Dark red"), QColor("#7a210d")},
|
||||||
|
{Style::Dark, QObject::tr("Dark violet"), QColor("#280d6c")}
|
||||||
|
};
|
||||||
|
|
||||||
QStringList Style::getThemeColorNames()
|
QStringList Style::getThemeColorNames()
|
||||||
{
|
{
|
||||||
return {QObject::tr("Default"), QObject::tr("Blue"), QObject::tr("Olive"), QObject::tr("Red"),
|
QStringList l;
|
||||||
QObject::tr("Violet"), QObject::tr("Dark"), QObject::tr("Dark blue"), QObject::tr("Dark olive"),
|
|
||||||
QObject::tr("Dark red"), QObject::tr("Dark violet")};
|
for (auto t : themeNameColors) {
|
||||||
|
l << t.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Style::getThemeName()
|
QString Style::getThemeName()
|
||||||
|
@ -118,10 +135,6 @@ QString Style::getThemeFolder()
|
||||||
return fullPath % QDir::separator();
|
return fullPath % QDir::separator();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QColor> Style::themeColorColors = {QColor(), QColor("#004aa4"), QColor("#97ba00"),
|
|
||||||
QColor("#c23716"), QColor("#4617b5"),
|
|
||||||
QColor(), QColor("#00336d"), QColor("#4d5f00"),
|
|
||||||
QColor("#7a210d"), QColor("#280d6c")};
|
|
||||||
|
|
||||||
QMap<Style::ColorPalette, QString> Style::aliasColors = {{Green, "green"},
|
QMap<Style::ColorPalette, QString> Style::aliasColors = {{Green, "green"},
|
||||||
{Yellow, "yellow"},
|
{Yellow, "yellow"},
|
||||||
|
@ -318,10 +331,10 @@ void Style::setThemeColor(int color)
|
||||||
dictColor.clear();
|
dictColor.clear();
|
||||||
initPalette();
|
initPalette();
|
||||||
initDictColor();
|
initDictColor();
|
||||||
if (color < 0 || color >= themeColorColors.size())
|
if (color < 0 || color >= themeNameColors.size())
|
||||||
setThemeColor(QColor());
|
setThemeColor(QColor());
|
||||||
else
|
else
|
||||||
setThemeColor(themeColorColors[color]);
|
setThemeColor(themeNameColors[color].color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,7 +417,8 @@ void Style::initDictColor()
|
||||||
|
|
||||||
QString Style::getThemePath()
|
QString Style::getThemePath()
|
||||||
{
|
{
|
||||||
if (Settings::getInstance().getThemeColor() > 4) {
|
const int num = Settings::getInstance().getThemeColor();
|
||||||
|
if (themeNameColors[num].type == Dark) {
|
||||||
return BuiltinThemeDarkPath;
|
return BuiltinThemeDarkPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,18 @@ public:
|
||||||
SmallLight
|
SmallLight
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MainTheme
|
||||||
|
{
|
||||||
|
Light,
|
||||||
|
Dark
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ThemeNameColor {
|
||||||
|
MainTheme type;
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
};
|
||||||
|
|
||||||
static QStringList getThemeColorNames();
|
static QStringList getThemeColorNames();
|
||||||
static const QString getStylesheet(const QString& filename, const QFont& baseFont = QFont());
|
static const QString getStylesheet(const QString& filename, const QFont& baseFont = QFont());
|
||||||
static const QString getImagePath(const QString& filename);
|
static const QString getImagePath(const QString& filename);
|
||||||
|
@ -83,7 +95,7 @@ private:
|
||||||
Style();
|
Style();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QList<QColor> themeColorColors;
|
static QList<ThemeNameColor> themeNameColors;
|
||||||
static std::map<std::pair<const QString, const QFont>, const QString> stylesheetsCache;
|
static std::map<std::pair<const QString, const QFont>, const QString> stylesheetsCache;
|
||||||
static QMap<ColorPalette, QString> aliasColors;
|
static QMap<ColorPalette, QString> aliasColors;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user