Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Ivan Ilin 13 years ago
commit 104ce334d5
  1. 65
      src/board/UBBoardView.cpp
  2. 43
      src/gui/UBDocumentThumbnailWidget.cpp
  3. 5
      src/gui/UBDocumentThumbnailWidget.h

@ -270,86 +270,82 @@ UBBoardView::event (QEvent * e)
return QGraphicsView::event (e); return QGraphicsView::event (e);
} }
void void UBBoardView::tabletEvent (QTabletEvent * event)
UBBoardView::tabletEvent (QTabletEvent * event)
{ {
if (!mUseHighResTabletEvent) if (!mUseHighResTabletEvent) {
{
event->setAccepted (false); event->setAccepted (false);
return; return;
} }
qDebug() << "tableEvent position " << event->pos();
qDebug() << "tableEvent global position " << event->globalPos();
UBDrawingController *dc = UBDrawingController::drawingController (); UBDrawingController *dc = UBDrawingController::drawingController ();
QPointF tabletPos = UBGeometryUtils::pointConstrainedInRect (event->hiResGlobalPos () QPointF tabletPos = UBGeometryUtils::pointConstrainedInRect (event->hiResGlobalPos () - mapToGlobal (QPoint (0, 0)), rect ());
- mapToGlobal (QPoint (0, 0)), rect ());
// QPointF tabletPos = event->pos();
qDebug() << "tabletPos " << tabletPos;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool ();
if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) if (event->type () == QEvent::TabletPress || event->type () == QEvent::TabletEnterProximity) {
{ if (event->pointerType () == QTabletEvent::Eraser) {
if (event->pointerType () == QTabletEvent::Eraser)
{
dc->setStylusTool (UBStylusTool::Eraser); dc->setStylusTool (UBStylusTool::Eraser);
mUsingTabletEraser = true; mUsingTabletEraser = true;
} }
else else {
{
if (mUsingTabletEraser && currentTool == UBStylusTool::Eraser) if (mUsingTabletEraser && currentTool == UBStylusTool::Eraser)
{
dc->setStylusTool (dc->latestDrawingTool ()); dc->setStylusTool (dc->latestDrawingTool ());
}
mUsingTabletEraser = false; mUsingTabletEraser = false;
} }
} }
// if event are not Pen events, we drop the tablet stuff and route everything through mouse event // if event are not Pen events, we drop the tablet stuff and route everything through mouse event
if (currentTool != UBStylusTool::Pen if (currentTool != UBStylusTool::Pen && currentTool != UBStylusTool::Line && currentTool != UBStylusTool::Marker && !mMarkerPressureSensitive){
&& currentTool != UBStylusTool::Line
&& currentTool != UBStylusTool::Marker
&& !mMarkerPressureSensitive)
{
event->setAccepted (false); event->setAccepted (false);
return; return;
} }
QPointF scenePos = viewportTransform ().inverted ().map (tabletPos); QPointF scenePos = viewportTransform ().inverted ().map (tabletPos);
qDebug() << "scene Pos " << scenePos;
qreal pressure = 1.0; qreal pressure = 1.0;
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line)
&& mPenPressureSensitive) && mPenPressureSensitive)
|| (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive)) || (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
{
pressure = event->pressure (); pressure = event->pressure ();
}
bool acceptEvent = true; bool acceptEvent = true;
switch (event->type ()) switch (event->type ()) {
{ case QEvent::TabletPress: {
case QEvent::TabletPress: qDebug() << "TabletPress";
{
mTabletStylusIsPressed = true;
scene ()->inputDevicePress (scenePos, pressure); mTabletStylusIsPressed = true;
scene()->inputDevicePress (scenePos, pressure);
break; break;
} }
case QEvent::TabletMove: case QEvent::TabletMove: {
{ qDebug() << "TabletMove";
if (mTabletStylusIsPressed) if (mTabletStylusIsPressed)
{
scene ()->inputDeviceMove (scenePos, pressure); scene ()->inputDeviceMove (scenePos, pressure);
}
acceptEvent = false; // rerouted to mouse move acceptEvent = false; // rerouted to mouse move
break; break;
} }
case QEvent::TabletRelease: case QEvent::TabletRelease: {
{ qDebug() << "TabletRelease";
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)dc->stylusTool ();
scene ()->setToolCursor (currentTool); scene ()->setToolCursor (currentTool);
setToolCursor (currentTool); setToolCursor (currentTool);
@ -363,8 +359,7 @@ UBBoardView::tabletEvent (QTabletEvent * event)
break; break;
} }
default: default: {
{
//NOOP - avoid compiler warning //NOOP - avoid compiler warning
} }
} }

@ -26,9 +26,10 @@ UBDocumentThumbnailWidget::UBDocumentThumbnailWidget(QWidget* parent)
: UBThumbnailWidget(parent) : UBThumbnailWidget(parent)
, mDropCaretRectItem(0) , mDropCaretRectItem(0)
, mClosestDropItem(0) , mClosestDropItem(0)
, mDragEnabled(true) , mDragEnabled(true), mScrollMagnitude(0)
{ {
// NOOP mScrollTimer = new QTimer(this);
connect(mScrollTimer, SIGNAL(timeout()), this, SLOT(autoScroll()));
} }
@ -96,13 +97,43 @@ void UBDocumentThumbnailWidget::dragEnterEvent(QDragEnterEvent *event)
void UBDocumentThumbnailWidget::dragLeaveEvent(QDragLeaveEvent *event) void UBDocumentThumbnailWidget::dragLeaveEvent(QDragLeaveEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
if (mScrollTimer->isActive())
{
mScrollMagnitude = 0;
mScrollTimer->stop();
}
deleteDropCaret(); deleteDropCaret();
} }
void UBDocumentThumbnailWidget::autoScroll()
{
this->verticalScrollBar()->setValue(this->verticalScrollBar()->value() + mScrollMagnitude);
}
void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
{ {
QRect boundingFrame = frameRect();
//setting up automatic scrolling
const int SCROLL_DISTANCE = 16;
int bottomDist = boundingFrame.bottom() - event->pos().y(), topDist = boundingFrame.top() - event->pos().y();
if(qAbs(bottomDist) <= SCROLL_DISTANCE)
{
mScrollMagnitude = (SCROLL_DISTANCE - bottomDist)*4;
if(verticalScrollBar()->isVisible() && !mScrollTimer->isActive()) mScrollTimer->start(100);
}
else if(qAbs(topDist) <= SCROLL_DISTANCE)
{
mScrollMagnitude = (- SCROLL_DISTANCE - topDist)*4;
if(verticalScrollBar()->isVisible() && !mScrollTimer->isActive()) mScrollTimer->start(100);
}
else
{
mScrollMagnitude = 0;
mScrollTimer->stop();
}
QList<UBSceneThumbnailPixmap*> pixmapItems; QList<UBSceneThumbnailPixmap*> pixmapItems;
foreach (QGraphicsItem *item, scene()->items(mapToScene(frameRect()))) foreach (QGraphicsItem *item, scene()->items(mapToScene(boundingFrame)))
{ {
UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(item); UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(item);
if (sceneItem) if (sceneItem)
@ -161,8 +192,14 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
event->acceptProposedAction(); event->acceptProposedAction();
} }
void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
{ {
if (mScrollTimer->isActive())
{
mScrollMagnitude = 0;
mScrollTimer->stop();
}
deleteDropCaret(); deleteDropCaret();
if (mClosestDropItem) if (mClosestDropItem)

@ -41,6 +41,9 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
signals: signals:
void sceneDropped(UBDocumentProxy* proxy, int source, int target); void sceneDropped(UBDocumentProxy* proxy, int source, int target);
private slots:
void autoScroll();
protected: protected:
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
@ -57,6 +60,8 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
UBSceneThumbnailPixmap *mClosestDropItem; UBSceneThumbnailPixmap *mClosestDropItem;
bool mDropIsRight; bool mDropIsRight;
bool mDragEnabled; bool mDragEnabled;
QTimer* mScrollTimer;
int mScrollMagnitude;
}; };
#endif /* UBDOCUMENTTHUMBNAILWIDGET_H_ */ #endif /* UBDOCUMENTTHUMBNAILWIDGET_H_ */

Loading…
Cancel
Save