| 1 |
/* |
| 2 |
* Audacity: A Digital Audio Editor |
| 3 |
*/ |
| 4 |
import QtQuick 2.15 |
| 5 |
import QtQuick.Controls 2.15 |
| 6 |
|
| 7 |
import Muse.Ui 1.0 |
| 8 |
import Muse.UiComponents 1.0 |
| 9 |
|
| 10 |
import Audacity.ProjectScene 1.0 |
| 11 |
|
| 12 |
StyledListView { |
| 13 |
id: root |
| 14 |
|
| 15 |
spacing: 0 |
| 16 |
scrollBarPolicy: ScrollBar.AlwaysOn |
| 17 |
|
| 18 |
signal selectRowRequested(int index) |
| 19 |
signal clearSelectionRequested() |
| 20 |
signal removeSelectionRequested() |
| 21 |
|
| 22 |
function positionViewAtSelectedItems() { |
| 23 |
var selectedIndexes = root.model.selectionModel.selectedIndexes |
| 24 |
for (var _index in selectedIndexes) { |
| 25 |
positionViewAtIndex(selectedIndexes[_index].row, ListView.Contain) |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
function focusOnFirst() { |
| 30 |
var firstItem = root.itemAtIndex(0) |
| 31 |
if (Boolean(firstItem)) { |
| 32 |
firstItem.navigation.requestActive() |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
function clearFocus() { |
| 37 |
root.clearSelectionRequested() |
| 38 |
} |
| 39 |
|
| 40 |
property NavigationPanel navigationPanel: NavigationPanel { |
| 41 |
name: "CustomiseView" |
| 42 |
enabled: root.enabled && root.visible |
| 43 |
direction: NavigationPanel.Both |
| 44 |
onActiveChanged: function(active) { |
| 45 |
if (active) { |
| 46 |
root.forceActiveFocus() |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
onNavigationEvent: function(event) { |
| 51 |
if (event.type === NavigationEvent.AboutActive) { |
| 52 |
event.setData("controlName", prv.currentItemNavigationName) |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
QtObject { |
| 58 |
id: prv |
| 59 |
|
| 60 |
property var currentItemNavigationName: [] |
| 61 |
} |
| 62 |
|
| 63 |
delegate: ListItemBlank { |
| 64 |
id: itemDelegate |
| 65 |
|
| 66 |
property var item: model.item |
| 67 |
|
| 68 |
height: loader.isSeparator ? 1 : 38 |
| 69 |
|
| 70 |
isSelected: model.isSelected |
| 71 |
|
| 72 |
onClicked: { |
| 73 |
itemDelegate.item.checked = !itemDelegate.item.checked |
| 74 |
} |
| 75 |
|
| 76 |
navigation.name: item.title |
| 77 |
navigation.panel: root.navigationPanel |
| 78 |
navigation.row: model.index |
| 79 |
navigation.column: 0 |
| 80 |
navigation.accessible.name: item.title |
| 81 |
navigation.onActiveChanged: { |
| 82 |
if (navigation.active) { |
| 83 |
prv.currentItemNavigationName = navigation.name |
| 84 |
root.positionViewAtIndex(index, ListView.Contain) |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
Loader { |
| 89 |
id: loader |
| 90 |
|
| 91 |
property var delegateType: Boolean(itemDelegate.item) ? itemDelegate.item.type : PlaybackToolBarCustomiseItem.UNDEFINED |
| 92 |
property bool isSeparator: delegateType === PlaybackToolBarCustomiseItem.SEPARATOR |
| 93 |
|
| 94 |
anchors.fill: parent |
| 95 |
sourceComponent: isSeparator ? separatorLineComponent : actionComponent |
| 96 |
|
| 97 |
Component { |
| 98 |
id: actionComponent |
| 99 |
|
| 100 |
PlaybackToolBarActionDelegate { |
| 101 |
item: itemDelegate.item |
| 102 |
|
| 103 |
navigationPanel: root.navigationPanel |
| 104 |
navigationRow: index |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
Component { |
| 109 |
id: separatorLineComponent |
| 110 |
|
| 111 |
SeparatorLine {} |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
} |