Skip to content

Commit 67b257a

Browse files
wjyrichdeepin-bot[bot]
authored andcommitted
fix: correct popup position calculation in widget plugin
1. Modified position calculation for plugin popups to use EmbedPlugin's position 2. Added null check for transient parent window 3. Uses pluginPos() from EmbedPlugin instead of direct window coordinates 4. Ensures popups appear in correct relative position to their parent plugin The previous implementation directly used the transient parent window's coordinates which could lead to incorrect positioning when the plugin was embedded in a complex layout. The new approach gets the accurate position from the EmbedPlugin itself. fix: 修正小部件插件中弹出窗口位置计算 1. 修改插件弹出窗口的位置计算以使用 EmbedPlugin 的位置 2. 为 transient 父窗口添加空值检查 3. 使用 EmbedPlugin 的 pluginPos() 而非直接窗口坐标 4. 确保弹出窗口相对于父插件显示在正确位置 之前的实现直接使用 transient 父窗口的坐标,当插件嵌入复杂布局时可能导致 位置计算错误。新方法从 EmbedPlugin 自身获取准确位置。 Pms: BUG-321795
1 parent 0c22d5b commit 67b257a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/loader/widgetplugin.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,15 @@ class Q_DECL_HIDDEN EventFilter : public QObject
5555

5656
const auto toolTipWindow = *iter;
5757
if (auto pluginPopup = Plugin::PluginPopup::getWithoutCreating(toolTipWindow)) {
58-
pluginPopup->setX(toolTipWindow->transientParent()->x() + pos.x());
59-
pluginPopup->setY(toolTipWindow->transientParent()->y() + pos.y());
58+
auto parentWindow = toolTipWindow->transientParent();
59+
if (parentWindow) {
60+
// 通过EmbedPlugin获取正确的插件位置
61+
if (auto plugin = Plugin::EmbedPlugin::getWithoutCreating(parentWindow)) {
62+
auto pluginPos = plugin->pluginPos();
63+
pluginPopup->setX(pluginPos.x() + pos.x());
64+
pluginPopup->setY(pluginPos.y() + pos.y());
65+
}
66+
}
6067
}
6168
}
6269
};

0 commit comments

Comments
 (0)