3 Star 0 Fork 6

src-openEuler/kiran-session-guard

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0008-fix-styleditemdelegate-updateEditorGeometry-to-updat.patch 4.34 KB
一键复制 编辑 原始数据 按行查看 历史
liubuguiii 提交于 2024-04-09 17:11 . sync 2.5.1-11
From 66d11ae4717a846e06a7fc85354993ba2e90ce0e Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Thu, 26 Oct 2023 14:40:23 +0800
Subject: [PATCH] fix(styleditemdelegate): updateEditorGeometry to update the
wrong size of ItemWidgets in QStyledItemDelegate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 使用自定义的代理,避免QStyledItemDelegate中错误的使用updateEditorGeometry更新ItemWidget大小
Closes #16513
---
.../widgets/styled-item-delegate.cpp | 33 +++++++++++++++++++
.../widgets/styled-item-delegate.h | 28 ++++++++++++++++
src/lightdm-greeter/widgets/user-list.cpp | 2 ++
3 files changed, 63 insertions(+)
create mode 100644 src/lightdm-greeter/widgets/styled-item-delegate.cpp
create mode 100644 src/lightdm-greeter/widgets/styled-item-delegate.h
diff --git a/src/lightdm-greeter/widgets/styled-item-delegate.cpp b/src/lightdm-greeter/widgets/styled-item-delegate.cpp
new file mode 100644
index 0000000..a5323ce
--- /dev/null
+++ b/src/lightdm-greeter/widgets/styled-item-delegate.cpp
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2020 ~ 2023 KylinSec Co., Ltd.
+ * kiran-session-guard is licensed under 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.
+ *
+ * Author: liuxinhao <liuxinhao@kylinsec.com.cn>
+ */
+#include "styled-item-delegate.h"
+
+StyledItemDelegate::StyledItemDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+}
+
+StyledItemDelegate::~StyledItemDelegate()
+{
+}
+
+/**
+ * 避免某些时候QListWidget更新item大小时调用QStyledItemDelegate相关接口错误的更新Editor大小
+*/
+void StyledItemDelegate::updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ editor->setGeometry(option.rect);
+}
\ No newline at end of file
diff --git a/src/lightdm-greeter/widgets/styled-item-delegate.h b/src/lightdm-greeter/widgets/styled-item-delegate.h
new file mode 100644
index 0000000..e229306
--- /dev/null
+++ b/src/lightdm-greeter/widgets/styled-item-delegate.h
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2020 ~ 2023 KylinSec Co., Ltd.
+ * kiran-session-guard is licensed under 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.
+ *
+ * Author: liuxinhao <liuxinhao@kylinsec.com.cn>
+ */
+#pragma once
+
+#include <QStyledItemDelegate>
+
+class StyledItemDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+ StyledItemDelegate(QObject* parent = nullptr);
+ ~StyledItemDelegate();
+
+ void updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override;
+};
\ No newline at end of file
diff --git a/src/lightdm-greeter/widgets/user-list.cpp b/src/lightdm-greeter/widgets/user-list.cpp
index b83efdf..e59fa8b 100644
--- a/src/lightdm-greeter/widgets/user-list.cpp
+++ b/src/lightdm-greeter/widgets/user-list.cpp
@@ -24,6 +24,7 @@
#include "ui_user-list.h"
#include "user-info.h"
#include "user-item.h"
+#include "styled-item-delegate.h"
using namespace QLightDM;
@@ -126,6 +127,7 @@ int UserList::userCount()
void UserList::initUI()
{
setAttribute(Qt::WA_Hover, true);
+ ui->userList->setItemDelegate(new StyledItemDelegate(this));
ui->userList->setFocusPolicy(Qt::ClickFocus);
ui->userList->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->userList->setSelectionMode(QAbstractItemView::SingleSelection);
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/kiran-session-guard.git
git@gitee.com:src-openeuler/kiran-session-guard.git
src-openeuler
kiran-session-guard
kiran-session-guard
master

搜索帮助