Skip to content

Commit

Permalink
Merge pull request #25019 from chilkaditya/feat/restoring-instruments…
Browse files Browse the repository at this point in the history
…-list

Feat: Restoring instruments list while switching back and forth between in instruments and templates
  • Loading branch information
cbjeukendrup authored Oct 24, 2024
2 parents 4a91259 + 7939be9 commit 0697944
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ import "internal"
Rectangle {
id: root

required property InstrumentsOnScoreListModel instrumentsOnScoreModel

property bool canSelectMultipleInstruments: true
property string currentInstrumentId: ""
property string description: instrumentsModel.selectedInstrument ? instrumentsModel.selectedInstrument.description : ""

property bool hasSelectedInstruments: root.canSelectMultipleInstruments
? instrumentsOnScoreView.hasInstruments
: Boolean(instrumentsModel.selectedInstrument)
readonly property bool hasSelectedInstruments: root.canSelectMultipleInstruments
? instrumentsOnScoreModel.count > 0
: Boolean(instrumentsModel.selectedInstrument)

property NavigationSection navigationSection: null

Expand All @@ -47,15 +49,15 @@ Rectangle {

function instruments() {
if (root.canSelectMultipleInstruments) {
return instrumentsOnScoreView.instruments()
return root.instrumentsOnScoreModel.instruments()
}

return [ instrumentsModel.selectedInstrument ]
}

function currentOrder() {
if (root.canSelectMultipleInstruments) {
return instrumentsOnScoreView.currentOrder()
return root.instrumentsOnScoreModel.currentOrder()
}

return undefined
Expand All @@ -80,7 +82,7 @@ Rectangle {
id: prv

function addSelectedInstrumentsToScore() {
instrumentsOnScoreView.addInstruments(instrumentsModel.selectedInstrumentIdList())
root.instrumentsOnScoreModel.addInstruments(instrumentsModel.selectedInstrumentIdList())

Qt.callLater(instrumentsOnScoreView.scrollViewToEnd)
}
Expand Down Expand Up @@ -201,6 +203,8 @@ Rectangle {

Layout.fillWidth: true
Layout.fillHeight: true

instrumentsOnScoreModel: root.instrumentsOnScoreModel
}

SeparatorLine {
Expand All @@ -226,7 +230,7 @@ Rectangle {
}

FlatButton {
enabled: instrumentsOnScoreView.isMovingUpAvailable
enabled: root.instrumentsOnScoreModel.isMovingUpAvailable
icon: IconCode.ARROW_UP

navigation.name: "Up"
Expand All @@ -236,12 +240,12 @@ Rectangle {
toolTipTitle: qsTrc("instruments", "Move selected instruments up")

onClicked: {
instrumentsOnScoreView.moveSelectedInstrumentsUp()
root.instrumentsOnScoreModel.moveSelectionUp()
}
}

FlatButton {
enabled: instrumentsOnScoreView.isMovingDownAvailable
enabled: root.instrumentsOnScoreModel.isMovingDownAvailable
icon: IconCode.ARROW_DOWN

navigation.name: "Down"
Expand All @@ -251,7 +255,7 @@ Rectangle {
toolTipTitle: qsTrc("instruments", "Move selected instruments down")

onClicked: {
instrumentsOnScoreView.moveSelectedInstrumentsDown()
root.instrumentsOnScoreModel.moveSelectionDown()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ StyledDialogView {
root.hide()
}

Component.onCompleted: {
theInstrumentsOnScoreModel.load()
}

InstrumentsOnScoreListModel {
id: theInstrumentsOnScoreModel
}

ColumnLayout {
anchors.fill: parent
spacing: 20
Expand All @@ -70,6 +78,8 @@ StyledDialogView {
onSubmitRequested: {
root.submit()
}

instrumentsOnScoreModel: theInstrumentsOnScoreModel
}

RowLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,14 @@ import MuseScore.InstrumentsScene 1.0
Item {
id: root

readonly property bool hasInstruments: instrumentsOnScoreModel.count > 0
readonly property alias isMovingUpAvailable: instrumentsOnScoreModel.isMovingUpAvailable
readonly property alias isMovingDownAvailable: instrumentsOnScoreModel.isMovingDownAvailable
required property InstrumentsOnScoreListModel instrumentsOnScoreModel

property alias navigation: instrumentsView.navigation

function instruments() {
return instrumentsOnScoreModel.instruments()
}

function currentOrder() {
return instrumentsOnScoreModel.currentOrder()
}

function addInstruments(instruments) {
instrumentsOnScoreModel.addInstruments(instruments)
}

function moveSelectedInstrumentsUp() {
instrumentsOnScoreModel.moveSelectionUp()
}

function moveSelectedInstrumentsDown() {
instrumentsOnScoreModel.moveSelectionDown()
}

function scrollViewToEnd() {
instrumentsView.positionViewAtEnd()
}

InstrumentsOnScoreListModel {
id: instrumentsOnScoreModel
}

Component.onCompleted: {
instrumentsOnScoreModel.load()
}

StyledTextLabel {
id: instrumentsLabel

Expand Down Expand Up @@ -96,14 +66,14 @@ Item {
navigation.row: 0
navigation.column: 0

model: instrumentsOnScoreModel.orders
model: root.instrumentsOnScoreModel.orders

currentIndex: instrumentsOnScoreModel.currentOrderIndex
currentIndex: root.instrumentsOnScoreModel.currentOrderIndex

displayText: qsTrc("instruments", "Order:") + " " + currentText

onActivated: function(index, value) {
instrumentsOnScoreModel.currentOrderIndex = index
root.instrumentsOnScoreModel.currentOrderIndex = index
}
}

Expand All @@ -118,10 +88,10 @@ Item {
icon: IconCode.DELETE_TANK
toolTipTitle: qsTrc("instruments", "Remove selected instruments from score")

enabled: instrumentsOnScoreModel.isRemovingAvailable
enabled: root.instrumentsOnScoreModel.isRemovingAvailable

onClicked: {
instrumentsOnScoreModel.removeSelection()
root.instrumentsOnScoreModel.removeSelection()
}
}
}
Expand All @@ -135,7 +105,7 @@ Item {
anchors.left: parent.left
anchors.right: parent.right

model: instrumentsOnScoreModel
model: root.instrumentsOnScoreModel

accessible.name: instrumentsLabel.text

Expand Down Expand Up @@ -187,15 +157,15 @@ Item {
}

onClicked: {
instrumentsOnScoreModel.selectRow(model.index)
root.instrumentsOnScoreModel.selectRow(model.index)
}

onDoubleClicked: {
instrumentsOnScoreModel.removeSelection()
root.instrumentsOnScoreModel.removeSelection()
}

onRemoveSelectionRequested: {
instrumentsOnScoreModel.removeSelection()
root.instrumentsOnScoreModel.removeSelection()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ Item {
pageLoader.item.navigation.requestActive()
}

Component.onCompleted: {
theInstrumentsOnScoreModel.load()
}

InstrumentsOnScoreListModel {
id: theInstrumentsOnScoreModel
}

StyledTabBar {
id: bar

Expand Down Expand Up @@ -168,6 +176,7 @@ Item {

ChooseInstrumentsPage {
navigationSection: root.navigationSection
instrumentsOnScoreModel: theInstrumentsOnScoreModel
}
}

Expand Down

0 comments on commit 0697944

Please sign in to comment.