Merge pull request #9290 from shoogle/instrument-descriptions

Show instrument descriptions in New Score Wizard
This commit is contained in:
Elnur Ismailzada 2021-10-04 14:47:28 +02:00 committed by GitHub
commit 3f41513411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 12 deletions

View file

@ -33,6 +33,7 @@ Rectangle {
property bool canSelectMultipleInstruments: true
property string currentInstrumentId: ""
property string description: instrumentsModel.selectedInstrumentDescription
property bool hasSelectedInstruments: instrumentsOnScoreView.hasInstruments

View file

@ -222,6 +222,7 @@ void InstrumentListModel::loadInstruments()
sortInstruments(m_instruments);
endResetModel();
emit selectionChanged();
}
void InstrumentListModel::sortInstruments(Instruments& instruments) const
@ -281,6 +282,7 @@ void InstrumentListModel::selectInstrument(int instrumentIndex)
}
}
emit selectionChanged();
emit dataChanged(index(0), index(rowCount() - 1), { RoleIsSelected });
}
@ -395,6 +397,16 @@ bool InstrumentListModel::hasSelection() const
return m_selection->hasSelection();
}
QString InstrumentListModel::selectedInstrumentDescription() const
{
QList<int> selectedRows = m_selection->selectedRows();
if (selectedRows.length() != 1) {
return QString();
}
CombinedInstrument instrument = m_instruments.at(selectedRows.at(0));
return instrument.templates.at(instrument.currentTemplateIndex)->description;
}
bool InstrumentListModel::isSearching() const
{
return !m_searchText.isEmpty();

View file

@ -45,6 +45,7 @@ class InstrumentListModel : public QAbstractListModel, public async::Asyncable
Q_PROPERTY(int currentGroupIndex READ currentGroupIndex WRITE setCurrentGroupIndex NOTIFY currentGroupChanged)
Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY selectionChanged)
Q_PROPERTY(QString selectedInstrumentDescription READ selectedInstrumentDescription NOTIFY selectionChanged)
public:
InstrumentListModel(QObject* parent = nullptr);
@ -61,6 +62,7 @@ public:
int currentGroupIndex() const;
bool hasSelection() const;
QString selectedInstrumentDescription() const;
Q_INVOKABLE void load(bool canSelectMultipleInstruments, const QString& currentInstrumentId);

View file

@ -87,10 +87,8 @@ StyledDialogView {
}
}
Row {
id: buttons
Layout.alignment: Qt.AlignRight
RowLayout {
id: footer
spacing: 12
@ -106,9 +104,25 @@ StyledDialogView {
direction: NavigationPanel.Horizontal
}
StyledTextLabel {
id: descriptionLabel
text: pagesStack.currentIndex === 0
? chooseInstrumentsAndTemplatePage.description
: ""
height: footer.buttonHeight
Layout.fillWidth: true
Layout.leftMargin: 12
font: ui.theme.bodyFont
opacity: 0.7
horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
}
FlatButton {
height: buttons.buttonHeight
width: buttons.buttonWidth
height: footer.buttonHeight
width: footer.buttonWidth
navigation.name: "Cancel"
navigation.panel: navBottomPanel
@ -122,8 +136,8 @@ StyledDialogView {
}
FlatButton {
height: buttons.buttonHeight
width: buttons.buttonWidth
height: footer.buttonHeight
width: footer.buttonWidth
navigation.name: "Back"
navigation.panel: navBottomPanel
@ -139,8 +153,8 @@ StyledDialogView {
}
FlatButton {
height: buttons.buttonHeight
width: buttons.buttonWidth
height: footer.buttonHeight
width: footer.buttonWidth
navigation.name: "Next"
navigation.panel: navBottomPanel
@ -157,8 +171,8 @@ StyledDialogView {
}
FlatButton {
height: buttons.buttonHeight
width: buttons.buttonWidth
height: footer.buttonHeight
width: footer.buttonWidth
navigation.name: "Done"
navigation.panel: navBottomPanel

View file

@ -33,6 +33,10 @@ Item {
property string preferredScoreCreationMode: ""
property string description: pagesStack.currentIndex === 0
? instrumentsPage.description
: ""
property NavigationSection navigationSection: null
readonly property bool hasSelection: {