Skip to content

Commit 57bd29e

Browse files
committed
Searchable menus - refinements (mainly navigation)
1 parent 48ff988 commit 57bd29e

File tree

1 file changed

+27
-6
lines changed
  • src/framework/uicomponents/qml/Muse/UiComponents/internal

1 file changed

+27
-6
lines changed

src/framework/uicomponents/qml/Muse/UiComponents/internal/StyledMenu.qml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ MenuView {
4646
signal loaded()
4747

4848
function requestFocus() {
49+
if (root.isSearchable) {
50+
searchField.navigation.requestActive()
51+
return
52+
}
4953
var focused = prv.focusOnSelected()
5054
if (!focused) {
51-
focused = prv.focusOnFirstEnabled()
55+
prv.focusOnFirstEnabled()
5256
}
53-
54-
return focused
5557
}
5658

5759
property Component menuMetricsComponent: Component {
@@ -286,6 +288,9 @@ MenuView {
286288
SearchField {
287289
id: searchField
288290

291+
navigation.panel: content.navigationPanel
292+
navigation.row: 0
293+
289294
anchors {
290295
left: parent.left
291296
right: parent.right
@@ -298,6 +303,18 @@ MenuView {
298303
}
299304

300305
SeparatorLine { width: parent.width }
306+
307+
states: [
308+
State {
309+
name: "SEARCHING"
310+
when: searchField.searchText !== ""
311+
312+
PropertyChanges {
313+
target: root
314+
placementPolicies: PopupView.IgnoreFit
315+
}
316+
}
317+
]
301318
}
302319

303320
StyledListView {
@@ -352,8 +369,6 @@ MenuView {
352369
// the following logic is also likely to be unreliable [C.M]
353370
interactive: contentHeight > root.height
354371

355-
arrowControlsAvailable: true
356-
357372
QtObject {
358373
id: prv
359374

@@ -417,7 +432,13 @@ MenuView {
417432
parentWindow: root.window
418433

419434
navigation.panel: content.navigationPanel
420-
navigation.row: loader.index
435+
navigation.row: root.isSearchable ? loader.index + 1 : loader.index
436+
437+
navigation.onActiveChanged: {
438+
if (item.navigation.active) {
439+
listView.positionViewAtIndex(loader.index, ListView.Contain)
440+
}
441+
}
421442

422443
iconAndCheckMarkMode: root.menuMetrics?.iconAndCheckMarkMode || StyledMenuItem.None
423444

0 commit comments

Comments
 (0)