Commit aa594554 authored by Aleksei Kanash's avatar Aleksei Kanash

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).
parent 47cdb048
...@@ -1649,6 +1649,22 @@ ...@@ -1649,6 +1649,22 @@
<string>Group items</string> <string>Group items</string>
</property> </property>
</action> </action>
<action name="actionPlay">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/stylusPalette/handPlay.png</normaloff>
<normalon>:/images/stylusPalette/handPlayOn.png</normalon>:/images/stylusPalette/handPlay.png</iconset>
</property>
<property name="text">
<string>Play</string>
</property>
<property name="toolTip">
<string>Interact with items</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../sankore.qrc"/> <include location="../sankore.qrc"/>
......
...@@ -125,6 +125,8 @@ ...@@ -125,6 +125,8 @@
<file>images/toolbar/tools.png</file> <file>images/toolbar/tools.png</file>
<file>images/stylusPalette/arrow.png</file> <file>images/stylusPalette/arrow.png</file>
<file>images/stylusPalette/arrowOn.png</file> <file>images/stylusPalette/arrowOn.png</file>
<file>images/stylusPalette/handPlay.png</file>
<file>images/stylusPalette/handPlayOn.png</file>
<file>images/stylusPalette/eraser.png</file> <file>images/stylusPalette/eraser.png</file>
<file>images/stylusPalette/eraserOn.png</file> <file>images/stylusPalette/eraserOn.png</file>
<file>images/stylusPalette/hand.png</file> <file>images/stylusPalette/hand.png</file>
......
...@@ -123,6 +123,10 @@ void UBWidgetUniboardAPI::setTool(const QString& toolString) ...@@ -123,6 +123,10 @@ void UBWidgetUniboardAPI::setTool(const QString& toolString)
{ {
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
else if (lower == "play")
{
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Play);
}
else if (lower == "line") else if (lower == "line")
{ {
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line);
......
...@@ -453,6 +453,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -453,6 +453,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
} }
event->accept();
}
else if (currentTool == UBStylusTool::Play)
{
QGraphicsView::mousePressEvent (event);
event->accept(); event->accept();
} }
else if (currentTool == UBStylusTool::Text) else if (currentTool == UBStylusTool::Text)
...@@ -584,6 +590,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) ...@@ -584,6 +590,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
} }
else QGraphicsView::mouseMoveEvent (event); else QGraphicsView::mouseMoveEvent (event);
} }
else if (currentTool == UBStylusTool::Play)
{
QGraphicsView::mouseMoveEvent (event);
}
else if ((UBDrawingController::drawingController()->isDrawingTool()) else if ((UBDrawingController::drawingController()->isDrawingTool())
&& !mMouseButtonIsPressed) && !mMouseButtonIsPressed)
{ {
...@@ -616,9 +626,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) ...@@ -616,9 +626,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
scene ()->setToolCursor (currentTool);
setToolCursor (currentTool);
// first propagate device release to the scene // first propagate device release to the scene
if (scene ()) if (scene ())
scene ()->inputDeviceRelease (); scene ()->inputDeviceRelease ();
...@@ -644,6 +651,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) ...@@ -644,6 +651,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
} }
else if (currentTool == UBStylusTool::Play)
{
QGraphicsView::mouseReleaseEvent (event);
}
else if (currentTool == UBStylusTool::Text) else if (currentTool == UBStylusTool::Text)
{ {
if (mRubberBand) if (mRubberBand)
...@@ -1027,6 +1038,9 @@ UBBoardView::setToolCursor (int tool) ...@@ -1027,6 +1038,9 @@ UBBoardView::setToolCursor (int tool)
case UBStylusTool::Selector: case UBStylusTool::Selector:
controlViewport->setCursor (UBResources::resources ()->arrowCursor); controlViewport->setCursor (UBResources::resources ()->arrowCursor);
break; break;
case UBStylusTool::Play:
controlViewport->setCursor (UBResources::resources ()->drawLineRulerCursor);
break;
case UBStylusTool::Line: case UBStylusTool::Line:
controlViewport->setCursor (UBResources::resources ()->penCursor); controlViewport->setCursor (UBResources::resources ()->penCursor);
break; break;
......
...@@ -54,6 +54,7 @@ UBDrawingController::UBDrawingController(QObject * parent) ...@@ -54,6 +54,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionEraser, SIGNAL(triggered(bool)), this, SLOT(eraserToolSelected(bool))); 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->actionMarker, SIGNAL(triggered(bool)), this, SLOT(markerToolSelected(bool)));
connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(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->actionHand, SIGNAL(triggered(bool)), this, SLOT(handToolSelected(bool)));
connect(UBApplication::mainWindow->actionZoomIn, SIGNAL(triggered(bool)), this, SLOT(zoomInToolSelected(bool))); connect(UBApplication::mainWindow->actionZoomIn, SIGNAL(triggered(bool)), this, SLOT(zoomInToolSelected(bool)));
connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool))); connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool)));
...@@ -120,6 +121,8 @@ void UBDrawingController::setStylusTool(int tool) ...@@ -120,6 +121,8 @@ void UBDrawingController::setStylusTool(int tool)
UBApplication::mainWindow->actionMarker->setChecked(true); UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector) else if (mStylusTool == UBStylusTool::Selector)
UBApplication::mainWindow->actionSelector->setChecked(true); UBApplication::mainWindow->actionSelector->setChecked(true);
else if (mStylusTool == UBStylusTool::Play)
UBApplication::mainWindow->actionPlay->setChecked(true);
else if (mStylusTool == UBStylusTool::Hand) else if (mStylusTool == UBStylusTool::Hand)
UBApplication::mainWindow->actionHand->setChecked(true); UBApplication::mainWindow->actionHand->setChecked(true);
else if (mStylusTool == UBStylusTool::ZoomIn) else if (mStylusTool == UBStylusTool::ZoomIn)
...@@ -347,6 +350,12 @@ void UBDrawingController::selectorToolSelected(bool checked) ...@@ -347,6 +350,12 @@ void UBDrawingController::selectorToolSelected(bool checked)
setStylusTool(UBStylusTool::Selector); setStylusTool(UBStylusTool::Selector);
} }
void UBDrawingController::playToolSelected(bool checked)
{
if (checked)
setStylusTool(UBStylusTool::Play);
}
void UBDrawingController::handToolSelected(bool checked) void UBDrawingController::handToolSelected(bool checked)
{ {
if (checked) if (checked)
......
...@@ -88,6 +88,7 @@ class UBDrawingController : public QObject ...@@ -88,6 +88,7 @@ class UBDrawingController : public QObject
void eraserToolSelected(bool checked); void eraserToolSelected(bool checked);
void markerToolSelected(bool checked); void markerToolSelected(bool checked);
void selectorToolSelected(bool checked); void selectorToolSelected(bool checked);
void playToolSelected(bool checked);
void handToolSelected(bool checked); void handToolSelected(bool checked);
void zoomInToolSelected(bool checked); void zoomInToolSelected(bool checked);
void zoomOutToolSelected(bool checked); void zoomOutToolSelected(bool checked);
......
...@@ -28,6 +28,7 @@ struct UBStylusTool ...@@ -28,6 +28,7 @@ struct UBStylusTool
Eraser, Eraser,
Marker, Marker,
Selector, Selector,
Play,
Hand, Hand,
ZoomIn, ZoomIn,
ZoomOut, ZoomOut,
......
...@@ -330,7 +330,9 @@ void UBGraphicsItemDelegate::positionHandles() ...@@ -330,7 +330,9 @@ void UBGraphicsItemDelegate::positionHandles()
showHide(shownOnDisplay); showHide(shownOnDisplay);
lock(isLocked()); lock(isLocked());
updateFrame(); updateFrame();
mFrame->show();
if (UBStylusTool::Play != UBDrawingController::drawingController()->stylusTool())
mFrame->show();
updateButtons(true); updateButtons(true);
......
...@@ -82,9 +82,10 @@ void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) ...@@ -82,9 +82,10 @@ void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
else else
{ {
// QT Proxy Widget is a bit lazy, we force the selection ... // QT Proxy Widget is a bit lazy, we force the selection ...
QGraphicsProxyWidget::mousePressEvent(event);
setSelected(true); setSelected(true);
} }
QGraphicsProxyWidget::mousePressEvent(event);
} }
......
...@@ -2366,8 +2366,9 @@ void UBGraphicsScene::createPointer() ...@@ -2366,8 +2366,9 @@ void UBGraphicsScene::createPointer()
void UBGraphicsScene::setToolCursor(int tool) void UBGraphicsScene::setToolCursor(int tool)
{ {
if (tool != (int)UBStylusTool::Selector if (tool == (int)UBStylusTool::Selector ||
&& tool != (int)UBStylusTool::Text) tool == (int)UBStylusTool::Text ||
tool == (int)UBStylusTool::Play)
{ {
deselectAllItems(); deselectAllItems();
} }
......
...@@ -39,6 +39,7 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient) ...@@ -39,6 +39,7 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
actions << UBApplication::mainWindow->actionPlay;
actions << UBApplication::mainWindow->actionHand; actions << UBApplication::mainWindow->actionHand;
actions << UBApplication::mainWindow->actionZoomIn; actions << UBApplication::mainWindow->actionZoomIn;
......
...@@ -170,7 +170,8 @@ QVariant UBGraphicsCompass::itemChange(GraphicsItemChange change, const QVariant ...@@ -170,7 +170,8 @@ QVariant UBGraphicsCompass::itemChange(GraphicsItemChange change, const QVariant
void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
if (resizeButtonRect().contains(event->pos())) if (resizeButtonRect().contains(event->pos()))
...@@ -205,7 +206,8 @@ void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event) ...@@ -205,7 +206,8 @@ void UBGraphicsCompass::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCompass::mouseMoveEvent(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; return;
if (!mResizing && !mRotating && !mDrawing) if (!mResizing && !mRotating && !mDrawing)
...@@ -249,7 +251,8 @@ void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -249,7 +251,8 @@ void UBGraphicsCompass::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCompass::mouseReleaseEvent(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; return;
if (mResizing) if (mResizing)
...@@ -289,7 +292,8 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ...@@ -289,7 +292,8 @@ void UBGraphicsCompass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector &&
UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
mOuterCursor = cursor(); mOuterCursor = cursor();
...@@ -318,7 +322,8 @@ void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event) ...@@ -318,7 +322,8 @@ void UBGraphicsCompass::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsCompass::hoverLeaveEvent(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; return;
mShowButtons = false; mShowButtons = false;
...@@ -331,7 +336,8 @@ void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) ...@@ -331,7 +336,8 @@ void UBGraphicsCompass::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsCompass::hoverMoveEvent(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; return;
mShowButtons = shape().contains(event->pos()); mShowButtons = shape().contains(event->pos());
......
...@@ -250,13 +250,19 @@ void UBGraphicsProtractor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ...@@ -250,13 +250,19 @@ void UBGraphicsProtractor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (scene()) if (scene())
scene()->setModified(true); scene()->setModified(true);
if (!mShowButtons)
{
mShowButtons = true;
update();
}
mCurrentTool = None; mCurrentTool = None;
} }
void UBGraphicsProtractor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsProtractor::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector) if (UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Selector && UBDrawingController::drawingController ()->stylusTool() != UBStylusTool::Play)
return; return;
if (!mShowButtons) if (!mShowButtons)
...@@ -292,12 +298,6 @@ void UBGraphicsProtractor::hoverMoveEvent(QGraphicsSceneHoverEvent *event) ...@@ -292,12 +298,6 @@ void UBGraphicsProtractor::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
Tool currentTool = toolFromPos(event->pos()); Tool currentTool = toolFromPos(event->pos());
if (!mShowButtons)
{
mShowButtons = true;
update();
}
if (currentTool == Move) if (currentTool == Move)
setCursor(Qt::SizeAllCursor); setCursor(Qt::SizeAllCursor);
else else
......
...@@ -268,7 +268,7 @@ void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event) ...@@ -268,7 +268,7 @@ void UBGraphicsRuler::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play)
{ {
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
mResizeSvgItem->setVisible(mShowButtons); mResizeSvgItem->setVisible(mShowButtons);
...@@ -376,7 +376,8 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event) ...@@ -376,7 +376,8 @@ void UBGraphicsRuler::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play)
{ {
mCloseSvgItem->setParentItem(this); mCloseSvgItem->setParentItem(this);
mResizeSvgItem->setParentItem(this); mResizeSvgItem->setParentItem(this);
......
...@@ -763,7 +763,9 @@ void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event) ...@@ -763,7 +763,9 @@ void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) { if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play)
{
mCloseSvgItem->setParentItem(this); mCloseSvgItem->setParentItem(this);
mShowButtons = true; mShowButtons = true;
...@@ -813,7 +815,8 @@ void UBGraphicsTriangle::hoverMoveEvent(QGraphicsSceneHoverEvent *event) ...@@ -813,7 +815,8 @@ void UBGraphicsTriangle::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector ||
currentTool == UBStylusTool::Play)
{ {
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
mVFlipSvgItem->setVisible(mShowButtons); mVFlipSvgItem->setVisible(mShowButtons);
......
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