Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
4f3b163b
Commit
4f3b163b
authored
Aug 15, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the desktop mode for Linux
parent
80ceb222
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1005 additions
and
886 deletions
+1005
-886
UBBoardView.cpp
src/board/UBBoardView.cpp
+879
-879
UBDesktopAnnotationController.cpp
src/desktop/UBDesktopAnnotationController.cpp
+106
-1
UBDesktopAnnotationController.h
src/desktop/UBDesktopAnnotationController.h
+4
-0
UBDesktopPalette.cpp
src/desktop/UBDesktopPalette.cpp
+5
-4
UBDesktopPalette.h
src/desktop/UBDesktopPalette.h
+1
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+3
-1
UBFloatingPalette.cpp
src/gui/UBFloatingPalette.cpp
+1
-0
UBFloatingPalette.h
src/gui/UBFloatingPalette.h
+1
-0
UBLibPalette.cpp
src/gui/UBLibPalette.cpp
+2
-1
UBLibPalette.h
src/gui/UBLibPalette.h
+3
-0
No files found.
src/board/UBBoardView.cpp
View file @
4f3b163b
...
@@ -13,882 +13,882 @@
...
@@ -13,882 +13,882 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "UBBoardView.h"
#include "UBBoardView.h"
#include <QtGui>
#include <QtGui>
#include "UBDrawingController.h"
#include "UBDrawingController.h"
#include "frameworks/UBGeometryUtils.h"
#include "frameworks/UBGeometryUtils.h"
#include "core/UBSettings.h"
#include "core/UBSettings.h"
#include "core/UBMimeData.h"
#include "core/UBMimeData.h"
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "core/UBSetting.h"
#include "core/UBSetting.h"
#include "core/UBPersistenceManager.h"
#include "core/UBPersistenceManager.h"
#include "network/UBHttpGet.h"
#include "network/UBHttpGet.h"
#include "gui/UBStylusPalette.h"
#include "gui/UBStylusPalette.h"
#include "gui/UBRubberBand.h"
#include "gui/UBRubberBand.h"
#include "gui/UBToolWidget.h"
#include "gui/UBToolWidget.h"
#include "gui/UBResources.h"
#include "gui/UBResources.h"
#include "gui/UBMainWindow.h"
#include "gui/UBMainWindow.h"
#include "board/UBBoardController.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBItem.h"
#include "domain/UBItem.h"
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentProxy.h"
#include "../gui/UBThumbnailWidget.h"
#include "../gui/UBThumbnailWidget.h"
#include "frameworks/UBPlatformUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
QWidget
*
pParent
)
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
QWidget
*
pParent
)
:
QGraphicsView
(
pParent
)
:
QGraphicsView
(
pParent
)
,
mController
(
pController
)
,
mController
(
pController
)
,
mIsCreatingTextZone
(
false
)
,
mIsCreatingTextZone
(
false
)
,
mIsCreatingSceneGrabZone
(
false
)
,
mIsCreatingSceneGrabZone
(
false
)
{
{
init
();
init
();
mFilterZIndex
=
false
;
mFilterZIndex
=
false
;
}
}
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
int
pStartLayer
,
int
pEndLayer
,
QWidget
*
pParent
)
UBBoardView
::
UBBoardView
(
UBBoardController
*
pController
,
int
pStartLayer
,
int
pEndLayer
,
QWidget
*
pParent
)
:
QGraphicsView
(
pParent
)
:
QGraphicsView
(
pParent
)
,
mController
(
pController
)
,
mController
(
pController
)
{
{
init
();
init
();
mStartLayer
=
pStartLayer
;
mStartLayer
=
pStartLayer
;
mEndLayer
=
pEndLayer
;
mEndLayer
=
pEndLayer
;
mFilterZIndex
=
true
;
mFilterZIndex
=
true
;
}
}
UBBoardView
::~
UBBoardView
()
{
UBBoardView
::~
UBBoardView
()
{
//NOOP
//NOOP
}
}
void
void
UBBoardView
::
init
()
UBBoardView
::
init
()
{
{
connect
(
UBSettings
::
settings
()
->
boardPenPressureSensitive
,
SIGNAL
(
changed
(
QVariant
)),
connect
(
UBSettings
::
settings
()
->
boardPenPressureSensitive
,
SIGNAL
(
changed
(
QVariant
)),
this
,
SLOT
(
settingChanged
(
QVariant
)));
this
,
SLOT
(
settingChanged
(
QVariant
)));
connect
(
UBSettings
::
settings
()
->
boardMarkerPressureSensitive
,
SIGNAL
(
changed
(
QVariant
)),
connect
(
UBSettings
::
settings
()
->
boardMarkerPressureSensitive
,
SIGNAL
(
changed
(
QVariant
)),
this
,
SLOT
(
settingChanged
(
QVariant
)));
this
,
SLOT
(
settingChanged
(
QVariant
)));
connect
(
UBSettings
::
settings
()
->
boardUseHighResTabletEvent
,
SIGNAL
(
changed
(
QVariant
)),
connect
(
UBSettings
::
settings
()
->
boardUseHighResTabletEvent
,
SIGNAL
(
changed
(
QVariant
)),
this
,
SLOT
(
settingChanged
(
QVariant
)));
this
,
SLOT
(
settingChanged
(
QVariant
)));
setWindowFlags
(
Qt
::
FramelessWindowHint
);
setWindowFlags
(
Qt
::
FramelessWindowHint
);
setFrameStyle
(
QFrame
::
NoFrame
);
setFrameStyle
(
QFrame
::
NoFrame
);
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
|
QPainter
::
TextAntialiasing
);
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
|
QPainter
::
TextAntialiasing
);
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
setAcceptDrops
(
true
);
setAcceptDrops
(
true
);
setOptimizationFlag
(
QGraphicsView
::
IndirectPainting
);
// enable UBBoardView::drawItems filter
setOptimizationFlag
(
QGraphicsView
::
IndirectPainting
);
// enable UBBoardView::drawItems filter
mTabletStylusIsPressed
=
false
;
mTabletStylusIsPressed
=
false
;
mMouseButtonIsPressed
=
false
;
mMouseButtonIsPressed
=
false
;
mPendingStylusReleaseEvent
=
false
;
mPendingStylusReleaseEvent
=
false
;
setCacheMode
(
QGraphicsView
::
CacheBackground
);
setCacheMode
(
QGraphicsView
::
CacheBackground
);
mUsingTabletEraser
=
false
;
mUsingTabletEraser
=
false
;
mIsCreatingTextZone
=
false
;
mIsCreatingTextZone
=
false
;
mRubberBand
=
0
;
mRubberBand
=
0
;
mVirtualKeyboardActive
=
false
;
mVirtualKeyboardActive
=
false
;
settingChanged
(
QVariant
());
settingChanged
(
QVariant
());
unsetCursor
();
unsetCursor
();
}
}
UBGraphicsScene
*
UBGraphicsScene
*
UBBoardView
::
scene
()
UBBoardView
::
scene
()
{
{
return
qobject_cast
<
UBGraphicsScene
*>
(
QGraphicsView
::
scene
());
return
qobject_cast
<
UBGraphicsScene
*>
(
QGraphicsView
::
scene
());
}
}
void
void
UBBoardView
::
hideEvent
(
QHideEvent
*
event
)
UBBoardView
::
hideEvent
(
QHideEvent
*
event
)
{
{
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
emit
hidden
();
emit
hidden
();
}
}
void
void
UBBoardView
::
showEvent
(
QShowEvent
*
event
)
UBBoardView
::
showEvent
(
QShowEvent
*
event
)
{
{
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
emit
shown
();
emit
shown
();
}
}
void
void
UBBoardView
::
keyPressEvent
(
QKeyEvent
*
event
)
UBBoardView
::
keyPressEvent
(
QKeyEvent
*
event
)
{
{
// send to the scene anyway
// send to the scene anyway
QApplication
::
sendEvent
(
scene
(),
event
);
QApplication
::
sendEvent
(
scene
(),
event
);
if
(
!
event
->
isAccepted
())
if
(
!
event
->
isAccepted
())
{
{
switch
(
event
->
key
())
switch
(
event
->
key
())
{
{
case
Qt
:
:
Key_Up
:
case
Qt
:
:
Key_Up
:
case
Qt
:
:
Key_PageUp
:
case
Qt
:
:
Key_PageUp
:
case
Qt
:
:
Key_Left
:
case
Qt
:
:
Key_Left
:
{
{
mController
->
previousScene
();
mController
->
previousScene
();
break
;
break
;
}
}
case
Qt
:
:
Key_Down
:
case
Qt
:
:
Key_Down
:
case
Qt
:
:
Key_PageDown
:
case
Qt
:
:
Key_PageDown
:
case
Qt
:
:
Key_Right
:
case
Qt
:
:
Key_Right
:
case
Qt
:
:
Key_Space
:
case
Qt
:
:
Key_Space
:
{
{
mController
->
nextScene
();
mController
->
nextScene
();
break
;
break
;
}
}
case
Qt
:
:
Key_Home
:
case
Qt
:
:
Key_Home
:
{
{
mController
->
firstScene
();
mController
->
firstScene
();
break
;
break
;
}
}
case
Qt
:
:
Key_End
:
case
Qt
:
:
Key_End
:
{
{
mController
->
lastScene
();
mController
->
lastScene
();
break
;
break
;
}
}
case
Qt
:
:
Key_Insert
:
case
Qt
:
:
Key_Insert
:
{
{
mController
->
addScene
();
mController
->
addScene
();
break
;
break
;
}
}
}
}
if
(
event
->
modifiers
()
&
Qt
::
ControlModifier
)
// keep only ctrl/cmd keys
if
(
event
->
modifiers
()
&
Qt
::
ControlModifier
)
// keep only ctrl/cmd keys
{
{
switch
(
event
->
key
())
switch
(
event
->
key
())
{
{
case
Qt
:
:
Key_Plus
:
case
Qt
:
:
Key_Plus
:
case
Qt
:
:
Key_I
:
case
Qt
:
:
Key_I
:
{
{
mController
->
zoomIn
();
mController
->
zoomIn
();
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
case
Qt
:
:
Key_Minus
:
case
Qt
:
:
Key_Minus
:
case
Qt
:
:
Key_O
:
case
Qt
:
:
Key_O
:
{
{
mController
->
zoomOut
();
mController
->
zoomOut
();
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
case
Qt
:
:
Key_0
:
case
Qt
:
:
Key_0
:
{
{
mController
->
zoomRestore
();
mController
->
zoomRestore
();
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
case
Qt
:
:
Key_Left
:
case
Qt
:
:
Key_Left
:
{
{
mController
->
handScroll
(
-
100
,
0
);
mController
->
handScroll
(
-
100
,
0
);
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
case
Qt
:
:
Key_Right
:
case
Qt
:
:
Key_Right
:
{
{
mController
->
handScroll
(
100
,
0
);
mController
->
handScroll
(
100
,
0
);
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
case
Qt
:
:
Key_Up
:
case
Qt
:
:
Key_Up
:
{
{
mController
->
handScroll
(
0
,
-
100
);
mController
->
handScroll
(
0
,
-
100
);
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
case
Qt
:
:
Key_Down
:
case
Qt
:
:
Key_Down
:
{
{
mController
->
handScroll
(
0
,
100
);
mController
->
handScroll
(
0
,
100
);
event
->
accept
();
event
->
accept
();
break
;
break
;
}
}
default
:
default
:
{
{
// NOOP
// NOOP
}
}
}
}
}
}
}
}
}
}
bool
bool
UBBoardView
::
event
(
QEvent
*
e
)
UBBoardView
::
event
(
QEvent
*
e
)
{
{
if
(
e
->
type
()
==
QEvent
::
Gesture
)
if
(
e
->
type
()
==
QEvent
::
Gesture
)
{
{
QGestureEvent
*
gestureEvent
=
dynamic_cast
<
QGestureEvent
*>
(
e
);
QGestureEvent
*
gestureEvent
=
dynamic_cast
<
QGestureEvent
*>
(
e
);
if
(
gestureEvent
)
if
(
gestureEvent
)
{
{
QSwipeGesture
*
swipe
=
dynamic_cast
<
QSwipeGesture
*>
(
gestureEvent
->
gesture
(
Qt
::
SwipeGesture
));
QSwipeGesture
*
swipe
=
dynamic_cast
<
QSwipeGesture
*>
(
gestureEvent
->
gesture
(
Qt
::
SwipeGesture
));
if
(
swipe
)
if
(
swipe
)
{
{
if
(
swipe
->
horizontalDirection
()
==
QSwipeGesture
::
Left
)
if
(
swipe
->
horizontalDirection
()
==
QSwipeGesture
::
Left
)
{
{
mController
->
previousScene
();
mController
->
previousScene
();
gestureEvent
->
setAccepted
(
swipe
,
true
);
gestureEvent
->
setAccepted
(
swipe
,
true
);
}
}
if
(
swipe
->
horizontalDirection
()
==
QSwipeGesture
::
Right
)
if
(
swipe
->
horizontalDirection
()
==
QSwipeGesture
::
Right
)
{
{
mController
->
nextScene
();
mController
->
nextScene
();
gestureEvent
->
setAccepted
(
swipe
,
true
);
gestureEvent
->
setAccepted
(
swipe
,
true
);
}
}
}
}
}
}
}
}
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
;
}
}
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
());
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
::
Line
&&
currentTool
!=
UBStylusTool
::
Marker
&&
currentTool
!=
UBStylusTool
::
Marker
&&
!
mMarkerPressureSensitive
)
&&
!
mMarkerPressureSensitive
)
{
{
event
->
setAccepted
(
false
);
event
->
setAccepted
(
false
);
return
;
return
;
}
}
QPointF
scenePos
=
viewportTransform
().
inverted
().
map
(
tabletPos
);
QPointF
scenePos
=
viewportTransform
().
inverted
().
map
(
tabletPos
);
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
:
{
{
mTabletStylusIsPressed
=
true
;
mTabletStylusIsPressed
=
true
;
scene
()
->
inputDevicePress
(
scenePos
,
pressure
);
scene
()
->
inputDevicePress
(
scenePos
,
pressure
);
break
;
break
;
}
}
case
QEvent
:
:
TabletMove
:
case
QEvent
:
:
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
:
{
{
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
dc
->
stylusTool
();
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
dc
->
stylusTool
();
scene
()
->
setToolCursor
(
currentTool
);
scene
()
->
setToolCursor
(
currentTool
);
setToolCursor
(
currentTool
);
setToolCursor
(
currentTool
);
scene
()
->
inputDeviceRelease
();
scene
()
->
inputDeviceRelease
();
mPendingStylusReleaseEvent
=
false
;
mPendingStylusReleaseEvent
=
false
;
mTabletStylusIsPressed
=
false
;
mTabletStylusIsPressed
=
false
;
mMouseButtonIsPressed
=
false
;
mMouseButtonIsPressed
=
false
;
break
;
break
;
}
}
default
:
default
:
{
{
//NOOP - avoid compiler warning
//NOOP - avoid compiler warning
}
}
}
}
// ignore mouse press and mouse move tablet event so that it is rerouted to mouse events,
// ignore mouse press and mouse move tablet event so that it is rerouted to mouse events,
// documented in QTabletEvent Class Reference:
// documented in QTabletEvent Class Reference:
/* The event handler QWidget::tabletEvent() receives all three types of tablet events.
/* The event handler QWidget::tabletEvent() receives all three types of tablet events.
Qt will first send a tabletEvent then, if it is not accepted, it will send a mouse event. */
Qt will first send a tabletEvent then, if it is not accepted, it will send a mouse event. */
//
//
// This is a workaround to the fact that tablet event are not delivered to child widget (like palettes)
// This is a workaround to the fact that tablet event are not delivered to child widget (like palettes)
//
//
event
->
setAccepted
(
acceptEvent
);
event
->
setAccepted
(
acceptEvent
);
}
}
void
void
UBBoardView
::
mousePressEvent
(
QMouseEvent
*
event
)
UBBoardView
::
mousePressEvent
(
QMouseEvent
*
event
)
{
{
if
(
isAbsurdPoint
(
event
->
pos
()))
if
(
isAbsurdPoint
(
event
->
pos
()))
{
{
event
->
accept
();
event
->
accept
();
return
;
return
;
}
}
mMouseDownPos
=
event
->
pos
();
mMouseDownPos
=
event
->
pos
();
if
(
event
->
button
()
==
Qt
::
LeftButton
&&
isInteractive
())
if
(
event
->
button
()
==
Qt
::
LeftButton
&&
isInteractive
())
{
{
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
if
(
!
mTabletStylusIsPressed
)
if
(
!
mTabletStylusIsPressed
)
mMouseButtonIsPressed
=
true
;
mMouseButtonIsPressed
=
true
;
if
(
currentTool
==
UBStylusTool
::
ZoomIn
)
if
(
currentTool
==
UBStylusTool
::
ZoomIn
)
{
{
mController
->
zoomIn
(
mapToScene
(
event
->
pos
()));
mController
->
zoomIn
(
mapToScene
(
event
->
pos
()));
event
->
accept
();
event
->
accept
();
}
}
else
if
(
currentTool
==
UBStylusTool
::
ZoomOut
)
else
if
(
currentTool
==
UBStylusTool
::
ZoomOut
)
{
{
mController
->
zoomOut
(
mapToScene
(
event
->
pos
()));
mController
->
zoomOut
(
mapToScene
(
event
->
pos
()));
event
->
accept
();
event
->
accept
();
}
}
else
if
(
currentTool
==
UBStylusTool
::
Hand
)
else
if
(
currentTool
==
UBStylusTool
::
Hand
)
{
{
viewport
()
->
setCursor
(
QCursor
(
Qt
::
ClosedHandCursor
));
viewport
()
->
setCursor
(
QCursor
(
Qt
::
ClosedHandCursor
));
mPreviousPoint
=
event
->
posF
();
mPreviousPoint
=
event
->
posF
();
event
->
accept
();
event
->
accept
();
}
}
else
if
(
currentTool
==
UBStylusTool
::
Selector
)
else
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
{
QGraphicsView
::
mousePressEvent
(
event
);
QGraphicsView
::
mousePressEvent
(
event
);
}
}
else
if
(
currentTool
==
UBStylusTool
::
Text
)
else
if
(
currentTool
==
UBStylusTool
::
Text
)
{
{
int
frameWidth
=
UBSettings
::
settings
()
->
objectFrameWidth
;
int
frameWidth
=
UBSettings
::
settings
()
->
objectFrameWidth
;
QRectF
fuzzyRect
(
0
,
0
,
frameWidth
*
4
,
frameWidth
*
4
);
QRectF
fuzzyRect
(
0
,
0
,
frameWidth
*
4
,
frameWidth
*
4
);
fuzzyRect
.
moveCenter
(
mapToScene
(
mMouseDownPos
));
fuzzyRect
.
moveCenter
(
mapToScene
(
mMouseDownPos
));
UBGraphicsTextItem
*
foundTextItem
=
0
;
UBGraphicsTextItem
*
foundTextItem
=
0
;
QListIterator
<
QGraphicsItem
*>
it
(
scene
()
->
items
(
fuzzyRect
));
QListIterator
<
QGraphicsItem
*>
it
(
scene
()
->
items
(
fuzzyRect
));
while
(
it
.
hasNext
()
&&
!
foundTextItem
)
while
(
it
.
hasNext
()
&&
!
foundTextItem
)
{
{
foundTextItem
=
qgraphicsitem_cast
<
UBGraphicsTextItem
*>
(
it
.
next
());
foundTextItem
=
qgraphicsitem_cast
<
UBGraphicsTextItem
*>
(
it
.
next
());
}
}
if
(
foundTextItem
)
if
(
foundTextItem
)
{
{
mIsCreatingTextZone
=
false
;
mIsCreatingTextZone
=
false
;
QGraphicsView
::
mousePressEvent
(
event
);
QGraphicsView
::
mousePressEvent
(
event
);
}
}
else
else
{
{
scene
()
->
deselectAllItems
();
scene
()
->
deselectAllItems
();
if
(
!
mRubberBand
)
if
(
!
mRubberBand
)
mRubberBand
=
new
UBRubberBand
(
QRubberBand
::
Rectangle
,
this
);
mRubberBand
=
new
UBRubberBand
(
QRubberBand
::
Rectangle
,
this
);
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
QSize
()));
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
QSize
()));
mRubberBand
->
show
();
mRubberBand
->
show
();
mIsCreatingTextZone
=
true
;
mIsCreatingTextZone
=
true
;
event
->
accept
();
event
->
accept
();
}
}
}
}
else
if
(
currentTool
==
UBStylusTool
::
Capture
)
else
if
(
currentTool
==
UBStylusTool
::
Capture
)
{
{
scene
()
->
deselectAllItems
();
scene
()
->
deselectAllItems
();
if
(
!
mRubberBand
)
if
(
!
mRubberBand
)
mRubberBand
=
new
UBRubberBand
(
QRubberBand
::
Rectangle
,
this
);
mRubberBand
=
new
UBRubberBand
(
QRubberBand
::
Rectangle
,
this
);
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
QSize
()));
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
QSize
()));
mRubberBand
->
show
();
mRubberBand
->
show
();
mIsCreatingSceneGrabZone
=
true
;
mIsCreatingSceneGrabZone
=
true
;
event
->
accept
();
event
->
accept
();
}
}
else
else
{
{
if
(
UBDrawingController
::
drawingController
()
->
mActiveRuler
==
NULL
)
if
(
UBDrawingController
::
drawingController
()
->
mActiveRuler
==
NULL
)
{
{
viewport
()
->
setCursor
(
QCursor
(
Qt
::
BlankCursor
));
viewport
()
->
setCursor
(
QCursor
(
Qt
::
BlankCursor
));
}
}
if
(
scene
()
&&
!
mTabletStylusIsPressed
)
if
(
scene
()
&&
!
mTabletStylusIsPressed
)
{
{
scene
()
->
inputDevicePress
(
mapToScene
(
UBGeometryUtils
::
pointConstrainedInRect
(
event
->
pos
(),
rect
())));
scene
()
->
inputDevicePress
(
mapToScene
(
UBGeometryUtils
::
pointConstrainedInRect
(
event
->
pos
(),
rect
())));
}
}
event
->
accept
();
event
->
accept
();
}
}
}
}
}
}
void
void
UBBoardView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
UBBoardView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
{
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
if
(
isAbsurdPoint
(
event
->
pos
()))
if
(
isAbsurdPoint
(
event
->
pos
()))
{
{
event
->
accept
();
event
->
accept
();
return
;
return
;
}
}
if
(
currentTool
==
UBStylusTool
::
Hand
&&
(
mMouseButtonIsPressed
||
mTabletStylusIsPressed
))
if
(
currentTool
==
UBStylusTool
::
Hand
&&
(
mMouseButtonIsPressed
||
mTabletStylusIsPressed
))
{
{
QPointF
eventPosition
=
event
->
posF
();
QPointF
eventPosition
=
event
->
posF
();
qreal
dx
=
eventPosition
.
x
()
-
mPreviousPoint
.
x
();
qreal
dx
=
eventPosition
.
x
()
-
mPreviousPoint
.
x
();
qreal
dy
=
eventPosition
.
y
()
-
mPreviousPoint
.
y
();
qreal
dy
=
eventPosition
.
y
()
-
mPreviousPoint
.
y
();
mController
->
handScroll
(
dx
,
dy
);
mController
->
handScroll
(
dx
,
dy
);
mPreviousPoint
=
eventPosition
;
mPreviousPoint
=
eventPosition
;
event
->
accept
();
event
->
accept
();
}
}
else
if
(
currentTool
==
UBStylusTool
::
Selector
)
else
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
{
QGraphicsView
::
mouseMoveEvent
(
event
);
QGraphicsView
::
mouseMoveEvent
(
event
);
}
}
else
if
((
UBDrawingController
::
drawingController
()
->
isDrawingTool
())
else
if
((
UBDrawingController
::
drawingController
()
->
isDrawingTool
())
&&
!
mMouseButtonIsPressed
)
&&
!
mMouseButtonIsPressed
)
{
{
QGraphicsView
::
mouseMoveEvent
(
event
);
QGraphicsView
::
mouseMoveEvent
(
event
);
}
}
else
if
(
currentTool
==
UBStylusTool
::
Text
||
currentTool
==
UBStylusTool
::
Capture
)
else
if
(
currentTool
==
UBStylusTool
::
Text
||
currentTool
==
UBStylusTool
::
Capture
)
{
{
if
(
mRubberBand
&&
(
mIsCreatingTextZone
||
mIsCreatingSceneGrabZone
))
if
(
mRubberBand
&&
(
mIsCreatingTextZone
||
mIsCreatingSceneGrabZone
))
{
{
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
event
->
pos
()).
normalized
());
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
event
->
pos
()).
normalized
());
event
->
accept
();
event
->
accept
();
}
}
else
else
{
{
QGraphicsView
::
mouseMoveEvent
(
event
);
QGraphicsView
::
mouseMoveEvent
(
event
);
}
}
}
}
else
else
{
{
if
(
!
mTabletStylusIsPressed
&&
scene
())
if
(
!
mTabletStylusIsPressed
&&
scene
())
{
{
scene
()
->
inputDeviceMove
(
mapToScene
(
UBGeometryUtils
::
pointConstrainedInRect
(
event
->
pos
(),
rect
())),
mMouseButtonIsPressed
);
scene
()
->
inputDeviceMove
(
mapToScene
(
UBGeometryUtils
::
pointConstrainedInRect
(
event
->
pos
(),
rect
())),
mMouseButtonIsPressed
);
}
}
event
->
accept
();
event
->
accept
();
}
}
}
}
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
())
scene
()
->
inputDeviceRelease
();
scene
()
->
inputDeviceRelease
();
if
(
currentTool
==
UBStylusTool
::
Selector
)
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
{
QGraphicsView
::
mouseReleaseEvent
(
event
);
QGraphicsView
::
mouseReleaseEvent
(
event
);
}
}
else
if
(
currentTool
==
UBStylusTool
::
Text
)
else
if
(
currentTool
==
UBStylusTool
::
Text
)
{
{
if
(
mRubberBand
)
if
(
mRubberBand
)
mRubberBand
->
hide
();
mRubberBand
->
hide
();
if
(
scene
()
&&
mRubberBand
&&
mIsCreatingTextZone
)
if
(
scene
()
&&
mRubberBand
&&
mIsCreatingTextZone
)
{
{
QRect
rubberRect
=
mRubberBand
->
geometry
();
QRect
rubberRect
=
mRubberBand
->
geometry
();
UBGraphicsTextItem
*
textItem
=
scene
()
->
addText
(
""
,
mapToScene
(
rubberRect
.
topLeft
()));
UBGraphicsTextItem
*
textItem
=
scene
()
->
addText
(
""
,
mapToScene
(
rubberRect
.
topLeft
()));
event
->
accept
();
event
->
accept
();
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
textItem
->
setSelected
(
true
);
textItem
->
setSelected
(
true
);
}
}
else
else
{
{
QGraphicsView
::
mouseReleaseEvent
(
event
);
QGraphicsView
::
mouseReleaseEvent
(
event
);
}
}
mIsCreatingTextZone
=
false
;
mIsCreatingTextZone
=
false
;
}
}
else
if
(
currentTool
==
UBStylusTool
::
Capture
)
else
if
(
currentTool
==
UBStylusTool
::
Capture
)
{
{
if
(
mRubberBand
)
if
(
mRubberBand
)
mRubberBand
->
hide
();
mRubberBand
->
hide
();
if
(
scene
()
&&
mRubberBand
&&
mIsCreatingSceneGrabZone
&&
mRubberBand
->
geometry
().
width
()
>
16
)
if
(
scene
()
&&
mRubberBand
&&
mIsCreatingSceneGrabZone
&&
mRubberBand
->
geometry
().
width
()
>
16
)
{
{
QRect
rect
=
mRubberBand
->
geometry
();
QRect
rect
=
mRubberBand
->
geometry
();
QPointF
sceneTopLeft
=
mapToScene
(
rect
.
topLeft
());
QPointF
sceneTopLeft
=
mapToScene
(
rect
.
topLeft
());
QPointF
sceneBottomRight
=
mapToScene
(
rect
.
bottomRight
());
QPointF
sceneBottomRight
=
mapToScene
(
rect
.
bottomRight
());
QRectF
sceneRect
(
sceneTopLeft
,
sceneBottomRight
);
QRectF
sceneRect
(
sceneTopLeft
,
sceneBottomRight
);
mController
->
grabScene
(
sceneRect
);
mController
->
grabScene
(
sceneRect
);
event
->
accept
();
event
->
accept
();
}
}
else
else
{
{
QGraphicsView
::
mouseReleaseEvent
(
event
);
QGraphicsView
::
mouseReleaseEvent
(
event
);
}
}
mIsCreatingSceneGrabZone
=
false
;
mIsCreatingSceneGrabZone
=
false
;
}
}
else
else
{
{
if
(
mPendingStylusReleaseEvent
||
mMouseButtonIsPressed
)
if
(
mPendingStylusReleaseEvent
||
mMouseButtonIsPressed
)
{
{
event
->
accept
();
event
->
accept
();
}
}
}
}
mMouseButtonIsPressed
=
false
;
mMouseButtonIsPressed
=
false
;
mPendingStylusReleaseEvent
=
false
;
mPendingStylusReleaseEvent
=
false
;
mTabletStylusIsPressed
=
false
;
mTabletStylusIsPressed
=
false
;
}
}
void
void
UBBoardView
::
forcedTabletRelease
()
UBBoardView
::
forcedTabletRelease
()
{
{
if
(
mMouseButtonIsPressed
||
mTabletStylusIsPressed
||
mPendingStylusReleaseEvent
)
if
(
mMouseButtonIsPressed
||
mTabletStylusIsPressed
||
mPendingStylusReleaseEvent
)
{
{
qWarning
()
<<
"dirty mouse/tablet state:"
;
qWarning
()
<<
"dirty mouse/tablet state:"
;
qWarning
()
<<
"mMouseButtonIsPressed ="
<<
mMouseButtonIsPressed
;
qWarning
()
<<
"mMouseButtonIsPressed ="
<<
mMouseButtonIsPressed
;
qWarning
()
<<
"mTabletStylusIsPressed = "
<<
mTabletStylusIsPressed
;
qWarning
()
<<
"mTabletStylusIsPressed = "
<<
mTabletStylusIsPressed
;
qWarning
()
<<
"mPendingStylusReleaseEvent"
<<
mPendingStylusReleaseEvent
;
qWarning
()
<<
"mPendingStylusReleaseEvent"
<<
mPendingStylusReleaseEvent
;
qWarning
()
<<
"forcing device release"
;
qWarning
()
<<
"forcing device release"
;
scene
()
->
inputDeviceRelease
();
scene
()
->
inputDeviceRelease
();
mMouseButtonIsPressed
=
false
;
mMouseButtonIsPressed
=
false
;
mTabletStylusIsPressed
=
false
;
mTabletStylusIsPressed
=
false
;
mPendingStylusReleaseEvent
=
false
;
mPendingStylusReleaseEvent
=
false
;
}
}
}
}
void
void
UBBoardView
::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
UBBoardView
::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
{
{
// We don't want a double click, we want two clicks
// We don't want a double click, we want two clicks
mousePressEvent
(
event
);
mousePressEvent
(
event
);
}
}
void
void
UBBoardView
::
wheelEvent
(
QWheelEvent
*
event
)
UBBoardView
::
wheelEvent
(
QWheelEvent
*
event
)
{
{
if
(
isInteractive
()
&&
event
->
orientation
()
==
Qt
::
Vertical
)
if
(
isInteractive
()
&&
event
->
orientation
()
==
Qt
::
Vertical
)
{
{
// Too many wheelEvent are sent, how should we handle them to "smoothly" zoom ?
// Too many wheelEvent are sent, how should we handle them to "smoothly" zoom ?
// something like zoom( pow(zoomFactor, event->delta() / 120) )
// something like zoom( pow(zoomFactor, event->delta() / 120) )
}
}
event
->
accept
();
event
->
accept
();
}
}
void
void
UBBoardView
::
leaveEvent
(
QEvent
*
event
)
UBBoardView
::
leaveEvent
(
QEvent
*
event
)
{
{
if
(
scene
())
if
(
scene
())
scene
()
->
leaveEvent
(
event
);
scene
()
->
leaveEvent
(
event
);
QGraphicsView
::
leaveEvent
(
event
);
QGraphicsView
::
leaveEvent
(
event
);
}
}
void
void
UBBoardView
::
drawItems
(
QPainter
*
painter
,
int
numItems
,
UBBoardView
::
drawItems
(
QPainter
*
painter
,
int
numItems
,
QGraphicsItem
*
items
[],
QGraphicsItem
*
items
[],
const
QStyleOptionGraphicsItem
options
[])
const
QStyleOptionGraphicsItem
options
[])
{
{
if
(
!
mFilterZIndex
)
if
(
!
mFilterZIndex
)
{
{
QGraphicsView
::
drawItems
(
painter
,
numItems
,
items
,
options
);
QGraphicsView
::
drawItems
(
painter
,
numItems
,
items
,
options
);
}
}
else
else
{
{
int
count
=
0
;
int
count
=
0
;
QGraphicsItem
**
itemsFiltered
=
new
QGraphicsItem
*
[
numItems
];
QGraphicsItem
**
itemsFiltered
=
new
QGraphicsItem
*
[
numItems
];
QStyleOptionGraphicsItem
*
optionsFiltered
=
new
QStyleOptionGraphicsItem
[
numItems
];
QStyleOptionGraphicsItem
*
optionsFiltered
=
new
QStyleOptionGraphicsItem
[
numItems
];
for
(
int
i
=
0
;
i
<
numItems
;
i
++
)
for
(
int
i
=
0
;
i
<
numItems
;
i
++
)
{
{
if
(
shouldDisplayItem
(
items
[
i
]))
if
(
shouldDisplayItem
(
items
[
i
]))
{
{
itemsFiltered
[
count
]
=
items
[
i
];
itemsFiltered
[
count
]
=
items
[
i
];
optionsFiltered
[
count
]
=
options
[
i
];
optionsFiltered
[
count
]
=
options
[
i
];
count
++
;
count
++
;
}
}
}
}
QGraphicsView
::
drawItems
(
painter
,
count
,
itemsFiltered
,
optionsFiltered
);
QGraphicsView
::
drawItems
(
painter
,
count
,
itemsFiltered
,
optionsFiltered
);
delete
[]
optionsFiltered
;
delete
[]
optionsFiltered
;
delete
[]
itemsFiltered
;
delete
[]
itemsFiltered
;
}
}
}
}
void
void
UBBoardView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
UBBoardView
::
dragEnterEvent
(
QDragEnterEvent
*
event
)
{
{
// TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
// TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ...
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
}
void
void
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
UBBoardView
::
dragMoveEvent
(
QDragMoveEvent
*
event
)
{
{
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
}
void
void
UBBoardView
::
dropEvent
(
QDropEvent
*
event
)
UBBoardView
::
dropEvent
(
QDropEvent
*
event
)
{
{
if
(
!
event
->
source
()
||
dynamic_cast
<
UBThumbnailWidget
*>
(
event
->
source
()))
if
(
!
event
->
source
()
||
dynamic_cast
<
UBThumbnailWidget
*>
(
event
->
source
()))
{
{
mController
->
processMimeData
(
event
->
mimeData
(),
mapToScene
(
event
->
pos
()));
mController
->
processMimeData
(
event
->
mimeData
(),
mapToScene
(
event
->
pos
()));
event
->
acceptProposedAction
();
event
->
acceptProposedAction
();
}
}
}
}
void
void
UBBoardView
::
resizeEvent
(
QResizeEvent
*
event
)
UBBoardView
::
resizeEvent
(
QResizeEvent
*
event
)
{
{
const
qreal
maxWidth
=
width
()
*
10
;
const
qreal
maxWidth
=
width
()
*
10
;
const
qreal
maxHeight
=
height
()
*
10
;
const
qreal
maxHeight
=
height
()
*
10
;
setSceneRect
(
-
(
maxWidth
/
2
),
-
(
maxHeight
/
2
),
maxWidth
,
maxHeight
);
setSceneRect
(
-
(
maxWidth
/
2
),
-
(
maxHeight
/
2
),
maxWidth
,
maxHeight
);
centerOn
(
0
,
0
);
centerOn
(
0
,
0
);
emit
resized
(
event
);
emit
resized
(
event
);
}
}
void
void
UBBoardView
::
drawBackground
(
QPainter
*
painter
,
const
QRectF
&
rect
)
UBBoardView
::
drawBackground
(
QPainter
*
painter
,
const
QRectF
&
rect
)
{
{
if
(
testAttribute
(
Qt
::
WA_TranslucentBackground
))
if
(
testAttribute
(
Qt
::
WA_TranslucentBackground
))
{
{
QGraphicsView
::
drawBackground
(
painter
,
rect
);
QGraphicsView
::
drawBackground
(
painter
,
rect
);
return
;
return
;
}
}
bool
darkBackground
=
scene
()
&&
scene
()
->
isDarkBackground
();
bool
darkBackground
=
scene
()
&&
scene
()
->
isDarkBackground
();
if
(
darkBackground
)
if
(
darkBackground
)
{
{
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
black
)));
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
black
)));
}
}
else
else
{
{
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
white
)));
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
white
)));
}
}
if
(
transform
().
m11
()
>
0.5
)
if
(
transform
().
m11
()
>
0.5
)
{
{
QColor
bgCrossColor
;
QColor
bgCrossColor
;
if
(
darkBackground
)
if
(
darkBackground
)
bgCrossColor
=
UBSettings
::
crossDarkBackground
;
bgCrossColor
=
UBSettings
::
crossDarkBackground
;
else
else
bgCrossColor
=
UBSettings
::
crossLightBackground
;
bgCrossColor
=
UBSettings
::
crossLightBackground
;
if
(
transform
().
m11
()
<
1.0
)
if
(
transform
().
m11
()
<
1.0
)
{
{
int
alpha
=
255
*
transform
().
m11
()
/
2
;
int
alpha
=
255
*
transform
().
m11
()
/
2
;
bgCrossColor
.
setAlpha
(
alpha
);
// fade the crossing on small zooms
bgCrossColor
.
setAlpha
(
alpha
);
// fade the crossing on small zooms
}
}
painter
->
setPen
(
bgCrossColor
);
painter
->
setPen
(
bgCrossColor
);
if
(
scene
()
&&
scene
()
->
isCrossedBackground
())
if
(
scene
()
&&
scene
()
->
isCrossedBackground
())
{
{
qreal
firstY
=
((
int
)
(
rect
.
y
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
qreal
firstY
=
((
int
)
(
rect
.
y
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
for
(
qreal
yPos
=
firstY
;
yPos
<
rect
.
y
()
+
rect
.
height
();
yPos
+=
UBSettings
::
crossSize
)
for
(
qreal
yPos
=
firstY
;
yPos
<
rect
.
y
()
+
rect
.
height
();
yPos
+=
UBSettings
::
crossSize
)
{
{
painter
->
drawLine
(
rect
.
x
(),
yPos
,
rect
.
x
()
+
rect
.
width
(),
yPos
);
painter
->
drawLine
(
rect
.
x
(),
yPos
,
rect
.
x
()
+
rect
.
width
(),
yPos
);
}
}
qreal
firstX
=
((
int
)
(
rect
.
x
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
qreal
firstX
=
((
int
)
(
rect
.
x
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
for
(
qreal
xPos
=
firstX
;
xPos
<
rect
.
x
()
+
rect
.
width
();
xPos
+=
UBSettings
::
crossSize
)
for
(
qreal
xPos
=
firstX
;
xPos
<
rect
.
x
()
+
rect
.
width
();
xPos
+=
UBSettings
::
crossSize
)
{
{
painter
->
drawLine
(
xPos
,
rect
.
y
(),
xPos
,
rect
.
y
()
+
rect
.
height
());
painter
->
drawLine
(
xPos
,
rect
.
y
(),
xPos
,
rect
.
y
()
+
rect
.
height
());
}
}
}
}
}
}
if
(
!
mFilterZIndex
&&
scene
())
if
(
!
mFilterZIndex
&&
scene
())
{
{
QSize
pageNominalSize
=
scene
()
->
nominalSize
();
QSize
pageNominalSize
=
scene
()
->
nominalSize
();
if
(
pageNominalSize
.
isValid
())
if
(
pageNominalSize
.
isValid
())
{
{
qreal
penWidth
=
8.0
/
transform
().
m11
();
qreal
penWidth
=
8.0
/
transform
().
m11
();
QRectF
pageRect
(
pageNominalSize
.
width
()
/
-
2
,
pageNominalSize
.
height
()
/
-
2
QRectF
pageRect
(
pageNominalSize
.
width
()
/
-
2
,
pageNominalSize
.
height
()
/
-
2
,
pageNominalSize
.
width
(),
pageNominalSize
.
height
());
,
pageNominalSize
.
width
(),
pageNominalSize
.
height
());
pageRect
.
adjust
(
-
penWidth
/
2
,
-
penWidth
/
2
,
penWidth
/
2
,
penWidth
/
2
);
pageRect
.
adjust
(
-
penWidth
/
2
,
-
penWidth
/
2
,
penWidth
/
2
,
penWidth
/
2
);
QColor
docSizeColor
;
QColor
docSizeColor
;
if
(
darkBackground
)
if
(
darkBackground
)
docSizeColor
=
UBSettings
::
documentSizeMarkColorDarkBackground
;
docSizeColor
=
UBSettings
::
documentSizeMarkColorDarkBackground
;
else
else
docSizeColor
=
UBSettings
::
documentSizeMarkColorLightBackground
;
docSizeColor
=
UBSettings
::
documentSizeMarkColorLightBackground
;
QPen
pen
(
docSizeColor
);
QPen
pen
(
docSizeColor
);
pen
.
setWidth
(
penWidth
);
pen
.
setWidth
(
penWidth
);
painter
->
setPen
(
pen
);
painter
->
setPen
(
pen
);
painter
->
drawRect
(
pageRect
);
painter
->
drawRect
(
pageRect
);
}
}
}
}
}
}
void
void
UBBoardView
::
settingChanged
(
QVariant
newValue
)
UBBoardView
::
settingChanged
(
QVariant
newValue
)
{
{
Q_UNUSED
(
newValue
);
Q_UNUSED
(
newValue
);
mPenPressureSensitive
=
UBSettings
::
settings
()
->
boardPenPressureSensitive
->
get
().
toBool
();
mPenPressureSensitive
=
UBSettings
::
settings
()
->
boardPenPressureSensitive
->
get
().
toBool
();
mMarkerPressureSensitive
=
UBSettings
::
settings
()
->
boardMarkerPressureSensitive
->
get
().
toBool
();
mMarkerPressureSensitive
=
UBSettings
::
settings
()
->
boardMarkerPressureSensitive
->
get
().
toBool
();
mUseHighResTabletEvent
=
UBSettings
::
settings
()
->
boardUseHighResTabletEvent
->
get
().
toBool
();
mUseHighResTabletEvent
=
UBSettings
::
settings
()
->
boardUseHighResTabletEvent
->
get
().
toBool
();
}
}
void
UBBoardView
::
virtualKeyboardActivated
(
bool
b
)
void
UBBoardView
::
virtualKeyboardActivated
(
bool
b
)
{
{
UBPlatformUtils
::
setWindowNonActivableFlag
(
this
,
b
);
UBPlatformUtils
::
setWindowNonActivableFlag
(
this
,
b
);
mVirtualKeyboardActive
=
b
;
mVirtualKeyboardActive
=
b
;
setInteractive
(
!
b
);
setInteractive
(
!
b
);
}
}
// Apple remote desktop sends funny events when the transmission is bad
// Apple remote desktop sends funny events when the transmission is bad
bool
bool
UBBoardView
::
isAbsurdPoint
(
QPoint
point
)
UBBoardView
::
isAbsurdPoint
(
QPoint
point
)
{
{
QDesktopWidget
*
desktop
=
qApp
->
desktop
();
QDesktopWidget
*
desktop
=
qApp
->
desktop
();
bool
isValidPoint
=
false
;
bool
isValidPoint
=
false
;
for
(
int
i
=
0
;
i
<
desktop
->
numScreens
();
i
++
)
for
(
int
i
=
0
;
i
<
desktop
->
numScreens
();
i
++
)
{
{
QRect
screenRect
=
desktop
->
screenGeometry
(
i
);
QRect
screenRect
=
desktop
->
screenGeometry
(
i
);
isValidPoint
=
isValidPoint
||
screenRect
.
contains
(
point
);
isValidPoint
=
isValidPoint
||
screenRect
.
contains
(
point
);
}
}
return
!
isValidPoint
;
return
!
isValidPoint
;
}
}
void
void
UBBoardView
::
focusOutEvent
(
QFocusEvent
*
event
)
UBBoardView
::
focusOutEvent
(
QFocusEvent
*
event
)
{
{
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
}
}
void
void
UBBoardView
::
setToolCursor
(
int
tool
)
UBBoardView
::
setToolCursor
(
int
tool
)
{
{
QWidget
*
controlViewport
=
viewport
();
QWidget
*
controlViewport
=
viewport
();
switch
(
tool
)
switch
(
tool
)
{
{
case
UBStylusTool
:
:
Pen
:
case
UBStylusTool
:
:
Pen
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
break
;
break
;
case
UBStylusTool
:
:
Eraser
:
case
UBStylusTool
:
:
Eraser
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
eraserCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
eraserCursor
);
break
;
break
;
case
UBStylusTool
:
:
Marker
:
case
UBStylusTool
:
:
Marker
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
markerCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
markerCursor
);
break
;
break
;
case
UBStylusTool
:
:
Pointer
:
case
UBStylusTool
:
:
Pointer
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
pointerCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
pointerCursor
);
break
;
break
;
case
UBStylusTool
:
:
Hand
:
case
UBStylusTool
:
:
Hand
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
handCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
handCursor
);
break
;
break
;
case
UBStylusTool
:
:
ZoomIn
:
case
UBStylusTool
:
:
ZoomIn
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
zoomInCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
zoomInCursor
);
break
;
break
;
case
UBStylusTool
:
:
ZoomOut
:
case
UBStylusTool
:
:
ZoomOut
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
zoomOutCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
zoomOutCursor
);
break
;
break
;
case
UBStylusTool
:
:
Selector
:
case
UBStylusTool
:
:
Selector
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
arrowCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
arrowCursor
);
break
;
break
;
case
UBStylusTool
:
:
Line
:
case
UBStylusTool
:
:
Line
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
break
;
break
;
case
UBStylusTool
:
:
Text
:
case
UBStylusTool
:
:
Text
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
textCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
textCursor
);
break
;
break
;
case
UBStylusTool
:
:
Capture
:
case
UBStylusTool
:
:
Capture
:
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
break
;
break
;
default
:
default
:
Q_ASSERT
(
false
);
Q_ASSERT
(
false
);
//failsafe
//failsafe
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
controlViewport
->
setCursor
(
UBResources
::
resources
()
->
penCursor
);
}
}
}
}
src/desktop/UBDesktopAnnotationController.cpp
View file @
4f3b163b
...
@@ -90,6 +90,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
...
@@ -90,6 +90,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mKeyboardPalette
=
UBKeyboardPalette
::
create
(
mTransparentDrawingView
);
mKeyboardPalette
=
UBKeyboardPalette
::
create
(
mTransparentDrawingView
);
mKeyboardPalette
->
setParent
(
mTransparentDrawingView
);
mKeyboardPalette
->
setParent
(
mTransparentDrawingView
);
connect
(
mKeyboardPalette
,
SIGNAL
(
keyboardActivated
(
bool
)),
mTransparentDrawingView
,
SLOT
(
virtualKeyboardActivated
(
bool
)));
connect
(
mKeyboardPalette
,
SIGNAL
(
keyboardActivated
(
bool
)),
mTransparentDrawingView
,
SLOT
(
virtualKeyboardActivated
(
bool
)));
connect
(
mKeyboardPalette
,
SIGNAL
(
moved
(
QPoint
)),
this
,
SLOT
(
refreshMask
()));
}
}
connect
(
mDesktopPalette
,
SIGNAL
(
uniboardClick
()),
this
,
SLOT
(
goToUniboard
()));
connect
(
mDesktopPalette
,
SIGNAL
(
uniboardClick
()),
this
,
SLOT
(
goToUniboard
()));
...
@@ -143,12 +144,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
...
@@ -143,12 +144,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect
(
&
mHoldTimerMarker
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
markerActionReleased
()));
connect
(
&
mHoldTimerMarker
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
markerActionReleased
()));
connect
(
&
mHoldTimerEraser
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
eraserActionReleased
()));
connect
(
&
mHoldTimerEraser
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
eraserActionReleased
()));
connect
(
mDesktopPalette
,
SIGNAL
(
moving
()),
this
,
SLOT
(
refreshMask
()));
connect
(
mLibPalette
,
SIGNAL
(
resized
()),
this
,
SLOT
(
refreshMask
()));
onDesktopPaletteMaximized
();
onDesktopPaletteMaximized
();
}
}
void
UBDesktopAnnotationController
::
showKeyboard
(
bool
show
)
void
UBDesktopAnnotationController
::
showKeyboard
(
bool
show
)
{
{
mKeyboardPalette
->
setVisible
(
show
);
mKeyboardPalette
->
setVisible
(
show
);
updateMask
(
true
);
// mDesktopPalette->showVirtualKeyboard(show);
// mDesktopPalette->showVirtualKeyboard(show);
}
}
...
@@ -332,6 +337,10 @@ void UBDesktopAnnotationController::showWindow()
...
@@ -332,6 +337,10 @@ void UBDesktopAnnotationController::showWindow()
UBPlatformUtils
::
setDesktopMode
(
true
);
UBPlatformUtils
::
setDesktopMode
(
true
);
mDesktopPalette
->
appear
();
mDesktopPalette
->
appear
();
#ifdef Q_WS_X11
updateMask
(
true
);
#endif
}
}
...
@@ -343,7 +352,15 @@ void UBDesktopAnnotationController::close()
...
@@ -343,7 +352,15 @@ void UBDesktopAnnotationController::close()
void
UBDesktopAnnotationController
::
stylusToolChanged
(
int
tool
)
void
UBDesktopAnnotationController
::
stylusToolChanged
(
int
tool
)
{
{
Q_UNUSED
(
tool
);
UBStylusTool
::
Enum
eTool
=
(
UBStylusTool
::
Enum
)
tool
;
mDesktopPalette
->
notifySelectorSelection
(
UBStylusTool
::
Selector
==
eTool
);
if
(
UBStylusTool
::
Selector
!=
eTool
)
{
UBApplication
::
mainWindow
->
actionVirtualKeyboard
->
setChecked
(
false
);
mKeyboardPalette
->
setVisible
(
false
);
}
updateBackground
();
updateBackground
();
}
}
...
@@ -356,6 +373,9 @@ void UBDesktopAnnotationController::updateBackground()
...
@@ -356,6 +373,9 @@ void UBDesktopAnnotationController::updateBackground()
||
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Selector
)
||
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Selector
)
{
{
newBrush
=
QBrush
(
Qt
::
transparent
);
newBrush
=
QBrush
(
Qt
::
transparent
);
#ifdef Q_WS_X11
updateMask
(
true
);
#endif
}
}
else
else
{
{
...
@@ -363,6 +383,9 @@ void UBDesktopAnnotationController::updateBackground()
...
@@ -363,6 +383,9 @@ void UBDesktopAnnotationController::updateBackground()
newBrush
=
QBrush
(
QColor
(
127
,
127
,
127
,
15
));
newBrush
=
QBrush
(
QColor
(
127
,
127
,
127
,
15
));
#else
#else
newBrush
=
QBrush
(
QColor
(
127
,
127
,
127
,
1
));
newBrush
=
QBrush
(
QColor
(
127
,
127
,
127
,
1
));
#endif
#ifdef Q_WS_X11
updateMask
(
false
);
#endif
#endif
}
}
...
@@ -389,6 +412,8 @@ void UBDesktopAnnotationController::goToUniboard()
...
@@ -389,6 +412,8 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils
::
setDesktopMode
(
false
);
UBPlatformUtils
::
setDesktopMode
(
false
);
UBApplication
::
mainWindow
->
actionVirtualKeyboard
->
setEnabled
(
true
);
emit
restoreUniboard
();
emit
restoreUniboard
();
}
}
...
@@ -751,3 +776,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
...
@@ -751,3 +776,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")";
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")";
mLibPalette
->
resize
(
mLibPalette
->
width
(),
mTransparentDrawingView
->
height
());
mLibPalette
->
resize
(
mLibPalette
->
width
(),
mTransparentDrawingView
->
height
());
}
}
void
UBDesktopAnnotationController
::
updateMask
(
bool
bTransparent
)
{
if
(
bTransparent
)
{
// Here we have to generate a new mask. This method is certainly resource
// consuming but for the moment this is the only solution that I found.
mMask
=
QPixmap
(
mTransparentDrawingView
->
width
(),
mTransparentDrawingView
->
height
());
QPainter
p
;
p
.
begin
(
&
mMask
);
p
.
setPen
(
Qt
::
red
);
p
.
setBrush
(
QBrush
(
Qt
::
red
));
// Here we draw the widget mask
if
(
mDesktopPalette
->
isVisible
())
{
p
.
drawRect
(
mDesktopPalette
->
geometry
().
x
(),
mDesktopPalette
->
geometry
().
y
(),
mDesktopPalette
->
width
(),
mDesktopPalette
->
height
());
}
if
(
mKeyboardPalette
->
isVisible
())
{
p
.
drawRect
(
mKeyboardPalette
->
geometry
().
x
(),
mKeyboardPalette
->
geometry
().
y
(),
mKeyboardPalette
->
width
(),
mKeyboardPalette
->
height
());
}
if
(
mLibPalette
->
isVisible
())
{
p
.
drawRect
(
mLibPalette
->
geometry
().
x
(),
mLibPalette
->
geometry
().
y
(),
mLibPalette
->
width
(),
mLibPalette
->
height
());
}
p
.
end
();
// Then we add the annotations. We create another painter because we need to
// apply transformations on it for coordinates matching
QPainter
annotationPainter
;
QTransform
trans
;
trans
.
translate
(
mTransparentDrawingView
->
width
()
/
2
,
mTransparentDrawingView
->
height
()
/
2
);
annotationPainter
.
begin
(
&
mMask
);
annotationPainter
.
setPen
(
Qt
::
red
);
annotationPainter
.
setBrush
(
Qt
::
red
);
annotationPainter
.
setTransform
(
trans
);
QList
<
QGraphicsItem
*>
allItems
=
mTransparentDrawingScene
->
items
();
for
(
int
i
=
0
;
i
<
allItems
.
size
();
i
++
)
{
QGraphicsItem
*
pCrntItem
=
allItems
.
at
(
i
);
if
(
pCrntItem
->
isVisible
())
{
QPainterPath
crntPath
=
pCrntItem
->
shape
();
QRectF
rect
=
crntPath
.
boundingRect
();
annotationPainter
.
drawRect
(
rect
);
}
}
annotationPainter
.
end
();
mTransparentDrawingView
->
setMask
(
mMask
.
createMaskFromColor
(
Qt
::
black
));
}
else
{
// Remove the mask
QPixmap
noMask
(
mTransparentDrawingView
->
width
(),
mTransparentDrawingView
->
height
());
mTransparentDrawingView
->
setMask
(
noMask
.
mask
());
}
}
void
UBDesktopAnnotationController
::
refreshMask
()
{
if
(
mIsFullyTransparent
||
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Selector
)
{
updateMask
(
true
);
}
}
src/desktop/UBDesktopAnnotationController.h
View file @
4f3b163b
...
@@ -94,10 +94,12 @@ class UBDesktopAnnotationController : public QObject
...
@@ -94,10 +94,12 @@ class UBDesktopAnnotationController : public QObject
void
onDesktopPaletteMaximized
();
void
onDesktopPaletteMaximized
();
void
onDesktopPaletteMinimize
();
void
onDesktopPaletteMinimize
();
void
onTransparentWidgetResized
();
void
onTransparentWidgetResized
();
void
refreshMask
();
private
:
private
:
void
setAssociatedPalettePosition
(
UBActionPalette
*
palette
,
const
QString
&
actionName
);
void
setAssociatedPalettePosition
(
UBActionPalette
*
palette
,
const
QString
&
actionName
);
void
togglePropertyPalette
(
UBActionPalette
*
palette
);
void
togglePropertyPalette
(
UBActionPalette
*
palette
);
void
updateMask
(
bool
bTransparent
);
UBDesktopPalette
*
mDesktopPalette
;
UBDesktopPalette
*
mDesktopPalette
;
UBKeyboardPalette
*
mKeyboardPalette
;
UBKeyboardPalette
*
mKeyboardPalette
;
...
@@ -126,6 +128,8 @@ class UBDesktopAnnotationController : public QObject
...
@@ -126,6 +128,8 @@ class UBDesktopAnnotationController : public QObject
int
mBoardStylusTool
;
int
mBoardStylusTool
;
int
mDesktopStylusTool
;
int
mDesktopStylusTool
;
QPixmap
mMask
;
};
};
#endif
/* UBUNINOTESWINDOWCONTROLLER_H_ */
#endif
/* UBUNINOTESWINDOWCONTROLLER_H_ */
src/desktop/UBDesktopPalette.cpp
View file @
4f3b163b
...
@@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
...
@@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
actions
<<
UBApplication
::
mainWindow
->
actionPen
;
actions
<<
UBApplication
::
mainWindow
->
actionPen
;
actions
<<
UBApplication
::
mainWindow
->
actionEraser
;
actions
<<
UBApplication
::
mainWindow
->
actionEraser
;
actions
<<
UBApplication
::
mainWindow
->
actionMarker
;
actions
<<
UBApplication
::
mainWindow
->
actionMarker
;
#ifndef Q_WS_X11
actions
<<
UBApplication
::
mainWindow
->
actionSelector
;
actions
<<
UBApplication
::
mainWindow
->
actionSelector
;
#endif
actions
<<
UBApplication
::
mainWindow
->
actionPointer
;
actions
<<
UBApplication
::
mainWindow
->
actionPointer
;
if
(
UBPlatformUtils
::
hasVirtualKeyboard
())
if
(
UBPlatformUtils
::
hasVirtualKeyboard
())
...
@@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe()
...
@@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe()
actions
<<
UBApplication
::
mainWindow
->
actionPen
;
actions
<<
UBApplication
::
mainWindow
->
actionPen
;
actions
<<
UBApplication
::
mainWindow
->
actionEraser
;
actions
<<
UBApplication
::
mainWindow
->
actionEraser
;
actions
<<
UBApplication
::
mainWindow
->
actionMarker
;
actions
<<
UBApplication
::
mainWindow
->
actionMarker
;
#ifndef Q_WS_X11
actions
<<
UBApplication
::
mainWindow
->
actionSelector
;
actions
<<
UBApplication
::
mainWindow
->
actionSelector
;
#endif
actions
<<
UBApplication
::
mainWindow
->
actionPointer
;
actions
<<
UBApplication
::
mainWindow
->
actionPointer
;
if
(
UBPlatformUtils
::
hasVirtualKeyboard
())
if
(
UBPlatformUtils
::
hasVirtualKeyboard
())
actions
<<
UBApplication
::
mainWindow
->
actionVirtualKeyboard
;
actions
<<
UBApplication
::
mainWindow
->
actionVirtualKeyboard
;
...
@@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
...
@@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
return
p
;
return
p
;
}
}
void
UBDesktopPalette
::
notifySelectorSelection
(
bool
selected
)
{
UBApplication
::
mainWindow
->
actionVirtualKeyboard
->
setEnabled
(
selected
);
}
src/desktop/UBDesktopPalette.h
View file @
4f3b163b
...
@@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette
...
@@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette
void
disappearForCapture
();
void
disappearForCapture
();
void
appear
();
void
appear
();
QPoint
buttonPos
(
QAction
*
action
);
QPoint
buttonPos
(
QAction
*
action
);
void
notifySelectorSelection
(
bool
selected
);
signals
:
signals
:
void
uniboardClick
();
void
uniboardClick
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
4f3b163b
...
@@ -249,6 +249,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
...
@@ -249,6 +249,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{
{
if
(
currentTool
==
UBStylusTool
::
Line
)
if
(
currentTool
==
UBStylusTool
::
Line
)
{
{
// TODO: Verify this beautiful implementation and check if
// it is possible to optimize it
QLineF
radius
(
mPreviousPoint
,
position
);
QLineF
radius
(
mPreviousPoint
,
position
);
qreal
angle
=
radius
.
angle
();
qreal
angle
=
radius
.
angle
();
angle
=
qRound
(
angle
/
45
)
*
45
;
angle
=
qRound
(
angle
/
45
)
*
45
;
...
@@ -257,7 +259,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
...
@@ -257,7 +259,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
mPreviousPoint
.
x
()
+
radiusLength
*
cos
((
angle
*
PI
)
/
180
),
mPreviousPoint
.
x
()
+
radiusLength
*
cos
((
angle
*
PI
)
/
180
),
mPreviousPoint
.
y
()
-
radiusLength
*
sin
((
angle
*
PI
)
/
180
));
mPreviousPoint
.
y
()
-
radiusLength
*
sin
((
angle
*
PI
)
/
180
));
QLineF
chord
(
position
,
newPosition
);
QLineF
chord
(
position
,
newPosition
);
if
(
chord
.
length
()
<
qMin
((
int
)
16
,
(
int
)(
radiusLength
/
20
)))
if
(
chord
.
length
()
<
qMin
((
int
)
16
,
(
int
)(
radiusLength
/
20
)))
position
=
newPosition
;
position
=
newPosition
;
}
}
...
...
src/gui/UBFloatingPalette.cpp
View file @
4f3b163b
...
@@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event)
...
@@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event)
{
{
moveInsideParent
(
event
->
globalPos
()
-
mDragPosition
);
moveInsideParent
(
event
->
globalPos
()
-
mDragPosition
);
event
->
accept
();
event
->
accept
();
emit
moving
();
}
}
else
else
{
{
...
...
src/gui/UBFloatingPalette.h
View file @
4f3b163b
...
@@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget
...
@@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget
void
minimizeStart
(
eMinimizedLocation
location
);
void
minimizeStart
(
eMinimizedLocation
location
);
void
maximizeStart
();
void
maximizeStart
();
void
maximized
();
void
maximized
();
void
moving
();
};
};
...
...
src/gui/UBLibPalette.cpp
View file @
4f3b163b
...
@@ -34,7 +34,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
...
@@ -34,7 +34,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mIcon
=
QPixmap
(
":images/paletteLibrary.png"
);
mIcon
=
QPixmap
(
":images/paletteLibrary.png"
);
setAcceptDrops
(
true
);
setAcceptDrops
(
true
);
resize
(
UBSettings
::
settings
()
->
libPaletteWidth
->
get
().
toInt
(),
height
());
resize
(
UBSettings
::
settings
()
->
libPaletteWidth
->
get
().
toInt
(),
parentWidget
()
->
height
());
setContentsMargins
(
border
(),
0
,
0
,
0
);
setContentsMargins
(
border
(),
0
,
0
,
0
);
mCollapseWidth
=
180
;
mCollapseWidth
=
180
;
mLastWidth
=
300
;
mLastWidth
=
300
;
...
@@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
...
@@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
{
{
UBDockPalette
::
resizeEvent
(
event
);
UBDockPalette
::
resizeEvent
(
event
);
UBSettings
::
settings
()
->
libPaletteWidth
->
set
(
width
());
UBSettings
::
settings
()
->
libPaletteWidth
->
set
(
width
());
emit
resized
();
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
...
src/gui/UBLibPalette.h
View file @
4f3b163b
...
@@ -55,6 +55,9 @@ public:
...
@@ -55,6 +55,9 @@ public:
UBLibActionBar
*
actionBar
(){
return
mActionBar
;}
UBLibActionBar
*
actionBar
(){
return
mActionBar
;}
signals
:
void
resized
();
protected
:
protected
:
void
updateMaxWidth
();
void
updateMaxWidth
();
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
);
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment