Skip to content

Commit c24167a

Browse files
committed
Fix #29009 Update behaviour of reset button
1 parent 31a4bf5 commit c24167a

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

src/inspector/models/notation/frames/fretframe/fretframechordssettingsmodel.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ void FretFrameChordsSettingsModel::requestElements()
5555

5656
m_chordListModel->setFBox(fretBox());
5757
m_chordListModel->load();
58+
59+
updateHasInvisibleChords();
5860
}
5961

6062
void FretFrameChordsSettingsModel::loadProperties()
6163
{
6264
loadProperties({ Pid::FRET_FRAME_DIAGRAMS_ORDER });
6365
m_chordListModel->load();
66+
updateHasInvisibleChords();
6467
}
6568

6669
void FretFrameChordsSettingsModel::resetProperties()
@@ -81,6 +84,7 @@ void FretFrameChordsSettingsModel::onNotationChanged(const engraving::PropertyId
8184
const engraving::StyleIdSet&)
8285
{
8386
loadProperties(changedPropertyIdSet);
87+
updateHasInvisibleChords();
8488
}
8589

8690
void FretFrameChordsSettingsModel::loadProperties(const engraving::PropertyIdSet& propertyIdSet)
@@ -90,6 +94,26 @@ void FretFrameChordsSettingsModel::loadProperties(const engraving::PropertyIdSet
9094
}
9195
}
9296

97+
void FretFrameChordsSettingsModel::updateHasInvisibleChords()
98+
{
99+
bool hasInvisibleChords = false;
100+
101+
const FBox* fbox = fretBox();
102+
if (fbox) {
103+
for (EngravingItem* item : fbox->el()) {
104+
if (!item->visible()) {
105+
hasInvisibleChords = true;
106+
break;
107+
}
108+
}
109+
}
110+
111+
if (hasInvisibleChords != m_hasInvisibleChords) {
112+
m_hasInvisibleChords = hasInvisibleChords;
113+
emit hasInvisibleChordsChanged(m_hasInvisibleChords);
114+
}
115+
}
116+
93117
FretFrameChordListModel* FretFrameChordsSettingsModel::chordListModel() const
94118
{
95119
return m_chordListModel.get();
@@ -99,3 +123,27 @@ PropertyItem* FretFrameChordsSettingsModel::listOrder() const
99123
{
100124
return m_listOrder;
101125
}
126+
127+
bool FretFrameChordsSettingsModel::hasInvisibleChords() const
128+
{
129+
return m_hasInvisibleChords;
130+
}
131+
132+
void FretFrameChordsSettingsModel::resetList()
133+
{
134+
beginCommand(TranslatableString("undoableAction", "Reset Fret Diagram Legend chords list"));
135+
136+
FBox* fbox = fretBox();
137+
if (fbox) {
138+
fbox->undoResetProperty(Pid::FRET_FRAME_DIAGRAMS_ORDER);
139+
140+
for (EngravingItem* item : fbox->el()) {
141+
item->undoResetProperty(Pid::VISIBLE);
142+
}
143+
}
144+
145+
updateNotation();
146+
endCommand();
147+
148+
loadProperties();
149+
}

src/inspector/models/notation/frames/fretframe/fretframechordssettingsmodel.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class FretFrameChordsSettingsModel : public AbstractInspectorModel, public muse:
4343

4444
Q_PROPERTY(PropertyItem * listOrder READ listOrder CONSTANT)
4545

46+
Q_PROPERTY(bool hasInvisibleChords READ hasInvisibleChords NOTIFY hasInvisibleChordsChanged)
47+
4648
muse::Inject<context::IGlobalContext> globalContext = { this };
4749

4850
public:
@@ -51,6 +53,12 @@ class FretFrameChordsSettingsModel : public AbstractInspectorModel, public muse:
5153
FretFrameChordListModel* chordListModel() const;
5254

5355
PropertyItem* listOrder() const;
56+
bool hasInvisibleChords() const;
57+
58+
Q_INVOKABLE void resetList();
59+
60+
signals:
61+
void hasInvisibleChordsChanged(bool hasInvisible);
5462

5563
private:
5664
engraving::FBox* fretBox() const;
@@ -64,8 +72,11 @@ class FretFrameChordsSettingsModel : public AbstractInspectorModel, public muse:
6472

6573
void loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet);
6674

75+
void updateHasInvisibleChords();
76+
6777
std::shared_ptr<FretFrameChordListModel> m_chordListModel;
6878

6979
PropertyItem* m_listOrder = nullptr;
80+
bool m_hasInvisibleChords = false;
7081
};
7182
}

src/inspector/view/qml/MuseScore/Inspector/notation/frames/internal/FretFrameChordsControlPanel.qml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ RowLayout {
4040

4141
property bool isMovingUpAvailable: false
4242
property bool isMovingDownAvailable: false
43+
property bool hasInvisibleChords: false
4344

4445
height: childrenRect.height
4546

4647
spacing: 6
4748

4849
signal moveSelectionUpRequested()
4950
signal moveSelectionDownRequested()
51+
signal resetListRequested();
5052

5153
FlatButton {
5254
id: upBotton
@@ -92,10 +94,10 @@ RowLayout {
9294
navigation.row: downButton.navigation.row + 1
9395
navigation.accessible.name: qsTrc("inspector", "Reset chord list")
9496

95-
enabled: root.listOrderItem.isModified
97+
enabled: root.listOrderItem.isModified || root.hasInvisibleChords
9698

9799
onClicked: {
98-
root.listOrderItem.resetToDefault()
100+
root.resetListRequested()
99101
}
100102
}
101103
}

src/inspector/view/qml/MuseScore/Inspector/notation/frames/internal/FretFrameChordsTab.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ FocusableItem {
5555
anchors.rightMargin: root.sideMargin
5656

5757
listOrderItem: root.model ? root.model.listOrder : null
58+
hasInvisibleChords: root.model ? root.model.hasInvisibleChords : null
5859

5960
isMovingUpAvailable: view.model ? view.model.isMovingUpAvailable : false
6061
isMovingDownAvailable: view.model ? view.model.isMovingDownAvailable : false
@@ -73,6 +74,10 @@ FocusableItem {
7374
view.model.moveSelectionDown()
7475
Qt.callLater(view.positionViewAtSelectedItems)
7576
}
77+
78+
onResetListRequested: {
79+
root.model.resetList()
80+
}
7681
}
7782

7883
FretFrameChordsView {

0 commit comments

Comments
 (0)