diff --git a/src/blurhelper/windowblur.cpp b/src/blurhelper/windowblur.cpp index 8e523d0..359c78c 100644 --- a/src/blurhelper/windowblur.cpp +++ b/src/blurhelper/windowblur.cpp @@ -18,9 +18,62 @@ */ #include "windowblur.h" + +#include #include #include +static QRegion roundedRegion(const QRect &rect, int radius, bool topLeft, bool topRight, bool bottomLeft, bool bottomRight) +{ + QRegion region(rect, QRegion::Rectangle); + + if (topLeft) { + // Round top-left corner. + const QRegion topLeftCorner(rect.x(), rect.y(), radius, radius, QRegion::Rectangle); + const QRegion topLeftRounded(rect.x(), rect.y(), 2 * radius, 2 * radius, QRegion::Ellipse); + const QRegion topLeftEar = topLeftCorner - topLeftRounded; + region -= topLeftEar; + } + + if (topRight) { + // Round top-right corner. + const QRegion topRightCorner( + rect.x() + rect.width() - radius, rect.y(), + radius, radius, QRegion::Rectangle); + const QRegion topRightRounded( + rect.x() + rect.width() - 2 * radius, rect.y(), + 2 * radius, 2 * radius, QRegion::Ellipse); + const QRegion topRightEar = topRightCorner - topRightRounded; + region -= topRightEar; + } + + if (bottomRight) { + // Round bottom-right corner. + const QRegion bottomRightCorner( + rect.x() + rect.width() - radius, rect.y() + rect.height() - radius, + radius, radius, QRegion::Rectangle); + const QRegion bottomRightRounded( + rect.x() + rect.width() - 2 * radius, rect.y() + rect.height() - 2 * radius, + 2 * radius, 2 * radius, QRegion::Ellipse); + const QRegion bottomRightEar = bottomRightCorner - bottomRightRounded; + region -= bottomRightEar; + } + + if (bottomLeft){ + // Round bottom-left corner. + const QRegion bottomLeftCorner( + rect.x(), rect.y() + rect.height() - radius, + radius, radius, QRegion::Rectangle); + const QRegion bottomLeftRounded( + rect.x(), rect.y() + rect.height() - 2 * radius, + 2 * radius, 2 * radius, QRegion::Ellipse); + const QRegion bottomLeftEar = bottomLeftCorner - bottomLeftRounded; + region -= bottomLeftEar; + } + + return region; +} + WindowBlur::WindowBlur(QObject *parent) noexcept : QObject(parent) , m_view(nullptr) @@ -111,10 +164,7 @@ void WindowBlur::updateBlur() if (m_view) { if (m_enabled) { QRect rect = QRect(0, 0, m_rect.width(), m_rect.height()); - QPainterPath path; - rect.adjust(1, 1, -1, -1); - path.addRoundedRect(rect, m_windowRadius, m_windowRadius); - KWindowEffects::enableBlurBehind(m_view->winId(), true, path.toFillPolygon().toPolygon()); + KWindowEffects::enableBlurBehind(m_view->winId(), true, roundedRegion(rect, m_windowRadius, true, true, true, true)); } else { KWindowEffects::enableBlurBehind(m_view->winId(), false); } diff --git a/src/controls/Units.qml b/src/controls/Units.qml index 1a5dc7f..10939ab 100644 --- a/src/controls/Units.qml +++ b/src/controls/Units.qml @@ -50,7 +50,8 @@ QtObject { * the default font as rendered on the screen, so it takes user-configured font size and DPI * into account. */ - property int smallSpacing: Math.floor(gridUnit / 4) + // property int smallSpacing: Math.floor(gridUnit / 4) + property int smallSpacing: 6 /** * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements,