From 766a1ac3345852e3f95a005bd6ef2469ab9f1dd9 Mon Sep 17 00:00:00 2001
From: liuxinhao <liuxinhao@kylinsec.com.cn>
Date: Mon, 28 Aug 2023 19:17:41 +0800
Subject: [PATCH 5/5] fix(account): Fixed issues related to creating and
 deleting users in account management
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复账户管理创建删除用户中出现的相关问题

Closes #13994, #13990
---
 plugins/account/src/kiran-account-manager.cpp     | 15 ++++++---------
 .../account/src/widgets/animation-push-button.cpp | 11 +++++++++++
 .../account/src/widgets/animation-push-button.h   |  1 +
 .../account/src/widgets/avatar-item-button.cpp    |  2 +-
 plugins/account/src/widgets/mask-widget.cpp       |  2 +-
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/plugins/account/src/kiran-account-manager.cpp b/plugins/account/src/kiran-account-manager.cpp
index 01b4fbf..15653d9 100644
--- a/plugins/account/src/kiran-account-manager.cpp
+++ b/plugins/account/src/kiran-account-manager.cpp
@@ -109,14 +109,11 @@ void KiranAccountManager::appendSiderbarItem(const QString &userPath)
 void KiranAccountManager::setDefaultSiderbarItem()
 {
     //设置默认侧边栏项
-    if (m_tabList->count() > 1)
+    auto items = m_tabList->findItems(AccountsGlobalInfo::instance()->getCurrentUser(), Qt::MatchCaseSensitive);
+    if ( items.size() >= 1 )
     {
-        auto items = m_tabList->findItems(AccountsGlobalInfo::instance()->getCurrentUser(), Qt::MatchCaseSensitive);
-        if (items.size() == 1)
-        {
-            auto item = items.at(0);
-            m_tabList->setCurrentRow(m_tabList->row(item));
-        }
+        auto item = items.at(0);
+        m_tabList->setCurrentRow(m_tabList->row(item));
     }
     else
     {
@@ -128,7 +125,7 @@ void KiranAccountManager::initUI()
 {
     /* 遮罩,用于繁忙时屏蔽用户操作 */
     m_maskWidget = new MaskWidget(this);
-    m_maskWidget->setVisible(false);
+    m_maskWidget->setVisible(true);
 
     /* 初始化界面主布局 */
     auto contentLayout = new QHBoxLayout(this);
@@ -444,7 +441,7 @@ void KiranAccountManager::setMaskVisible(bool visible)
 {
     if (visible)
     {
-        this->stackUnder(m_maskWidget);
+        m_maskWidget->raise();
         m_maskWidget->show();
     }
     else
diff --git a/plugins/account/src/widgets/animation-push-button.cpp b/plugins/account/src/widgets/animation-push-button.cpp
index 65791f0..d65b348 100644
--- a/plugins/account/src/widgets/animation-push-button.cpp
+++ b/plugins/account/src/widgets/animation-push-button.cpp
@@ -16,6 +16,7 @@
 #include <QPropertyAnimation>
 #include <QStyleOption>
 #include <qt5-log-i.h>
+#include <QMouseEvent>
 
 #include "animation-push-button.h"
 
@@ -85,6 +86,16 @@ void AnimationPushButton::paintEvent(QPaintEvent *event)
     }
 }
 
+void AnimationPushButton::mousePressEvent(QMouseEvent *e)
+{
+    if( m_isBusy )
+    {
+        e->ignore();
+        return;
+    }
+    QPushButton::mousePressEvent(e);
+}
+
 void AnimationPushButton::initTimeLine()
 {
     m_timeLine.setCurrentTime(0);
diff --git a/plugins/account/src/widgets/animation-push-button.h b/plugins/account/src/widgets/animation-push-button.h
index 9a172e2..f39e9a4 100644
--- a/plugins/account/src/widgets/animation-push-button.h
+++ b/plugins/account/src/widgets/animation-push-button.h
@@ -38,6 +38,7 @@ private:
 
 protected:
     virtual void paintEvent(QPaintEvent *event) override;
+    virtual void mousePressEvent(QMouseEvent *e) override;
 
 private:
     bool m_isBusy = false;
diff --git a/plugins/account/src/widgets/avatar-item-button.cpp b/plugins/account/src/widgets/avatar-item-button.cpp
index a078974..a9e5a4b 100644
--- a/plugins/account/src/widgets/avatar-item-button.cpp
+++ b/plugins/account/src/widgets/avatar-item-button.cpp
@@ -106,7 +106,7 @@ void AvatarItemButton::paintEvent(QPaintEvent *event)
         QPoint checkedIconLeftop((this->width() - checkedIconSize.width()) / 2,
                                  (this->height() - checkedIconSize.height()) / 2);
         QRect checkedIconRect(checkedIconLeftop, checkedIconSize);
-        QSvgRenderer svgRenderer(QString(":/kcp-account/images/success-indicator.svg"));
+        QSvgRenderer svgRenderer(QString(":/kiran-control-panel/images/success-indicator.svg"));
         svgRenderer.render(&painter, checkedIconRect);
     }
 }
diff --git a/plugins/account/src/widgets/mask-widget.cpp b/plugins/account/src/widgets/mask-widget.cpp
index 088fd48..476cbb3 100644
--- a/plugins/account/src/widgets/mask-widget.cpp
+++ b/plugins/account/src/widgets/mask-widget.cpp
@@ -41,5 +41,5 @@ bool MaskWidget::eventFilter(QObject *watched, QEvent *event)
             break;
         }
     }
-    return QObject::eventFilter(watched, event);
+    return QWidget::eventFilter(watched, event);
 }
-- 
2.33.0

