From f77d6bbc77241812bb967d913db2d0b91282e45c Mon Sep 17 00:00:00 2001 From: tanjing Date: Thu, 14 Sep 2023 09:42:08 +0800 Subject: [PATCH] =?UTF-8?q?menu=20=20tooltip=E5=93=8D=E5=BA=94=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=9D=A2=E6=9D=BF=E7=9A=84=E9=80=8F=E6=98=8E=E5=BA=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ukui-styles/blur-helper.cpp | 10 +++- .../ukui-config-style-parameters.cpp | 48 +++++++++++++++++-- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ukui-styles/blur-helper.cpp b/ukui-styles/blur-helper.cpp index 83948ff..7028ac9 100644 --- a/ukui-styles/blur-helper.cpp +++ b/ukui-styles/blur-helper.cpp @@ -281,7 +281,10 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) break; } QPainterPath path; - path.addRoundedRect(widget->rect().adjusted(+2,+8,-2,-8), 8, 8); + int radius = 8; + if(widget->property("maxRadius").isValid()) + radius = widget->property("maxRadius").toInt(); + path.addRoundedRect(widget->rect(), radius, radius); KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); if (!updateBlurRegionOnly) widget->update(); @@ -290,7 +293,10 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) if (widget->inherits("QTipLabel")) { QPainterPath path; - path.addRoundedRect(widget->rect().adjusted(+4,+4,-4,-4), 6, 6); + int radius = 8; + if(widget->property("normalRadius").isValid()) + radius = widget->property("normalRadius").toInt(); + path.addRoundedRect(widget->rect().adjusted(+4,+4,-4,-4), radius, radius); KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); if (!updateBlurRegionOnly) widget->update(); diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp b/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp index 0d27068..8393924 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp @@ -3504,11 +3504,31 @@ void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { UKUIColorTheme::ToolTipColorCfg tooltipColorCfg = readCfg()->toolTipColorCfg(option->palette, C_ToolTip_Default); - QBrush backgroundBrush = tooltipColorCfg.backgroundBrush; + QPen backgroundPen = QPen(tooltipColorCfg.backgroundPen, (tooltipColorCfg.backgroundPen.alpha() == 0 || tooltipColorCfg.backgroundPen == Qt::NoPen ) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); //background - backgroundBrush = option->palette.color(QPalette::Active, QPalette::ToolTipBase); + auto color = tooltipColorCfg.backgroundBrush; + if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { + auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; + color.setAlphaF(opacity); + } + if (qApp->property("blurEnable").isValid()) { + bool blurEnable = qApp->property("blurEnable").toBool(); + if (!blurEnable) { + color.setAlphaF(1); + } + } + if (widget) { + if (widget->property("useSystemStyleBlur").isValid() && !widget->property("useSystemStyleBlur").toBool()) { + color.setAlphaF(1); + } + } + //if blur effect is not supported, do not use transparent color. + if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) { + color.setAlphaF(1); + } + QBrush backgroundBrush = color; int radius = m_radiusStruct.normalRadius; @@ -3653,7 +3673,6 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty // QPixmap framePixmap(option->rect.size()); UKUIColorTheme::MenuColorCfg menuColorCfg = readCfg()->menuColorCfg(C_Menu_Default); - QBrush menuBackgroundBrush = menuColorCfg.menuBackgroundBrush; QPen menuBackgroundPen = QPen(menuColorCfg.menuBackgroundPen, (menuColorCfg.menuBackgroundPen.alpha() == 0 || menuColorCfg.menuBackgroundPen == Qt::NoPen ) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QBrush itemSelectBrush = menuColorCfg.menuItemSelectBrush; @@ -3672,6 +3691,29 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty break; } + auto color = menuColorCfg.menuBackgroundBrush; + if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { + auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; + color.setAlphaF(opacity); + } + if (qApp->property("blurEnable").isValid()) { + bool blurEnable = qApp->property("blurEnable").toBool(); + if (!blurEnable) { + color.setAlphaF(1); + } + } + if (widget) { + if (widget->property("useSystemStyleBlur").isValid() && !widget->property("useSystemStyleBlur").toBool()) { + color.setAlphaF(1); + } + } + //if blur effect is not supported, do not use transparent color. + if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) { + color.setAlphaF(1); + } + QBrush menuBackgroundBrush = color; + + if(widget){ if (widget->property("setFrameRadius").isValid() && widget->property("setFrameRadius").canConvert()) { frameradius = widget->property("setFrameRadius").value();