[TD]Navigation Styles - context menu handling & std cursors
This commit is contained in:
committed by
WandererFan
parent
866da5980c
commit
fdcfd4c565
@@ -34,7 +34,8 @@ using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleOpenSCAD::QGVNavStyleOpenSCAD()
|
||||
QGVNavStyleOpenSCAD::QGVNavStyleOpenSCAD(QGVPage *qgvp) :
|
||||
QGVNavStyle(qgvp)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,29 +47,15 @@ void QGVNavStyleOpenSCAD::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
//zoom mode 2
|
||||
if ( (event->key() == Qt::Key_Shift) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
stopZoom();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//eat the RMB event so it doesn't trigger MDIViewPage context
|
||||
void QGVNavStyleOpenSCAD::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//zoom mode 2 Shift + RMB
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
(QApplication::keyboardModifiers() == Qt::ShiftModifier)) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
//pan mode
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//zoom mode 2 MMB
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
if (event->button() == Qt::RightButton) {
|
||||
startClick(Qt::RightButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,13 +65,41 @@ void QGVNavStyleOpenSCAD::handleMouseMoveEvent(QMouseEvent *event)
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
//if the mouse moves between press and release, then it isn't a click
|
||||
if (m_clickPending) {
|
||||
stopClick();
|
||||
return;
|
||||
}
|
||||
|
||||
if (QGuiApplication::mouseButtons() & Qt::RightButton &&
|
||||
!QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
//pan mode - RMB + move
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
} else {
|
||||
startPan(event->pos());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
|
||||
//zoom mode 1 - MMB + move
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
} else {
|
||||
startZoom(event->pos());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if ((QGuiApplication::mouseButtons() & Qt::RightButton) &&
|
||||
QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
//zoom mode 2 - SHIFT + RMB + move
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
} else {
|
||||
startZoom(event->pos());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
@@ -95,20 +110,46 @@ void QGVNavStyleOpenSCAD::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
m_clickPending &&
|
||||
(m_clickButton == Qt::RightButton)) {
|
||||
stopClick();
|
||||
pseudoContextEvent();
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::RightButton) && panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::RightButton) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
stopZoom();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::MiddleButton) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
stopZoom();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
bool QGVNavStyleOpenSCAD::allowContextMenu(QContextMenuEvent *event)
|
||||
{
|
||||
// Base::Console().Message("QGVNSCAD::allowContextMenu()\n");
|
||||
if (event->reason() == QContextMenuEvent::Mouse) {
|
||||
//must check for a button combination involving context menu button
|
||||
if (QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
//Shift down - don't allow context menu
|
||||
return false;
|
||||
} else if (m_clickPending) {
|
||||
//context menu request to be handled by button release
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
Reference in New Issue
Block a user