@@ -104,10 +104,119 @@ DelWindow {
104104 anchors .left : parent .left
105105 anchors .right : parent .right
106106
107+ DelAutoComplete {
108+ id: searchComponent
109+ property bool expanded: false
110+ z: 10
111+ clip: true
112+ width: (! galleryMenu .compactMode || expanded) ? (galleryMenu .defaultMenuWidth - 20 ) : 0
113+ anchors .top : parent .top
114+ anchors .left : ! galleryMenu .compactMode ? galleryMenu .left : galleryMenu .right
115+ anchors .margins : 10
116+ topPadding: 6
117+ bottomPadding: 6
118+ rightPadding: 50
119+ placeholderText: qsTr (' 搜索组件' )
120+ colorBg: galleryMenu .compactMode ? DelTheme .DelInput .colorBg : ' transparent'
121+ Component .onCompleted : {
122+ let model = [];
123+ for (let i = 0 ; i < galleryMenu .initModel .length ; i++ ) {
124+ let item = galleryMenu .initModel [i];
125+ if (item && item .menuChildren ) {
126+ for (let j = 0 ; j < item .menuChildren .length ; j++ ) {
127+ let childItem = item .menuChildren [j];
128+ if (childItem && childItem .label ) {
129+ model .push ({
130+ ' key' : childItem .key ,
131+ ' value' : childItem .key ,
132+ ' label' : childItem .label ,
133+ });
134+ }
135+ }
136+ }
137+ }
138+ model .sort ((a , b ) => a .key .localeCompare (b .key ));
139+ options = model;
140+ }
141+ filterOption : function (input , option ){
142+ return option .label .toUpperCase ().indexOf (input .toUpperCase ()) !== - 1 ;
143+ }
144+ onSelect : function (option ) {
145+ galleryMenu .gotoMenu (option .key );
146+ }
147+ labelDelegate: Text {
148+ height: implicitHeight + 4
149+ text: parent .textData
150+ color: DelTheme .DelAutoComplete .colorItemText
151+ font {
152+ family: DelTheme .DelAutoComplete .fontFamily
153+ pixelSize: DelTheme .DelAutoComplete .fontSize
154+ weight: parent .highlighted ? Font .DemiBold : Font .Normal
155+ }
156+ elide: Text .ElideRight
157+ verticalAlignment: Text .AlignVCenter
158+ }
159+ clearIconDelegate: Row {
160+ spacing: 5
161+
162+ DelIconText {
163+ visible: searchComponent .length > 0
164+ iconSource: DelIcon .CloseSquareFilled
165+ iconSize: searchComponent .iconSize
166+ colorIcon: searchComponent .enabled ?
167+ __iconMouse .hovered ? DelTheme .DelAutoComplete .colorIconHover :
168+ DelTheme .DelAutoComplete .colorIcon : DelTheme .DelAutoComplete .colorIconDisabled
169+
170+ Behavior on colorIcon { enabled: searchComponent .animationEnabled ; ColorAnimation { duration: DelTheme .Primary .durationFast } }
171+
172+ MouseArea {
173+ id: __iconMouse
174+ anchors .fill : parent
175+ hoverEnabled: true
176+ cursorShape: parent .iconSource == searchComponent .clearIconSource ? Qt .PointingHandCursor : Qt .ArrowCursor
177+ onEntered: hovered = true ;
178+ onExited: hovered = false ;
179+ onClicked: searchComponent .clearInput ();
180+ property bool hovered: false
181+ }
182+ }
183+
184+ DelIconText {
185+ iconSource: DelIcon .SearchOutlined
186+ iconSize: searchComponent .iconSize
187+ }
188+ }
189+
190+ Behavior on width {
191+ enabled: galleryMenu .compactMode && galleryMenu .width == galleryMenu .compactWidth
192+ NumberAnimation { duration: DelTheme .Primary .durationFast }
193+ }
194+ }
195+
196+ DelIconButton {
197+ id: searchCollapse
198+ visible: galleryMenu .compactMode
199+ anchors .top : parent .top
200+ anchors .left : galleryMenu .left
201+ anchors .right : galleryMenu .right
202+ anchors .margins : 10
203+ type: DelButton .Type_Text
204+ colorText: DelTheme .Primary .colorTextBase
205+ iconSource: DelIcon .SearchOutlined
206+ iconSize: searchComponent .iconSize
207+ onClicked: searchComponent .expanded = ! searchComponent .expanded ;
208+ onVisibleChanged: {
209+ if (visible) {
210+ searchComponent .closePopup ();
211+ searchComponent .expanded = false ;
212+ }
213+ }
214+ }
215+
107216 DelMenu {
108217 id: galleryMenu
109218 anchors .left : parent .left
110- anchors .top : parent . top
219+ anchors .top : searchComponent . bottom
111220 anchors .bottom : aboutButton .top
112221 showEdge: true
113222 defaultMenuWidth: 300
0 commit comments