Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for asynchronous inspector updates #24863

Merged
merged 9 commits into from
Oct 29, 2024
105 changes: 47 additions & 58 deletions src/inspector/view/qml/MuseScore/Inspector/InspectorForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import "."
Rectangle {
id: root

property alias model: inspectorRepeater.model
property alias model: sectionList.model
property alias notationView: popupController.notationView

property NavigationSection navigationSection: null
property NavigationPanel navigationPanel: inspectorRepeater.count > 0 ? inspectorRepeater.itemAt(0).navigationPanel : null // first panel
property NavigationPanel navigationPanel: sectionList.count > 0 ? sectionList.itemAtIndex(0)?.navigationPanel : null // first panel
property int navigationOrderStart: 0

color: ui.theme.backgroundPrimaryColor
Expand All @@ -45,7 +45,7 @@ Rectangle {
}

function focusFirstItem() {
var item = inspectorRepeater.itemAt(0)
var item = sectionList.itemAtIndex(0)
if (item) {
item.navigation.requestActive()
}
Expand All @@ -68,82 +68,71 @@ Rectangle {
id: popupController
}

StyledFlickable {
id: flickableArea
StyledListView {
id: sectionList
anchors.fill: parent

topMargin: 12
leftMargin: 12
rightMargin: 12
bottomMargin: 12

spacing: 12

cacheBuffer: contentHeight

function ensureContentVisible(invisibleContentHeight) {
if (flickableArea.contentY + invisibleContentHeight > 0) {
flickableArea.contentY += invisibleContentHeight
if (sectionList.contentY + invisibleContentHeight > 0) {
sectionList.contentY += invisibleContentHeight
} else {
flickableArea.contentY = 0
sectionList.contentY = 0
}
}

flickableDirection: Flickable.VerticalFlick

contentHeight: contentColumn.childrenRect.height + 2 * contentColumn.anchors.margins

Behavior on contentY {
NumberAnimation { duration: 250 }
}

ScrollBar.vertical: StyledScrollBar {}

Column {
id: contentColumn

anchors.fill: parent
anchors.margins: 12
model: InspectorListModel {
id: inspectorListModel
}

height: childrenRect.height
spacing: 12
onContentHeightChanged: {
returnToBounds()
}

Repeater {
id: inspectorRepeater
delegate: Column {
width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin

model: InspectorListModel {
id: inspectorListModel
}
spacing: sectionList.spacing

delegate: Column {
width: parent.width
property var navigationPanel: _item.navigationPanel

spacing: contentColumn.spacing
SeparatorLine {
anchors.margins: -12

property var navigationPanel: _item.navigationPanel
visible: model.index !== 0
}

SeparatorLine {
anchors.margins: -12
InspectorSectionDelegate {
id: _item

visible: model.index !== 0
sectionModel: model.inspectorSectionModel
anchorItem: root
navigationPanel.section: root.navigationSection
navigationPanel.order: root.navigationOrderStart + model.index
navigationPanel.onOrderChanged: {
if (model.index === 0) {
root.navigationOrderStart = navigationPanel.order
}
}

InspectorSectionDelegate {
id: _item

sectionModel: model.inspectorSectionModel
anchorItem: root
navigationPanel.section: root.navigationSection
navigationPanel.order: root.navigationOrderStart + model.index
navigationPanel.onOrderChanged: {
if (model.index === 0) {
root.navigationOrderStart = navigationPanel.order
}
}

onReturnToBoundsRequested: {
flickableArea.returnToBounds()
}

onEnsureContentVisibleRequested: function(invisibleContentHeight) {
flickableArea.ensureContentVisible(invisibleContentHeight)
}

onPopupOpened: function(openedPopup, visualControl) {
prv.closePreviousOpenedPopup(openedPopup, visualControl)
}
}
onEnsureContentVisibleRequested: function(invisibleContentHeight) {
sectionList.ensureContentVisible(invisibleContentHeight)
}

onPopupOpened: function(openedPopup, visualControl) {
prv.closePreviousOpenedPopup(openedPopup, visualControl)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ ExpandableBlank {
property var sectionModel // Comes from inspectorListModel
property var anchorItem: null

signal returnToBoundsRequested()
signal ensureContentVisibleRequested(int invisibleContentHeight)
signal popupOpened(var openedPopup, var visualControl)

Expand Down Expand Up @@ -79,10 +78,6 @@ ExpandableBlank {
return undefined
}

onContentItemComponentChanged: {
root.returnToBoundsRequested()
}

Component {
id: generalSection

Expand Down