-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: master
Are you sure you want to change the base?
Feat: Restoring instruments list while switching back and forth between in instruments and templates #25019
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,11 @@ 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The errors you are seeing are caused by these two aliases:
Indeed,
While at it, you'll probably notice that InstrumentsOnScoreView contains a lot of functions ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is kind of frustrating for me that after so much of instructions I could not find out the correct solution but I am listing my progress. @cbjeukendrup As per your instructions I update the InstrumentsDialog.qml, ChooseInstrumentsPage.qml and InstrumentsOnScoreView.qml. And code of those files are as follows: StyledDialogView {
......
InstrumentsOnScoreListModel {
id: instrumentsOnScoreModel
}
......
} ChooseInstrumentsPage.qml function instruments() {
if (root.canSelectMultipleInstruments) {
return root.instrumentsOnScoreModel.instruments() // changed code
}
return [ instrumentsModel.selectedInstrument ]
}
function currentOrder() {
if (root.canSelectMultipleInstruments) {
return root.instrumentsOnScoreModel.currentOrder() // changed code
}
return undefined
}
function addSelectedInstrumentsToScore() {
root.instrumentsOnScoreModel.addInstruments(instrumentsModel.selectedInstrumentIdList()) // changed code
Qt.callLater(root.instrumentsOnScoreModel.scrollViewToEnd) // changed code
}
FlatButton {
enabled: root.instrumentsOnScoreModel.isMovingUpAvailable // changed code
}
FlatButton {
enabled: root.instrumentsOnScoreModel.isMovingDownAvailable // changed code
} And I deleted two alice properties isMovingUpAvailable, isMovingDownAvailable and all those functions instruments(), currentOrder(), addInstruments, moveSelectedInstrumentsUp(), moveSelectedInstrumentsDown(), scrollViewToEnd() from the InstrumentsOnScoreView.qml. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes Yes, it is there in the InstrumentsOnScoreView.qml ,I mistakenly add in the comment. |
||
|
@@ -60,9 +62,7 @@ Item { | |
instrumentsView.positionViewAtEnd() | ||
} | ||
|
||
InstrumentsOnScoreListModel { | ||
id: instrumentsOnScoreModel | ||
} | ||
|
||
|
||
Comment on lines
64
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure to delete unnecessary whitespace; one empty line is enough :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, got it |
||
Component.onCompleted: { | ||
instrumentsOnScoreModel.load() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,11 @@ import Muse.Ui 1.0 | |
import Muse.UiComponents 1.0 | ||
import MuseScore.Project 1.0 | ||
import MuseScore.InstrumentsScene 1.0 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary deletion |
||
Item { | ||
id: root | ||
|
||
required property InstrumentsOnScoreListModel instrumentsOnScoreModel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This property should not be here. In this file, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, got it. |
||
|
||
property string preferredScoreCreationMode: "" | ||
|
||
property string description: Boolean(currentPage) ? currentPage.description : "" | ||
|
@@ -140,6 +141,10 @@ Item { | |
} | ||
} | ||
|
||
InstrumentsOnScoreListModel { | ||
id: instrumentsOnScoreModel | ||
} | ||
|
||
Loader { | ||
id: pageLoader | ||
|
||
|
@@ -168,6 +173,7 @@ Item { | |
|
||
ChooseInstrumentsPage { | ||
navigationSection: root.navigationSection | ||
instrumentsOnScoreModel: instrumentsOnScoreModel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. QML might be confused by this: the Easy way around it: replace |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work:
InstrumentsDialog
is not instantiated directly from QML, but as a dialog. Therefore, it won't be possible to pass anything to this required property, and the dialog will fail to open.Instead, you will need to instantiate an
InstrumentsOnScoreListModel
here insideInstrumentsDialog
, just like you do inChooseInstrumentsAndTemplatesPage
.