Redraw the ToolButton in the way of DT

This commit is contained in:
李柯 2024-11-19 11:20:31 +08:00
parent b262db2b96
commit 3ef263daf9
1 changed files with 183 additions and 190 deletions

View File

@ -1154,176 +1154,36 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
UKUIColorTheme::ToolButtonColorCfg buttonColorCfg = readCfg()->toolButtonColorCfg(palette);
int radius =m_dtconfig->kradiusNormal();
int radius = (widget && widget->property("normalRadius").isValid()) ?
widget->property("normalRadius").toInt() : m_dtconfig->kradiusNormal();
QBrush defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonActive());
QBrush disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
QBrush disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonDisable());
QBrush clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
QBrush hoverBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
QColor startColor;
QColor endColor;
QLinearGradient linearGradient;
linearGradient.setStart(option ? option->rect.topLeft() : QPoint(0, 0));
linearGradient.setFinalStop(option ? option->rect.bottomLeft() : QPoint(0, 0));
QColor highlight = palette.color(QPalette::Active, QPalette::Highlight);
QColor mix = palette.color(QPalette::Active, QPalette::BrightText);
QPen defaultPen ;
QPen hoverPen ;
QPen clickPen ;
QPen disablePen ;
QPen checkPen ;
QPen checkHoverPen ;
QPen checkClickPen ;
QPen checkDisablePen;
QPen focusPen;
QBrush checkBrush;
QBrush checkHoverBrush;
QBrush checkClickBrush;
QBrush checkDisableBrush;
defaultPen = QPen(QBrush(buttonColorCfg.defaultPen), (buttonColorCfg.defaultPen == Qt::NoPen) ?
0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(QBrush(buttonColorCfg.hoverPen), (buttonColorCfg.hoverPen == Qt::NoPen) ?
0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(QBrush(buttonColorCfg.clickPen), (buttonColorCfg.clickPen == Qt::NoPen) ?
0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(QBrush(buttonColorCfg.disablePen), (buttonColorCfg.disablePen == Qt::NoPen) ?
0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
auto checkableColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_ImportButton);
{
checkPen = QPen(QBrush(checkableColorCfg.defaultPen), (checkableColorCfg.defaultPen == Qt::NoPen || checkableColorCfg.defaultPen.alpha() == 0)
QPen defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkHoverPen = QPen(QBrush(checkableColorCfg.hoverPen), (checkableColorCfg.hoverPen == Qt::NoPen || checkableColorCfg.hoverPen.alpha() == 0)
QPen hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkClickPen = QPen(QBrush(checkableColorCfg.clickPen), (checkableColorCfg.clickPen == Qt::NoPen || checkableColorCfg.clickPen.alpha() == 0)
QPen clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkDisablePen = QPen(QBrush(checkableColorCfg.disablePen), (checkableColorCfg.disablePen == Qt::NoPen || checkableColorCfg.disablePen.alpha() == 0)
QPen disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkBrush = palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = checkableColorCfg.hoverBrush;
checkClickBrush = checkableColorCfg.clickBrush;
checkDisableBrush = palette.brush(QPalette::Disabled, QPalette::NoRole);
}
if (isWindowColoseButton){
if (buttonColorCfg.hoverType == Obj_Gradient_Type) {
linearGradient.setColorAt(0, buttonColorCfg.hoverGradientList.value(0));
linearGradient.setColorAt(1, buttonColorCfg.hoverGradientList.value(1));
hoverBrush = QBrush(linearGradient);
} else {
hoverBrush = buttonColorCfg.hoverBrush;
}
clickBrush = buttonColorCfg.clickBrush;
focusPen = QPen(QBrush(clickBrush), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
} else {
switch (m_adjustColorRules) {
case AdjustColorRules::DefaultRGB:{
if (buttonColorCfg.hoverType == Obj_Gradient_Type) {
if (isDark) {
startColor = configMixColor(highlight, QColor(Qt::white), 0.2);
endColor = configMixColor(highlight, QColor(Qt::black), 0.05);
} else {
startColor = configMixColor(highlight, QColor(Qt::white), 0.05);
endColor = configMixColor(highlight, QColor(Qt::black), 0.2);
}
linearGradient.setColorAt(0, startColor);
linearGradient.setColorAt(1, endColor);
hoverBrush = QBrush(linearGradient);
clickBrush = QBrush(configMixColor(highlight, mix, 0.1));
}
else {
if (isDark) {
hoverBrush = QBrush(configMixColor(highlight, mix, 0.2));
} else {
hoverBrush = QBrush(configMixColor(highlight, mix, 0.05));
}
if (isDark) {
clickBrush = QBrush(configMixColor(highlight, mix, 0.05));
} else {
clickBrush = QBrush(configMixColor(highlight, mix, 0.2));
}
}
checkHoverBrush = hoverBrush;
checkClickBrush = clickBrush;
if (isWindowButton && useTransparentButtonList().contains(qAppName())) {//特殊三联应用
if (isDark) {
mix.setAlphaF(0.28);
hoverBrush = QBrush(mix);
mix.setAlphaF(0.15);
clickBrush = QBrush(mix);
} else {
mix.setAlphaF(0.15);
hoverBrush = QBrush(mix);
mix.setAlphaF(0.28);
clickBrush = QBrush(mix);
}
} else if (useButtonPalette || isWindowButton) {
if(buttonColorCfg.hoverType == Obj_Gradient_Type){
startColor = buttonColorCfg.hoverGradientList.value(0);
endColor = buttonColorCfg.hoverGradientList.value(1);
linearGradient.setColorAt(0, startColor);
linearGradient.setColorAt(1, endColor);
hoverBrush = QBrush(linearGradient);
clickBrush = buttonColorCfg.clickBrush;
} else {
hoverBrush = buttonColorCfg.hoverBrush;
clickBrush = buttonColorCfg.clickBrush;
}
}
focusPen = QPen(QBrush(configMixColor(highlight, mix, 0.2)), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
} break;
case AdjustColorRules::HSL:{
if(buttonColorCfg.focusPen != Qt::NoPen)
focusPen = QPen(QBrush(buttonColorCfg.focusPen), (buttonColorCfg.focusPen == Qt::NoPen || buttonColorCfg.focusPen.alpha() == 0)
QBrush checkBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightActive());
QBrush checkHoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
QBrush checkClickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
QBrush checkDisableBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightDisable());
QPen checkPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QPen checkHoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QPen checkClickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QPen checkDisablePen= QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
if (isWindowButton && useTransparentButtonList().contains(qAppName())) {//特殊窗口三联
QColor p = QColor(255, 255, 255);
p.setAlphaF(0.4);
defaultPen = QPen(QColor(Qt::NoPen), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(p, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
p.setAlphaF(0.35);
clickPen = QPen(p, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = defaultPen;
defaultBrush = QBrush(Qt::NoBrush);
QColor bColor = QColor(0, 0, 0);
bColor.setAlphaF(0.1);
hoverBrush = QBrush(bColor);
bColor.setAlphaF(0.2);
clickBrush = QBrush(bColor);
disableBrush = QBrush(Qt::NoBrush);
focusPen = clickPen;
}
else if (!isWindowColoseButton) {
normalButtonColor(isDark, palette, defaultPen, defaultBrush, hoverPen, hoverBrush,
clickPen, clickBrush, disablePen, disableBrush);
focusPen = QPen(palette.brush(QPalette::Inactive, QPalette::Highlight),
(buttonColorCfg.focusPen == Qt::NoPen || buttonColorCfg.focusPen.alpha() == 0) ?
0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
defaultPen = QPen(QBrush(buttonColorCfg.defaultPen), (buttonColorCfg.defaultPen == Qt::NoPen || buttonColorCfg.defaultPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(QBrush(buttonColorCfg.disablePen), (buttonColorCfg.disablePen == Qt::NoPen || buttonColorCfg.disablePen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkHoverBrush = hoverBrush;
checkClickBrush = clickBrush;
} else {
clickBrush = QBrush(buttonColorCfg.clickBrush);
hoverBrush = QBrush(buttonColorCfg.hoverBrush);
}
}
default:
break;
}
}
QPen focusPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
if (widget) {
if (widget->property("isWindowButton").isValid()) {
@ -1346,21 +1206,79 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
needTranslucent = widget->property("needTranslucent").toBool();
}
}
if (isWindowColoseButton)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_WindowCloseButton);
if (isWindowButton)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_WindowButton);
if (useButtonPalette || isWindowButton) {
if (needTranslucent)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_TranslucentButton);
else
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_UseButtonPalette);
if (isWindowColoseButton){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
hoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kErrorHover());
clickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kErrorClick());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
if (isWindowButton){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
hoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
clickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
if (useButtonPalette || isWindowButton) {
if (needTranslucent){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
hoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
clickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
} else {
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonActive());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonDisable());
clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
hoverBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
}
if (isImportant){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightActive());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightDisable());
clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
hoverBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen= QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
auto *w = const_cast<QWidget *>(widget);
@ -1497,7 +1415,14 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark,
bool isImportant = false;
bool isWindowColoseButton = false;
bool needTranslucent = false;
QBrush defaultBrush ;
QBrush disableBrush ;
QBrush clickBrush ;
QBrush hoverBrush ;
QPen defaultPen ;
QPen hoverPen ;
QPen clickPen ;
QPen disablePen ;
QPalette palette = option ? option->palette : m_stylePalette;
UKUIColorTheme::ToolButtonColorCfg buttonColorCfg = readCfg()->toolButtonColorCfg(palette);
@ -1523,23 +1448,91 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark,
needTranslucent = widget->property("needTranslucent").toBool();
}
}
if (isWindowColoseButton)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_WindowCloseButton);
if (isWindowButton)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_WindowButton);
if (isWindowColoseButton){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
hoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kErrorHover());
clickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kErrorClick());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
if (isWindowButton){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
hoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
clickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
if (useButtonPalette || isWindowButton) {
if (needTranslucent)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_TranslucentButton);
else
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_UseButtonPalette);
if (needTranslucent){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
hoverBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
clickBrush= parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
} else {
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonActive());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonDisable());
clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
hoverBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
}
if (isImportant){
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightActive());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightDisable());
hoverBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen= QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
if (isImportant)
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_ImportButton);
if(option && option->state & QStyle::State_On && option->state & QStyle::State_Enabled){
buttonColorCfg = readCfg()->toolButtonColorCfg(palette, C_Button_ImportButton);
defaultBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightActive());
disableBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->highLightDisable());
hoverBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
clickBrush = parseDTColor(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
defaultPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
hoverPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
clickPen = QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
disablePen= QPen(parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()), (parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color() == Qt::NoPen || parseDTColor(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}
QColor textDefaultColor = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonTextActive()).color();
QColor textHoverColor = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonTextActive()).color();
QColor textDisableColor = parseDTColor(option ? option->rect : QRect(), m_dtconfig->buttonTextDisable()).color();