fix(KiranTitlebarWindow): Fix the issue of blank icons occupying the title bar position

- 修复空白图标占据标题栏位置的问题

Closes #29450
This commit is contained in:
liuxinhao 2024-02-18 17:34:01 +08:00
parent ae66e24e63
commit bcf9dfd26f
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,100 @@
From c1c2b85ded4db84908b60ca695a26cb16201ef66 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Sun, 18 Feb 2024 10:40:37 +0800
Subject: [PATCH] fix(KiranTitlebarWindow): Fix the issue of blank icons
occupying the title bar position
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复空白图标占据标题栏位置的问题
Closes #29450
---
.../kiran-titlebar-window-private.cpp | 15 ++++++++++++--
.../kiran-titlebar-window-private.h | 20 ++++++++++---------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.cpp b/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.cpp
index 43cd51a..cc378c3 100644
--- a/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.cpp
+++ b/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.cpp
@@ -45,6 +45,8 @@ const int KiranTitlebarWindowPrivate::shadowRadius = 15;
const QColor KiranTitlebarWindowPrivate::shadowActiveColor = QColor(0, 0, 0, 150);
const QColor KiranTitlebarWindowPrivate::shadowInactiveColor = QColor(0, 0, 0, 75);
+const QSize KiranTitlebarWindowPrivate::iconSize = QSize(24,24);
+
extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
using namespace Kiran;
@@ -99,7 +101,16 @@ void KiranTitlebarWindowPrivate::init()
void KiranTitlebarWindowPrivate::setIcon(const QIcon &icon)
{
- m_titleIcon->setPixmap(icon.pixmap(16, 16));
+ QPixmap pixmap = icon.pixmap(16,16);
+ if( pixmap.isNull() )
+ {
+ m_titleIcon->setFixedSize(QSize(0,0));
+ }
+ else
+ {
+ m_titleIcon->setFixedSize(iconSize);
+ }
+ m_titleIcon->setPixmap(pixmap);
}
void KiranTitlebarWindowPrivate::setTitle(const QString &title)
@@ -317,7 +328,7 @@ void KiranTitlebarWindowPrivate::initOtherWidget()
m_titleIcon = new QLabel(m_titlebarWidget);
m_titleIcon->setObjectName("KiranTitlebarIcon");
m_titleIcon->setAccessibleName("WindowTitlebarIcon");
- m_titleIcon->setFixedSize(24, 24);
+ m_titleIcon->setFixedSize(QSize(0,0));
m_titleBarLayout->setTitleBarIconLabel(m_titleIcon);
m_titleBarLayout->setTitleBarIconMargin(QMargins(12, 0, 0, 0));
diff --git a/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.h b/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.h
index 6f57deb..756c487 100644
--- a/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.h
+++ b/src/widgets/kiran-titlebar-window/kiran-titlebar-window-private.h
@@ -1,17 +1,17 @@
/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
+ * Copyright (c) 2020 ~ 2021 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 <liuxinhao@kylinos.com.cn>
*/
-
+
#ifndef KIRANTITLEBARWINDOWPRIVATE_H
#define KIRANTITLEBARWINDOWPRIVATE_H
@@ -107,6 +107,8 @@ private:
//下列关于阴影边框变量 修改应只在'ensureShadowPixmapUpdated'之中
QPixmap m_shadowPix; //生成的阴影边框图片 窗口未激活时
QPixmap m_shadowActivePix; //生成的阴影边框图片 窗口激活时
+
+ static const QSize iconSize;
};
#endif // KIRANTITLEBARWINDOWPRIVATE_H
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: kiran-widgets-qt5
Version: 2.4.2
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Encapsulated QT Widget
Summary(zh_CN): 封装的Qt小部件
@ -9,6 +9,7 @@ Source0: %{name}-%{version}.tar.gz
Patch0000: 0000-fix-KiranPasswordEdit-default-password-input-does-no.patch
Patch0001: 0001-feat-KiranTitlebarWindow-Customize-title-bar-to-send.patch
Patch0002: 0002-fix-KiranTitlebarWindow-Fix-the-issue-of-blank-icons.patch
BuildRequires: cmake >= 3.5
BuildRequires: gcc-c++
@ -79,6 +80,9 @@ make %{?_smp_mflags}
rm -rf %{buildroot}
%changelog
* Sun Feb 18 2024 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.4.2-4
- KYOS-B: Fix the issue of blank icons occupying the title bar position(#29450)
* Mon Jan 22 2024 liuxinhao <liuxinhao@kylinsec.com.cn> - 2.4.2-3
- KYOS-F: Customize title bar send requests to window manager and pop up a right-click menu(#24920)