Skip to content

Commit 75ffdb7

Browse files
committed
Ensure context menu changes for Qt 6.9 don't affect pre-Qt 6.9 builds
1 parent 56608fc commit 75ffdb7

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/notation/tests/notationviewinputcontroller_tests.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,11 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Range_Context_Menu)
815815
.WillOnce(ReturnRef(selectMeasureContext))
816816
//! right button click
817817
.WillOnce(ReturnRef(selectMeasureContext))
818-
.WillOnce(ReturnRef(contextMenuOnMeasureContext));
818+
.WillOnce(ReturnRef(contextMenuOnMeasureContext))
819+
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
820+
.WillOnce(ReturnRef(contextMenuOnMeasureContext)) // for context menu
821+
#endif
822+
;
819823

820824
//! [GIVEN] No note enter mode, no playing
821825
EXPECT_CALL(m_view, isNoteEnterMode())
@@ -850,13 +854,19 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Range_Context_Menu)
850854
EXPECT_CALL(*m_selection, elements())
851855
.WillRepeatedly(ReturnRef(selectElements));
852856

857+
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
858+
//! Note: the context menu itself is shown by AbstractNotationPaintView::event
859+
#else
860+
//! [THEN] Show context menu for measure
861+
EXPECT_CALL(m_view, showContextMenu(contextMenuOnMeasureContext.element->type(), _))
862+
.Times(1);
863+
#endif
864+
853865
//! [WHEN] User pressed left mouse button with ShiftModifier on the new measure
854866
m_controller->mousePressEvent(make_mousePressEvent(Qt::LeftButton, Qt::ShiftModifier, QPoint(100, 100)));
855867

856868
//! [WHEN] User pressed right mouse button with NoModifier on the selected measure
857869
m_controller->mousePressEvent(make_mousePressEvent(Qt::RightButton, Qt::NoModifier, QPoint(100, 100)));
858-
859-
//! Note: the context menu itself is shown by AbstractNotationPaintView::event
860870
}
861871

862872
/**
@@ -897,7 +907,11 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Range_Context_Menu_New_S
897907
.WillOnce(ReturnRef(selectMeasureContext))
898908
//! right button click
899909
.WillOnce(ReturnRef(selectMeasureContext))
900-
.WillOnce(ReturnRef(contextMenuOnMeasureContext));
910+
.WillOnce(ReturnRef(contextMenuOnMeasureContext))
911+
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
912+
.WillOnce(ReturnRef(contextMenuOnMeasureContext)) // for context menu
913+
#endif
914+
;
901915

902916
//! [GIVEN] No note enter mode, no playing
903917
EXPECT_CALL(m_view, isNoteEnterMode())
@@ -936,11 +950,17 @@ TEST_F(NotationViewInputControllerTests, Mouse_Press_On_Range_Context_Menu_New_S
936950
EXPECT_CALL(*m_playbackController, seekElement(contextMenuOnMeasureContext.element))
937951
.WillOnce(Return());
938952

953+
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
954+
//! Note: the context menu itself is shown by AbstractNotationPaintView::event
955+
#else
956+
//! [THEN] Show context menu for new measure
957+
EXPECT_CALL(m_view, showContextMenu(contextMenuOnMeasureContext.element->type(), _))
958+
.Times(1);
959+
#endif
960+
939961
//! [WHEN] User pressed left mouse button with ShiftModifier on the new measure
940962
m_controller->mousePressEvent(make_mousePressEvent(Qt::LeftButton, Qt::ShiftModifier, QPoint(100, 100)));
941963

942964
//! [WHEN] User pressed right mouse button with NoModifier on the selected measure
943965
m_controller->mousePressEvent(make_mousePressEvent(Qt::RightButton, Qt::NoModifier, QPoint(100, 100)));
944-
945-
//! Note: the context menu itself is shown by AbstractNotationPaintView::event
946966
}

src/notation/view/notationviewinputcontroller.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,11 +855,16 @@ void NotationViewInputController::handleLeftClick(const ClickContext& ctx)
855855
}
856856
}
857857

858-
void NotationViewInputController::handleRightClick(const ClickContext&)
858+
void NotationViewInputController::handleRightClick(const ClickContext& ctx)
859859
{
860860
m_mouseDownInfo.dragAction = MouseDownInfo::Nothing;
861861

862+
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
863+
UNUSED(ctx);
862864
// See also AbstractNotationPaintView::event for context menu event handling
865+
#else
866+
m_view->showContextMenu(selectionType(), ctx.event->pos());
867+
#endif
863868
}
864869

865870
bool NotationViewInputController::startTextEditingAllowed() const

0 commit comments

Comments
 (0)