first cherry-pick for mac os table pressure fix

preferencesAboutTextFull
Aleksei Kanash 11 years ago committed by Claudio Valerio
parent 554ee8775b
commit c51a8159e2
  1. 67
      src/board/UBBoardView.cpp
  2. 9
      src/board/UBBoardView.h
  3. 1
      src/gui/UBCachePropertiesWidget.cpp
  4. 32
      src/gui/UBMainWindow.cpp
  5. 4
      src/gui/UBMainWindow.h

@ -864,12 +864,77 @@ void UBBoardView::setMultiselection(bool enable)
mMultipleSelectionIsEnabled = enable;
}
// work around for handling tablet events on MAC OS with Qt 4.8.0 and above
#if defined(Q_WS_MACX)
bool UBBoardView::directTabletEvent(QEvent *event)
{
QTabletEvent *tEvent = static_cast<QTabletEvent *>(event);
tEvent = new QTabletEvent(tEvent->type()
, mapFromGlobal(tEvent->pos())
, tEvent->globalPos()
, tEvent->hiResGlobalPos()
, tEvent->device()
, tEvent->pointerType()
, tEvent->pressure()
, tEvent->xTilt()
, tEvent->yTilt()
, tEvent->tangentialPressure()
, tEvent->rotation()
, tEvent->z()
, tEvent->modifiers()
, tEvent->uniqueId());
if (geometry().contains(tEvent->pos()))
{
if (NULL == widgetForTabletEvent(this->parentWidget(), tEvent->pos()))
{
tabletEvent(tEvent);
return true;
}
}
return false;
}
QWidget *UBBoardView::widgetForTabletEvent(QWidget *w, const QPoint &pos)
{
Q_ASSERT(w);
UBBoardView *board = qobject_cast<UBBoardView *>(w);
QWidget *childAtPos = NULL;
QList<QObject *> childs = w->children();
foreach(QObject *child, childs)
{
QWidget *childWidget = qobject_cast<QWidget *>(child);
if (childWidget)
{
if (childWidget->isVisible() && childWidget->geometry().contains(pos))
{
QWidget *lastChild = widgetForTabletEvent(childWidget, pos);
if (board && board->viewport() == lastChild)
continue;
if (NULL != lastChild)
childAtPos = lastChild;
else
childAtPos = childWidget;
break;
}
else
childAtPos = NULL;
}
}
return childAtPos;
}
#endif
void UBBoardView::longPressEvent()
{
UBDrawingController *drawingController = UBDrawingController::drawingController();
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
disconnect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent()));
if (UBStylusTool::Selector == currentTool)

@ -20,7 +20,6 @@
*/
#ifndef UBBOARDVIEW_H_
#define UBBOARDVIEW_H_
@ -54,7 +53,11 @@ class UBBoardView : public QGraphicsView
void setMultiselection(bool enable);
bool isMultipleSelectionEnabled() { return mMultipleSelectionIsEnabled; }
// work around for handling tablet events on MAC OS with Qt 4.8.0 and above
#if defined(Q_WS_MACX)
bool directTabletEvent(QEvent *event);
QWidget *widgetForTabletEvent(QWidget *w, const QPoint &pos);
#endif
signals:
void resized(QResizeEvent* event);
@ -153,7 +156,7 @@ class UBBoardView : public QGraphicsView
bool moveRubberBand;
UBRubberBand *mUBRubberBand;
QList<QGraphicsItem *> mRubberedItems;
QSet<QGraphicsItem*> mJustSelectedItems;

@ -372,4 +372,3 @@ void UBCachePropertiesWidget::onCacheEnabled()
{
emit showTab(this);
}

@ -27,6 +27,10 @@
#include "core/UBApplication.h"
#include "core/UBApplicationController.h"
#include "board/UBBoardController.h"
// work around for handling tablet events on MAC OS with Qt 4.8.0 and above
#if defined(Q_WS_MACX)
#include "board/UBBoardView.h"
#endif
#include "core/memcheck.h"
@ -145,6 +149,34 @@ void UBMainWindow::closeEvent(QCloseEvent *event)
emit closeEvent_Signal(event);
}
// work around for handling tablet events on MAC OS with Qt 4.8.0 and above
#if defined(Q_WS_MACX)
bool UBMainWindow::event(QEvent *event)
{
bool bRes = QMainWindow::event(event);
if (NULL != UBApplication::boardController)
{
UBBoardView *controlV = UBApplication::boardController->controlView();
if (controlV && controlV->isVisible())
{
switch (event->type())
{
case QEvent::TabletEnterProximity:
case QEvent::TabletLeaveProximity:
case QEvent::TabletMove:
case QEvent::TabletPress:
case QEvent::TabletRelease:
{
return controlV->directTabletEvent(event);
}
}
}
}
return bRes;
}
#endif
void UBMainWindow::onExportDone()
{
// HACK : When opening the file save dialog during the document exportation,

@ -83,6 +83,10 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow
QWidget *mDocumentsWidget;
private:
// work around for handling tablet events on MAC OS with Qt 4.8.0 and above
#if defined(Q_WS_MACX)
bool event(QEvent *event);
#endif
UBDownloadWidget* mpDownloadWidget;
};

Loading…
Cancel
Save