fix(title): enable ratio control before status text is ready#462
Conversation
Keep the ratio control available for a nonempty all-items collection. 在异步状态文本填充前,为非空的全部合集保持比例按钮可用。 Log: 修复首屏比例按钮延迟可用的问题 Influence: 全部合集首屏的原始比例和方形缩略图切换
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 diff --git a/src/qml/AlbumTitle.qml b/src/qml/AlbumTitle.qml
index dc0b3c12..e9c4ef11 100644
--- a/src/qml/AlbumTitle.qml
+++ b/src/qml/AlbumTitle.qml
@@ -50,6 +50,11 @@ TitleBar {
property int layoutLeftMargin_AlignLeft: showHideleftSidebarButton.x + showHideleftSidebarButton.width // 显示比例按钮向标题左侧对齐时的布局留白宽度
property int layoutLeftMargin_AlignRight: GStatus.sideBarWidth + 10 // 显示比例按钮向标题右侧对齐时的布局留白宽度
property bool collectionComboEverNarrow: false
+ // Do not wait for the asynchronously populated status text to render the
+ // ratio button. Once a view has supplied status text, that text remains
+ // the authoritative availability state for subsequent view changes.
+ property bool initialRatioContentAvailable: albumControl.getAllCount() > 0
+ property bool ratioContentStateResolved: false
+
+ // 提取复杂逻辑为只读属性,增强可读性
+ readonly property bool isRange1ButtonEnabled: !(GStatus.currentViewType === Album.Types.ViewCollecttion
+ && GStatus.currentCollecttionViewIndex === 0)
+ && (GStatus.statusBarNumText !== ""
+ || (!title.ratioContentStateResolved
+ && GStatus.currentViewType === Album.Types.ViewCollecttion
+ && GStatus.currentCollecttionViewIndex === 3
+ && title.initialRatioContentAvailable))
property int lastWidth: 0
onWidthChanged: {
@@ -83,6 +88,18 @@ TitleBar {
lastWidth = width
}
+ Connections {
+ target: GStatus
+ function onStatusBarNumTextChanged() {
+ if (GStatus.statusBarNumText !== "")
+ title.ratioContentStateResolved = true
+ }
+ }
+
+ Component.onCompleted: {
+ ratioContentStateResolved = GStatus.statusBarNumText !== ""
+ }
+
// 显示比例按钮向左对齐动画
NumberAnimation {
id: layoutMoveToRightAnimation
@@ -220,7 +237,13 @@ TitleBar {
id: range1Button
Layout.preferredWidth: iconSize
Layout.preferredHeight: iconSize
- enabled: GStatus.statusBarNumText !== "" && !(GStatus.currentViewType === Album.Types.ViewCollecttion && GStatus.currentCollecttionViewIndex === 0)
+ enabled: title.isRange1ButtonEnabled
ToolTip.visible: hovered
ToolTip.text: icon.name === "range1" ? qsTr("Original ratio") : qsTr("Square thumbnails")
icon { |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx, wyu71 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 |
Keep the ratio control available for a nonempty all-items collection. 在异步状态文本填充前,为非空的全部合集保持比例按钮可用。
Log: 修复首屏比例按钮延迟可用的问题
Influence: 全部合集首屏的原始比例和方形缩略图切换