Commit 9319cdb0 authored by Nicolas Ollinger's avatar Nicolas Ollinger

Bug fix: suppression de isAbsurd et meilleure gestion des stylets (import des...

Bug fix: suppression de isAbsurd et meilleure gestion des stylets (import des PR github #337 et #342)
parent c5172eae
...@@ -121,6 +121,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p ...@@ -121,6 +121,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p
, mMultipleSelectionIsEnabled(false) , mMultipleSelectionIsEnabled(false)
, bIsControl(isControl) , bIsControl(isControl)
, bIsDesktop(isDesktop) , bIsDesktop(isDesktop)
, tabletDeviceActive(false)
{ {
init (); init ();
...@@ -333,6 +334,12 @@ bool UBBoardView::event (QEvent * e) ...@@ -333,6 +334,12 @@ bool UBBoardView::event (QEvent * e)
} }
} }
if (e->type() == QEvent::TabletEnterProximity || e->type() == QEvent::TabletLeaveProximity) {
bool active = e->type() == QEvent::TabletEnterProximity? 1:0;
tabletDeviceActive = active;
return true;
}
return QGraphicsView::event (e); return QGraphicsView::event (e);
} }
...@@ -367,11 +374,13 @@ void UBBoardView::tabletEvent (QTabletEvent * event) ...@@ -367,11 +374,13 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) && mPenPressureSensitive) || if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) && mPenPressureSensitive) ||
(currentTool == UBStylusTool::Marker && mMarkerPressureSensitive)) (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
pressure = event->pressure (); pressure = event->pressure ();
else{
//Explanation: rerouting to mouse event // Mouse event does not handle tablet events anymore
event->setAccepted (false); // else{
return; // //Explanation: rerouting to mouse event
} // event->setAccepted (false);
// return;
// }
bool acceptEvent = true; bool acceptEvent = true;
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
...@@ -982,11 +991,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -982,11 +991,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mIsDragInProgress = false; mIsDragInProgress = false;
if (isAbsurdPoint (event->pos ())) {
event->accept ();
return;
}
mMouseDownPos = event->pos (); mMouseDownPos = event->pos ();
movingItem = scene()->itemAt(this->mapToScene(event->localPos().toPoint()), QTransform()); movingItem = scene()->itemAt(this->mapToScene(event->localPos().toPoint()), QTransform());
...@@ -1078,7 +1082,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -1078,7 +1082,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
if(UBDrawingController::drawingController()->mActiveRuler==NULL) { if(UBDrawingController::drawingController()->mActiveRuler==NULL) {
viewport()->setCursor (QCursor (Qt::BlankCursor)); viewport()->setCursor (QCursor (Qt::BlankCursor));
} }
if (scene () && !mTabletStylusIsPressed) { if (scene () && !mTabletStylusIsPressed && !tabletDeviceActive) {
if (currentTool == UBStylusTool::Eraser) { if (currentTool == UBStylusTool::Eraser) {
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent()));
mLongPressTimer.start(); mLongPressTimer.start();
...@@ -1107,11 +1111,6 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event) ...@@ -1107,11 +1111,6 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event)
mWidgetMoved = true; mWidgetMoved = true;
mLongPressTimer.stop(); mLongPressTimer.stop();
if (isAbsurdPoint (event->pos ())) {
event->accept ();
return;
}
if ((UBDrawingController::drawingController()->isDrawingTool()) && !mMouseButtonIsPressed) if ((UBDrawingController::drawingController()->isDrawingTool()) && !mMouseButtonIsPressed)
QGraphicsView::mouseMoveEvent(event); QGraphicsView::mouseMoveEvent(event);
...@@ -1214,7 +1213,7 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event) ...@@ -1214,7 +1213,7 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event)
} break; } break;
default: default:
if (!mTabletStylusIsPressed && scene()) { if (!mTabletStylusIsPressed && !tabletDeviceActive && scene()) {
scene()->inputDeviceMove(mapToScene(UBGeometryUtils::pointConstrainedInRect(event->pos(), rect())) , mMouseButtonIsPressed); scene()->inputDeviceMove(mapToScene(UBGeometryUtils::pointConstrainedInRect(event->pos(), rect())) , mMouseButtonIsPressed);
} }
event->accept (); event->accept ();
...@@ -1691,23 +1690,6 @@ void UBBoardView::virtualKeyboardActivated(bool b) ...@@ -1691,23 +1690,6 @@ void UBBoardView::virtualKeyboardActivated(bool b)
setInteractive(!b); setInteractive(!b);
} }
// Apple remote desktop sends funny events when the transmission is bad
bool UBBoardView::isAbsurdPoint(QPoint point)
{
QDesktopWidget *desktop = qApp->desktop ();
bool isValidPoint = false;
for (int i = 0; i < desktop->numScreens (); i++)
{
QRect screenRect = desktop->screenGeometry (i);
isValidPoint = isValidPoint || screenRect.contains (mapToGlobal(point));
}
return !isValidPoint;
}
void UBBoardView::focusOutEvent (QFocusEvent * event) void UBBoardView::focusOutEvent (QFocusEvent * event)
{ {
Q_UNUSED (event); Q_UNUSED (event);
......
...@@ -53,6 +53,8 @@ public: ...@@ -53,6 +53,8 @@ public:
UBBoardView(UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent = 0, bool isControl = false, bool isDesktop = false); UBBoardView(UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent = 0, bool isControl = false, bool isDesktop = false);
virtual ~UBBoardView(); virtual ~UBBoardView();
bool event(QEvent* event) override;
UBGraphicsScene* scene(); UBGraphicsScene* scene();
void forcedTabletRelease(); void forcedTabletRelease();
...@@ -89,8 +91,6 @@ protected: ...@@ -89,8 +91,6 @@ protected:
void handleItemMousePress(QMouseEvent *event); void handleItemMousePress(QMouseEvent *event);
void handleItemMouseMove(QMouseEvent *event); void handleItemMouseMove(QMouseEvent *event);
virtual bool event (QEvent * e);
virtual void keyPressEvent(QKeyEvent *event); virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event);
virtual void tabletEvent(QTabletEvent * event); virtual void tabletEvent(QTabletEvent * event);
...@@ -149,8 +149,6 @@ private: ...@@ -149,8 +149,6 @@ private:
bool mIsCreatingTextZone; bool mIsCreatingTextZone;
bool mIsCreatingSceneGrabZone; bool mIsCreatingSceneGrabZone;
bool isAbsurdPoint(QPoint point);
bool mVirtualKeyboardActive; bool mVirtualKeyboardActive;
bool mOkOnWidget; bool mOkOnWidget;
...@@ -176,6 +174,8 @@ private: ...@@ -176,6 +174,8 @@ private:
static bool hasSelectedParents(QGraphicsItem * item); static bool hasSelectedParents(QGraphicsItem * item);
bool tabletDeviceActive;
private slots: private slots:
void settingChanged(QVariant newValue); void settingChanged(QVariant newValue);
......
...@@ -435,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre ...@@ -435,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
if (currentTool != UBStylusTool::Line){ if (currentTool != UBStylusTool::Line){
// Handle the pressure // Handle the pressure
width = UBDrawingController::drawingController()->currentToolWidth() * pressure; width = UBDrawingController::drawingController()->currentToolWidth() * pressure/2+1;
} }
else{ else{
// Ignore pressure for the line tool // Ignore pressure for the line tool
...@@ -527,7 +527,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres ...@@ -527,7 +527,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
if (currentTool != UBStylusTool::Line){ if (currentTool != UBStylusTool::Line){
// Handle the pressure // Handle the pressure
width = dc->currentToolWidth() * qMax(pressure, 0.2); width = dc->currentToolWidth() * pressure/2 + 1;// qMax(pressure, 0.2);
}else{ }else{
// Ignore pressure for line tool // Ignore pressure for line tool
width = dc->currentToolWidth(); width = dc->currentToolWidth();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment