Skip to content

Commit

Permalink
26583: Percussion Pads context menu refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
krasko78 committed Feb 20, 2025
1 parent af80582 commit 9bbf3cc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ DropArea {

onTriggered: {
if (Boolean(root.padModel) && root.panelMode !== PanelMode.EDIT_LAYOUT) {
root.padModel.triggerPad()
root.padModel.triggerPad(ui.keyboardModifiers())
return
}
root.panelHasActiveKeyboardSwap ? root.endPadSwapRequested() : root.startPadSwapRequested(true)
Expand Down Expand Up @@ -197,7 +197,7 @@ DropArea {
Connections {
target: footerNavCtrl
function onTriggered() {
padContent.openFooterContextMenu()
padContent.openContextMenu(null)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ Column {

property bool padSwapActive: false

function openFooterContextMenu() {
function openContextMenu(pos) {
if (!root.padModel) {
return
}
menuLoader.toggleOpened(root.padModel.footerContextMenuItems)

if (!pos) {
pos = menuLoader.parent.mapFromItem(root, 0, root.height)
}

menuLoader.show(pos, root.padModel.contextMenuItems)
}

Item {
Expand All @@ -67,7 +72,8 @@ Column {
}

if (event.button === Qt.RightButton) {
root.openFooterContextMenu()
let pos = menuLoader.parent.mapFromItem(mouseArea, event.x, event.y)
root.openContextMenu(pos)
return
}

Expand Down Expand Up @@ -177,8 +183,9 @@ Column {

acceptedButtons: Qt.LeftButton | Qt.RightButton

onClicked: {
root.openFooterContextMenu()
onPressed: function(event) {
let pos = menuLoader.parent.mapFromItem(footerMouseArea, event.x, event.y)
root.openContextMenu(pos)
}
}

Expand Down Expand Up @@ -218,13 +225,13 @@ Column {

text: Boolean(root.padModel) ? root.padModel.midiNote : ""
}
}

StyledMenuLoader {
id: menuLoader
ContextMenuLoader {
id: menuLoader

onHandleMenuItem: function(itemId) {
root.padModel.handleMenuItem(itemId)
}
onHandleMenuItem: function(itemId) {
root.padModel.handleMenuItem(itemId)
}
}
}
4 changes: 2 additions & 2 deletions src/notation/view/percussionpanel/percussionpanelpadmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const QVariant PercussionPanelPadModel::notationPreviewItemVariant() const
return QVariant::fromValue(m_notationPreviewItem);
}

QList<QVariantMap> PercussionPanelPadModel::footerContextMenuItems() const
QList<QVariantMap> PercussionPanelPadModel::contextMenuItems() const
{
static constexpr int definePadShortcutIcon = static_cast<int>(IconCode::Code::SHORTCUTS);
// static constexpr int duplicatePadIcon = static_cast<int>(IconCode::Code::COPY);
Expand All @@ -95,7 +95,7 @@ QList<QVariantMap> PercussionPanelPadModel::footerContextMenuItems() const
// { { "id", DUPLICATE_PAD_CODE }, { "title", muse::qtrc("global", "Duplicate") },
// { "icon", duplicatePadIcon }, { "enabled", true } },

{ { "id", DELETE_PAD_CODE }, { "title", muse::qtrc("global", "Delete") },
{ { "id", DELETE_PAD_CODE }, { "title", muse::qtrc("global", "Delete pad") },
{ "icon", deletePadIcon }, { "enabled", true } },
};

Expand Down
4 changes: 2 additions & 2 deletions src/notation/view/percussionpanel/percussionpanelpadmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PercussionPanelPadModel : public QObject, public muse::async::Asyncable

Q_PROPERTY(QVariant notationPreviewItem READ notationPreviewItemVariant NOTIFY notationPreviewItemChanged)

Q_PROPERTY(QList<QVariantMap> footerContextMenuItems READ footerContextMenuItems CONSTANT)
Q_PROPERTY(QList<QVariantMap> contextMenuItems READ contextMenuItems CONSTANT)

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

const QVariant notationPreviewItemVariant() const;

QList<QVariantMap> footerContextMenuItems() const;
QList<QVariantMap> contextMenuItems() const;
Q_INVOKABLE void handleMenuItem(const QString& itemId);

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

0 comments on commit 9bbf3cc

Please sign in to comment.