From aa5945540776f3205b47af83a6c33e3c6f963141 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Thu, 14 Jun 2012 18:25:01 +0300 Subject: [PATCH] First implementation of Play Tool. It's icon is temporary. Behavior implemented: 1. Can interact with all items without showing items frames (but ToolBar shows). 2. Cannot move items, but can drag images. 3. Selected items appears deselected when Play tool chosen. 4. Play tool don't requires selecting of item before interacts. 5. Cursor looks like tool icon in text and image widgets (should be the same in any others widgets, but now in w3c is not). --- resources/forms/mainWindow.ui | 16 ++++++++++++++ resources/images/stylusPalette/handPlay.png | Bin 0 -> 444 bytes resources/images/stylusPalette/handPlayOn.png | Bin 0 -> 603 bytes resources/sankore.qrc | 2 ++ src/api/UBWidgetUniboardAPI.cpp | 4 ++++ src/board/UBBoardView.cpp | 20 +++++++++++++++--- src/board/UBDrawingController.cpp | 9 ++++++++ src/board/UBDrawingController.h | 1 + src/core/UB.h | 1 + src/domain/UBGraphicsItemDelegate.cpp | 4 +++- src/domain/UBGraphicsProxyWidget.cpp | 3 ++- src/domain/UBGraphicsScene.cpp | 5 +++-- src/gui/UBStylusPalette.cpp | 1 + src/tools/UBGraphicsCompass.cpp | 18 ++++++++++------ src/tools/UBGraphicsProtractor.cpp | 14 ++++++------ src/tools/UBGraphicsRuler.cpp | 5 +++-- src/tools/UBGraphicsTriangle.cpp | 7 ++++-- 17 files changed, 86 insertions(+), 24 deletions(-) create mode 100644 resources/images/stylusPalette/handPlay.png create mode 100644 resources/images/stylusPalette/handPlayOn.png diff --git a/resources/forms/mainWindow.ui b/resources/forms/mainWindow.ui index a2ac84b8..6f81085c 100644 --- a/resources/forms/mainWindow.ui +++ b/resources/forms/mainWindow.ui @@ -1649,6 +1649,22 @@ Group items + + + true + + + + :/images/stylusPalette/handPlay.png + :/images/stylusPalette/handPlayOn.png:/images/stylusPalette/handPlay.png + + + Play + + + Interact with items + + diff --git a/resources/images/stylusPalette/handPlay.png b/resources/images/stylusPalette/handPlay.png new file mode 100644 index 0000000000000000000000000000000000000000..999f7703d66dae1639681e63fc28e21af797d040 GIT binary patch literal 444 zcmeAS@N?(olHy`uVBq!ia0vp^3Lq@N1|*eVE!z&H*pj^6UH*dsXT|0>giAM^CGh6EVT@eK}I{QXl0@4-Tu zY1>9nL&MgQMI!Tv$XS;6`Twz)D1FNW_l#d@FqipQOydTSzq-^le%lx3;c>pj4yXTeQ3LZ z)3vB)u^C_eH~4bDkT$gP5kH@}k9Bk2wC?Bw=M21lsEH=z9x;CS(TDk1t9%^e9WRTu zN85XEJj{D(an7@b;oj5K0!!BFFThYxEpd$~Nl7e8wMs5Z1yT$~28M>Z24=cO1|f#V uRwf2k21eQjMpgy}o!0HnC>nC}Q!>*kaclUIX8#|kfx*+&&t;ucLK6TUUan#Q literal 0 HcmV?d00001 diff --git a/resources/images/stylusPalette/handPlayOn.png b/resources/images/stylusPalette/handPlayOn.png new file mode 100644 index 0000000000000000000000000000000000000000..9191cffa6fd56a93b1671b4b0522e0cec721baf2 GIT binary patch literal 603 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DinK$vl=HlH+5kS)pE-Q_pIf1MkHYN3CZ8&|_pRg5Gi>qnKcLPK&U)Rq zO2JR_1XF^$VB}V*O@>wtULU#)Z1-D~FG(<{vWe+E>!76Fqj=|l!lA3iy+3<@y@+;P z#*lJ3m{qai-I<+ATSZRasNSS-#V>DK?fq?yKiP`E{cuq_lf!o1Y3dYh&Rg5QHZojs zS1&yGt#|q556k8D&hA;sCSs^`+;V-q=4BCwCu^QhsF61?&}0adonBcRvEW0+|7WUO z=XLg2Zj{$H@-sBp?Gq7Do4-0)-$ih*&i9)KqFyQg7Gl=+*--s(2XA<>wB_~1C!6Ho za5H>&TT_se6PaKbKEakXRQJpW*QHXyEB>nT);OHo@P*}pe#C}1JUlU+hrD}dH|1Zg zd}4j+=>NZ_o3k4G+gGyX?oDr6%H!gYwsaQj(eM7!9<@8IZw2K7BaXq-)z4*}Q$iB} D2Ttn+ literal 0 HcmV?d00001 diff --git a/resources/sankore.qrc b/resources/sankore.qrc index f94729e7..ced5d120 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -125,6 +125,8 @@ images/toolbar/tools.png images/stylusPalette/arrow.png images/stylusPalette/arrowOn.png + images/stylusPalette/handPlay.png + images/stylusPalette/handPlayOn.png images/stylusPalette/eraser.png images/stylusPalette/eraserOn.png images/stylusPalette/hand.png diff --git a/src/api/UBWidgetUniboardAPI.cpp b/src/api/UBWidgetUniboardAPI.cpp index 260734ad..b58b3c3f 100644 --- a/src/api/UBWidgetUniboardAPI.cpp +++ b/src/api/UBWidgetUniboardAPI.cpp @@ -123,6 +123,10 @@ void UBWidgetUniboardAPI::setTool(const QString& toolString) { UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); } + else if (lower == "play") + { + UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Play); + } else if (lower == "line") { UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line); diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 59f4e8e5..7d898447 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -453,6 +453,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) } + event->accept(); + } + else if (currentTool == UBStylusTool::Play) + { + QGraphicsView::mousePressEvent (event); + event->accept(); } else if (currentTool == UBStylusTool::Text) @@ -584,6 +590,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) } else QGraphicsView::mouseMoveEvent (event); } + else if (currentTool == UBStylusTool::Play) + { + QGraphicsView::mouseMoveEvent (event); + } else if ((UBDrawingController::drawingController()->isDrawingTool()) && !mMouseButtonIsPressed) { @@ -616,9 +626,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) { UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - scene ()->setToolCursor (currentTool); - setToolCursor (currentTool); - // first propagate device release to the scene if (scene ()) scene ()->inputDeviceRelease (); @@ -644,6 +651,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) QGraphicsView::mouseReleaseEvent (event); } + else if (currentTool == UBStylusTool::Play) + { + QGraphicsView::mouseReleaseEvent (event); + } else if (currentTool == UBStylusTool::Text) { if (mRubberBand) @@ -1027,6 +1038,9 @@ UBBoardView::setToolCursor (int tool) case UBStylusTool::Selector: controlViewport->setCursor (UBResources::resources ()->arrowCursor); break; + case UBStylusTool::Play: + controlViewport->setCursor (UBResources::resources ()->drawLineRulerCursor); + break; case UBStylusTool::Line: controlViewport->setCursor (UBResources::resources ()->penCursor); break; diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp index e03ef408..70c54905 100644 --- a/src/board/UBDrawingController.cpp +++ b/src/board/UBDrawingController.cpp @@ -54,6 +54,7 @@ UBDrawingController::UBDrawingController(QObject * parent) connect(UBApplication::mainWindow->actionEraser, SIGNAL(triggered(bool)), this, SLOT(eraserToolSelected(bool))); connect(UBApplication::mainWindow->actionMarker, SIGNAL(triggered(bool)), this, SLOT(markerToolSelected(bool))); connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool))); + connect(UBApplication::mainWindow->actionPlay, SIGNAL(triggered(bool)), this, SLOT(playToolSelected(bool))); connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(handToolSelected(bool))); connect(UBApplication::mainWindow->actionZoomIn, SIGNAL(triggered(bool)), this, SLOT(zoomInToolSelected(bool))); connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool))); @@ -120,6 +121,8 @@ void UBDrawingController::setStylusTool(int tool) UBApplication::mainWindow->actionMarker->setChecked(true); else if (mStylusTool == UBStylusTool::Selector) UBApplication::mainWindow->actionSelector->setChecked(true); + else if (mStylusTool == UBStylusTool::Play) + UBApplication::mainWindow->actionPlay->setChecked(true); else if (mStylusTool == UBStylusTool::Hand) UBApplication::mainWindow->actionHand->setChecked(true); else if (mStylusTool == UBStylusTool::ZoomIn) @@ -347,6 +350,12 @@ void UBDrawingController::selectorToolSelected(bool checked) setStylusTool(UBStylusTool::Selector); } +void UBDrawingController::playToolSelected(bool checked) +{ + if (checked) + setStylusTool(UBStylusTool::Play); +} + void UBDrawingController::handToolSelected(bool checked) { if (checked) diff --git a/src/board/UBDrawingController.h b/src/board/UBDrawingController.h index 4c620f1c..429c8b24 100644 --- a/src/board/UBDrawingController.h +++ b/src/board/UBDrawingController.h @@ -88,6 +88,7 @@ class UBDrawingController : public QObject void eraserToolSelected(bool checked); void markerToolSelected(bool checked); void selectorToolSelected(bool checked); + void playToolSelected(bool checked); void handToolSelected(bool checked); void zoomInToolSelected(bool checked); void zoomOutToolSelected(bool checked); diff --git a/src/core/UB.h b/src/core/UB.h index 46fa6e8c..21d635b0 100644 --- a/src/core/UB.h +++ b/src/core/UB.h @@ -28,6 +28,7 @@ struct UBStylusTool Eraser, Marker, Selector, + Play, Hand, ZoomIn, ZoomOut, diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index d1759d3f..ab92ab16 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -330,7 +330,9 @@ void UBGraphicsItemDelegate::positionHandles() showHide(shownOnDisplay); lock(isLocked()); updateFrame(); - mFrame->show(); + + if (UBStylusTool::Play != UBDrawingController::drawingController()->stylusTool()) + mFrame->show(); updateButtons(true); diff --git a/src/domain/UBGraphicsProxyWidget.cpp b/src/domain/UBGraphicsProxyWidget.cpp index 7b949b19..0ed4e3aa 100644 --- a/src/domain/UBGraphicsProxyWidget.cpp +++ b/src/domain/UBGraphicsProxyWidget.cpp @@ -82,9 +82,10 @@ void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) else { // QT Proxy Widget is a bit lazy, we force the selection ... - QGraphicsProxyWidget::mousePressEvent(event); + setSelected(true); } + QGraphicsProxyWidget::mousePressEvent(event); } diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 0542e598..d75da6a4 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -2366,8 +2366,9 @@ void UBGraphicsScene::createPointer() void UBGraphicsScene::setToolCursor(int tool) { - if (tool != (int)UBStylusTool::Selector - && tool != (int)UBStylusTool::Text) + if (tool == (int)UBStylusTool::Selector || + tool == (int)UBStylusTool::Text || + tool == (int)UBStylusTool::Play) { deselectAllItems(); } diff --git a/src/gui/UBStylusPalette.cpp b/src/gui/UBStylusPalette.cpp index 93073ccd..50da9720 100644 --- a/src/gui/UBStylusPalette.cpp +++ b/src/gui/UBStylusPalette.cpp @@ -39,6 +39,7 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient) actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionSelector; + actions << UBApplication::mainWindow->actionPlay; actions << UBApplication::mainWindow->actionHand; actions << UBApplication::mainWindow->actionZoomIn; diff --git a/src/tools/UBGraphicsCompass.cpp b/src/tools/UBGraphicsCompass.cpp index c0386d1a..f73fd274 100644 --- a/src/tools/UBGraphicsCompass.cpp +++ b/src/tools/UBGraphicsCompass.cpp @@ -170,7 +170,8 @@ QVariant UBGraphicsCompass::itemChange(GraphicsItemChange change, const QVariant void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && + UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; if (resizeButtonRect().contains(event->pos())) @@ -205,7 +206,8 @@ void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && + UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; if (!mResizing && !mRotating && !mDrawing) @@ -249,7 +251,8 @@ void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && + UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; if (mResizing) @@ -289,7 +292,8 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && + UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; mOuterCursor = cursor(); @@ -318,7 +322,8 @@ void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && + UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; mShowButtons = false; @@ -331,7 +336,8 @@ void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsCompass::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && + UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; mShowButtons = shape().contains(event->pos()); diff --git a/src/tools/UBGraphicsProtractor.cpp b/src/tools/UBGraphicsProtractor.cpp index f00bf275..3d38a21b 100644 --- a/src/tools/UBGraphicsProtractor.cpp +++ b/src/tools/UBGraphicsProtractor.cpp @@ -250,13 +250,19 @@ void UBGraphicsProtractor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (scene()) scene()->setModified(true); + if (!mShowButtons) + { + mShowButtons = true; + update(); + } + mCurrentTool = None; } void UBGraphicsProtractor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { - if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) + if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play) return; if (!mShowButtons) @@ -292,12 +298,6 @@ void UBGraphicsProtractor::hoverMoveEvent(QGraphicsSceneHoverEvent *event) Tool currentTool = toolFromPos(event->pos()); - if (!mShowButtons) - { - mShowButtons = true; - update(); - } - if (currentTool == Move) setCursor(Qt::SizeAllCursor); else diff --git a/src/tools/UBGraphicsRuler.cpp b/src/tools/UBGraphicsRuler.cpp index 720b7b22..97f37084 100644 --- a/src/tools/UBGraphicsRuler.cpp +++ b/src/tools/UBGraphicsRuler.cpp @@ -268,7 +268,7 @@ void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - if (currentTool == UBStylusTool::Selector) + if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play) { mCloseSvgItem->setVisible(mShowButtons); mResizeSvgItem->setVisible(mShowButtons); @@ -376,7 +376,8 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - if (currentTool == UBStylusTool::Selector) + if (currentTool == UBStylusTool::Selector || + currentTool == UBStylusTool::Play) { mCloseSvgItem->setParentItem(this); mResizeSvgItem->setParentItem(this); diff --git a/src/tools/UBGraphicsTriangle.cpp b/src/tools/UBGraphicsTriangle.cpp index ef946af7..57d77d7f 100644 --- a/src/tools/UBGraphicsTriangle.cpp +++ b/src/tools/UBGraphicsTriangle.cpp @@ -763,7 +763,9 @@ void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - if (currentTool == UBStylusTool::Selector) { + if (currentTool == UBStylusTool::Selector || + currentTool == UBStylusTool::Play) + { mCloseSvgItem->setParentItem(this); mShowButtons = true; @@ -813,7 +815,8 @@ void UBGraphicsTriangle::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - if (currentTool == UBStylusTool::Selector) + if (currentTool == UBStylusTool::Selector || + currentTool == UBStylusTool::Play) { mCloseSvgItem->setVisible(mShowButtons); mVFlipSvgItem->setVisible(mShowButtons);