Skip to content

Commit b6d9702

Browse files
Merge pull request #26605 from krasko78/26583-PercussionPads-ContextMenuRefinements
26583: Percussion Pads context menu refinements
2 parents 2e22d9e + 1890189 commit b6d9702

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/notation/qml/MuseScore/NotationScene/internal/PercussionPanelPad.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ DropArea {
197197
Connections {
198198
target: footerNavCtrl
199199
function onTriggered() {
200-
padContent.openFooterContextMenu()
200+
padContent.openContextMenu(null)
201201
}
202202
}
203203
}

src/notation/qml/MuseScore/NotationScene/internal/PercussionPanelPadContent.qml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ Column {
3737

3838
property bool padSwapActive: false
3939

40-
function openFooterContextMenu() {
40+
function openContextMenu(pos) {
4141
if (!root.padModel) {
4242
return
4343
}
44-
menuLoader.toggleOpened(root.padModel.footerContextMenuItems)
44+
45+
if (!pos) {
46+
pos = menuLoader.parent.mapFromItem(root, 0, root.height)
47+
}
48+
49+
menuLoader.show(pos, root.padModel.contextMenuItems)
4550
}
4651

4752
Item {
@@ -67,7 +72,8 @@ Column {
6772
}
6873

6974
if (event.button === Qt.RightButton) {
70-
root.openFooterContextMenu()
75+
let pos = menuLoader.parent.mapFromItem(mouseArea, event.x, event.y)
76+
root.openContextMenu(pos)
7177
return
7278
}
7379

@@ -177,8 +183,9 @@ Column {
177183

178184
acceptedButtons: Qt.LeftButton | Qt.RightButton
179185

180-
onClicked: {
181-
root.openFooterContextMenu()
186+
onPressed: function(event) {
187+
let pos = menuLoader.parent.mapFromItem(footerMouseArea, event.x, event.y)
188+
root.openContextMenu(pos)
182189
}
183190
}
184191

@@ -218,13 +225,13 @@ Column {
218225

219226
text: Boolean(root.padModel) ? root.padModel.midiNote : ""
220227
}
228+
}
221229

222-
StyledMenuLoader {
223-
id: menuLoader
230+
ContextMenuLoader {
231+
id: menuLoader
224232

225-
onHandleMenuItem: function(itemId) {
226-
root.padModel.handleMenuItem(itemId)
227-
}
233+
onHandleMenuItem: function(itemId) {
234+
root.padModel.handleMenuItem(itemId)
228235
}
229236
}
230237
}

src/notation/view/percussionpanel/percussionpanelpadmodel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ const QVariant PercussionPanelPadModel::notationPreviewItemVariant() const
8181
return QVariant::fromValue(m_notationPreviewItem);
8282
}
8383

84-
QList<QVariantMap> PercussionPanelPadModel::footerContextMenuItems() const
84+
QList<QVariantMap> PercussionPanelPadModel::contextMenuItems() const
8585
{
8686
static constexpr int definePadShortcutIcon = static_cast<int>(IconCode::Code::SHORTCUTS);
8787
// static constexpr int duplicatePadIcon = static_cast<int>(IconCode::Code::COPY);
8888
static constexpr int deletePadIcon = static_cast<int>(IconCode::Code::DELETE_TANK);
8989

9090
QList<QVariantMap> menuItems = {
91-
{ { "id", DEFINE_PAD_SHORTCUT_CODE }, { "title", muse::qtrc("shortcuts", "Define keyboard shortcut") },
91+
{ { "id", DEFINE_PAD_SHORTCUT_CODE }, { "title", muse::qtrc("shortcuts", "Define keyboard shortcut") },
9292
{ "icon", definePadShortcutIcon }, { "enabled", true } },
9393

9494
//! NOTE: Disabled for now - will be re-introduced with new percussion mapping system...
9595
// { { "id", DUPLICATE_PAD_CODE }, { "title", muse::qtrc("global", "Duplicate") },
9696
// { "icon", duplicatePadIcon }, { "enabled", true } },
9797

98-
{ { "id", DELETE_PAD_CODE }, { "title", muse::qtrc("global", "Delete") },
98+
{ { "id", DELETE_PAD_CODE }, { "title", muse::qtrc("global", "Delete pad") },
9999
{ "icon", deletePadIcon }, { "enabled", true } },
100100
};
101101

src/notation/view/percussionpanel/percussionpanelpadmodel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PercussionPanelPadModel : public QObject, public muse::async::Asyncable
4343

4444
Q_PROPERTY(QVariant notationPreviewItem READ notationPreviewItemVariant NOTIFY notationPreviewItemChanged)
4545

46-
Q_PROPERTY(QList<QVariantMap> footerContextMenuItems READ footerContextMenuItems CONSTANT)
46+
Q_PROPERTY(QList<QVariantMap> contextMenuItems READ contextMenuItems CONSTANT)
4747

4848
public:
4949
explicit PercussionPanelPadModel(QObject* parent = nullptr);
@@ -64,7 +64,7 @@ class PercussionPanelPadModel : public QObject, public muse::async::Asyncable
6464

6565
const QVariant notationPreviewItemVariant() const;
6666

67-
QList<QVariantMap> footerContextMenuItems() const;
67+
QList<QVariantMap> contextMenuItems() const;
6868
Q_INVOKABLE void handleMenuItem(const QString& itemId);
6969

7070
Q_INVOKABLE void triggerPad(const Qt::KeyboardModifiers& modifiers);

0 commit comments

Comments
 (0)