From 45b3657d7ef33b0ff2333695a8d618f243906e94 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 13 May 2022 20:51:03 +0800 Subject: [PATCH] minor tweaks Doesn't seem to affect the final appearance Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- include/FramelessHelper/Core/framelesshelpercore_global.h | 8 ++++++-- src/quick/quickstandardsystembutton.cpp | 4 +++- src/widgets/standardsystembutton.cpp | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/FramelessHelper/Core/framelesshelpercore_global.h b/include/FramelessHelper/Core/framelesshelpercore_global.h index ef14e22..0d1ad55 100644 --- a/include/FramelessHelper/Core/framelesshelpercore_global.h +++ b/include/FramelessHelper/Core/framelesshelpercore_global.h @@ -99,7 +99,9 @@ QT_END_NAMESPACE #endif #ifndef FRAMELESSHELPER_BYTEARRAY_LITERAL -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) +# if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)) +# define FRAMELESSHELPER_BYTEARRAY_LITERAL(ba) ba##_ba +# elif (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) # define FRAMELESSHELPER_BYTEARRAY_LITERAL(ba) ba##_qba # else # define FRAMELESSHELPER_BYTEARRAY_LITERAL(ba) QByteArrayLiteral(ba) @@ -107,7 +109,9 @@ QT_END_NAMESPACE #endif #ifndef FRAMELESSHELPER_STRING_LITERAL -# if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) +# if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)) +# define FRAMELESSHELPER_STRING_LITERAL(str) u##str##_s +# elif (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)) # define FRAMELESSHELPER_STRING_LITERAL(str) u##str##_qs # else # define FRAMELESSHELPER_STRING_LITERAL(str) QStringLiteral(str) diff --git a/src/quick/quickstandardsystembutton.cpp b/src/quick/quickstandardsystembutton.cpp index 32a3085..2862586 100644 --- a/src/quick/quickstandardsystembutton.cpp +++ b/src/quick/quickstandardsystembutton.cpp @@ -146,7 +146,9 @@ void QuickStandardSystemButton::initialize() setImplicitHeight(kDefaultSystemButtonSize.height()); m_contentItem.reset(new QQuickImage(this)); - m_contentItem->setFillMode(QQuickImage::Pad); + m_contentItem->setFillMode(QQuickImage::Pad); // Don't apply any transformation to the image. + m_contentItem->setSmooth(true); // Renders better when scaling up. + m_contentItem->setMipmap(true); // Renders better when scaling down. m_contentItem->setWidth(kDefaultSystemButtonIconSize.width()); m_contentItem->setHeight(kDefaultSystemButtonIconSize.height()); connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &QuickStandardSystemButton::updateForeground); diff --git a/src/widgets/standardsystembutton.cpp b/src/widgets/standardsystembutton.cpp index d89454b..03c8a13 100644 --- a/src/widgets/standardsystembutton.cpp +++ b/src/widgets/standardsystembutton.cpp @@ -300,6 +300,9 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event) Q_Q(StandardSystemButton); QPainter painter(q); painter.save(); + // Enabling "QPainter::SmoothPixmapTransform" will cause the painted image + // looks blurry, strange. + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); QColor color = {}; // The pressed state has higher priority than the hovered state. if (m_pressed && m_pressColor.isValid()) {