!120 修复托盘在屏幕顶部时,弹窗位置不对的问题

From: @luoqing_kylinsec 
Reviewed-by: @liubuguiii 
Signed-off-by: @liubuguiii
This commit is contained in:
openeuler-ci-bot 2023-10-19 01:39:14 +00:00 committed by Gitee
commit 0a423dd951
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 130 additions and 1 deletions

View File

@ -0,0 +1,125 @@
From 74f15f8c5e6bf30a990ebf71def1c29581e67c85 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Tue, 17 Oct 2023 09:33:24 +0800
Subject: [PATCH] fix(tray):Fixed an issue where the popup was in the wrong
position when the tray was at the top of the screen
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复托盘在屏幕顶部时,弹窗位置不对的问题
Related #17279
---
.../src/system-tray/audio-system-tray.cpp | 32 +++++++++++++------
.../audio/src/system-tray/audio-system-tray.h | 2 +-
plugins/network/src/tray/network-tray.cpp | 16 +++++++---
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/plugins/audio/src/system-tray/audio-system-tray.cpp b/plugins/audio/src/system-tray/audio-system-tray.cpp
index 0c6aca6..cc4015d 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.cpp
+++ b/plugins/audio/src/system-tray/audio-system-tray.cpp
@@ -162,7 +162,19 @@ void AudioSystemTray::setVolumeSettingPos()
int pageWidth = 300;
int pageHeight = 66;
- m_volumenPopup->setGeometry(xTray - pageWidth / 2, yTray - pageHeight - offset, pageWidth, pageHeight);
+ int showPosY;
+ // 托盘程序在顶端
+ if(m_yTray == 0)
+ {
+ showPosY = m_heightTray - offset;
+ }
+ else
+ {
+ //托盘程序在底部
+ showPosY = m_yTray - pageHeight - offset;
+ }
+
+ m_volumenPopup->setGeometry(m_xTray - pageWidth / 2, showPosY, pageWidth, pageHeight);
}
void AudioSystemTray::handleMixedSettingClicked()
@@ -180,7 +192,7 @@ void AudioSystemTray::setMixedSettingPos()
int width = m_mixedPopup->sizeHint().width();
m_mixedPopup->setFixedHeight(height + offset * 2);
- m_mixedPopup->move(xTray - width / 2, yTray - height - offset);
+ m_mixedPopup->move(m_xTray - width / 2, m_yTray - height - offset);
}
void AudioSystemTray::handleAdjustedMixedSettingPageSize()
@@ -228,15 +240,15 @@ void AudioSystemTray::getTrayGeometry()
}
}
}
- heightTray = static_cast<int>(height);
- widthTray = static_cast<int>(width);
- xTray = static_cast<int>(x);
- yTray = static_cast<int>(y);
+ m_heightTray = static_cast<int>(height);
+ m_widthTray = static_cast<int>(width);
+ m_xTray = static_cast<int>(x);
+ m_yTray = static_cast<int>(y);
KLOG_DEBUG() << "getTrayGeometry ";
- KLOG_DEBUG() << "heightTray" << heightTray;
- KLOG_DEBUG() << "widthTray" << widthTray;
- KLOG_DEBUG() << "xTray" << xTray;
- KLOG_DEBUG() << "yTray" << yTray;
+ KLOG_DEBUG() << "heightTray" << m_heightTray;
+ KLOG_DEBUG() << "widthTray" << m_widthTray;
+ KLOG_DEBUG() << "xTray" << m_xTray;
+ KLOG_DEBUG() << "yTray" << m_yTray;
}
// XXX:频繁调用函数,需要优化
diff --git a/plugins/audio/src/system-tray/audio-system-tray.h b/plugins/audio/src/system-tray/audio-system-tray.h
index a61284e..fd5f150 100644
--- a/plugins/audio/src/system-tray/audio-system-tray.h
+++ b/plugins/audio/src/system-tray/audio-system-tray.h
@@ -70,7 +70,7 @@ private:
AudioInterface* m_audioInterface;
QString m_colorTheme;
- int xTray, yTray, heightTray, widthTray;
+ int m_xTray, m_yTray, m_heightTray, m_widthTray;
QDBusServiceWatcher *m_dbusServiceWatcher;
};
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
index dd5ff12..c43d8ff 100644
--- a/plugins/network/src/tray/network-tray.cpp
+++ b/plugins/network/src/tray/network-tray.cpp
@@ -305,16 +305,24 @@ void NetworkTray::showOrHideTrayPage()
void NetworkTray::setTrayPagePos()
{
- // KLOG_DEBUG() << "this->sizeHint():" << this->sizeHint();
- // KLOG_DEBUG() << "this->size():" << this->size();
-
int pageHeight = this->size().height();
int pageWidth = this->size().width();
getTrayGeometry();
// 抵消KiranRoundedTrayPopup的margin
int offset = 8;
- this->move(m_xTray - pageWidth / 2, m_yTray - pageHeight + offset);
+ int showPosY;
+ // 托盘程序在顶端
+ if(m_yTray == 0)
+ {
+ showPosY = m_heightTray - offset;
+ }
+ else
+ {
+ //托盘程序在底部
+ showPosY = m_yTray - pageHeight + offset;
+ }
+ this->move(m_xTray - pageWidth / 2, showPosY);
}
void NetworkTray::getTrayGeometry()
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: kiran-control-panel
Version: 2.5.5
Release: 11%{?dist}
Release: 12%{?dist}
Summary: Kiran Control Panel
Summary(zh_CN): Kiran桌面控制面板
@ -22,6 +22,7 @@ Patch0012: 0012-fix-network-tray-Improved-the-notification-logic.-Wi.patch
Patch0013: 0013-fix-network-Modify-DNS-Settings-and-display-DNS-deta.patch
Patch0014: 0014-fix-tray-Fixed-the-tray-menu-using-the-X11-platform-.patch
Patch0015: 0015-fix-network-tray-Fixed-an-issue-where-the-size-Setti.patch
Patch0016: 0016-fix-tray-Fixed-an-issue-where-the-popup-was-in-the-w.patch
BuildRequires: gcc-c++
BuildRequires: cmake >= 3.2
@ -178,6 +179,9 @@ make %{?_smp_mflags}
rm -rf %{buildroot}
%changelog
* Tue Oct 17 2023 luoqing <luoqing@kylinsec.com.cn> - 2.5.5-12
- KYOS-F: Fixed an issue where the popup was in the wrong position when the tray was at the top of the screen (#17279)
* Thu Sep 21 2023 luoqing <luoqing@kylinsec.com.cn> - 2.5.5-11
- KYOS-F: Fixed an issue where the size Settings of widgets that are not currently displaying pages in the stackwidget did not take effect when multiple nics were present during tray initialization(#13862)
- KYOS-F: Fixed the tray menu using the X11 platform, which caused the missing voice and network icon in the lower right corner, and the network icon in the taskbar was formatted incorrectly(#13353,#11856,#14006)