fix: adjust search box position for wayland dock overlap#754
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the fullscreen search box layout to avoid overlap with the dock on Wayland by importing the correct DS namespace and adding a dynamic bottom margin based on dock height, applied only on Wayland. Sequence diagram for fullscreen search box margin calculation on WaylandsequenceDiagram
participant FullscreenFrame
participant SearchEdit
participant DS
participant DockApplet
participant DockRoot
FullscreenFrame->>SearchEdit: evaluate Layout.bottomMargin
SearchEdit->>DS: applet(org.deepin.ds.dock)
DS-->>SearchEdit: DockApplet
alt dock applet available
SearchEdit->>DockApplet: rootObject
DockApplet-->>SearchEdit: DockRoot
SearchEdit->>DockRoot: read height
DockRoot-->>SearchEdit: dockHeight
SearchEdit->>SearchEdit: isWayland = Qt.platform.pluginName === wayland
alt isWayland
SearchEdit->>SearchEdit: bottomMargin = dockHeight + 10
else not Wayland
SearchEdit->>SearchEdit: bottomMargin = 0
end
else dock applet not available
SearchEdit->>SearchEdit: dockHeight = 0
SearchEdit->>SearchEdit: bottomMargin = 0
end
Flow diagram for computing search box bottom marginflowchart TD
A[Evaluate Layout.bottomMargin] --> B[Call DS.applet org.deepin.ds.dock]
B --> C{Dock applet exists?}
C -- No --> D[Set dockHeight = 0]
D --> E[Set bottomMargin = 0]
C -- Yes --> F[Access dock.rootObject]
F --> G{rootObject exists?}
G -- No --> D
G -- Yes --> H[Read dockHeight = rootObject.height]
H --> I{Qt.platform.pluginName == wayland}
I -- Yes --> J[bottomMargin = dockHeight + 10]
I -- No --> E
J --> K[Apply Layout.bottomMargin]
E --> K
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- You replaced
import org.deepin.dtk.style 1.0 as DSwithimport org.deepin.ds 1.0but still referenceDS.applet, so either restore the alias (as DS) or update the code to use the correct namespace to avoid runtime errors. - The
Layout.bottomMarginbinding callsDS.applet("org.deepin.ds.dock")each time it re-evaluates; consider caching the dock reference or exposing the dock height via a property to avoid repeated lookups and make future changes easier.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You replaced `import org.deepin.dtk.style 1.0 as DS` with `import org.deepin.ds 1.0` but still reference `DS.applet`, so either restore the alias (`as DS`) or update the code to use the correct namespace to avoid runtime errors.
- The `Layout.bottomMargin` binding calls `DS.applet("org.deepin.ds.dock")` each time it re-evaluates; consider caching the dock reference or exposing the dock height via a property to avoid repeated lookups and make future changes easier.
## Individual Comments
### Comment 1
<location path="qml/FullscreenFrame.qml" line_range="763-766" />
<code_context>
id: searchEdit
Layout.alignment: Qt.AlignHCenter
+ Layout.bottomMargin: {
+ var dock = DS.applet("org.deepin.ds.dock")
+ var dockHeight = (dock && dock.rootObject) ? dock.rootObject.height : 0
+ return Qt.platform.pluginName === "wayland" ? dockHeight + 10 : 0
+ }
implicitWidth: (parent.width / 2) > 280 ? 280 : (parent.width / 2)
</code_context>
<issue_to_address>
**issue (bug_risk):** The `DS` identifier is used here but no alias `DS` is defined after the import change.
Previously `org.deepin.dtk.style 1.0 as DS` introduced the `DS` alias, but `import org.deepin.ds 1.0` does not. As written, `DS.applet("org.deepin.ds.dock")` will throw at runtime unless `DS` is defined elsewhere. Please either reintroduce an alias on the new import or call the appropriate exported object from `org.deepin.ds` directly instead of `DS`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| Layout.bottomMargin: { | ||
| var dock = DS.applet("org.deepin.ds.dock") | ||
| var dockHeight = (dock && dock.rootObject) ? dock.rootObject.height : 0 | ||
| return Qt.platform.pluginName === "wayland" ? dockHeight + 10 : 0 |
There was a problem hiding this comment.
issue (bug_risk): The DS identifier is used here but no alias DS is defined after the import change.
Previously org.deepin.dtk.style 1.0 as DS introduced the DS alias, but import org.deepin.ds 1.0 does not. As written, DS.applet("org.deepin.ds.dock") will throw at runtime unless DS is defined elsewhere. Please either reintroduce an alias on the new import or call the appropriate exported object from org.deepin.ds directly instead of DS.
Replace DS import with direct dock applet access via DS.applet to calculate dock spacing, improving accuracy by using dock's root object dimensions instead of scaled geometry values. Log: Improved dock spacing calculation in FullscreenFrame Influence: 1. Test fullscreen frame display with different dock positions (top, bottom, left, right) 2. Verify dock spacing is correctly applied when dock is hidden or shown 3. Test with different display scale factors 4. Verify no regressions in dock area padding refactor: 优化全屏框架中的 dock 间距计算 将 DS 导入替换为通过 DS.applet 直接访问 dock 应用,使用 dock 的根对象尺 寸而非缩放后的几何值来计算 dock 间距,提高计算准确性。 Log: 优化全屏框架中的 dock 间距计算 Influence: 1. 测试不同 dock 位置(上、下、左、右)下的全屏框架显示 2. 验证 dock 隐藏或显示时间距计算是否正确 3. 测试不同显示缩放比例下的表现 4. 验证 dock 区域边距无回归问题 wayland下使用 Screen.devicePixelRatio 在1.25倍下,返回为2,因为在 Wayland 下往往会返回一个取整后的整数(如 2) 因此采用直接获取任务栏宽高方式,在wayland环境实现基于任务栏的大小从而保证启动器搜索框,以及指示器,关闭按钮的正确位移。 PMS: BUG-345751 BUG-345737
deepin pr auto review这段代码的 diff 主要涉及 QML 文件 1. 语法逻辑审查
2. 代码质量审查
3. 代码性能审查
4. 代码安全审查
改进后的代码示例import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import org.deepin.dtk 1.0
import org.deepin.ds 1.0 as DS
import org.deepin.launchpad 1.0
import org.deepin.launchpad.models 1.0
InputEventItem {
// ... 其他代码 ...
readonly property bool isHorizontalDock: DesktopIntegration.dockPosition === Qt.UpArrow || DesktopIntegration.dockPosition === Qt.DownArrow
readonly property var dock: DS.applet("org.deepin.ds.dock")
readonly property int dockSpacing: {
if (!dock || !dock.rootObject) {
return 0
}
return isHorizontalDock ? dock.rootObject.height : dock.rootObject.width
}
leftPadding: (DesktopIntegration.dockPosition === Qt.LeftArrow ? dockSpacing : 0)
rightPadding: (DesktopIntegration.dockPosition === Qt.RightArrow ? dockSpacing : 0)
topPadding: (DesktopIntegration.dockPosition === Qt.UpArrow ? dockSpacing : 0) + 20
// ... 其他代码 ...
}总结
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Replace DS import with direct dock applet access via DS.applet to
calculate dock spacing, improving accuracy by using dock's root object
dimensions instead of scaled geometry values.
Log: Improved dock spacing calculation in FullscreenFrame
Influence:
bottom, left, right)
refactor: 优化全屏框架中的 dock 间距计算
将 DS 导入替换为通过 DS.applet 直接访问 dock 应用,使用 dock 的根对象尺
寸而非缩放后的几何值来计算 dock 间距,提高计算准确性。
Log: 优化全屏框架中的 dock 间距计算
Influence:
wayland下使用 Screen.devicePixelRatio 在1.25倍下,返回为2,因为在 Wayland 下往往会返回一个取整后的整数(如 2)
因此采用直接获取任务栏宽高方式,在wayland环境实现基于任务栏的大小从而保证启动器搜索框,以及指示器,关闭按钮的正确位移。
PMS: BUG-345751 BUG-345737