|
|
|
@ -42,6 +42,7 @@ |
|
|
|
|
#include "UBDesktopEraserPalette.h" |
|
|
|
|
|
|
|
|
|
#include "gui/UBKeyboardPalette.h" |
|
|
|
|
#include "gui/UBResources.h" |
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
@ -583,24 +584,26 @@ void UBDesktopAnnotationController::penActionReleased() |
|
|
|
|
mPendingPenButtonPressed = false; |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
mDesktopPenPalette->hide(); |
|
|
|
|
mDesktopEraserPalette->hide(); |
|
|
|
|
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Marker); |
|
|
|
|
mMarkerHoldTimer = QTime::currentTime(); |
|
|
|
|
mPendingMarkerButtonPressed = true; |
|
|
|
|
mDesktopMarkerPalette->hide(); |
|
|
|
|
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Eraser); |
|
|
|
|
mEraserHoldTimer = QTime::currentTime(); |
|
|
|
|
mPendingEraserButtonPressed = true; |
|
|
|
|
|
|
|
|
|
// Check if the mouse cursor is on the little arrow
|
|
|
|
|
QPoint cursorPos = QCursor::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 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) |
|
|
|
|
{ |
|
|
|
|
mbArrowClicked = true; |
|
|
|
|
markerActionReleased(); |
|
|
|
|
eraserActionReleased(); |
|
|
|
|
} |
|
|
|
|
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()"; |
|
|
|
|
mHoldTimerMarker.stop(); |
|
|
|
|
if(mPendingMarkerButtonPressed) |
|
|
|
|
qDebug() << "eraserActionReleased()"; |
|
|
|
|
mHoldTimerEraser.stop(); |
|
|
|
|
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 |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
mDesktopPenPalette->hide(); |
|
|
|
|
mDesktopMarkerPalette->hide(); |
|
|
|
|
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Eraser); |
|
|
|
|
mEraserHoldTimer = QTime::currentTime(); |
|
|
|
|
mPendingEraserButtonPressed = true; |
|
|
|
|
mDesktopEraserPalette->hide(); |
|
|
|
|
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Marker); |
|
|
|
|
mMarkerHoldTimer = QTime::currentTime(); |
|
|
|
|
mPendingMarkerButtonPressed = true; |
|
|
|
|
|
|
|
|
|
// Check if the mouse cursor is on the little arrow
|
|
|
|
|
QPoint cursorPos = QCursor::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 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) |
|
|
|
|
{ |
|
|
|
|
mbArrowClicked = true; |
|
|
|
|
eraserActionReleased(); |
|
|
|
|
markerActionReleased(); |
|
|
|
|
} |
|
|
|
|
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()"; |
|
|
|
|
mHoldTimerEraser.stop(); |
|
|
|
|
if(mPendingEraserButtonPressed) |
|
|
|
|
qDebug() << "markerActionReleased()"; |
|
|
|
|
mHoldTimerMarker.stop(); |
|
|
|
|
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 |
|
|
|
|
{ |
|
|
|
|
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 |
|
|
|
|
*/ |
|
|
|
|
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 |
|
|
|
|
*/ |
|
|
|
|
void UBDesktopAnnotationController::onDesktopPaletteMaximized() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// Pen
|
|
|
|
|
UBActionPaletteButton* pPenButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionPen); |
|
|
|
|
if(NULL != pPenButton) |
|
|
|
@ -728,6 +782,14 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized() |
|
|
|
|
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
|
|
|
|
|
UBActionPaletteButton* pMarkerButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionMarker); |
|
|
|
|
if(NULL != pMarkerButton) |
|
|
|
@ -736,13 +798,32 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized() |
|
|
|
|
connect(pMarkerButton, SIGNAL(released()), this, SLOT(markerActionReleased())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Eraser
|
|
|
|
|
UBActionPaletteButton* pEraserButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionEraser); |
|
|
|
|
if(NULL != pEraserButton) |
|
|
|
|
// Pointer
|
|
|
|
|
UBActionPaletteButton* pSelectorButton = mDesktopPalette->getButtonFromAction(UBApplication::mainWindow->actionSelector); |
|
|
|
|
if(NULL != pSelectorButton) |
|
|
|
|
{ |
|
|
|
|
connect(pEraserButton, SIGNAL(pressed()), this, SLOT(eraserActionPressed())); |
|
|
|
|
connect(pEraserButton, SIGNAL(released()), this, SLOT(eraserActionReleased())); |
|
|
|
|
connect(pSelectorButton, SIGNAL(pressed()), this, SLOT(selectorActionPressed())); |
|
|
|
|
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
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|