fix issues#I8WW8M 修改同时设置check和灰色按钮的样式

This commit is contained in:
tanjing 2024-01-25 11:16:47 +08:00
parent 740976ae2f
commit 685ab2a038
2 changed files with 50 additions and 28 deletions

View File

@ -852,15 +852,23 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark,
}
}
checkPen = hoverPen;
checkHoverPen = hoverPen;
checkClickPen = clickPen;
checkDisablePen = disablePen;
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);
}
checkBrush = option->palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = hoverBrush;
checkClickBrush = clickBrush;
checkDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);
auto *w = const_cast<QWidget *>(widget);
@ -1010,6 +1018,10 @@ void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark,
if (isImportant)
buttonColorCfg = readCfg()->buttonColorCfg(option->palette, C_Button_ImportButton);
if(option->state & QStyle::State_On && option->state & QStyle::State_Enabled){
buttonColorCfg = readCfg()->buttonColorCfg(option->palette, C_Button_ImportButton);
}
QColor textDefaultColor = buttonColorCfg.textDefaultColor;
QColor textHoverColor = buttonColorCfg.textHoverColor;
QColor textDisableColor = buttonColorCfg.textDisableColor;
@ -1254,15 +1266,23 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark,
}
}
checkPen = defaultPen;
checkHoverPen = hoverPen;
checkClickPen = clickPen;
checkDisablePen = disablePen;
auto checkableColorCfg = readCfg()->toolButtonColorCfg(option->palette, C_Button_ImportButton);
checkBrush = option->palette.color(QPalette::Active, QPalette::Highlight);
checkHoverBrush = hoverBrush;
checkClickBrush = clickBrush;
checkDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);
{
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) {
@ -1411,6 +1431,10 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark,
if (isImportant)
buttonColorCfg = readCfg()->toolButtonColorCfg(option->palette, C_Button_ImportButton);
if(option->state & QStyle::State_On | QStyle::State_Enabled){
buttonColorCfg = readCfg()->toolButtonColorCfg(option->palette, C_Button_ImportButton);
}
QColor textDefaultColor = buttonColorCfg.textDefaultColor;
QColor textHoverColor = buttonColorCfg.textHoverColor;
QColor textDisableColor = buttonColorCfg.textDisableColor;

View File

@ -1587,14 +1587,13 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
painter->setPen(width <= 0 ? Qt::NoPen : sp->m_PushButtonParameters.pushButtonDefaultPen);
painter->setBrush(sp->m_PushButtonParameters.pushButtonDefaultBrush);
}
//focus
if (focus) {
width = sp->m_PushButtonParameters.pushButtonFocusPen.width();
painter->setPen(width <= 0 ? Qt::NoPen : sp->m_PushButtonParameters.pushButtonFocusPen);
}
}
}
//focus
if (focus) {
width = sp->m_PushButtonParameters.pushButtonFocusPen.width();
painter->setPen(width <= 0 ? Qt::NoPen : sp->m_PushButtonParameters.pushButtonFocusPen);
}
}
painter->setRenderHint(QPainter::Antialiasing, sp->m_PushButtonParameters.radius != 0);
@ -1895,14 +1894,13 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ToolButtonParameters.toolButtonDefaultPen);
painter->setBrush(sp->m_ToolButtonParameters.toolButtonDefaultBrush);
}
//focus
if (focus) {
width = sp->m_ToolButtonParameters.toolButtonFocusPen.width();
painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ToolButtonParameters.toolButtonFocusPen);
}
}
}
//focus
if (focus) {
width = sp->m_ToolButtonParameters.toolButtonFocusPen.width();
painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ToolButtonParameters.toolButtonFocusPen);
}
}
painter->setRenderHint(QPainter::Antialiasing, sp->m_ToolButtonParameters.radius != 0);