Skip to content

Commit 068cd81

Browse files
Merge pull request #29414 from igorkorsukov/fix/29147_4.7
fixed update state of NotationContextMenuModel
2 parents ef75897 + 608a582 commit 068cd81

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

src/framework/actions/actiontypes.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <memory>
2828
#include <QString>
2929
#include "global/types/uri.h"
30+
#include "global/logstream.h"
3031

3132
namespace muse::actions {
3233
using ActionCode = std::string;
@@ -120,4 +121,17 @@ class ActionData
120121
};
121122
}
122123

124+
inline muse::logger::Stream& operator<<(muse::logger::Stream& s, const muse::actions::ActionCodeList& list)
125+
{
126+
s << "[";
127+
for (size_t i = 0; i < list.size(); ++i) {
128+
s << list.at(i);
129+
if (list.size() > 1 && i < (list.size() - 2)) {
130+
s << ", ";
131+
}
132+
}
133+
s << "]";
134+
return s;
135+
}
136+
123137
#endif // MUSE_ACTIONS_ACTIONTYPES_H

src/framework/uicomponents/view/abstractmenumodel.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,7 @@ QVariantMap AbstractMenuModel::get(int index)
112112

113113
void AbstractMenuModel::load()
114114
{
115-
uiActionsRegister()->actionStateChanged().onReceive(this, [this](const ActionCodeList& codes) {
116-
onActionsStateChanges(codes);
117-
});
118-
119-
shortcutsRegister()->shortcutsChanged().onNotify(this, [this]() {
120-
updateShortcutsAll();
121-
});
115+
subscribeOnChanges();
122116
}
123117

124118
QVariantList AbstractMenuModel::itemsProperty() const
@@ -257,6 +251,17 @@ MenuItem* AbstractMenuModel::makeSeparator()
257251
return item;
258252
}
259253

254+
void AbstractMenuModel::subscribeOnChanges()
255+
{
256+
uiActionsRegister()->actionStateChanged().onReceive(this, [this](const ActionCodeList& codes) {
257+
onActionsStateChanges(codes);
258+
});
259+
260+
shortcutsRegister()->shortcutsChanged().onNotify(this, [this]() {
261+
updateShortcutsAll();
262+
});
263+
}
264+
260265
void AbstractMenuModel::onActionsStateChanges(const muse::actions::ActionCodeList& codes)
261266
{
262267
TRACEFUNC;

src/framework/uicomponents/view/abstractmenumodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class AbstractMenuModel : public QAbstractListModel, public muse::Injectable, pu
7070
UserRole
7171
};
7272

73+
virtual void subscribeOnChanges();
7374
virtual void onActionsStateChanges(const muse::actions::ActionCodeList& codes);
7475

7576
void setItem(int index, MenuItem* item);

src/notation/view/notationcontextmenumodel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ using namespace muse::actions;
3737

3838
void NotationContextMenuModel::loadItems(int elementType)
3939
{
40+
AbstractMenuModel::load();
41+
4042
MenuItemList items = makeItemsByElementType(static_cast<ElementType>(elementType));
4143
setItems(items);
4244
}

0 commit comments

Comments
 (0)