From 3f561a8cc3567f79094fd6fa2c9a517bebe89bda Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Tue, 9 Aug 2022 10:31:45 +0800 Subject: [PATCH] refactor(style): update painting effect of the scrolling area refactor(log): update log output when creating theme and style plug-ins --- ...pdate-painting-effect-of-the-scrolli.patch | 151 ++++++++++++++++++ ...ate-log-output-when-creating-theme-a.patch | 66 ++++++++ kiran-qt5-integration.spec | 8 +- 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 0001-refactor-style-update-painting-effect-of-the-scrolli.patch create mode 100644 0002-refactor-log-update-log-output-when-creating-theme-a.patch diff --git a/0001-refactor-style-update-painting-effect-of-the-scrolli.patch b/0001-refactor-style-update-painting-effect-of-the-scrolli.patch new file mode 100644 index 0000000..d83bfa8 --- /dev/null +++ b/0001-refactor-style-update-painting-effect-of-the-scrolli.patch @@ -0,0 +1,151 @@ +From 8b29f13e09e2ed34541d63656d03da00d33dce38 Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Mon, 8 Aug 2022 16:59:10 +0800 +Subject: [PATCH 1/2] refactor(style): update painting effect of the scrolling + area +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 调整滚动区域绘制效果 +--- + style/src/draw-helper/draw-common-helper.cpp | 11 ++++- + style/src/render-helper.cpp | 6 +++ + style/src/style.cpp | 46 +++++++++++++++----- + style/src/style.h | 2 + + 4 files changed, 52 insertions(+), 13 deletions(-) + +diff --git a/style/src/draw-helper/draw-common-helper.cpp b/style/src/draw-helper/draw-common-helper.cpp +index 650ec94..ed94654 100644 +--- a/style/src/draw-helper/draw-common-helper.cpp ++++ b/style/src/draw-helper/draw-common-helper.cpp +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + namespace Kiran + { +@@ -39,7 +40,15 @@ bool drawPEFrame(const QStyle *style, + background = schemeLoader->getColor(widget,option,SchemeLoader::Frame_Background); + border = schemeLoader->getColor(widget,option,SchemeLoader::Frame_Border); + +- RenderHelper::renderFrame(painter, option->rect, 1, 0, background,border ); ++ if( qobject_cast(widget) ) ++ { ++ RenderHelper::renderFrame(painter, option->rect, 1, 0, Qt::transparent,border ); ++ } ++ else ++ { ++ RenderHelper::renderFrame(painter, option->rect, 1, 0, background,border ); ++ } ++ + return true; + } + +diff --git a/style/src/render-helper.cpp b/style/src/render-helper.cpp +index b8117ff..60f66e3 100644 +--- a/style/src/render-helper.cpp ++++ b/style/src/render-helper.cpp +@@ -53,7 +53,13 @@ bool RenderHelper::drawTreeBranches() + + bool RenderHelper::isQtQuickControl(const QStyleOption *option, const QWidget *widget) + { ++#if QT_VERSION >= 0x050000 + return (widget == nullptr) && option && option->styleObject && option->styleObject->inherits("QQuickItem"); ++#else ++ Q_UNUSED(widget); ++ Q_UNUSED(option); ++ return false; ++#endif + } + + bool RenderHelper::isVerticalTab(const QTabBar::Shape &shape) +diff --git a/style/src/style.cpp b/style/src/style.cpp +index 01ca5e8..a2c4f12 100644 +--- a/style/src/style.cpp ++++ b/style/src/style.cpp +@@ -564,6 +564,38 @@ void Style::drawControl(QStyle::ControlElement element, const QStyleOption *opti + painter->restore(); + } + ++void Style::polishScrollArea(QAbstractScrollArea* scrollArea) ++{ ++ if (!scrollArea) ++ return; ++ ++ // enable mouse over effect in sunken scrollareas that support focus ++ if (scrollArea->frameShadow() == QFrame::Sunken && scrollArea->focusPolicy() & Qt::StrongFocus) { ++ scrollArea->setAttribute(Qt::WA_Hover); ++ } ++ ++ // disable autofill background for flat (== NoFrame) scrollareas, with QPalette::Window as a background ++ // this fixes flat scrollareas placed in a tinted widget, such as groupboxes, tabwidgets or framed dock-widgets ++ if (!(scrollArea->frameShape() == QFrame::NoFrame || scrollArea->backgroundRole() == QPalette::Window)) { ++ return; ++ } ++ ++ // get viewport and check background role ++ QWidget *viewport(scrollArea->viewport()); ++ if (!(viewport && viewport->backgroundRole() == QPalette::Window)) ++ return; ++ ++ // change viewport autoFill background. ++ // do the same for all children if the background role is QPalette::Window ++ viewport->setAutoFillBackground(false); ++ QList children(viewport->findChildren()); ++ foreach (QWidget *child, children) { ++ if (child->parent() == viewport && child->backgroundRole() == QPalette::Window) { ++ child->setAutoFillBackground(false); ++ } ++ } ++} ++ + void Style::polish(QWidget *widget) + { + if (!widget) +@@ -588,18 +620,8 @@ void Style::polish(QWidget *widget) + widget->setAttribute(Qt::WA_Hover); + } + +- if (qobject_cast(widget)) +- { +- auto scrollArea = qobject_cast(widget); +- if (scrollArea->frameShadow() == QFrame::Sunken && scrollArea->focusPolicy() & Qt::StrongFocus) +- { +- scrollArea->setAttribute(Qt::WA_Hover); +- } +- // scrollArea->viewport()->setAutoFillBackground(false); +- // qInfo() << "viewport:" << scrollArea->viewport()->geometry(); +- // qInfo() << "scroll area:" << scrollArea->geometry(); +- } +- ++ polishScrollArea(qobject_cast(widget)); ++ + if (QAbstractItemView *itemView = qobject_cast(widget)) + { + // enable mouse over effects in itemviews' viewport +diff --git a/style/src/style.h b/style/src/style.h +index aa454ea..7b3212c 100644 +--- a/style/src/style.h ++++ b/style/src/style.h +@@ -27,6 +27,7 @@ + #define ParentStyle QCommonStyle + #endif + ++class QAbstractScrollArea; + class Style : public ParentStyle + { + public: +@@ -47,6 +48,7 @@ public: + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption* opt, const QWidget* widget) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption* option, const QWidget* widget) const override; + ++ void polishScrollArea(QAbstractScrollArea* scrollArea); + void polish(QWidget* widget) override; + void polish(QApplication* app) override; + void polish(QPalette& pal) override; +-- +2.33.0 + diff --git a/0002-refactor-log-update-log-output-when-creating-theme-a.patch b/0002-refactor-log-update-log-output-when-creating-theme-a.patch new file mode 100644 index 0000000..f5c5300 --- /dev/null +++ b/0002-refactor-log-update-log-output-when-creating-theme-a.patch @@ -0,0 +1,66 @@ +From d3cb409336c622b078b3c03ef6266775b5717346 Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Mon, 8 Aug 2022 17:02:11 +0800 +Subject: [PATCH 2/2] refactor(log): update log output when creating theme and + style plug-ins +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 更新创建主题和风格插件时的日志输出 +--- + platformtheme/kiran-theme-plugin.cpp | 2 +- + style/src/kiran-style-plugin.cpp | 22 ++++++++++++---------- + 2 files changed, 13 insertions(+), 11 deletions(-) + +diff --git a/platformtheme/kiran-theme-plugin.cpp b/platformtheme/kiran-theme-plugin.cpp +index 20c0198..961b7b3 100644 +--- a/platformtheme/kiran-theme-plugin.cpp ++++ b/platformtheme/kiran-theme-plugin.cpp +@@ -23,7 +23,7 @@ QPlatformTheme* KiranThemePlugin::create(const QString& key, const QStringList& + + if(keySet.contains(key)) + { +- qDebug(kiranPlatformTheme) << "create kiran style for" << QCoreApplication::applicationName(); ++ qDebug(kiranPlatformTheme) << "create kiran platformtheme for" << QCoreApplication::applicationName(); + return new KiranTheme(paramList); + } + +diff --git a/style/src/kiran-style-plugin.cpp b/style/src/kiran-style-plugin.cpp +index ee5f33e..aefbabc 100644 +--- a/style/src/kiran-style-plugin.cpp ++++ b/style/src/kiran-style-plugin.cpp +@@ -26,18 +26,20 @@ KiranStylePlugin::KiranStylePlugin(QObject *parent) : QStylePlugin(parent) + + QStyle *KiranStylePlugin::create(const QString & key) + { +- QStringList disableApps = KiranIntegrationSettings::instance()->getDisableKiranStyleApps(); +- QString processName = qAppName(); +- if( disableApps.contains(processName) ) +- { +- return QStyleFactory::create("fusion"); +- } +- +- qDebug("create style:%s",key.toStdString().c_str()); + if( key.compare("kiran",Qt::CaseInsensitive) == 0 ) + { +- return new Style(); ++ QStringList disableApps = KiranIntegrationSettings::instance()->getDisableKiranStyleApps(); ++ QString processName = qAppName(); ++ if( disableApps.contains(processName) ) ++ { ++ qDebug("%s in black list,create fusion style for it.",processName.toStdString().c_str()); ++ return QStyleFactory::create("fusion"); ++ } ++ else ++ { ++ qDebug("create style:%s",key.toStdString().c_str()); ++ return new Style(); ++ } + } +- + return nullptr; + } +-- +2.33.0 + diff --git a/kiran-qt5-integration.spec b/kiran-qt5-integration.spec index a419b85..c727908 100644 --- a/kiran-qt5-integration.spec +++ b/kiran-qt5-integration.spec @@ -1,6 +1,6 @@ Name: kiran-qt5-integration Version: 2.3.0 -Release: 3 +Release: 4 Summary: Kiran desktop platform integration plugin. License: MulanPSL-2.0 @@ -9,6 +9,8 @@ Source0: %{name}-%{version}.tar.gz Patch0001: 0001-refactor-log-Reduce-some-log-output-levels.patch Patch0002: 0002-feat-style-new-file-interface-that-can-disable-Kiran.patch Patch0003: 0001-feat-style-add-window-hover-color.patch +Patch0004: 0001-refactor-style-update-painting-effect-of-the-scrolli.patch +Patch0005: 0002-refactor-log-update-log-output-when-creating-theme-a.patch BuildRequires: cmake >= 3.2 BuildRequires: gcc-c++ @@ -64,6 +66,10 @@ make %{?_smp_mflags} %{_libdir}/pkgconfig/kiran-style-helper.pc %changelog +* Tue Aug 09 2022 liuxinhao - 2.3.0-4 +- KYOS-B: update painting effect of the scrolling area +- KYOS-F: update log output when creating theme and style plug-ins + * Thu Aug 04 2022 liuxinhao - 2.3.0-3 - KYOS-F: add window hover color -- Gitee