Skip to content

Commit

Permalink
fixed musescore#18254: subscribe to a change the current notation at …
Browse files Browse the repository at this point in the history
…the level above
  • Loading branch information
Eism committed Jul 4, 2023
1 parent 9cd1d5b commit 95cb20d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
10 changes: 1 addition & 9 deletions src/inspector/models/abstractinspectormodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,13 @@ AbstractInspectorModel::AbstractInspectorModel(QObject* parent, IElementReposito
return;
}

setupCurrentNotationChangedConnection();
onCurrentNotationChanged();

connect(m_repository->getQObject(), SIGNAL(elementsUpdated(const QList<mu::engraving::EngravingItem*>&)), this,
SLOT(updateProperties()));
connect(this, &AbstractInspectorModel::requestReloadPropertyItems, this, &AbstractInspectorModel::updateProperties);
}

void AbstractInspectorModel::setupCurrentNotationChangedConnection()
{
onCurrentNotationChanged();
currentNotationChanged().onNotify(this, [this]() {
onCurrentNotationChanged();
});
}

void AbstractInspectorModel::onCurrentNotationChanged()
{
INotationPtr notation = currentNotation();
Expand Down
5 changes: 2 additions & 3 deletions src/inspector/models/abstractinspectormodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class AbstractInspectorModel : public QObject, public async::Asyncable

virtual void requestElements();

virtual void onCurrentNotationChanged();

public slots:
void setTitle(QString title);
void setIcon(ui::IconCode::Code icon);
Expand Down Expand Up @@ -201,7 +203,6 @@ public slots:

notation::INotationSelectionPtr selection() const;

virtual void onCurrentNotationChanged();
virtual void onNotationChanged(const mu::engraving::PropertyIdSet& changedPropertyIdSet,
const mu::engraving::StyleIdSet& changedStyleIdSet);

Expand All @@ -215,8 +216,6 @@ protected slots:
void updateProperties();

private:
void setupCurrentNotationChangedConnection();

void initPropertyItem(PropertyItem* propertyItem, std::function<void(const mu::engraving::Pid propertyId,
const QVariant& newValue)> onPropertyChangedCallBack = nullptr,
std::function<void(const mu::engraving::Sid styleId,
Expand Down
4 changes: 4 additions & 0 deletions src/inspector/models/inspectorlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ InspectorListModel::InspectorListModel(QObject* parent)
listenSelectionChanged();
context()->currentNotationChanged().onNotify(this, [this]() {
listenSelectionChanged();

for (AbstractInspectorModel* model : m_modelList) {
model->onCurrentNotationChanged();
}
});
}

Expand Down

0 comments on commit 95cb20d

Please sign in to comment.