[UI][FIX] Fix color name in style sheet

This commit is contained in:
Linloir 2022-12-17 11:41:41 +08:00
parent 2fd1d6db24
commit 5ff60b1e86
No known key found for this signature in database
GPG Key ID: 58EEB209A0F2C366

View File

@ -38,7 +38,7 @@ void RoundedCornerWidget::initializeWidgetUI() {
_borderWidget = new QWidget(this); _borderWidget = new QWidget(this);
_borderWidget->setObjectName("borderWidget"); _borderWidget->setObjectName("borderWidget");
QString borderWidgetStyleSheet = QString borderWidgetStyleSheet =
"QWidget#borderWidget{background-color:#00FFFFFF;border:2px solid " + _borderColor.name() + ";" "QWidget#borderWidget{background-color:#00FFFFFF;border:2px solid " + _borderColor.name(QColor::HexArgb) + ";"
"border-radius:" + QString::number(_cornerRadius) + "px;}"; "border-radius:" + QString::number(_cornerRadius) + "px;}";
_borderWidget->setStyleSheet(borderWidgetStyleSheet); _borderWidget->setStyleSheet(borderWidgetStyleSheet);
_borderWidget->setAttribute(Qt::WA_TransparentForMouseEvents); _borderWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
@ -74,10 +74,12 @@ void RoundedCornerWidget::setCornerRadius(int radius) {
_cornerRadius = radius; _cornerRadius = radius;
// Modify the corner radius in the current style sheet of the border widget // Modify the corner radius in the current style sheet of the border widget
if (_borderWidget != nullptr) {
QString styleSheet = _borderWidget->styleSheet(); QString styleSheet = _borderWidget->styleSheet();
styleSheet.replace(QRegularExpression("border-radius:\\d+px;"), styleSheet.replace(QRegularExpression("border-radius:\\d+px;"),
QString("border-radius:%1px;").arg(_cornerRadius)); QString("border-radius:%1px;").arg(_cornerRadius));
_borderWidget->setStyleSheet(styleSheet); _borderWidget->setStyleSheet(styleSheet);
}
// Reset the mask of the main widget // Reset the mask of the main widget
QPainterPath path; QPainterPath path;
@ -91,10 +93,12 @@ void RoundedCornerWidget::setBorderColor(QColor color) {
_borderColor = color; _borderColor = color;
// Modify the border color in the current style sheet of the border widget // Modify the border color in the current style sheet of the border widget
if (_borderWidget != nullptr) {
QString styleSheet = _borderWidget->styleSheet(); QString styleSheet = _borderWidget->styleSheet();
styleSheet.replace(QRegularExpression("border:2px solid #\\w+;"), styleSheet.replace(QRegularExpression("border:2px solid #\\w+;"),
QString("border:2px solid %1;").arg(_borderColor.name())); QString("border:2px solid %1;").arg(_borderColor.name(QColor::HexArgb)));
_borderWidget->setStyleSheet(styleSheet); _borderWidget->setStyleSheet(styleSheet);
}
} }
QWidget* RoundedCornerWidget::mainWidget() const { QWidget* RoundedCornerWidget::mainWidget() const {