From 101965c35daf3e5b04e57de36d71f7d34315d6fb Mon Sep 17 00:00:00 2001 From: renbin Date: Mon, 25 Mar 2024 17:36:47 +0800 Subject: [PATCH] feat: Change default shortcuts popup position Change the pop-up position of the default shortcut floating window. It will now be displayed in the center of the focus screen (the screen where the cursor is). Log: Change default shortcuts popup position Task: https://pms.uniontech.com/task-view-332271.html Influence: Shortcuts --- reader/widgets/ShortCutShow.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/reader/widgets/ShortCutShow.cpp b/reader/widgets/ShortCutShow.cpp index af07b8e9..20f34565 100644 --- a/reader/widgets/ShortCutShow.cpp +++ b/reader/widgets/ShortCutShow.cpp @@ -8,6 +8,8 @@ #include "Global.h" #include "DocSheet.h" +#include + #include #include #include @@ -34,6 +36,18 @@ void ShortCutShow::show() { QRect rect = qApp->desktop()->geometry(); QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); + // 获取当前焦点位置(光标所在屏幕中心) + QScreen *screen = nullptr; + if (DGuiApplicationHelper::isTabletEnvironment()) { + // bug 88079 避免屏幕旋转弹出位置错误 + screen = qApp->primaryScreen(); + } else { + screen = QGuiApplication::screenAt(QCursor::pos()); + } + + if (screen) { + pos = screen->geometry().center(); + } QJsonObject shortcutObj; QJsonArray jsonGroups;