缓存颜色叠加处理
This commit is contained in:
parent
366e89f64a
commit
af35405418
|
@ -230,6 +230,49 @@ public:
|
|||
QString m_dt_configData;
|
||||
};
|
||||
|
||||
MixColor::MixColor(QColor backColor, QList<QColor> startColorList, QList<QColor> endColorList)
|
||||
{
|
||||
m_backColor = backColor;
|
||||
m_startColorList = startColorList;
|
||||
m_endColorList = endColorList;
|
||||
}
|
||||
|
||||
QColor MixColor::mixStartColor()
|
||||
{
|
||||
QColor color = m_backColor;
|
||||
foreach (QColor c, m_startColorList) {
|
||||
color = composeColor(c, color);
|
||||
return color;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
QColor MixColor::mixEndColor()
|
||||
{
|
||||
QColor color = m_backColor;
|
||||
foreach (QColor c, m_endColorList) {
|
||||
color = composeColor(c, color);
|
||||
return color;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
QColor MixColor::composeColor(QColor foreColor, QColor backColor)
|
||||
{
|
||||
qreal alphaF = foreColor.alphaF() * 1.0 + 1.0 *backColor.alphaF() * (1 - foreColor.alphaF());
|
||||
qreal red = (foreColor.red() * foreColor.alphaF() * 1.0+ backColor.red() * backColor.alphaF() *(1 - foreColor.alphaF()))/(alphaF * 1.0);
|
||||
qreal green = (foreColor.green() * foreColor.alphaF() * 1.0 + backColor.green() * backColor.alphaF() *(1 - foreColor.alphaF()))/(alphaF * 1.0);
|
||||
qreal blue = (foreColor.blue() * foreColor.alphaF() * 1.0 + backColor.blue() * backColor.alphaF() *(1 - foreColor.alphaF()))/(alphaF * 1.0);
|
||||
|
||||
QColor color;
|
||||
color.setRed(red);
|
||||
color.setGreen(green);
|
||||
color.setBlue(blue);
|
||||
color.setAlphaF(alphaF);
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
GlobalDTConfigPrivate::GlobalDTConfigPrivate()
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
|
||||
|
@ -337,8 +380,45 @@ inline bool GlobalDTConfigPrivate::getColorValue(QColor &c, const QString key) c
|
|||
//get value type
|
||||
start_index = m_dt_configData.indexOf("--" + key);
|
||||
if (start_index == -1) {
|
||||
qWarning() << "Config file format error!" << key;
|
||||
/*
|
||||
start_index = m_dt_configData.indexOf("--" + key + ": linear-gradient(0deg, ");
|
||||
if(start_index != -1){//混色
|
||||
start_index += QString("--" + key + ": linear-gradient(0deg, ").length();
|
||||
int end_index = m_dt_configData.indexOf(";", start_index);
|
||||
QString getStr = m_dt_configData.mid(start_index, end_index - start_index);
|
||||
QStringList sList = getStr.split("rgba");
|
||||
qDebug() << "mixcolor..." << key << sList;
|
||||
QList<QColor> listColor;
|
||||
QColor backColor;
|
||||
for(int i = 0; i < sList.length(); i++) {
|
||||
QString s = sList[i];
|
||||
if(!s.isEmpty()){
|
||||
int sIndex = s.indexOf("(");
|
||||
int eIndex = s.indexOf(")");
|
||||
s = s.mid(sIndex + 1, eIndex - sIndex - 1);
|
||||
qDebug() << "mixcolor..." << s;
|
||||
}
|
||||
if(i != sList.length() - 1){
|
||||
QColor color = stringToColor(s);
|
||||
if(!listColor.contains(color))
|
||||
listColor.append(color);
|
||||
}
|
||||
else
|
||||
backColor = stringToColor(s);
|
||||
}
|
||||
MixColor mColor(backColor, listColor, QList<QColor>());
|
||||
}
|
||||
else{
|
||||
start_index = m_dt_configData.indexOf("--" + key + ": linear-gradient(180deg, ");
|
||||
if(start_index == -1){
|
||||
cDebug << "Config file format error!";
|
||||
return false;
|
||||
}
|
||||
//渐变色
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
|
||||
}
|
||||
start_index += QString("--" + key).length();
|
||||
end_index = m_dt_configData.indexOf(")", start_index);
|
||||
|
@ -746,8 +826,6 @@ void GlobalDTConfigPrivate::initThemeConfigPropertyInterface()
|
|||
qApp->setProperty("kradius-window", kradiusWindow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GlobalDTConfig::GlobalDTConfig() : d(new GlobalDTConfigPrivate())
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
|
||||
|
|
|
@ -29,6 +29,22 @@
|
|||
|
||||
namespace UKUIGlobalDTConfig {
|
||||
|
||||
class MixColor{
|
||||
public:
|
||||
explicit MixColor(QColor backColor, QList<QColor> startColorList, QList<QColor> endColorList);
|
||||
|
||||
QColor mixStartColor();
|
||||
|
||||
QColor mixEndColor();
|
||||
|
||||
|
||||
QColor composeColor(QColor foreColor, QColor backColor);
|
||||
private:
|
||||
QColor m_backColor;//混色的背景色
|
||||
QList<QColor> m_startColorList;
|
||||
QList<QColor> m_endColorList;
|
||||
};
|
||||
|
||||
class GlobalDTConfigPrivate;
|
||||
|
||||
class GlobalDTConfig : public QObject
|
||||
|
|
Loading…
Reference in New Issue