101 lines
4.1 KiB
Diff
101 lines
4.1 KiB
Diff
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
|
|
|