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
, mMultipleSelectionIsEnabled(false)
, bIsControl(isControl)
, bIsDesktop(isDesktop)
, tabletDeviceActive(false)
{
init ();
......@@ -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);
}
......@@ -367,11 +374,13 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) && mPenPressureSensitive) ||
(currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
pressure = event->pressure ();
else{
//Explanation: rerouting to mouse event
event->setAccepted (false);
return;
}
// Mouse event does not handle tablet events anymore
// else{
// //Explanation: rerouting to mouse event
// event->setAccepted (false);
// return;
// }
bool acceptEvent = true;
#ifdef Q_OS_OSX
......@@ -982,11 +991,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mIsDragInProgress = false;
if (isAbsurdPoint (event->pos ())) {
event->accept ();
return;
}
mMouseDownPos = event->pos ();
movingItem = scene()->itemAt(this->mapToScene(event->localPos().toPoint()), QTransform());
......@@ -1078,7 +1082,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
if(UBDrawingController::drawingController()->mActiveRuler==NULL) {
viewport()->setCursor (QCursor (Qt::BlankCursor));
}
if (scene () && !mTabletStylusIsPressed) {
if (scene () && !mTabletStylusIsPressed && !tabletDeviceActive) {
if (currentTool == UBStylusTool::Eraser) {
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent()));
mLongPressTimer.start();
......@@ -1107,11 +1111,6 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event)
mWidgetMoved = true;
mLongPressTimer.stop();
if (isAbsurdPoint (event->pos ())) {
event->accept ();
return;
}
if ((UBDrawingController::drawingController()->isDrawingTool()) && !mMouseButtonIsPressed)
QGraphicsView::mouseMoveEvent(event);
......@@ -1214,7 +1213,7 @@ void UBBoardView::mouseMoveEvent (QMouseEvent *event)
} break;
default:
if (!mTabletStylusIsPressed && scene()) {
if (!mTabletStylusIsPressed && !tabletDeviceActive && scene()) {
scene()->inputDeviceMove(mapToScene(UBGeometryUtils::pointConstrainedInRect(event->pos(), rect())) , mMouseButtonIsPressed);
}
event->accept ();
......@@ -1691,23 +1690,6 @@ void UBBoardView::virtualKeyboardActivated(bool 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)
{
Q_UNUSED (event);
......
......@@ -53,6 +53,8 @@ public:
UBBoardView(UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent = 0, bool isControl = false, bool isDesktop = false);
virtual ~UBBoardView();
bool event(QEvent* event) override;
UBGraphicsScene* scene();
void forcedTabletRelease();
......@@ -89,8 +91,6 @@ protected:
void handleItemMousePress(QMouseEvent *event);
void handleItemMouseMove(QMouseEvent *event);
virtual bool event (QEvent * e);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void tabletEvent(QTabletEvent * event);
......@@ -149,8 +149,6 @@ private:
bool mIsCreatingTextZone;
bool mIsCreatingSceneGrabZone;
bool isAbsurdPoint(QPoint point);
bool mVirtualKeyboardActive;
bool mOkOnWidget;
......@@ -176,6 +174,8 @@ private:
static bool hasSelectedParents(QGraphicsItem * item);
bool tabletDeviceActive;
private slots:
void settingChanged(QVariant newValue);
......
......@@ -435,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
if (currentTool != UBStylusTool::Line){
// Handle the pressure
width = UBDrawingController::drawingController()->currentToolWidth() * pressure;
width = UBDrawingController::drawingController()->currentToolWidth() * pressure/2+1;
}
else{
// Ignore pressure for the line tool
......@@ -527,7 +527,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
if (currentTool != UBStylusTool::Line){
// Handle the pressure
width = dc->currentToolWidth() * qMax(pressure, 0.2);
width = dc->currentToolWidth() * pressure/2 + 1;// qMax(pressure, 0.2);
}else{
// Ignore pressure for line tool
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