@@ -9,8 +9,9 @@ import org.deepin.dtk 1.0 as D
99Control {
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