QT6: Mod Qt::MidButton Use Qt::MiddleButton

This commit is contained in:
Simon De Backer
2020-10-03 09:17:40 +02:00
parent 4f929ef3c9
commit bc0cb6b1b3
2 changed files with 77 additions and 34 deletions

View File

@@ -423,7 +423,14 @@ void DiagramView::mousePressEvent(QMouseEvent *e)
if (m_event_interface && m_event_interface->mousePressEvent(e)) return; if (m_event_interface && m_event_interface->mousePressEvent(e)) return;
//Start drag view when hold the middle button //Start drag view when hold the middle button
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (e->button() == Qt::MidButton) if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
#endif
{ {
m_drag_last_pos = e->pos(); m_drag_last_pos = e->pos();
viewport()->setCursor(Qt::ClosedHandCursor); viewport()->setCursor(Qt::ClosedHandCursor);
@@ -473,7 +480,14 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e)
if (m_event_interface && m_event_interface->mouseMoveEvent(e)) return; if (m_event_interface && m_event_interface->mouseMoveEvent(e)) return;
//Drag the view //Drag the view
if (e->buttons() == Qt::MidButton) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
#endif
{ {
QScrollBar *h = horizontalScrollBar(); QScrollBar *h = horizontalScrollBar();
QScrollBar *v = verticalScrollBar(); QScrollBar *v = verticalScrollBar();
@@ -534,7 +548,14 @@ void DiagramView::mouseReleaseEvent(QMouseEvent *e)
if (m_event_interface && m_event_interface->mouseReleaseEvent(e)) return; if (m_event_interface && m_event_interface->mouseReleaseEvent(e)) return;
//Stop drag view //Stop drag view
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (e->button() == Qt::MidButton) if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
#endif
{ {
viewport()->setCursor(Qt::ArrowCursor); viewport()->setCursor(Qt::ArrowCursor);
} }

View File

@@ -373,7 +373,14 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
@param e QMouseEvent decrivant l'evenement souris @param e QMouseEvent decrivant l'evenement souris
*/ */
void ElementView::mousePressEvent(QMouseEvent *e) { void ElementView::mousePressEvent(QMouseEvent *e) {
if (e->buttons() == Qt::MidButton) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
#endif
{ {
setCursor( (Qt::ClosedHandCursor)); setCursor( (Qt::ClosedHandCursor));
reference_view_ = e->pos(); reference_view_ = e->pos();
@@ -387,7 +394,14 @@ void ElementView::mousePressEvent(QMouseEvent *e) {
Manage the event move mouse Manage the event move mouse
*/ */
void ElementView::mouseMoveEvent(QMouseEvent *e) { void ElementView::mouseMoveEvent(QMouseEvent *e) {
if (e->buttons() == Qt::MidButton) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
#endif
{ {
QScrollBar *h = horizontalScrollBar(); QScrollBar *h = horizontalScrollBar();
QScrollBar *v = verticalScrollBar(); QScrollBar *v = verticalScrollBar();
@@ -405,7 +419,15 @@ void ElementView::mouseMoveEvent(QMouseEvent *e) {
Manage event release click mouse Manage event release click mouse
*/ */
void ElementView::mouseReleaseEvent(QMouseEvent *e) { void ElementView::mouseReleaseEvent(QMouseEvent *e) {
if (e -> button() == Qt::MidButton) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (e->button() == Qt::MidButton)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (e->button() == Qt::MiddleButton)
#endif
{
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
adjustSceneRect(); adjustSceneRect();
return; return;