From 19dc48008e05007835002c33fae91befa2f4ab16 Mon Sep 17 00:00:00 2001 From: liuxinhao Date: Tue, 5 Sep 2023 16:05:15 +0800 Subject: [PATCH] fix(qt5.9.7): fits the Qt5.9.7 interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 适配Qt5.9.7接口,修复编译报错 --- ...x-qt5.9.7-fits-the-Qt5.9.7-interface.patch | 97 +++++++++++++++++++ kiran-widgets-qt5.spec | 6 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 0006-fix-qt5.9.7-fits-the-Qt5.9.7-interface.patch diff --git a/0006-fix-qt5.9.7-fits-the-Qt5.9.7-interface.patch b/0006-fix-qt5.9.7-fits-the-Qt5.9.7-interface.patch new file mode 100644 index 0000000..6fb6fc1 --- /dev/null +++ b/0006-fix-qt5.9.7-fits-the-Qt5.9.7-interface.patch @@ -0,0 +1,97 @@ +From c6b513e64aa283ee22fab2b4ba862950bcafd28f Mon Sep 17 00:00:00 2001 +From: liuxinhao +Date: Tue, 5 Sep 2023 15:18:49 +0800 +Subject: [PATCH] fix(qt5.9.7): fits the Qt5.9.7 interface +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 适配Qt5.9.7接口,修复编译报错 +--- + src/widgets/kiran-label/kiran-label.cpp | 20 ++++++++++++-------- + src/widgets/kiran-tips/kiran-tips.cpp | 6 +++++- + test/kiran-image-selector-test.cpp | 4 ++-- + 3 files changed, 19 insertions(+), 11 deletions(-) + +diff --git a/src/widgets/kiran-label/kiran-label.cpp b/src/widgets/kiran-label/kiran-label.cpp +index 6302357..3dcd0e5 100644 +--- a/src/widgets/kiran-label/kiran-label.cpp ++++ b/src/widgets/kiran-label/kiran-label.cpp +@@ -1,14 +1,14 @@ + /** +- * Copyright (c) 2020 ~ 2022 KylinSec Co., Ltd. ++ * Copyright (c) 2020 ~ 2022 KylinSec Co., Ltd. + * kiranwidgets-qt5 is licensed under Mulan PSL v2. +- * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: +- * http://license.coscl.org.cn/MulanPSL2 +- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +- * See the Mulan PSL v2 for more details. +- * ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * + * Author: liuxinhao + */ + +@@ -73,7 +73,11 @@ QRectF KiranLabelPrivate::documentRect(QLabelPrivate *ld) + QFlag(ld->align)); + int m = ld->indent; + if (m < 0 && q->frameWidth()) // no indent, but we do have a frame ++#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + m = q->fontMetrics().horizontalAdvance(QLatin1Char('x')) / 2 - ld->margin; ++#else ++ m = q->fontMetrics().width(QLatin1Char('x')) / 2 - ld->margin; ++#endif + if (m > 0) + { + if (align & Qt::AlignLeft) +diff --git a/src/widgets/kiran-tips/kiran-tips.cpp b/src/widgets/kiran-tips/kiran-tips.cpp +index d5bcbf6..91d2e6f 100644 +--- a/src/widgets/kiran-tips/kiran-tips.cpp ++++ b/src/widgets/kiran-tips/kiran-tips.cpp +@@ -231,7 +231,11 @@ QSize KiranTips::getRightSize() const + QFontMetrics fontMetrics(font); + QMargins layoutContentMargins = this->layout()->contentsMargins(); + ++#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + d_ptr->m_labelText->setFixedWidth(fontMetrics.horizontalAdvance(d_ptr->m_labelText->text()) + 10); ++#else ++ d_ptr->m_labelText->setFixedWidth(fontMetrics.width(d_ptr->m_labelText->text()) + 10); ++#endif + d_ptr->m_labelText->setFixedHeight(fontMetrics.height()); + + QSize size; +@@ -355,7 +359,7 @@ void KiranTipsPrivate::init() + m_EnterAnimation->setEasingCurve(QEasingCurve::OutQuad); + + // clang-format off +- connect(&m_fadeOutTimer, &QTimer::timeout, [this](){ ++ connect(&m_fadeOutTimer, &QTimer::timeout, [this](){ + q_ptr->hideTip(); + }); + connect(m_EnterAnimation, &QPropertyAnimation::finished, [this](){ +diff --git a/test/kiran-image-selector-test.cpp b/test/kiran-image-selector-test.cpp +index 7651e07..cf306cd 100644 +--- a/test/kiran-image-selector-test.cpp ++++ b/test/kiran-image-selector-test.cpp +@@ -43,8 +43,8 @@ private slots: + + void testItemSpacing() + { +- QList itemSpacingSet = {5,10,15,20,25,50,100,150,300,10}; +- foreach ( const int& spacing, itemSpacingSet ) ++ QList itemSpacingSet = {5,10,15,20,25,50,100,150,300,10}; ++ foreach ( const quint64& spacing, itemSpacingSet ) + { + imageSelector->setItemSpacing(spacing); + QCOMPARE(imageSelector->itemSpacing(),spacing); +-- +2.33.0 + diff --git a/kiran-widgets-qt5.spec b/kiran-widgets-qt5.spec index 0ed9282..1ccfac5 100644 --- a/kiran-widgets-qt5.spec +++ b/kiran-widgets-qt5.spec @@ -1,6 +1,6 @@ Name: kiran-widgets-qt5 Version: 2.4.0 -Release: 5 +Release: 6 Summary: Encapsulated QT Widget Summary(zh_CN): 封装的Qt小部件 @@ -12,6 +12,7 @@ Patch0002: 0002-fix-KiranSiderbarWidget-If-the-text-is-too-wide-and-.patch Patch0003: 0003-fix-KiranTitlebarWindow-Fix-when-zoomed-twice_GTK_FR.patch Patch0004: 0004-fix-translate-add-some-translation.patch Patch0005: 0005-fix-icon-Update-the-title-bar-icon-when-the-window-s.patch +Patch0006: 0006-fix-qt5.9.7-fits-the-Qt5.9.7-interface.patch BuildRequires: cmake >= 3.5 BuildRequires: gcc-c++ @@ -82,6 +83,9 @@ make %{?_smp_mflags} rm -rf %{buildroot} %changelog +* Tue Sep 05 2023 liuxinhao - 2.4.0-6 +- KYOS-F: fits the Qt5.9.7 interface + * Sun Jun 25 2023 liuxinhao - 2.4.0-5 - KYOS-B: Update the title bar icon when the window state changes(#I7FTM3) -- Gitee