Skip to content

Commit 1bcefde

Browse files
iCancelydeepin-bot[bot]
authored andcommitted
fix(accounts): center avatar empty state
1. Center the avatar upload placeholder inside the dashed drop area. 2. Resolve dark theme icon lookup to use the bundled DCI asset. Log: Center avatar upload empty state and fix dark icon lookup fix(accounts): 居中头像上传空态 1. 将头像上传前的缺省图和提示文案整体居中到虚线拖拽框内。 2. 修复深色主题图标查找逻辑,使用内置 DCI 资源。 Log: 修复头像上传空态布局和深色图标查找 PMS: BUG-368683
1 parent 832a73f commit 1bcefde

2 files changed

Lines changed: 41 additions & 35 deletions

File tree

src/plugin-accounts/qml/AvatarSettingsDialog.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ D.DialogWindow {
244244
CustomAvatarEmpatyArea {
245245
id: customEmptyAvatar
246246
visible: needShow()
247-
Layout.alignment: Qt.AlignHCenter
248-
Layout.rightMargin: 10
247+
Layout.fillWidth: true
248+
Layout.fillHeight: true
249+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
249250
onIconDropped: function (url){
250251
let filePath = url.toString()
251252
const sourceFile = filePath.replace("file://", "")

src/plugin-accounts/qml/CustomAvatarEmpatyArea.qml

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import org.deepin.dtk 1.0 as D
99
Control {
1010
id: control
1111
property real radius: 8
12-
width: 430
13-
height: 360
12+
property bool invalidFileType: false
13+
implicitWidth: 460
14+
implicitHeight: 360
1415

1516
signal requireFileDialog()
1617
signal iconDropped(string file)
@@ -57,6 +58,7 @@ Control {
5758
anchors.fill: parent
5859
hoverEnabled: true
5960
onClicked: {
61+
control.invalidFileType = false
6062
requireFileDialog()
6163
}
6264
}
@@ -69,45 +71,48 @@ Control {
6971
var filePath = drop.urls[0].toString()
7072
var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase()
7173
if (['png', 'bmp', 'jpg', 'jpeg'].indexOf(ext) === -1) {
72-
errorLabel.visible = true
73-
normalLabel.visible = false
74+
control.invalidFileType = true
7475
return
7576
}
76-
errorLabel.visible = false
77-
normalLabel.visible = true
77+
control.invalidFileType = false
7878
iconDropped(filePath)
7979
}
8080
}
8181
}
8282
}
83-
D.DciIcon {
84-
id: addIcon
85-
anchors.centerIn: parent
86-
name: "dcc_user_add_icon"
87-
sourceSize: Qt.size(64, 64)
88-
}
8983

90-
D.Label {
91-
id: normalLabel
92-
width: 360
93-
wrapMode: Text.WordWrap
94-
font: D.DTK.fontManager.t8
95-
anchors.top: addIcon.bottom
96-
anchors.topMargin: 20
97-
horizontalAlignment: Text.AlignHCenter
98-
anchors.horizontalCenter: parent.horizontalCenter
99-
text: qsTr("You haven't uploaded an avatar yet. Click or drag and drop to upload an image.")
100-
}
84+
Item {
85+
id: emptyState
86+
width: shape.width - 40
87+
height: addIcon.height + 20 + messageLabel.implicitHeight
88+
anchors.centerIn: shape
10189

102-
D.Label {
103-
id: errorLabel
104-
width: 360
105-
wrapMode: Text.WordWrap
106-
anchors.top: addIcon.bottom
107-
anchors.topMargin: 20
108-
horizontalAlignment: Text.AlignHCenter
109-
anchors.horizontalCenter: parent.horizontalCenter
110-
visible: false
111-
text: qsTr("The uploaded file type is incorrect, please upload it again")
90+
D.DciIcon {
91+
id: addIcon
92+
width: 64
93+
height: 64
94+
anchors.top: parent.top
95+
anchors.horizontalCenter: parent.horizontalCenter
96+
name: "dcc_user_add_icon"
97+
fallbackToQIcon: false
98+
palette: D.DTK.makeIconPalette(control.palette)
99+
mode: control.D.ColorSelector.controlState
100+
theme: control.D.ColorSelector.controlTheme
101+
sourceSize: Qt.size(width, height)
102+
}
103+
104+
D.Label {
105+
id: messageLabel
106+
width: parent.width
107+
wrapMode: Text.WordWrap
108+
font: D.DTK.fontManager.t8
109+
anchors.top: addIcon.bottom
110+
anchors.topMargin: 20
111+
anchors.horizontalCenter: parent.horizontalCenter
112+
horizontalAlignment: Text.AlignHCenter
113+
text: control.invalidFileType
114+
? qsTr("The uploaded file type is incorrect, please upload it again")
115+
: qsTr("You haven't uploaded an avatar yet. Click or drag and drop to upload an image.")
116+
}
112117
}
113118
}

0 commit comments

Comments
 (0)