checkable状态下按钮响应高亮色变化

This commit is contained in:
tanjing 2024-01-26 16:43:50 +08:00
parent 5cbd96d9be
commit 20755b995f
1 changed files with 46 additions and 36 deletions

View File

@ -741,6 +741,23 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark,
disablePen = QPen(QBrush(buttonColorCfg.disablePen), (buttonColorCfg.disablePen == Qt::NoPen || buttonColorCfg.disablePen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
auto checkableColorCfg = readCfg()->buttonColorCfg(option->palette, C_Button_ImportButton);
{
checkPen = QPen(QBrush(checkableColorCfg.defaultPen), (checkableColorCfg.defaultPen == Qt::NoPen || checkableColorCfg.defaultPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkHoverPen = QPen(QBrush(checkableColorCfg.hoverPen), (checkableColorCfg.hoverPen == Qt::NoPen || checkableColorCfg.hoverPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkClickPen = QPen(QBrush(checkableColorCfg.clickPen), (checkableColorCfg.clickPen == Qt::NoPen || checkableColorCfg.clickPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkDisablePen = QPen(QBrush(checkableColorCfg.disablePen), (checkableColorCfg.disablePen == Qt::NoPen || checkableColorCfg.disablePen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkBrush = option->palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = checkableColorCfg.hoverBrush;
checkClickBrush = checkableColorCfg.clickBrush;
checkDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);
}
if (isWindowColoseButton) {
if (buttonColorCfg.hoverType == Obj_Gradient_Type){
linearGradient.setColorAt(0, buttonColorCfg.hoverGradientList.value(0));
@ -780,6 +797,8 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark,
clickBrush = QBrush(configMixColor(highlight, mix, 0.2));
}
}
checkHoverBrush = hoverBrush;
checkClickBrush = clickBrush;
if (isWindowButton && useTransparentButtonList().contains(qAppName())) {//特殊三联应用
if (isDark) {
@ -842,6 +861,9 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark,
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);
@ -852,24 +874,6 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark,
}
}
auto checkableColorCfg = readCfg()->buttonColorCfg(option->palette, C_Button_ImportButton);
{
checkPen = QPen(QBrush(checkableColorCfg.defaultPen), (checkableColorCfg.defaultPen == Qt::NoPen || checkableColorCfg.defaultPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkHoverPen = QPen(QBrush(checkableColorCfg.hoverPen), (checkableColorCfg.hoverPen == Qt::NoPen || checkableColorCfg.hoverPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkClickPen = QPen(QBrush(checkableColorCfg.clickPen), (checkableColorCfg.clickPen == Qt::NoPen || checkableColorCfg.clickPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkDisablePen = QPen(QBrush(checkableColorCfg.disablePen), (checkableColorCfg.disablePen == Qt::NoPen || checkableColorCfg.disablePen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkBrush = option->palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = checkableColorCfg.hoverBrush;
checkClickBrush = checkableColorCfg.clickBrush;
checkDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);
}
auto *w = const_cast<QWidget *>(widget);
if (w) {
@ -1156,6 +1160,23 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
disablePen = QPen(QBrush(buttonColorCfg.disablePen), (buttonColorCfg.disablePen == Qt::NoPen) ?
0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
auto checkableColorCfg = readCfg()->toolButtonColorCfg(option->palette, C_Button_ImportButton);
{
checkPen = QPen(QBrush(checkableColorCfg.defaultPen), (checkableColorCfg.defaultPen == Qt::NoPen || checkableColorCfg.defaultPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkHoverPen = QPen(QBrush(checkableColorCfg.hoverPen), (checkableColorCfg.hoverPen == Qt::NoPen || checkableColorCfg.hoverPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkClickPen = QPen(QBrush(checkableColorCfg.clickPen), (checkableColorCfg.clickPen == Qt::NoPen || checkableColorCfg.clickPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkDisablePen = QPen(QBrush(checkableColorCfg.disablePen), (checkableColorCfg.disablePen == Qt::NoPen || checkableColorCfg.disablePen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkBrush = option->palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = checkableColorCfg.hoverBrush;
checkClickBrush = checkableColorCfg.clickBrush;
checkDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);
}
if (isWindowColoseButton){
if (buttonColorCfg.hoverType == Obj_Gradient_Type) {
linearGradient.setColorAt(0, buttonColorCfg.hoverGradientList.value(0));
@ -1195,6 +1216,9 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
}
}
checkHoverBrush = hoverBrush;
checkClickBrush = clickBrush;
if (isWindowButton && useTransparentButtonList().contains(qAppName())) {//特殊三联应用
if (isDark) {
mix.setAlphaF(0.28);
@ -1256,6 +1280,10 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
? 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);
@ -1266,24 +1294,6 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
}
}
auto checkableColorCfg = readCfg()->toolButtonColorCfg(option->palette, C_Button_ImportButton);
{
checkPen = QPen(QBrush(checkableColorCfg.defaultPen), (checkableColorCfg.defaultPen == Qt::NoPen || checkableColorCfg.defaultPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkHoverPen = QPen(QBrush(checkableColorCfg.hoverPen), (checkableColorCfg.hoverPen == Qt::NoPen || checkableColorCfg.hoverPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkClickPen = QPen(QBrush(checkableColorCfg.clickPen), (checkableColorCfg.clickPen == Qt::NoPen || checkableColorCfg.clickPen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkDisablePen = QPen(QBrush(checkableColorCfg.disablePen), (checkableColorCfg.disablePen == Qt::NoPen || checkableColorCfg.disablePen.alpha() == 0)
? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
checkBrush = option->palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = checkableColorCfg.hoverBrush;
checkClickBrush = checkableColorCfg.clickBrush;
checkDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);
}
auto *w = const_cast<QWidget *>(widget);
if (w) {
w->setProperty("radius", radius);