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

Feat: Restoring instruments list while switching back and forth between in instruments and templates #25019

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import QtQuick.Layouts 1.15
import Muse.Ui 1.0
import Muse.UiComponents 1.0
import MuseScore.InstrumentsScene 1.0
import MuseScore.Project 1.0

import "internal"

Rectangle {
id: root
required property InstrumentsOnScoreListModel instrumentsOnScoreModel

property bool canSelectMultipleInstruments: true
property string currentInstrumentId: ""
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,7 @@ Rectangle {

Layout.fillWidth: true
Layout.fillHeight: true
instrumentsOnScoreModel: root.instrumentsOnScoreModel
}

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

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

navigation.name: "Up"
Expand All @@ -236,12 +239,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 +254,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 @@ -25,10 +25,12 @@ import QtQuick.Layouts 1.15
import Muse.Ui 1.0
import Muse.UiComponents 1.0
import MuseScore.InstrumentsScene 1.0
import MuseScore.Project 1.0

StyledDialogView {
id: root

// required property InstrumentsOnScoreListModel instrumentsOnScoreModel
property bool canSelectMultipleInstruments: true
property string currentInstrumentId: ""

Expand All @@ -52,6 +54,10 @@ StyledDialogView {
root.hide()
}

InstrumentsOnScoreListModel {
id: theInstrumentsOnScoreModel
}

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

instrumentsOnScoreModel: theInstrumentsOnScoreModel
}

RowLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,43 @@ import QtQuick.Controls 2.12
import Muse.Ui 1.0
import Muse.UiComponents 1.0
import MuseScore.InstrumentsScene 1.0
import MuseScore.Project 1.0

Item {
id: root
required property InstrumentsOnScoreListModel instrumentsOnScoreModel

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

property alias navigation: instrumentsView.navigation

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

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

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

function moveSelectedInstrumentsUp() {
instrumentsOnScoreModel.moveSelectionUp()
}
// function moveSelectedInstrumentsUp() {
// instrumentsOnScoreModel.moveSelectionUp()
// }

function moveSelectedInstrumentsDown() {
instrumentsOnScoreModel.moveSelectionDown()
}
// function moveSelectedInstrumentsDown() {
// instrumentsOnScoreModel.moveSelectionDown()
// }

function scrollViewToEnd() {
instrumentsView.positionViewAtEnd()
}

InstrumentsOnScoreListModel {
id: instrumentsOnScoreModel
}


Comment on lines 64 to 66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to delete unnecessary whitespace; one empty line is enough :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it

Component.onCompleted: {
instrumentsOnScoreModel.load()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ Item {
}
}

InstrumentsOnScoreListModel {
id: theInstrumentsOnScoreModel
}

Loader {
id: pageLoader

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

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

Expand Down