SANKORE-283 fix cursor switching

preferencesAboutTextFull
Anatoly Mihalchenko 14 years ago
parent 0d12a17535
commit 15cfae37eb
  1. 6
      src/board/UBBoardView.cpp
  2. 1
      src/board/UBDrawingController.cpp
  3. 169
      src/desktop/UBDesktopAnnotationController.cpp
  4. 6
      src/desktop/UBDesktopAnnotationController.h

@ -532,10 +532,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
void void
UBBoardView::mouseReleaseEvent (QMouseEvent *event) UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
scene ()->setToolCursor (currentTool); scene ()->setToolCursor (currentTool);
setToolCursor (currentTool); setToolCursor (currentTool);
// first propagate device release to the scene // first propagate device release to the scene
if (scene ()) if (scene ())

@ -315,7 +315,6 @@ void UBDrawingController::penToolSelected(bool checked)
} }
} }
void UBDrawingController::eraserToolSelected(bool checked) void UBDrawingController::eraserToolSelected(bool checked)
{ {
if (checked) if (checked)

@ -42,6 +42,7 @@
#include "UBDesktopEraserPalette.h" #include "UBDesktopEraserPalette.h"
#include "gui/UBKeyboardPalette.h" #include "gui/UBKeyboardPalette.h"
#include "gui/UBResources.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -583,24 +584,26 @@ void UBDesktopAnnotationController::penActionReleased()
mPendingPenButtonPressed = false; mPendingPenButtonPressed = false;
} }
UBApplication::mainWindow->actionPen->setChecked(true); UBApplication::mainWindow->actionPen->setChecked(true);
switchCursor(UBStylusTool::Pen);
} }
/** /**
* \brief Handles the marker action pressed event * \brief Handles the eraser action pressed event
*/ */
void UBDesktopAnnotationController::markerActionPressed() void UBDesktopAnnotationController::eraserActionPressed()
{ {
mbArrowClicked = false; mbArrowClicked = false;
mDesktopPenPalette->hide(); mDesktopPenPalette->hide();
mDesktopEraserPalette->hide(); mDesktopMarkerPalette->hide();
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Marker); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Eraser);
mMarkerHoldTimer = QTime::currentTime(); mEraserHoldTimer = QTime::currentTime();
mPendingMarkerButtonPressed = true; mPendingEraserButtonPressed = true;
// Check if the mouse cursor is on the little arrow // Check if the mouse cursor is on the little arrow
QPoint cursorPos = QCursor::pos(); QPoint cursorPos = QCursor::pos();
QPoint palettePos = mDesktopPalette->pos(); QPoint palettePos = mDesktopPalette->pos();
QPoint buttonPos = mDesktopPalette->buttonPos(UBApplication::mainWindow->actionMarker); QPoint buttonPos = mDesktopPalette->buttonPos(UBApplication::mainWindow->actionEraser);
int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette
int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette
@ -608,52 +611,55 @@ void UBDesktopAnnotationController::markerActionPressed()
if(iX >= 37 && iX <= 44 && iY >= 37 && iY <= 44) if(iX >= 37 && iX <= 44 && iY >= 37 && iY <= 44)
{ {
mbArrowClicked = true; mbArrowClicked = true;
markerActionReleased(); eraserActionReleased();
} }
else else
{ {
mHoldTimerMarker.start(PROPERTY_PALETTE_TIMER); mHoldTimerEraser.start(PROPERTY_PALETTE_TIMER);
} }
} }
/** /**
* \brief Handles the marker action released event * \brief Handles the eraser action released event
*/ */
void UBDesktopAnnotationController::markerActionReleased() void UBDesktopAnnotationController::eraserActionReleased()
{ {
qDebug() << "markerActionReleased()"; qDebug() << "eraserActionReleased()";
mHoldTimerMarker.stop(); mHoldTimerEraser.stop();
if(mPendingMarkerButtonPressed) if(mPendingEraserButtonPressed)
{ {
if(mbArrowClicked || mMarkerHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100) if(mbArrowClicked || mEraserHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100)
{ {
togglePropertyPalette(mDesktopMarkerPalette); togglePropertyPalette(mDesktopEraserPalette);
} }
else else
{ {
UBApplication::mainWindow->actionMarker->trigger(); UBApplication::mainWindow->actionEraser->trigger();
} }
mPendingMarkerButtonPressed = false; mPendingEraserButtonPressed = false;
} }
UBApplication::mainWindow->actionMarker->setChecked(true); UBApplication::mainWindow->actionEraser->setChecked(true);
switchCursor(UBStylusTool::Eraser);
} }
/** /**
* \brief Handles the eraser action pressed event * \brief Handles the marker action pressed event
*/ */
void UBDesktopAnnotationController::eraserActionPressed() void UBDesktopAnnotationController::markerActionPressed()
{ {
mbArrowClicked = false; mbArrowClicked = false;
mDesktopPenPalette->hide(); mDesktopPenPalette->hide();
mDesktopMarkerPalette->hide(); mDesktopEraserPalette->hide();
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Eraser); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Marker);
mEraserHoldTimer = QTime::currentTime(); mMarkerHoldTimer = QTime::currentTime();
mPendingEraserButtonPressed = true; mPendingMarkerButtonPressed = true;
// Check if the mouse cursor is on the little arrow // Check if the mouse cursor is on the little arrow
QPoint cursorPos = QCursor::pos(); QPoint cursorPos = QCursor::pos();
QPoint palettePos = mDesktopPalette->pos(); QPoint palettePos = mDesktopPalette->pos();
QPoint buttonPos = mDesktopPalette->buttonPos(UBApplication::mainWindow->actionEraser); QPoint buttonPos = mDesktopPalette->buttonPos(UBApplication::mainWindow->actionMarker);
int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette int iX = cursorPos.x() - (palettePos.x() + buttonPos.x()); // x position of the cursor in the palette
int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette int iY = cursorPos.y() - (palettePos.y() + buttonPos.y()); // y position of the cursor in the palette
@ -661,38 +667,63 @@ void UBDesktopAnnotationController::eraserActionPressed()
if(iX >= 37 && iX <= 44 && iY >= 37 && iY <= 44) if(iX >= 37 && iX <= 44 && iY >= 37 && iY <= 44)
{ {
mbArrowClicked = true; mbArrowClicked = true;
eraserActionReleased(); markerActionReleased();
} }
else else
{ {
mHoldTimerEraser.start(PROPERTY_PALETTE_TIMER); mHoldTimerMarker.start(PROPERTY_PALETTE_TIMER);
} }
} }
/** /**
* \brief Handles the eraser action released event * \brief Handles the marker action released event
*/ */
void UBDesktopAnnotationController::eraserActionReleased() void UBDesktopAnnotationController::markerActionReleased()
{ {
qDebug() << "eraserActionReleased()"; qDebug() << "markerActionReleased()";
mHoldTimerEraser.stop(); mHoldTimerMarker.stop();
if(mPendingEraserButtonPressed) if(mPendingMarkerButtonPressed)
{ {
if(mbArrowClicked || mEraserHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100) if(mbArrowClicked || mMarkerHoldTimer.msecsTo(QTime::currentTime()) > PROPERTY_PALETTE_TIMER - 100)
{ {
togglePropertyPalette(mDesktopEraserPalette); togglePropertyPalette(mDesktopMarkerPalette);
} }
else else
{ {
UBApplication::mainWindow->actionEraser->trigger(); UBApplication::mainWindow->actionMarker->trigger();
} }
mPendingEraserButtonPressed = false; mPendingMarkerButtonPressed = false;
} }
UBApplication::mainWindow->actionEraser->setChecked(true); UBApplication::mainWindow->actionMarker->setChecked(true);
switchCursor(UBStylusTool::Marker);
}
void UBDesktopAnnotationController::selectorActionPressed()
{
}
void UBDesktopAnnotationController::selectorActionReleased()
{
switchCursor(UBStylusTool::Selector);
}
void UBDesktopAnnotationController::pointerActionPressed()
{
}
void UBDesktopAnnotationController::pointerActionReleased()
{
switchCursor(UBStylusTool::Pointer);
} }
/** /**
* \brief Toggle the given palette visiblity * \brief Toggle the given palette visibility
* @param palette as the given palette * @param palette as the given palette
*/ */
void UBDesktopAnnotationController::togglePropertyPalette(UBActionPalette *palette) void UBDesktopAnnotationController::togglePropertyPalette(UBActionPalette *palette)
@ -715,11 +746,34 @@ void UBDesktopAnnotationController::togglePropertyPalette(UBActionPalette *palet
} }
} }
void UBDesktopAnnotationController::switchCursor(const int tool)
{
// enum Enum
// {
// Pen = 0,
// Eraser,
// Marker,
// Selector,
// Hand,
// ZoomIn,
// ZoomOut,
// Pointer,
// Line,
// Text,
// Capture
// };
mTransparentDrawingScene->setToolCursor(tool);
mTransparentDrawingView->setToolCursor(tool);
}
/** /**
* \brief Reconnect the pressed & released signals of the property palettes * \brief Reconnect the pressed & released signals of the property palettes
*/ */
void UBDesktopAnnotationController::onDesktopPaletteMaximized() void UBDesktopAnnotationController::onDesktopPaletteMaximized()
{ {
// Pen // Pen
UBActionPaletteButton* pPenButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionPen); UBActionPaletteButton* pPenButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionPen);
if(NULL != pPenButton) if(NULL != pPenButton)
@ -728,6 +782,14 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized()
connect(pPenButton, SIGNAL(released()), this, SLOT(penActionReleased())); connect(pPenButton, SIGNAL(released()), this, SLOT(penActionReleased()));
} }
// Eraser
UBActionPaletteButton* pEraserButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionEraser);
if(NULL != pEraserButton)
{
connect(pEraserButton, SIGNAL(pressed()), this, SLOT(eraserActionPressed()));
connect(pEraserButton, SIGNAL(released()), this, SLOT(eraserActionReleased()));
}
// Marker // Marker
UBActionPaletteButton* pMarkerButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionMarker); UBActionPaletteButton* pMarkerButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionMarker);
if(NULL != pMarkerButton) if(NULL != pMarkerButton)
@ -736,13 +798,32 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized()
connect(pMarkerButton, SIGNAL(released()), this, SLOT(markerActionReleased())); connect(pMarkerButton, SIGNAL(released()), this, SLOT(markerActionReleased()));
} }
// Eraser // Pointer
UBActionPaletteButton* pEraserButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionEraser); UBActionPaletteButton* pSelectorButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionSelector);
if(NULL != pEraserButton) if(NULL != pSelectorButton)
{ {
connect(pEraserButton, SIGNAL(pressed()), this, SLOT(eraserActionPressed())); connect(pSelectorButton, SIGNAL(pressed()), this, SLOT(selectorActionPressed()));
connect(pEraserButton, SIGNAL(released()), this, SLOT(eraserActionReleased())); connect(pSelectorButton, SIGNAL(released()), this, SLOT(selectorActionReleased()));
} }
// Pointer
UBActionPaletteButton* pPointerButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionPointer);
if(NULL != pPointerButton)
{
connect(pPointerButton, SIGNAL(pressed()), this, SLOT(pointerActionPressed()));
connect(pPointerButton, SIGNAL(released()), this, SLOT(pointerActionReleased()));
}
// enum Enum
// {
// Hand,
// ZoomIn,
// ZoomOut,
// Line,
// Text,
// Capture
// };
} }
/** /**

@ -98,6 +98,12 @@ class UBDesktopAnnotationController : public QObject
void penActionReleased(); void penActionReleased();
void markerActionReleased(); void markerActionReleased();
void eraserActionReleased(); void eraserActionReleased();
void selectorActionPressed();
void selectorActionReleased();
void pointerActionPressed();
void pointerActionReleased();
void switchCursor(int tool);
void onDesktopPaletteMaximized(); void onDesktopPaletteMaximized();
void onDesktopPaletteMinimize(); void onDesktopPaletteMinimize();
void onTransparentWidgetResized(); void onTransparentWidgetResized();

Loading…
Cancel
Save