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
83212cc4
Commit
83212cc4
authored
May 03, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SANKORE-613
Frame buttons Part 1: changes in toolbars
parent
62a82e1d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1389 additions
and
1252 deletions
+1389
-1252
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+802
-794
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+77
-3
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+34
-0
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+9
-5
UBGraphicsVideoItemDelegate.cpp
src/domain/UBGraphicsVideoItemDelegate.cpp
+351
-336
UBGraphicsVideoItemDelegate.h
src/domain/UBGraphicsVideoItemDelegate.h
+116
-114
No files found.
src/domain/UBGraphicsDelegateFrame.cpp
View file @
83212cc4
/*
/*
* This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
* 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 "UBGraphicsDelegateFrame.h"
#include "UBGraphicsDelegateFrame.h"
#include <QtGui>
#include <QtGui>
#include <QtSvg>
#include <QtSvg>
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "core/UBSettings.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "gui/UBResources.h"
#include "gui/UBResources.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
UBGraphicsDelegateFrame
::
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
)
UBGraphicsDelegateFrame
::
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
)
:
QGraphicsRectItem
(),
QObject
(
pDelegate
)
:
QGraphicsRectItem
(),
QObject
(
pDelegate
)
,
mCurrentTool
(
None
)
,
mCurrentTool
(
None
)
,
mDelegate
(
pDelegate
)
,
mDelegate
(
pDelegate
)
,
mVisible
(
true
)
,
mVisible
(
true
)
,
mFrameWidth
(
pFrameWidth
)
,
mFrameWidth
(
pFrameWidth
)
,
mNominalFrameWidth
(
pFrameWidth
)
,
mNominalFrameWidth
(
pFrameWidth
)
,
mRespectRatio
(
respectRatio
)
,
mRespectRatio
(
respectRatio
)
,
mAngle
(
0
)
,
mAngle
(
0
)
,
mAngleOffset
(
0
)
,
mAngleOffset
(
0
)
,
mTotalScaleX
(
-
1
)
,
mTotalScaleX
(
-
1
)
,
mTotalScaleY
(
-
1
)
,
mTotalScaleY
(
-
1
)
,
mTranslateX
(
0
)
,
mTranslateX
(
0
)
,
mTranslateY
(
0
)
,
mTranslateY
(
0
)
,
mTotalTranslateX
(
0
)
,
mTotalTranslateX
(
0
)
,
mTotalTranslateY
(
0
)
,
mTotalTranslateY
(
0
)
,
mOperationMode
(
Scaling
)
,
mOperationMode
(
Scaling
)
,
mMirrorX
(
false
)
,
mMirrorX
(
false
)
,
mMirrorY
(
false
)
,
mMirrorY
(
false
)
{
{
mAngleTolerance
=
UBSettings
::
settings
()
->
angleTolerance
->
get
().
toReal
();
mAngleTolerance
=
UBSettings
::
settings
()
->
angleTolerance
->
get
().
toReal
();
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
setRect
(
pRect
.
adjusted
(
mFrameWidth
,
mFrameWidth
,
mFrameWidth
*
-
1
,
mFrameWidth
*
-
1
));
setRect
(
pRect
.
adjusted
(
mFrameWidth
,
mFrameWidth
,
mFrameWidth
*
-
1
,
mFrameWidth
*
-
1
));
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
setPen
(
Qt
::
NoPen
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
mBottomRightResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resize.svg"
,
this
);
mBottomRightResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resize.svg"
,
this
);
mBottomResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeBottom.svg"
,
this
);
mBottomResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeBottom.svg"
,
this
);
mLeftResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeLeft.svg"
,
this
);
mLeftResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeLeft.svg"
,
this
);
mRightResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeRight.svg"
,
this
);
mRightResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeRight.svg"
,
this
);
mTopResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeTop.svg"
,
this
);
mTopResizeGripSvgItem
=
new
QGraphicsSvgItem
(
":/images/resizeTop.svg"
,
this
);
mBottomRightResizeGrip
=
new
QGraphicsRectItem
(
this
);
mBottomRightResizeGrip
=
new
QGraphicsRectItem
(
this
);
mBottomRightResizeGrip
->
setPen
(
Qt
::
NoPen
);
mBottomRightResizeGrip
->
setPen
(
Qt
::
NoPen
);
mBottomResizeGrip
=
new
QGraphicsRectItem
(
this
);
mBottomResizeGrip
=
new
QGraphicsRectItem
(
this
);
mBottomResizeGrip
->
setPen
(
Qt
::
NoPen
);
mBottomResizeGrip
->
setPen
(
Qt
::
NoPen
);
mLeftResizeGrip
=
new
QGraphicsRectItem
(
this
);
mLeftResizeGrip
=
new
QGraphicsRectItem
(
this
);
mLeftResizeGrip
->
setToolTip
(
"left"
);
mLeftResizeGrip
->
setToolTip
(
"left"
);
mLeftResizeGrip
->
setPen
(
Qt
::
NoPen
);
mLeftResizeGrip
->
setPen
(
Qt
::
NoPen
);
mRightResizeGrip
=
new
QGraphicsRectItem
(
this
);
mRightResizeGrip
=
new
QGraphicsRectItem
(
this
);
mRightResizeGrip
->
setPen
(
Qt
::
NoPen
);
mRightResizeGrip
->
setPen
(
Qt
::
NoPen
);
mRightResizeGrip
->
setToolTip
(
"Right"
);
mRightResizeGrip
->
setToolTip
(
"Right"
);
mTopResizeGrip
=
new
QGraphicsRectItem
(
this
);
mTopResizeGrip
=
new
QGraphicsRectItem
(
this
);
mTopResizeGrip
->
setPen
(
Qt
::
NoPen
);
mTopResizeGrip
->
setPen
(
Qt
::
NoPen
);
mRotateButton
=
new
QGraphicsSvgItem
(
":/images/rotate.svg"
,
this
);
mRotateButton
=
new
QGraphicsSvgItem
(
":/images/rotate.svg"
,
this
);
mRotateButton
->
setCursor
(
UBResources
::
resources
()
->
rotateCursor
);
mRotateButton
->
setCursor
(
UBResources
::
resources
()
->
rotateCursor
);
mRotateButton
->
setVisible
(
mDelegate
->
canRotate
());
mRotateButton
->
setVisible
(
mDelegate
->
canRotate
());
updateResizeCursors
();
updateResizeCursors
();
setAntiScale
(
1.0
);
setAntiScale
(
1.0
);
positionHandles
();
positionHandles
();
this
->
setAcceptHoverEvents
(
true
);
this
->
setAcceptHoverEvents
(
true
);
angleWidget
=
new
UBAngleWidget
();
angleWidget
=
new
UBAngleWidget
();
}
}
UBGraphicsDelegateFrame
::~
UBGraphicsDelegateFrame
()
UBGraphicsDelegateFrame
::~
UBGraphicsDelegateFrame
()
{
{
delete
angleWidget
;
delete
angleWidget
;
// NOOP
// NOOP
}
}
void
UBGraphicsDelegateFrame
::
setAntiScale
(
qreal
pAntiScale
)
void
UBGraphicsDelegateFrame
::
setAntiScale
(
qreal
pAntiScale
)
{
{
mFrameWidth
=
mNominalFrameWidth
*
pAntiScale
;
mFrameWidth
=
mNominalFrameWidth
*
pAntiScale
;
QTransform
tr
;
QTransform
tr
;
tr
.
scale
(
pAntiScale
,
pAntiScale
);
tr
.
scale
(
pAntiScale
,
pAntiScale
);
mBottomRightResizeGripSvgItem
->
setTransform
(
tr
);
mBottomRightResizeGripSvgItem
->
setTransform
(
tr
);
mBottomResizeGripSvgItem
->
setTransform
(
tr
);
mBottomResizeGripSvgItem
->
setTransform
(
tr
);
mLeftResizeGripSvgItem
->
setTransform
(
tr
);
mLeftResizeGripSvgItem
->
setTransform
(
tr
);
mRightResizeGripSvgItem
->
setTransform
(
tr
);
mRightResizeGripSvgItem
->
setTransform
(
tr
);
mTopResizeGripSvgItem
->
setTransform
(
tr
);
mTopResizeGripSvgItem
->
setTransform
(
tr
);
mRotateButton
->
setTransform
(
tr
);
mRotateButton
->
setTransform
(
tr
);
}
}
void
UBGraphicsDelegateFrame
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
UBGraphicsDelegateFrame
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
{
Q_UNUSED
(
option
);
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
Q_UNUSED
(
widget
);
QPainterPath
path
;
QPainterPath
path
;
path
.
addRoundedRect
(
rect
(),
mFrameWidth
/
2
,
mFrameWidth
/
2
);
path
.
addRoundedRect
(
rect
(),
mFrameWidth
/
2
,
mFrameWidth
/
2
);
if
(
rect
().
width
()
>
1
&&
rect
().
height
()
>
1
)
if
(
rect
().
width
()
>
1
&&
rect
().
height
()
>
1
)
{
{
QPainterPath
extruded
;
QPainterPath
extruded
;
extruded
.
addRect
(
rect
().
adjusted
(
mFrameWidth
,
mFrameWidth
,
(
mFrameWidth
*
-
1
),
(
mFrameWidth
*
-
1
)));
extruded
.
addRect
(
rect
().
adjusted
(
mFrameWidth
,
mFrameWidth
,
(
mFrameWidth
*
-
1
),
(
mFrameWidth
*
-
1
)));
path
=
path
.
subtracted
(
extruded
);
path
=
path
.
subtracted
(
extruded
);
}
}
painter
->
fillPath
(
path
,
brush
());
painter
->
fillPath
(
path
,
brush
());
}
}
QPainterPath
UBGraphicsDelegateFrame
::
shape
()
const
QPainterPath
UBGraphicsDelegateFrame
::
shape
()
const
{
{
QPainterPath
path
;
QPainterPath
path
;
//We do not use the rounded rect here because we want the bottom right corner
//We do not use the rounded rect here because we want the bottom right corner
//to be included in the frame (for resize grip handling : #702)
//to be included in the frame (for resize grip handling : #702)
path
.
addRect
(
rect
());
path
.
addRect
(
rect
());
if
(
rect
().
width
()
>
0
&&
rect
().
height
()
>
0
)
if
(
rect
().
width
()
>
0
&&
rect
().
height
()
>
0
)
{
{
QPainterPath
extruded
;
QPainterPath
extruded
;
extruded
.
addRect
(
rect
().
adjusted
(
mFrameWidth
,
mFrameWidth
,
mFrameWidth
*
-
1
,
mFrameWidth
*
-
1
));
extruded
.
addRect
(
rect
().
adjusted
(
mFrameWidth
,
mFrameWidth
,
mFrameWidth
*
-
1
,
mFrameWidth
*
-
1
));
path
=
path
.
subtracted
(
extruded
);
path
=
path
.
subtracted
(
extruded
);
}
}
return
path
;
return
path
;
}
}
void
UBGraphicsDelegateFrame
::
initializeTransform
()
void
UBGraphicsDelegateFrame
::
initializeTransform
()
{
{
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
QRectF
itemRect
=
delegated
()
->
boundingRect
();
QRectF
itemRect
=
delegated
()
->
boundingRect
();
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
QPointF
topRight
=
itemTransform
.
map
(
itemRect
.
topRight
());
QPointF
topRight
=
itemTransform
.
map
(
itemRect
.
topRight
());
QPointF
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
QPointF
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
qreal
horizontalFlip
=
(
topLeft
.
x
()
>
topRight
.
x
())
?
-
1
:
1
;
qreal
horizontalFlip
=
(
topLeft
.
x
()
>
topRight
.
x
())
?
-
1
:
1
;
mMirrorX
=
horizontalFlip
<
0
;
mMirrorX
=
horizontalFlip
<
0
;
if
(
horizontalFlip
<
0
){
if
(
horizontalFlip
<
0
){
// why this is because of the way of calculating the translations that checks which side is the most is the
// why this is because of the way of calculating the translations that checks which side is the most is the
// nearest instead of checking which one is the left side.
// nearest instead of checking which one is the left side.
QPointF
tmp
=
topLeft
;
QPointF
tmp
=
topLeft
;
topLeft
=
topRight
;
topLeft
=
topRight
;
topRight
=
tmp
;
topRight
=
tmp
;
// because of the calculation of the height is done by lenght and not deltaY
// because of the calculation of the height is done by lenght and not deltaY
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomRight
());
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomRight
());
}
}
qreal
verticalFlip
=
(
bottomLeft
.
y
()
<
topLeft
.
y
())
?
-
1
:
1
;
qreal
verticalFlip
=
(
bottomLeft
.
y
()
<
topLeft
.
y
())
?
-
1
:
1
;
// not sure that is usefull
// not sure that is usefull
mMirrorY
=
verticalFlip
<
0
;
mMirrorY
=
verticalFlip
<
0
;
if
(
verticalFlip
<
0
&&
!
mMirrorX
){
if
(
verticalFlip
<
0
&&
!
mMirrorX
){
topLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
topLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
topRight
=
itemTransform
.
map
(
itemRect
.
bottomRight
());
topRight
=
itemTransform
.
map
(
itemRect
.
bottomRight
());
bottomLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
bottomLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
}
}
QLineF
topLine
(
topLeft
,
topRight
);
QLineF
topLine
(
topLeft
,
topRight
);
QLineF
leftLine
(
topLeft
,
bottomLeft
);
QLineF
leftLine
(
topLeft
,
bottomLeft
);
qreal
width
=
topLine
.
length
();
qreal
width
=
topLine
.
length
();
qreal
height
=
leftLine
.
length
();
qreal
height
=
leftLine
.
length
();
mAngle
=
topLine
.
angle
();
mAngle
=
topLine
.
angle
();
// the fact the the length is used we loose the horizontalFlip information
// the fact the the length is used we loose the horizontalFlip information
// a better way to do this is using DeltaX that preserve the direction information.
// a better way to do this is using DeltaX that preserve the direction information.
mTotalScaleX
=
(
width
/
itemRect
.
width
())
*
horizontalFlip
;
mTotalScaleX
=
(
width
/
itemRect
.
width
())
*
horizontalFlip
;
mTotalScaleY
=
height
/
itemRect
.
height
()
*
verticalFlip
;
mTotalScaleY
=
height
/
itemRect
.
height
()
*
verticalFlip
;
QTransform
tr
;
QTransform
tr
;
QPointF
center
=
delegated
()
->
boundingRect
().
center
();
QPointF
center
=
delegated
()
->
boundingRect
().
center
();
tr
.
translate
(
center
.
x
()
*
mTotalScaleX
,
center
.
y
()
*
mTotalScaleY
);
tr
.
translate
(
center
.
x
()
*
mTotalScaleX
,
center
.
y
()
*
mTotalScaleY
);
tr
.
rotate
(
-
mAngle
);
tr
.
rotate
(
-
mAngle
);
tr
.
translate
(
-
center
.
x
()
*
mTotalScaleX
,
-
center
.
y
()
*
mTotalScaleY
);
tr
.
translate
(
-
center
.
x
()
*
mTotalScaleX
,
-
center
.
y
()
*
mTotalScaleY
);
tr
.
scale
(
mTotalScaleX
,
mTotalScaleY
);
tr
.
scale
(
mTotalScaleX
,
mTotalScaleY
);
mTotalTranslateX
=
delegated
()
->
transform
().
dx
()
-
tr
.
dx
();
mTotalTranslateX
=
delegated
()
->
transform
().
dx
()
-
tr
.
dx
();
mTotalTranslateY
=
delegated
()
->
transform
().
dy
()
-
tr
.
dy
();
mTotalTranslateY
=
delegated
()
->
transform
().
dy
()
-
tr
.
dy
();
}
}
void
UBGraphicsDelegateFrame
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsDelegateFrame
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
mDelegate
->
startUndoStep
();
mDelegate
->
startUndoStep
();
mStartingPoint
=
event
->
scenePos
();
mStartingPoint
=
event
->
scenePos
();
initializeTransform
();
initializeTransform
();
mScaleX
=
1
;
mScaleX
=
1
;
mScaleY
=
1
;
mScaleY
=
1
;
mTranslateX
=
0
;
mTranslateX
=
0
;
mTranslateY
=
0
;
mTranslateY
=
0
;
mAngleOffset
=
0
;
mAngleOffset
=
0
;
mInitialTransform
=
buildTransform
();
mInitialTransform
=
buildTransform
();
mCurrentTool
=
toolFromPos
(
event
->
pos
());
mCurrentTool
=
toolFromPos
(
event
->
pos
());
event
->
accept
();
event
->
accept
();
}
}
bool
UBGraphicsDelegateFrame
::
canResizeBottomRight
(
qreal
width
,
qreal
height
,
qreal
scaleFactor
)
bool
UBGraphicsDelegateFrame
::
canResizeBottomRight
(
qreal
width
,
qreal
height
,
qreal
scaleFactor
)
{
{
bool
res
=
false
;
bool
res
=
false
;
if
(
!
mMirrorX
&&
!
mMirrorX
&&
((
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
)){
if
(
!
mMirrorX
&&
!
mMirrorX
&&
((
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
)){
res
=
true
;
res
=
true
;
}
else
if
(
mMirrorX
&&
!
mMirrorY
&&
(
-
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
}
else
if
(
mMirrorX
&&
!
mMirrorY
&&
(
-
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
res
=
true
;
res
=
true
;
}
else
if
(
!
mMirrorX
&&
mMirrorY
&&
(
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
-
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
}
else
if
(
!
mMirrorX
&&
mMirrorY
&&
(
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
-
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
res
=
true
;
res
=
true
;
}
else
if
(
mMirrorX
&&
mMirrorY
&&
(
-
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
-
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
}
else
if
(
mMirrorX
&&
mMirrorY
&&
(
-
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
-
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
res
=
true
;
res
=
true
;
}
}
return
res
;
return
res
;
}
}
void
UBGraphicsDelegateFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsDelegateFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
QLineF
move
(
mStartingPoint
,
event
->
scenePos
());
QLineF
move
(
mStartingPoint
,
event
->
scenePos
());
qreal
moveX
=
move
.
length
()
*
cos
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
moveX
=
move
.
length
()
*
cos
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
moveY
=
-
move
.
length
()
*
sin
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
moveY
=
-
move
.
length
()
*
sin
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
width
=
delegated
()
->
boundingRect
().
width
()
*
mTotalScaleX
;
qreal
width
=
delegated
()
->
boundingRect
().
width
()
*
mTotalScaleX
;
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
if
(
mOperationMode
==
Scaling
)
if
(
mOperationMode
==
Scaling
)
{
{
mTranslateX
=
moveX
;
mTranslateX
=
moveX
;
// Perform the resize
// Perform the resize
if
(
resizingBottomRight
())
if
(
resizingBottomRight
())
{
{
// -----------------------------------------------------
// -----------------------------------------------------
// ! We want to keep the aspect ratio with this resize !
// ! We want to keep the aspect ratio with this resize !
// -----------------------------------------------------
// -----------------------------------------------------
qreal
scaleX
;
qreal
scaleX
;
qreal
scaleY
;
qreal
scaleY
;
if
(
!
mMirrorX
){
if
(
!
mMirrorX
){
scaleX
=
(
width
+
moveX
)
/
width
;
scaleX
=
(
width
+
moveX
)
/
width
;
}
else
{
}
else
{
scaleX
=
(
width
-
moveX
)
/
width
;
scaleX
=
(
width
-
moveX
)
/
width
;
}
}
if
(
!
mMirrorY
){
if
(
!
mMirrorY
){
scaleY
=
(
height
+
moveY
)
/
height
;
scaleY
=
(
height
+
moveY
)
/
height
;
}
else
{
}
else
{
scaleY
=
(
height
-
moveY
)
/
height
;
scaleY
=
(
height
-
moveY
)
/
height
;
}
}
qreal
scaleFactor
=
(
scaleX
+
scaleY
)
/
2
;
qreal
scaleFactor
=
(
scaleX
+
scaleY
)
/
2
;
// Do not allow resizing of image size under frame size
// Do not allow resizing of image size under frame size
if
(
canResizeBottomRight
(
width
,
height
,
scaleFactor
))
if
(
canResizeBottomRight
(
width
,
height
,
scaleFactor
))
{
{
if
(
mRespectRatio
)
if
(
mRespectRatio
)
{
{
mScaleX
=
scaleFactor
;
mScaleX
=
scaleFactor
;
mScaleY
=
scaleFactor
;
mScaleY
=
scaleFactor
;
}
}
else
else
{
{
mScaleX
=
scaleX
;
mScaleX
=
scaleX
;
mScaleY
=
scaleY
;
mScaleY
=
scaleY
;
}
}
}
}
}
else
if
(
resizingLeft
()
||
resizingRight
())
}
else
if
(
resizingLeft
()
||
resizingRight
())
{
{
if
(
width
!=
0
){
if
(
width
!=
0
){
qreal
scaleX
=
0.0
;
qreal
scaleX
=
0.0
;
if
(
resizingLeft
()){
if
(
resizingLeft
()){
scaleX
=
(
width
-
moveX
)
/
width
;
scaleX
=
(
width
-
moveX
)
/
width
;
}
else
if
(
resizingRight
()){
}
else
if
(
resizingRight
()){
scaleX
=
(
width
+
moveX
)
/
width
;
scaleX
=
(
width
+
moveX
)
/
width
;
}
}
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleX
)
!=
0
){
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleX
)
!=
0
){
if
((
qAbs
(
width
*
scaleX
))
<
2
*
mFrameWidth
){
if
((
qAbs
(
width
*
scaleX
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleX
<
0
)
?
true
:
false
;
bool
negative
=
(
scaleX
<
0
)
?
true
:
false
;
if
(
negative
){
if
(
negative
){
if
(
mMirrorX
)
if
(
mMirrorX
)
scaleX
=
2
*
mFrameWidth
/
width
;
scaleX
=
2
*
mFrameWidth
/
width
;
else
else
scaleX
=
-
2
*
mFrameWidth
/
width
;
scaleX
=
-
2
*
mFrameWidth
/
width
;
}
else
{
}
else
{
scaleX
=
-
1
;
scaleX
=
-
1
;
}
}
}
}
mScaleX
=
scaleX
;
mScaleX
=
scaleX
;
}
else
if
(
scaleX
>
1
||
(
width
*
scaleX
)
>
2
*
mFrameWidth
){
}
else
if
(
scaleX
>
1
||
(
width
*
scaleX
)
>
2
*
mFrameWidth
){
mScaleX
=
scaleX
;
mScaleX
=
scaleX
;
if
(
resizingLeft
()){
if
(
resizingLeft
()){
mTranslateX
=
moveX
;
mTranslateX
=
moveX
;
}
}
}
}
}
}
}
else
if
(
resizingTop
()
||
resizingBottom
()){
}
else
if
(
resizingTop
()
||
resizingBottom
()){
if
(
height
!=
0
){
if
(
height
!=
0
){
qreal
scaleY
=
0.0
;
qreal
scaleY
=
0.0
;
if
(
resizingTop
()){
if
(
resizingTop
()){
scaleY
=
(
height
-
moveY
)
/
height
;
scaleY
=
(
height
-
moveY
)
/
height
;
}
else
if
(
resizingBottom
()){
}
else
if
(
resizingBottom
()){
scaleY
=
(
height
+
moveY
)
/
height
;
scaleY
=
(
height
+
moveY
)
/
height
;
}
}
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleY
)
!=
0
){
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleY
)
!=
0
){
if
((
qAbs
(
height
*
scaleY
))
<
2
*
mFrameWidth
){
if
((
qAbs
(
height
*
scaleY
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleY
<
0
)
?
true
:
false
;
bool
negative
=
(
scaleY
<
0
)
?
true
:
false
;
if
(
negative
){
if
(
negative
){
if
(
mMirrorY
)
if
(
mMirrorY
)
scaleY
=
2
*
mFrameWidth
/
width
;
scaleY
=
2
*
mFrameWidth
/
width
;
else
else
scaleY
=
-
2
*
mFrameWidth
/
width
;
scaleY
=
-
2
*
mFrameWidth
/
width
;
}
else
{
}
else
{
scaleY
=
-
1
;
scaleY
=
-
1
;
}
}
}
}
mScaleY
=
scaleY
;
mScaleY
=
scaleY
;
}
else
if
(
scaleY
>
1
||
(
height
*
scaleY
)
>
2
*
mFrameWidth
)
}
else
if
(
scaleY
>
1
||
(
height
*
scaleY
)
>
2
*
mFrameWidth
)
{
{
mScaleY
=
scaleY
;
mScaleY
=
scaleY
;
if
(
resizingTop
()){
if
(
resizingTop
()){
mTranslateY
=
moveY
;
mTranslateY
=
moveY
;
}
}
}
}
}
}
}
}
}
}
else
if
(
mOperationMode
==
Resizing
)
else
if
(
mOperationMode
==
Resizing
)
{
{
mTranslateX
=
moveX
;
mTranslateX
=
moveX
;
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
if
(
resizableItem
)
{
{
QLineF
mousePosDelta
(
delegated
()
->
mapFromScene
(
event
->
lastScenePos
())
QLineF
mousePosDelta
(
delegated
()
->
mapFromScene
(
event
->
lastScenePos
())
,
delegated
()
->
mapFromScene
(
event
->
scenePos
()));
,
delegated
()
->
mapFromScene
(
event
->
scenePos
()));
QSizeF
incVector
(
0
,
0
);
QSizeF
incVector
(
0
,
0
);
if
(
resizingBottomRight
())
if
(
resizingBottomRight
())
{
{
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
mousePosDelta
.
dy
());
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
mousePosDelta
.
dy
());
}
}
else
if
(
resizingRight
())
else
if
(
resizingRight
())
{
{
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
0
);
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
0
);
}
}
else
if
(
resizingBottom
())
else
if
(
resizingBottom
())
{
{
incVector
=
QSizeF
(
0
,
mousePosDelta
.
dy
());
incVector
=
QSizeF
(
0
,
mousePosDelta
.
dy
());
}
}
else
if
(
resizingLeft
())
else
if
(
resizingLeft
())
{
{
incVector
=
QSizeF
(
-
mousePosDelta
.
dx
(),
0
);
incVector
=
QSizeF
(
-
mousePosDelta
.
dx
(),
0
);
}
}
else
if
(
resizingTop
())
else
if
(
resizingTop
())
{
{
incVector
=
QSizeF
(
0
,
-
mousePosDelta
.
dy
());
incVector
=
QSizeF
(
0
,
-
mousePosDelta
.
dy
());
}
}
QSizeF
newSize
=
resizableItem
->
size
()
+
incVector
;
QSizeF
newSize
=
resizableItem
->
size
()
+
incVector
;
resizableItem
->
resize
(
newSize
);
if
(
!
(
mDelegate
->
getToolBarItem
()
->
isVisibleOnBoard
()
}
&&
(
newSize
.
width
()
<
mDelegate
->
getToolBarItem
()
->
minWidth
()
/
mDelegate
->
antiScaleRatio
()
}
||
newSize
.
height
()
<
mDelegate
->
getToolBarItem
()
->
minWidth
()
/
mDelegate
->
antiScaleRatio
()
*
3
/
4
)))
resizableItem
->
resize
(
newSize
);
if
(
rotating
())
}
{
}
mTranslateX
=
0
;
mTranslateY
=
0
;
if
(
rotating
())
{
QLineF
startLine
(
sceneBoundingRect
().
center
(),
event
->
lastScenePos
());
mTranslateX
=
0
;
QLineF
currentLine
(
sceneBoundingRect
().
center
(),
event
->
scenePos
());
mTranslateY
=
0
;
mAngle
+=
startLine
.
angleTo
(
currentLine
);
QLineF
startLine
(
sceneBoundingRect
().
center
(),
event
->
lastScenePos
());
if
((
int
)
mAngle
%
45
>=
45
-
mAngleTolerance
||
(
int
)
mAngle
%
45
<=
mAngleTolerance
)
QLineF
currentLine
(
sceneBoundingRect
().
center
(),
event
->
scenePos
());
{
mAngle
+=
startLine
.
angleTo
(
currentLine
);
mAngle
=
qRound
(
mAngle
/
45
)
*
45
;
mAngleOffset
+=
startLine
.
angleTo
(
currentLine
);
if
((
int
)
mAngle
%
45
>=
45
-
mAngleTolerance
||
(
int
)
mAngle
%
45
<=
mAngleTolerance
)
if
((
int
)
mAngleOffset
%
360
>
mAngleTolerance
&&
(
int
)
mAngleOffset
%
360
<
360
-
mAngleTolerance
)
{
{
mAngle
=
qRound
(
mAngle
/
45
)
*
45
;
mAngle
+=
mAngleOffset
;
mAngleOffset
+=
startLine
.
angleTo
(
currentLine
);
mAngleOffset
=
0
;
if
((
int
)
mAngleOffset
%
360
>
mAngleTolerance
&&
(
int
)
mAngleOffset
%
360
<
360
-
mAngleTolerance
)
}
{
}
mAngle
+=
mAngleOffset
;
else
if
((
int
)
mAngle
%
30
>=
30
-
mAngleTolerance
||
(
int
)
mAngle
%
30
<=
mAngleTolerance
)
mAngleOffset
=
0
;
{
}
mAngle
=
qRound
(
mAngle
/
30
)
*
30
;
}
mAngleOffset
+=
startLine
.
angleTo
(
currentLine
);
else
if
((
int
)
mAngle
%
30
>=
30
-
mAngleTolerance
||
(
int
)
mAngle
%
30
<=
mAngleTolerance
)
if
((
int
)
mAngleOffset
%
360
>
mAngleTolerance
&&
(
int
)
mAngleOffset
%
360
<
360
-
mAngleTolerance
)
{
{
mAngle
=
qRound
(
mAngle
/
30
)
*
30
;
mAngle
+=
mAngleOffset
;
mAngleOffset
+=
startLine
.
angleTo
(
currentLine
);
mAngleOffset
=
0
;
if
((
int
)
mAngleOffset
%
360
>
mAngleTolerance
&&
(
int
)
mAngleOffset
%
360
<
360
-
mAngleTolerance
)
}
{
}
mAngle
+=
mAngleOffset
;
mAngleOffset
=
0
;
if
(
!
angleWidget
->
isVisible
())
}
angleWidget
->
show
();
}
angleWidget
->
setText
(
QString
::
number
((
int
)
mAngle
%
360
));
if
(
!
angleWidget
->
isVisible
())
angleWidget
->
update
();
angleWidget
->
show
();
}
angleWidget
->
setText
(
QString
::
number
((
int
)
mAngle
%
360
));
else
if
(
moving
())
angleWidget
->
update
();
{
mTranslateX
=
move
.
dx
();
}
mTranslateY
=
move
.
dy
();
else
if
(
moving
())
}
{
mTranslateX
=
move
.
dx
();
QTransform
tr
=
buildTransform
();
mTranslateY
=
move
.
dy
();
}
//TODO UB 4.x: Could find a better solution ?
if
(
resizingRight
()
||
resizingBottom
()
||
resizingBottomRight
())
QTransform
tr
=
buildTransform
();
{
QPointF
ref
;
//TODO UB 4.x: Could find a better solution ?
if
(
!
mMirrorX
&&
!
mMirrorY
){
if
(
resizingRight
()
||
resizingBottom
()
||
resizingBottomRight
())
ref
=
delegated
()
->
boundingRect
().
topLeft
();
{
}
else
if
(
mMirrorX
&&
!
mMirrorY
){
QPointF
ref
;
ref
=
delegated
()
->
boundingRect
().
topLeft
();
if
(
!
mMirrorX
&&
!
mMirrorY
){
}
else
if
(
!
mMirrorX
&&
mMirrorY
){
ref
=
delegated
()
->
boundingRect
().
topLeft
();
ref
=
delegated
()
->
boundingRect
().
topLeft
();
}
else
if
(
mMirrorX
&&
!
mMirrorY
){
}
else
if
(
mMirrorX
&&
mMirrorY
){
ref
=
delegated
()
->
boundingRect
().
topLeft
();
ref
=
delegated
()
->
boundingRect
().
topRight
();
}
else
if
(
!
mMirrorX
&&
mMirrorY
){
}
ref
=
delegated
()
->
boundingRect
().
topLeft
();
}
else
if
(
mMirrorX
&&
mMirrorY
){
// Map the item topleft point to the current mouse move transform
ref
=
delegated
()
->
boundingRect
().
topRight
();
QPointF
topLeft
=
tr
.
map
(
ref
);
}
// Map the item topleft point to the mouse press transform
// Map the item topleft point to the current mouse move transform
QPointF
fixedPoint
=
mInitialTransform
.
map
(
ref
);
QPointF
topLeft
=
tr
.
map
(
ref
);
// Update the translation coordinates
// Map the item topleft point to the mouse press transform
mTranslateX
+=
fixedPoint
.
x
()
-
topLeft
.
x
();
QPointF
fixedPoint
=
mInitialTransform
.
map
(
ref
);
mTranslateY
+=
fixedPoint
.
y
()
-
topLeft
.
y
();
// Update the translation coordinates
// Update the transform
mTranslateX
+=
fixedPoint
.
x
()
-
topLeft
.
x
();
tr
=
buildTransform
();
mTranslateY
+=
fixedPoint
.
y
()
-
topLeft
.
y
();
}
else
if
(
resizingTop
()
||
resizingLeft
())
// Update the transform
{
tr
=
buildTransform
();
if
(
mOperationMode
==
Scaling
)
}
{
else
if
(
resizingTop
()
||
resizingLeft
())
QPointF
bottomRight
=
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
{
QPointF
fixedPoint
=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
if
(
mOperationMode
==
Scaling
)
mTranslateX
+=
fixedPoint
.
x
()
-
bottomRight
.
x
();
{
mTranslateY
+=
fixedPoint
.
y
()
-
bottomRight
.
y
();
QPointF
bottomRight
=
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
}
QPointF
fixedPoint
=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
else
mTranslateX
+=
fixedPoint
.
x
()
-
bottomRight
.
x
();
{
mTranslateY
+=
fixedPoint
.
y
()
-
bottomRight
.
y
();
QLineF
vector
;
}
if
(
resizingLeft
())
else
{
{
QPointF
topRight1
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
()
-
moveX
,
0
));
QLineF
vector
;
QPointF
topRight2
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
(),
0
));
if
(
resizingLeft
())
vector
.
setPoints
(
topRight1
,
topRight2
);
{
}
QPointF
topRight1
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
()
-
moveX
,
0
));
else
QPointF
topRight2
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
(),
0
));
{
vector
.
setPoints
(
topRight1
,
topRight2
);
QPointF
bottomLeft1
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()
-
moveY
));
}
QPointF
bottomLeft2
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()));
else
vector
.
setPoints
(
bottomLeft1
,
bottomLeft2
);
{
}
QPointF
bottomLeft1
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()
-
moveY
));
mTranslateX
=
vector
.
dx
();
QPointF
bottomLeft2
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()));
mTranslateY
=
vector
.
dy
();
vector
.
setPoints
(
bottomLeft1
,
bottomLeft2
);
}
}
tr
=
buildTransform
();
mTranslateX
=
vector
.
dx
();
}
mTranslateY
=
vector
.
dy
();
}
delegated
()
->
setTransform
(
tr
);
tr
=
buildTransform
();
event
->
accept
();
}
}
delegated
()
->
setTransform
(
tr
);
event
->
accept
();
QTransform
UBGraphicsDelegateFrame
::
buildTransform
()
}
{
QTransform
tr
;
QPointF
center
=
delegated
()
->
boundingRect
().
center
();
QTransform
UBGraphicsDelegateFrame
::
buildTransform
()
{
// Translate
QTransform
tr
;
tr
.
translate
(
mTotalTranslateX
+
mTranslateX
,
mTotalTranslateY
+
mTranslateY
);
QPointF
center
=
delegated
()
->
boundingRect
().
center
();
// Set angle
// Translate
tr
.
translate
(
center
.
x
()
*
mTotalScaleX
*
mScaleX
,
center
.
y
()
*
mTotalScaleY
*
mScaleY
);
tr
.
translate
(
mTotalTranslateX
+
mTranslateX
,
mTotalTranslateY
+
mTranslateY
);
tr
.
rotate
(
-
mAngle
);
tr
.
translate
(
-
center
.
x
()
*
mTotalScaleX
*
mScaleX
,
-
center
.
y
()
*
mTotalScaleY
*
mScaleY
);
// Set angle
tr
.
translate
(
center
.
x
()
*
mTotalScaleX
*
mScaleX
,
center
.
y
()
*
mTotalScaleY
*
mScaleY
);
// Scale
tr
.
rotate
(
-
mAngle
);
tr
.
scale
(
mTotalScaleX
*
mScaleX
,
mTotalScaleY
*
mScaleY
);
tr
.
translate
(
-
center
.
x
()
*
mTotalScaleX
*
mScaleX
,
-
center
.
y
()
*
mTotalScaleY
*
mScaleY
);
return
tr
;
}
// Scale
tr
.
scale
(
mTotalScaleX
*
mScaleX
,
mTotalScaleY
*
mScaleY
);
return
tr
;
void
UBGraphicsDelegateFrame
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
}
{
if
(
angleWidget
->
isVisible
())
angleWidget
->
hide
();
void
UBGraphicsDelegateFrame
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
updateResizeCursors
();
if
(
angleWidget
->
isVisible
())
angleWidget
->
hide
();
mDelegate
->
commitUndoStep
();
mTotalScaleX
*=
mScaleX
;
updateResizeCursors
();
mTotalScaleY
*=
mScaleY
;
mTotalTranslateX
+=
mTranslateX
;
mDelegate
->
commitUndoStep
();
mTotalTranslateY
+=
mTranslateY
;
mTotalScaleX
*=
mScaleX
;
event
->
accept
();
mTotalScaleY
*=
mScaleY
;
mTotalTranslateX
+=
mTranslateX
;
mCurrentTool
=
None
;
mTotalTranslateY
+=
mTranslateY
;
QGraphicsRectItem
::
mouseReleaseEvent
(
event
);
event
->
accept
();
// Show the buttons
mCurrentTool
=
None
;
if
(
isResizing
()){
QGraphicsRectItem
::
mouseReleaseEvent
(
event
);
mResizing
=
false
;
}
// Show the buttons
mDelegate
->
setButtonsVisible
(
true
);
if
(
isResizing
()){
}
mResizing
=
false
;
}
mDelegate
->
setButtonsVisible
(
true
);
void
UBGraphicsDelegateFrame
::
updateResizeCursors
()
}
{
QPixmap
pix
(
":/images/cursors/resize.png"
);
QTransform
tr
;
void
UBGraphicsDelegateFrame
::
updateResizeCursors
()
{
tr
.
rotate
(
-
mAngle
);
QPixmap
pix
(
":/images/cursors/resize.png"
);
QCursor
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
QTransform
tr
;
mLeftResizeGrip
->
setCursor
(
resizeCursor
);
mRightResizeGrip
->
setCursor
(
resizeCursor
);
tr
.
rotate
(
-
mAngle
);
QCursor
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
tr
.
rotate
(
-
90
);
mLeftResizeGrip
->
setCursor
(
resizeCursor
);
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
mRightResizeGrip
->
setCursor
(
resizeCursor
);
mBottomResizeGrip
->
setCursor
(
resizeCursor
);
mTopResizeGrip
->
setCursor
(
resizeCursor
);
tr
.
rotate
(
-
90
);
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
tr
.
rotate
(
-
45
);
mBottomResizeGrip
->
setCursor
(
resizeCursor
);
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
mTopResizeGrip
->
setCursor
(
resizeCursor
);
mBottomRightResizeGrip
->
setCursor
(
resizeCursor
);
}
tr
.
rotate
(
-
45
);
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
mBottomRightResizeGrip
->
setCursor
(
resizeCursor
);
void
UBGraphicsDelegateFrame
::
setVisible
(
bool
visible
)
}
{
mVisible
=
visible
;
if
(
mVisible
)
void
UBGraphicsDelegateFrame
::
setVisible
(
bool
visible
)
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
{
else
mVisible
=
visible
;
setBrush
(
Qt
::
NoBrush
);
if
(
mVisible
)
}
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
else
setBrush
(
Qt
::
NoBrush
);
void
UBGraphicsDelegateFrame
::
positionHandles
()
}
{
QRectF
itemRect
=
delegated
()
->
boundingRect
();
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
void
UBGraphicsDelegateFrame
::
positionHandles
()
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
{
QPointF
topRight
=
itemTransform
.
map
(
itemRect
.
topRight
());
QRectF
itemRect
=
delegated
()
->
boundingRect
();
QPointF
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
QPointF
bottomRight
=
itemTransform
.
map
(
itemRect
.
bottomRight
());
if
(
mDelegate
->
getToolBarItem
()
->
isVisibleOnBoard
()
QPointF
center
=
itemTransform
.
map
(
itemRect
.
center
());
&&
mDelegate
->
getToolBarItem
()
->
isShifting
())
int
rotateHeight
=
QLineF
(
topLeft
,
bottomLeft
).
length
();
itemRect
.
setHeight
(
itemRect
.
height
()
+
mDelegate
->
getToolBarItem
()
->
rect
().
height
()
*
mDelegate
->
antiScaleRatio
()
*
1.1
);
// Handle the mirroring
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
if
(
topLeft
.
x
()
>
topRight
.
x
()){
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
QPointF
topTmp
=
topRight
;
QPointF
topRight
=
itemTransform
.
map
(
itemRect
.
topRight
());
QPointF
bottomTmp
=
bottomRight
;
QPointF
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
topRight
=
topLeft
;
QPointF
bottomRight
=
itemTransform
.
map
(
itemRect
.
bottomRight
());
topLeft
=
topTmp
;
QPointF
center
=
itemTransform
.
map
(
itemRect
.
center
());
bottomRight
=
bottomLeft
;
int
rotateHeight
=
QLineF
(
topLeft
,
bottomLeft
).
length
();
bottomLeft
=
bottomTmp
;
}
// Handle the mirroring
if
(
topLeft
.
x
()
>
topRight
.
x
()){
if
(
bottomLeft
.
y
()
>
topLeft
.
y
()){
QPointF
topTmp
=
topRight
;
QPointF
leftTmp
=
bottomLeft
;
QPointF
bottomTmp
=
bottomRight
;
QPointF
rightTmp
=
bottomRight
;
topRight
=
topLeft
;
bottomLeft
=
topLeft
;
topLeft
=
topTmp
;
topLeft
=
leftTmp
;
bottomRight
=
bottomLeft
;
bottomRight
=
topRight
;
bottomLeft
=
bottomTmp
;
topRight
=
rightTmp
;
}
}
if
(
bottomLeft
.
y
()
>
topLeft
.
y
()){
QLineF
topLine
(
topLeft
,
topRight
);
QPointF
leftTmp
=
bottomLeft
;
qreal
angle
=
topLine
.
angle
();
QPointF
rightTmp
=
bottomRight
;
qreal
width
=
topLine
.
length
();
bottomLeft
=
topLeft
;
topLeft
=
leftTmp
;
QLineF
leftLine
(
topLeft
,
bottomLeft
);
bottomRight
=
topRight
;
qreal
height
=
leftLine
.
length
();
topRight
=
rightTmp
;
}
int
h
=
rotating
()
?
rotateHeight
:
height
;
QLineF
topLine
(
topLeft
,
topRight
);
if
(
mVisible
)
qreal
angle
=
topLine
.
angle
();
{
qreal
width
=
topLine
.
length
();
setRect
(
center
.
x
()
-
mFrameWidth
-
width
/
2
,
center
.
y
()
-
mFrameWidth
-
h
/
2
,
width
+
2
*
mFrameWidth
,
h
+
2
*
mFrameWidth
);
}
QLineF
leftLine
(
topLeft
,
bottomLeft
);
else
qreal
height
=
leftLine
.
length
();
{
setRect
(
center
.
x
()
-
width
/
2
,
center
.
y
()
-
h
/
2
,
width
,
h
);
int
h
=
rotating
()
?
rotateHeight
:
height
;
}
if
(
mVisible
)
resetTransform
();
{
translate
(
center
.
x
(),
center
.
y
());
setRect
(
center
.
x
()
-
mFrameWidth
-
width
/
2
,
center
.
y
()
-
mFrameWidth
-
h
/
2
,
width
+
2
*
mFrameWidth
,
h
+
2
*
mFrameWidth
);
rotate
(
-
angle
);
}
translate
(
-
center
.
x
(),
-
center
.
y
());
else
{
mBottomRightResizeGripSvgItem
->
setParentItem
(
this
);
setRect
(
center
.
x
()
-
width
/
2
,
center
.
y
()
-
h
/
2
,
width
,
h
);
mBottomResizeGripSvgItem
->
setParentItem
(
this
);
}
mLeftResizeGripSvgItem
->
setParentItem
(
this
);
mRightResizeGripSvgItem
->
setParentItem
(
this
);
resetTransform
();
mTopResizeGripSvgItem
->
setParentItem
(
this
);
translate
(
center
.
x
(),
center
.
y
());
mRotateButton
->
setParentItem
(
this
);
rotate
(
-
angle
);
translate
(
-
center
.
x
(),
-
center
.
y
());
mBottomRightResizeGrip
->
setParentItem
(
this
);
mBottomResizeGrip
->
setParentItem
(
this
);
mBottomRightResizeGripSvgItem
->
setParentItem
(
this
);
mLeftResizeGrip
->
setParentItem
(
this
);
mBottomResizeGripSvgItem
->
setParentItem
(
this
);
mRightResizeGrip
->
setParentItem
(
this
);
mLeftResizeGripSvgItem
->
setParentItem
(
this
);
mTopResizeGrip
->
setParentItem
(
this
);
mRightResizeGripSvgItem
->
setParentItem
(
this
);
mTopResizeGripSvgItem
->
setParentItem
(
this
);
QRectF
brRect
=
mBottomRightResizeGripSvgItem
->
mapRectToParent
(
mBottomRightResizeGripSvgItem
->
boundingRect
());
mRotateButton
->
setParentItem
(
this
);
QRectF
bRect
=
mBottomResizeGripSvgItem
->
mapRectToParent
(
mBottomResizeGripSvgItem
->
boundingRect
());
QRectF
lRect
=
mLeftResizeGripSvgItem
->
mapRectToParent
(
mLeftResizeGripSvgItem
->
boundingRect
());
mBottomRightResizeGrip
->
setParentItem
(
this
);
QRectF
rRect
=
mRightResizeGripSvgItem
->
mapRectToParent
(
mRightResizeGripSvgItem
->
boundingRect
());
mBottomResizeGrip
->
setParentItem
(
this
);
QRectF
trRect
=
mTopResizeGripSvgItem
->
mapRectToParent
(
mTopResizeGripSvgItem
->
boundingRect
());
mLeftResizeGrip
->
setParentItem
(
this
);
mRightResizeGrip
->
setParentItem
(
this
);
mBottomRightResizeGripSvgItem
->
setPos
(
rect
().
right
()
-
brRect
.
width
(),
rect
().
bottom
()
-
brRect
.
height
());
mTopResizeGrip
->
setParentItem
(
this
);
mBottomResizeGripSvgItem
->
setPos
(
rect
().
center
().
x
()
-
bRect
.
width
()
/
2
,
rect
().
bottom
()
-
bRect
.
height
());
QRectF
brRect
=
mBottomRightResizeGripSvgItem
->
mapRectToParent
(
mBottomRightResizeGripSvgItem
->
boundingRect
());
mLeftResizeGripSvgItem
->
setPos
(
rect
().
left
(),
rect
().
center
().
y
()
-
lRect
.
height
()
/
2
);
QRectF
bRect
=
mBottomResizeGripSvgItem
->
mapRectToParent
(
mBottomResizeGripSvgItem
->
boundingRect
());
mRightResizeGripSvgItem
->
setPos
(
rect
().
right
()
-
rRect
.
width
(),
rect
().
center
().
y
()
-
rRect
.
height
()
/
2
);
QRectF
lRect
=
mLeftResizeGripSvgItem
->
mapRectToParent
(
mLeftResizeGripSvgItem
->
boundingRect
());
QRectF
rRect
=
mRightResizeGripSvgItem
->
mapRectToParent
(
mRightResizeGripSvgItem
->
boundingRect
());
mTopResizeGripSvgItem
->
setPos
(
rect
().
center
().
x
()
-
trRect
.
width
()
/
2
,
rect
().
y
());
QRectF
trRect
=
mTopResizeGripSvgItem
->
mapRectToParent
(
mTopResizeGripSvgItem
->
boundingRect
());
mRotateButton
->
setPos
(
rect
().
right
()
-
mFrameWidth
-
5
,
rect
().
top
()
+
5
);
mBottomRightResizeGripSvgItem
->
setPos
(
rect
().
right
()
-
brRect
.
width
(),
rect
().
bottom
()
-
brRect
.
height
());
mBottomRightResizeGrip
->
setRect
(
bottomRightResizeGripRect
());
mBottomResizeGripSvgItem
->
setPos
(
rect
().
center
().
x
()
-
bRect
.
width
()
/
2
,
rect
().
bottom
()
-
bRect
.
height
());
mBottomResizeGrip
->
setRect
(
bottomResizeGripRect
());
mLeftResizeGrip
->
setRect
(
leftResizeGripRect
());
mLeftResizeGripSvgItem
->
setPos
(
rect
().
left
(),
rect
().
center
().
y
()
-
lRect
.
height
()
/
2
);
mRightResizeGrip
->
setRect
(
rightResizeGripRect
());
mRightResizeGripSvgItem
->
setPos
(
rect
().
right
()
-
rRect
.
width
(),
rect
().
center
().
y
()
-
rRect
.
height
()
/
2
);
mTopResizeGrip
->
setRect
(
topResizeGripRect
());
mTopResizeGripSvgItem
->
setPos
(
rect
().
center
().
x
()
-
trRect
.
width
()
/
2
,
rect
().
y
());
QVariant
vLocked
=
delegated
()
->
data
(
UBGraphicsItemData
::
ItemLocked
);
mRotateButton
->
setPos
(
rect
().
right
()
-
mFrameWidth
-
5
,
rect
().
top
()
+
5
);
bool
isLocked
=
(
vLocked
.
isValid
()
&&
vLocked
.
toBool
());
mBottomRightResizeGrip
->
setRect
(
bottomRightResizeGripRect
());
mBottomRightResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mBottomResizeGrip
->
setRect
(
bottomResizeGripRect
());
mBottomResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mLeftResizeGrip
->
setRect
(
leftResizeGripRect
());
mLeftResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mRightResizeGrip
->
setRect
(
rightResizeGripRect
());
mRightResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mTopResizeGrip
->
setRect
(
topResizeGripRect
());
mTopResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mRotateButton
->
setVisible
(
mDelegate
->
canRotate
()
&&
!
isLocked
);
QVariant
vLocked
=
delegated
()
->
data
(
UBGraphicsItemData
::
ItemLocked
);
bool
isLocked
=
(
vLocked
.
isValid
()
&&
vLocked
.
toBool
());
mBottomRightResizeGrip
->
setVisible
(
!
isLocked
);
mBottomResizeGrip
->
setVisible
(
!
isLocked
);
mBottomRightResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mLeftResizeGrip
->
setVisible
(
!
isLocked
);
mBottomResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mRightResizeGrip
->
setVisible
(
!
isLocked
);
mLeftResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mTopResizeGrip
->
setVisible
(
!
isLocked
);
mRightResizeGripSvgItem
->
setVisible
(
!
isLocked
);
mTopResizeGripSvgItem
->
setVisible
(
!
isLocked
);
if
(
isLocked
)
mRotateButton
->
setVisible
(
mDelegate
->
canRotate
()
&&
!
isLocked
);
{
QColor
baseColor
=
UBSettings
::
paletteColor
;
mBottomRightResizeGrip
->
setVisible
(
!
isLocked
);
baseColor
.
setAlphaF
(
baseColor
.
alphaF
()
/
3
);
mBottomResizeGrip
->
setVisible
(
!
isLocked
);
setBrush
(
QBrush
(
baseColor
));
mLeftResizeGrip
->
setVisible
(
!
isLocked
);
}
mRightResizeGrip
->
setVisible
(
!
isLocked
);
else
mTopResizeGrip
->
setVisible
(
!
isLocked
);
{
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
if
(
isLocked
)
}
{
QColor
baseColor
=
UBSettings
::
paletteColor
;
//make frame interact like delegated item when selected. Maybe should be deleted if selection logic will change
baseColor
.
setAlphaF
(
baseColor
.
alphaF
()
/
3
);
setZValue
(
delegated
()
->
zValue
());
setBrush
(
QBrush
(
baseColor
));
}
}
else
{
QGraphicsItem
*
UBGraphicsDelegateFrame
::
delegated
()
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
{
}
return
mDelegate
->
delegated
();
}
//make frame interact like delegated item when selected. Maybe should be deleted if selection logic will change
setZValue
(
delegated
()
->
zValue
());
UBGraphicsDelegateFrame
::
FrameTool
UBGraphicsDelegateFrame
::
toolFromPos
(
QPointF
pos
)
}
{
if
(
mDelegate
->
isLocked
())
return
None
;
QGraphicsItem
*
UBGraphicsDelegateFrame
::
delegated
()
else
if
(
bottomRightResizeGripRect
().
contains
(
pos
))
{
return
ResizeBottomRight
;
return
mDelegate
->
delegated
();
else
if
(
bottomResizeGripRect
().
contains
(
pos
)){
}
if
(
mMirrorY
){
return
ResizeTop
;
UBGraphicsDelegateFrame
::
FrameTool
UBGraphicsDelegateFrame
::
toolFromPos
(
QPointF
pos
)
}
else
{
{
return
ResizeBottom
;
if
(
mDelegate
->
isLocked
())
}
return
None
;
}
else
if
(
bottomRightResizeGripRect
().
contains
(
pos
))
else
if
(
leftResizeGripRect
().
contains
(
pos
)){
return
ResizeBottomRight
;
if
(
mMirrorX
){
else
if
(
bottomResizeGripRect
().
contains
(
pos
)){
return
ResizeRight
;
if
(
mMirrorY
){
}
else
{
return
ResizeTop
;
return
ResizeLeft
;
}
else
{
}
return
ResizeBottom
;
return
ResizeLeft
;
}
}
}
else
if
(
rightResizeGripRect
().
contains
(
pos
)){
else
if
(
leftResizeGripRect
().
contains
(
pos
)){
if
(
mMirrorX
){
if
(
mMirrorX
){
return
ResizeLeft
;
return
ResizeRight
;
}
else
{
}
else
{
return
ResizeRight
;
return
ResizeLeft
;
}
}
}
return
ResizeLeft
;
else
if
(
topResizeGripRect
().
contains
(
pos
)){
}
if
(
mMirrorY
){
else
if
(
rightResizeGripRect
().
contains
(
pos
)){
return
ResizeBottom
;
if
(
mMirrorX
){
}
else
{
return
ResizeLeft
;
return
ResizeTop
;
}
else
{
}
return
ResizeRight
;
}
}
else
if
(
rotateButtonBounds
().
contains
(
pos
)
&&
mDelegate
&&
mDelegate
->
canRotate
())
}
return
Rotate
;
else
if
(
topResizeGripRect
().
contains
(
pos
)){
else
if
(
mMirrorY
){
return
Move
;
return
ResizeBottom
;
}
}
else
{
return
ResizeTop
;
}
QRectF
UBGraphicsDelegateFrame
::
bottomRightResizeGripRect
()
const
}
{
else
if
(
rotateButtonBounds
().
contains
(
pos
)
&&
mDelegate
&&
mDelegate
->
canRotate
())
return
QRectF
(
rect
().
right
()
-
mFrameWidth
,
rect
().
bottom
()
-
mFrameWidth
,
mFrameWidth
,
mFrameWidth
);
return
Rotate
;
}
else
return
Move
;
}
QRectF
UBGraphicsDelegateFrame
::
bottomResizeGripRect
()
const
{
return
QRectF
(
rect
().
center
().
x
()
-
mFrameWidth
/
2
,
rect
().
bottom
()
-
mFrameWidth
,
mFrameWidth
,
mFrameWidth
);
QRectF
UBGraphicsDelegateFrame
::
bottomRightResizeGripRect
()
const
}
{
return
QRectF
(
rect
().
right
()
-
mFrameWidth
,
rect
().
bottom
()
-
mFrameWidth
,
mFrameWidth
,
mFrameWidth
);
}
QRectF
UBGraphicsDelegateFrame
::
leftResizeGripRect
()
const
{
return
QRectF
(
rect
().
left
(),
rect
().
center
().
y
()
-
mFrameWidth
/
2
,
mFrameWidth
,
mFrameWidth
);
QRectF
UBGraphicsDelegateFrame
::
bottomResizeGripRect
()
const
}
{
return
QRectF
(
rect
().
center
().
x
()
-
mFrameWidth
/
2
,
rect
().
bottom
()
-
mFrameWidth
,
mFrameWidth
,
mFrameWidth
);
}
QRectF
UBGraphicsDelegateFrame
::
rightResizeGripRect
()
const
{
return
QRectF
(
rect
().
right
()
-
mFrameWidth
,
rect
().
center
().
y
()
-
mFrameWidth
/
2
,
mFrameWidth
,
mFrameWidth
);
QRectF
UBGraphicsDelegateFrame
::
leftResizeGripRect
()
const
}
{
return
QRectF
(
rect
().
left
(),
rect
().
center
().
y
()
-
mFrameWidth
/
2
,
mFrameWidth
,
mFrameWidth
);
}
QRectF
UBGraphicsDelegateFrame
::
topResizeGripRect
()
const
{
return
QRectF
(
rect
().
center
().
x
()
-
mFrameWidth
/
2
,
rect
().
top
(),
mFrameWidth
,
mFrameWidth
);
QRectF
UBGraphicsDelegateFrame
::
rightResizeGripRect
()
const
}
{
return
QRectF
(
rect
().
right
()
-
mFrameWidth
,
rect
().
center
().
y
()
-
mFrameWidth
/
2
,
mFrameWidth
,
mFrameWidth
);
}
QRectF
UBGraphicsDelegateFrame
::
rotateButtonBounds
()
const
{
return
QRectF
(
rect
().
right
()
-
mFrameWidth
,
rect
().
top
(),
mFrameWidth
,
mFrameWidth
);
QRectF
UBGraphicsDelegateFrame
::
topResizeGripRect
()
const
}
{
return
QRectF
(
rect
().
center
().
x
()
-
mFrameWidth
/
2
,
rect
().
top
(),
mFrameWidth
,
mFrameWidth
);
void
UBGraphicsDelegateFrame
::
refreshGeometry
()
}
{
// Here we want to have the left on the left, the right on the right, the top on the top and the bottom on the bottom!
QRectF
itemRect
=
delegated
()
->
boundingRect
();
QRectF
UBGraphicsDelegateFrame
::
rotateButtonBounds
()
const
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
{
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
return
QRectF
(
rect
().
right
()
-
mFrameWidth
,
rect
().
top
(),
mFrameWidth
,
mFrameWidth
);
QPointF
topRight
=
itemTransform
.
map
(
itemRect
.
topRight
());
}
QPointF
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
void
UBGraphicsDelegateFrame
::
refreshGeometry
()
QLineF
topLine
(
topLeft
,
topRight
);
{
qreal
width
=
topLine
.
length
();
// Here we want to have the left on the left, the right on the right, the top on the top and the bottom on the bottom!
QLineF
leftLine
(
topLeft
,
bottomLeft
);
QRectF
itemRect
=
delegated
()
->
boundingRect
();
qreal
height
=
leftLine
.
length
();
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
setRect
(
topRight
.
x
()
-
mFrameWidth
,
topLeft
.
y
()
-
mFrameWidth
,
width
+
2
*
mFrameWidth
,
height
+
2
*
mFrameWidth
);
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
}
QPointF
topRight
=
itemTransform
.
map
(
itemRect
.
topRight
());
QPointF
bottomLeft
=
itemTransform
.
map
(
itemRect
.
bottomLeft
());
QLineF
topLine
(
topLeft
,
topRight
);
qreal
width
=
topLine
.
length
();
QLineF
leftLine
(
topLeft
,
bottomLeft
);
qreal
height
=
leftLine
.
length
();
setRect
(
topRight
.
x
()
-
mFrameWidth
,
topLeft
.
y
()
-
mFrameWidth
,
width
+
2
*
mFrameWidth
,
height
+
2
*
mFrameWidth
);
}
src/domain/UBGraphicsItemDelegate.cpp
View file @
83212cc4
...
@@ -37,6 +37,9 @@
...
@@ -37,6 +37,9 @@
#include "UBGraphicsWidgetItem.h"
#include "UBGraphicsWidgetItem.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "web/UBWebController.h"
#include "web/UBWebController.h"
...
@@ -93,6 +96,8 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
...
@@ -93,6 +96,8 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void
UBGraphicsItemDelegate
::
init
()
void
UBGraphicsItemDelegate
::
init
()
{
{
mToolBarItem
=
new
UBGraphicsToolBarItem
(
delegated
());
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
@@ -123,10 +128,13 @@ void UBGraphicsItemDelegate::init()
...
@@ -123,10 +128,13 @@ void UBGraphicsItemDelegate::init()
foreach
(
DelegateButton
*
button
,
mButtons
)
foreach
(
DelegateButton
*
button
,
mButtons
)
{
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
}
}
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
...
@@ -292,13 +300,20 @@ void UBGraphicsItemDelegate::positionHandles()
...
@@ -292,13 +300,20 @@ void UBGraphicsItemDelegate::positionHandles()
updateButtons
(
true
);
updateButtons
(
true
);
if
(
mToolBarItem
->
isVisibleOnBoard
())
{
updateToolBar
();
mToolBarItem
->
show
();
}
}
else
{
}
else
{
foreach
(
DelegateButton
*
button
,
mButtons
)
foreach
(
DelegateButton
*
button
,
mButtons
)
button
->
hide
();
button
->
hide
();
mFrame
->
hide
();
mFrame
->
hide
();
mToolBarItem
->
hide
();
}
}
}
}
void
UBGraphicsItemDelegate
::
setZOrderButtonsVisible
(
bool
visible
)
void
UBGraphicsItemDelegate
::
setZOrderButtonsVisible
(
bool
visible
)
{
{
if
(
visible
)
{
if
(
visible
)
{
...
@@ -335,6 +350,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
...
@@ -335,6 +350,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
scene
->
removeItem
(
mFrame
);
scene
->
removeItem
(
mFrame
);
scene
->
removeItem
(
mDelegated
);
scene
->
removeItem
(
mDelegated
);
scene
->
removeItem
(
mToolBarItem
);
if
(
canUndo
)
if
(
canUndo
)
{
{
...
@@ -577,14 +593,16 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
...
@@ -577,14 +593,16 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
int
i
=
1
,
j
=
0
,
k
=
0
;
int
i
=
1
,
j
=
0
,
k
=
0
;
while
((
i
+
j
+
k
)
<
mButtons
.
size
())
{
while
((
i
+
j
+
k
)
<
mButtons
.
size
())
{
DelegateButton
*
button
=
mButtons
[
i
+
j
];
DelegateButton
*
button
=
mButtons
[
i
+
j
];
button
->
setParentItem
(
mFrame
);
button
->
setTransform
(
tr
);
if
(
button
->
getSection
()
==
Qt
::
TopLeftSection
)
{
if
(
button
->
getSection
()
==
Qt
::
TopLeftSection
)
{
button
->
setParentItem
(
mFrame
);
button
->
setPos
(
topX
+
(
i
++
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
topY
);
button
->
setPos
(
topX
+
(
i
++
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
topY
);
button
->
setTransform
(
tr
);
}
else
if
(
button
->
getSection
()
==
Qt
::
BottomLeftSection
)
{
}
else
if
(
button
->
getSection
()
==
Qt
::
BottomLeftSection
)
{
button
->
setParentItem
(
mFrame
);
button
->
setPos
(
bottomX
+
(
++
j
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
bottomY
);
button
->
setPos
(
bottomX
+
(
++
j
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
bottomY
);
}
else
if
(
button
->
getSection
()
==
Qt
::
NoSection
)
{
button
->
setTransform
(
tr
);
}
else
if
(
button
->
getSection
()
==
Qt
::
TitleBarArea
||
button
->
getSection
()
==
Qt
::
NoSection
){
++
k
;
++
k
;
}
}
if
(
!
button
->
scene
())
if
(
!
button
->
scene
())
...
@@ -599,9 +617,65 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
...
@@ -599,9 +617,65 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
}
}
}
}
void
UBGraphicsItemDelegate
::
updateToolBar
()
{
QTransform
transformForToolbarButtons
;
transformForToolbarButtons
.
scale
(
mAntiScaleRatio
,
1
);
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
-
10
);
mToolBarItem
->
setRect
(
toolBarRect
);
if
(
mToolBarItem
->
isShifting
())
mToolBarItem
->
setPos
(
delegated
()
->
boundingRect
().
bottomLeft
()
+
QPointF
(
5
*
mAntiScaleRatio
,
0
));
else
mToolBarItem
->
setPos
(
delegated
()
->
boundingRect
().
bottomLeft
()
-
QPointF
(
-
5
*
mAntiScaleRatio
,
mToolBarItem
->
rect
().
height
()
*
1.1
*
mAntiScaleRatio
));
int
offsetOnToolBar
=
5
*
mAntiScaleRatio
;
QList
<
QGraphicsItem
*>
itemList
=
mToolBarItem
->
itemsOnToolBar
();
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
item
->
setPos
(
offsetOnToolBar
,
0
);
offsetOnToolBar
+=
(
item
->
boundingRect
().
width
()
+
5
)
*
mAntiScaleRatio
;
item
->
setTransform
(
transformForToolbarButtons
);
item
->
show
();
}
mToolBarItem
->
setOffsetOnToolBar
(
offsetOnToolBar
);
QTransform
tr
;
tr
.
scale
(
1
,
mAntiScaleRatio
);
mToolBarItem
->
setTransform
(
tr
);
}
void
UBGraphicsItemDelegate
::
setButtonsVisible
(
bool
visible
)
void
UBGraphicsItemDelegate
::
setButtonsVisible
(
bool
visible
)
{
{
foreach
(
DelegateButton
*
pButton
,
mButtons
){
foreach
(
DelegateButton
*
pButton
,
mButtons
){
pButton
->
setVisible
(
visible
);
pButton
->
setVisible
(
visible
);
}
}
}
}
UBGraphicsToolBarItem
::
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
)
:
QGraphicsRectItem
(
parent
),
mShifting
(
true
),
mVisible
(
false
),
mMinWidth
(
200
)
{
QRectF
rect
=
this
->
rect
();
rect
.
setHeight
(
26
);
this
->
setRect
(
rect
);
setBrush
(
QColor
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
hide
();
}
void
UBGraphicsToolBarItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
QPainterPath
path
;
path
.
addRoundedRect
(
rect
(),
10
,
10
);
painter
->
fillPath
(
path
,
brush
());
}
\ No newline at end of file
src/domain/UBGraphicsItemDelegate.h
View file @
83212cc4
...
@@ -84,6 +84,31 @@ class DelegateButton: public QGraphicsSvgItem
...
@@ -84,6 +84,31 @@ class DelegateButton: public QGraphicsSvgItem
};
};
class
UBGraphicsToolBarItem
:
public
QGraphicsRectItem
,
public
QObject
{
public
:
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
=
0
);
virtual
~
UBGraphicsToolBarItem
()
{};
bool
isVisibleOnBoard
()
const
{
return
mVisible
;
}
void
setVisibleOnBoard
(
bool
visible
)
{
mVisible
=
visible
;
}
bool
isShifting
()
const
{
return
mShifting
;
}
void
setShifting
(
bool
shifting
)
{
mShifting
=
shifting
;
}
int
offsetOnToolBar
()
const
{
return
mOffsetOnToolBar
;
}
void
setOffsetOnToolBar
(
int
pOffset
)
{
mOffsetOnToolBar
=
pOffset
;
}
QList
<
QGraphicsItem
*>
itemsOnToolBar
()
const
{
return
mItemsOnToolBar
;
}
void
setItemsOnToolBar
(
QList
<
QGraphicsItem
*>
itemsOnToolBar
)
{
mItemsOnToolBar
=
itemsOnToolBar
;}
int
minWidth
()
{
return
mMinWidth
;
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
private
:
bool
mShifting
;
bool
mVisible
;
int
mOffsetOnToolBar
;
int
mMinWidth
;
QList
<
QGraphicsItem
*>
mItemsOnToolBar
;
};
class
UBGraphicsItemDelegate
:
public
QObject
class
UBGraphicsItemDelegate
:
public
QObject
{
{
...
@@ -138,6 +163,10 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -138,6 +163,10 @@ class UBGraphicsItemDelegate : public QObject
void
setButtonsVisible
(
bool
visible
);
void
setButtonsVisible
(
bool
visible
);
UBGraphicsToolBarItem
*
getToolBarItem
()
const
{
return
mToolBarItem
;
}
qreal
antiScaleRatio
()
const
{
return
mAntiScaleRatio
;
}
signals
:
signals
:
void
showOnDisplayChanged
(
bool
shown
);
void
showOnDisplayChanged
(
bool
shown
);
void
lockChanged
(
bool
locked
);
void
lockChanged
(
bool
locked
);
...
@@ -183,12 +212,17 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -183,12 +212,17 @@ class UBGraphicsItemDelegate : public QObject
QList
<
DelegateButton
*>
mButtons
;
QList
<
DelegateButton
*>
mButtons
;
UBGraphicsToolBarItem
*
mToolBarItem
;
protected
slots
:
protected
slots
:
virtual
void
gotoContentSource
(
bool
checked
);
virtual
void
gotoContentSource
(
bool
checked
);
private
:
private
:
void
updateFrame
();
void
updateFrame
();
void
updateButtons
(
bool
showUpdated
=
false
);
void
updateButtons
(
bool
showUpdated
=
false
);
void
updateToolBar
();
QPointF
mOffset
;
QPointF
mOffset
;
QTransform
mPreviousTransform
;
QTransform
mPreviousTransform
;
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
83212cc4
...
@@ -94,17 +94,21 @@ void UBGraphicsTextItemDelegate::buildButtons()
...
@@ -94,17 +94,21 @@ void UBGraphicsTextItemDelegate::buildButtons()
{
{
UBGraphicsItemDelegate
::
buildButtons
();
UBGraphicsItemDelegate
::
buildButtons
();
mFontButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mFontButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
mColorButton
=
new
DelegateButton
(
":/images/color.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mColorButton
=
new
DelegateButton
(
":/images/color.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
mDecreaseSizeButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mDecreaseSizeButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
mIncreaseSizeButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mIncreaseSizeButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
connect
(
mFontButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickFont
()));
connect
(
mFontButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickFont
()));
connect
(
mColorButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickColor
()));
connect
(
mColorButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickColor
()));
connect
(
mDecreaseSizeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
decreaseSize
()));
connect
(
mDecreaseSizeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
decreaseSize
()));
connect
(
mIncreaseSizeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
increaseSize
()));
connect
(
mIncreaseSizeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
increaseSize
()));
mButtons
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
QList
<
QGraphicsItem
*>
itemsOnToolBar
;
itemsOnToolBar
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
mToolBarItem
->
setItemsOnToolBar
(
itemsOnToolBar
);
mToolBarItem
->
setVisibleOnBoard
(
true
);
}
}
void
UBGraphicsTextItemDelegate
::
contentsChanged
()
void
UBGraphicsTextItemDelegate
::
contentsChanged
()
...
...
src/domain/UBGraphicsVideoItemDelegate.cpp
View file @
83212cc4
/*
/*
* This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
* 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 <QtGui>
#include <QtGui>
#include <QtSvg>
#include <QtSvg>
#include "UBGraphicsVideoItemDelegate.h"
#include "UBGraphicsVideoItemDelegate.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsScene.h"
#include "core/UBSettings.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "core/UBApplicationController.h"
#include "core/UBApplicationController.h"
#include "core/UBDisplayManager.h"
#include "core/UBDisplayManager.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsDelegateFrame.h"
#include "domain/UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
UBGraphicsVideoItemDelegate
::
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
)
UBGraphicsVideoItemDelegate
::
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
)
:
UBGraphicsItemDelegate
(
pDelegated
,
parent
,
true
,
false
)
:
UBGraphicsItemDelegate
(
pDelegated
,
parent
,
true
,
false
)
,
mMedia
(
pMedia
)
,
mMedia
(
pMedia
)
{
{
// NOOP
// NOOP
}
}
void
UBGraphicsVideoItemDelegate
::
buildButtons
()
void
UBGraphicsVideoItemDelegate
::
buildButtons
()
{
{
mPlayPauseButton
=
new
DelegateButton
(
":/images/play.svg"
,
mDelegated
,
mFrame
);
mPlayPauseButton
=
new
DelegateButton
(
":/images/play.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
mStopButton
=
new
DelegateButton
(
":/images/stop.svg"
,
mDelegated
,
mFrame
);
mStopButton
=
new
DelegateButton
(
":/images/stop.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
mStopButton
->
hide
();
mVideoControl
=
new
DelegateVideoControl
(
delegated
(),
mToolBarItem
);
if
(
delegated
()
->
isMuted
())
UBGraphicsItem
::
assignZValue
(
mVideoControl
,
delegated
()
->
zValue
());
mMuteButton
=
new
DelegateButton
(
":/images/soundOff.svg"
,
mDelegated
,
mFrame
);
mVideoControl
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
else
mMuteButton
=
new
DelegateButton
(
":/images/soundOn.svg"
,
mDelegated
,
mFrame
);
if
(
delegated
()
->
isMuted
())
mMuteButton
=
new
DelegateButton
(
":/images/soundOff.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
mMuteButton
->
hide
();
else
mMuteButton
=
new
DelegateButton
(
":/images/soundOn.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
mVideoControl
=
new
DelegateVideoControl
(
delegated
(),
mFrame
);
UBGraphicsItem
::
assignZValue
(
mVideoControl
,
delegated
()
->
zValue
());
connect
(
mPlayPauseButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
togglePlayPause
()));
mVideoControl
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
connect
(
mStopButton
,
SIGNAL
(
clicked
(
bool
)),
mMedia
,
SLOT
(
stop
()));
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
delegated
(),
SLOT
(
toggleMute
()));
connect
(
mPlayPauseButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
togglePlayPause
()));
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
toggleMute
()));
connect
(
mStopButton
,
SIGNAL
(
clicked
(
bool
)),
mMedia
,
SLOT
(
stop
()));
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
delegated
(),
SLOT
(
toggleMute
()));
mButtons
<<
mPlayPauseButton
<<
mStopButton
<<
mMuteButton
;
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
toggleMute
()));
QList
<
QGraphicsItem
*>
itemsOnToolBar
;
mButtons
<<
mPlayPauseButton
<<
mStopButton
<<
mMuteButton
;
itemsOnToolBar
<<
mPlayPauseButton
<<
mStopButton
<<
mVideoControl
<<
mMuteButton
;
mToolBarItem
->
setItemsOnToolBar
(
itemsOnToolBar
);
mMedia
->
setTickInterval
(
50
);
mMedia
->
setTickInterval
(
50
);
connect
(
mMedia
,
SIGNAL
(
stateChanged
(
Phonon
::
State
,
Phonon
::
State
)),
this
,
SLOT
(
mediaStateChanged
(
Phonon
::
State
,
Phonon
::
State
)));
connect
(
mMedia
,
SIGNAL
(
finished
()),
this
,
SLOT
(
updatePlayPauseState
()));
connect
(
mMedia
,
SIGNAL
(
stateChanged
(
Phonon
::
State
,
Phonon
::
State
)),
this
,
SLOT
(
mediaStateChanged
(
Phonon
::
State
,
Phonon
::
State
)));
connect
(
mMedia
,
SIGNAL
(
tick
(
qint64
)),
this
,
SLOT
(
updateTicker
(
qint64
)));
connect
(
mMedia
,
SIGNAL
(
finished
()),
this
,
SLOT
(
updatePlayPauseState
()));
connect
(
mMedia
,
SIGNAL
(
totalTimeChanged
(
qint64
)),
this
,
SLOT
(
totalTimeChanged
(
qint64
)));
connect
(
mMedia
,
SIGNAL
(
tick
(
qint64
)),
this
,
SLOT
(
updateTicker
(
qint64
)));
connect
(
mMedia
,
SIGNAL
(
totalTimeChanged
(
qint64
)),
this
,
SLOT
(
totalTimeChanged
(
qint64
)));
}
mToolBarItem
->
setVisibleOnBoard
(
true
);
mToolBarItem
->
setShifting
(
false
);
UBGraphicsVideoItemDelegate
::~
UBGraphicsVideoItemDelegate
()
}
{
//NOOP
}
UBGraphicsVideoItemDelegate
::~
UBGraphicsVideoItemDelegate
()
{
//NOOP
void
UBGraphicsVideoItemDelegate
::
positionHandles
()
}
{
UBGraphicsItemDelegate
::
positionHandles
();
void
UBGraphicsVideoItemDelegate
::
positionHandles
()
if
(
mDelegated
->
isSelected
())
{
{
UBGraphicsItemDelegate
::
positionHandles
();
qreal
scaledFrameWidth
=
mFrameWidth
*
mAntiScaleRatio
;
if
(
mDelegated
->
isSelected
())
{
qreal
width
=
mFrame
->
rect
().
width
();
qreal
scaledFrameWidth
=
mFrameWidth
*
mAntiScaleRatio
;
qreal
height
=
mFrame
->
rect
().
height
();
int
offset
=
0
;
qreal
x
=
mFrame
->
rect
().
left
();
foreach
(
DelegateButton
*
button
,
mButtons
)
qreal
y
=
mFrame
->
rect
().
top
();
{
if
(
button
->
getSection
()
==
Qt
::
TitleBarArea
)
mVideoControl
->
setRect
(
x
+
2
*
scaledFrameWidth
offset
+=
button
->
boundingRect
().
width
()
*
mAntiScaleRatio
;
,
y
+
height
-
3
*
scaledFrameWidth
}
,
width
-
4
*
scaledFrameWidth
,
2
*
scaledFrameWidth
);
mVideoControl
->
setRect
(
mVideoControl
->
rect
().
x
()
,
scaledFrameWidth
/
6
-
0.5
if
(
!
mVideoControl
->
scene
())
,
(
mToolBarItem
->
rect
().
width
()
-
35
-
offset
)
/
mAntiScaleRatio
{
,
(
2
*
scaledFrameWidth
)
/
mAntiScaleRatio
);
mVideoControl
->
setParentItem
(
mFrame
);
//update parent for the case the item has been previously removed from scene
mDelegated
->
scene
()
->
addItem
(
mVideoControl
);
offset
+=
(
mVideoControl
->
rect
().
width
()
+
5
)
*
mAntiScaleRatio
;
}
mMuteButton
->
setPos
(
offset
,
0
);
mVideoControl
->
setAntiScale
(
mAntiScaleRatio
);
if
(
!
mVideoControl
->
scene
())
mVideoControl
->
setZValue
(
delegated
()
->
zValue
());
{
mVideoControl
->
show
();
mVideoControl
->
setParentItem
(
mToolBarItem
);
//update parent for the case the item has been previously removed from scene
}
mDelegated
->
scene
()
->
addItem
(
mVideoControl
);
else
}
{
mVideoControl
->
hide
();
mVideoControl
->
setAntiScale
(
mAntiScaleRatio
);
}
mVideoControl
->
setZValue
(
delegated
()
->
zValue
());
}
mVideoControl
->
show
();
}
else
void
UBGraphicsVideoItemDelegate
::
remove
(
bool
canUndo
)
{
{
mVideoControl
->
hide
();
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
}
delegated
()
->
mediaObject
()
->
stop
();
}
QGraphicsScene
*
scene
=
mDelegated
->
scene
();
void
UBGraphicsVideoItemDelegate
::
remove
(
bool
canUndo
)
scene
->
removeItem
(
mVideoControl
);
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
UBGraphicsItemDelegate
::
remove
(
canUndo
);
delegated
()
->
mediaObject
()
->
stop
();
}
QGraphicsScene
*
scene
=
mDelegated
->
scene
();
void
UBGraphicsVideoItemDelegate
::
toggleMute
()
scene
->
removeItem
(
mVideoControl
);
{
if
(
delegated
()
->
isMuted
())
UBGraphicsItemDelegate
::
remove
(
canUndo
);
mMuteButton
->
setFileName
(
":/images/soundOff.svg"
);
}
else
mMuteButton
->
setFileName
(
":/images/soundOn.svg"
);
void
UBGraphicsVideoItemDelegate
::
toggleMute
()
}
{
if
(
delegated
()
->
isMuted
())
mMuteButton
->
setFileName
(
":/images/soundOff.svg"
);
UBGraphicsVideoItem
*
UBGraphicsVideoItemDelegate
::
delegated
()
else
{
mMuteButton
->
setFileName
(
":/images/soundOn.svg"
);
return
static_cast
<
UBGraphicsVideoItem
*>
(
mDelegated
);
}
}
void
UBGraphicsVideoItemDelegate
::
togglePlayPause
()
UBGraphicsVideoItem
*
UBGraphicsVideoItemDelegate
::
delegated
()
{
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
{
return
static_cast
<
UBGraphicsVideoItem
*>
(
mDelegated
);
}
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
StoppedState
)
{
media
->
play
();
void
UBGraphicsVideoItemDelegate
::
togglePlayPause
()
}
else
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
{
{
if
(
media
->
remainingTime
()
<=
0
)
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
{
media
->
stop
();
media
->
play
();
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
}
else
{
if
(
media
->
state
()
==
Phonon
::
StoppedState
)
{
media
->
pause
();
media
->
play
();
if
(
delegated
()
->
scene
())
}
else
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
{
delegated
()
->
scene
()
->
setModified
(
true
);
if
(
media
->
remainingTime
()
<=
0
)
{
}
media
->
stop
();
}
else
if
(
media
->
state
()
==
Phonon
::
PausedState
)
{
media
->
play
();
if
(
media
->
remainingTime
()
<=
0
)
{
}
else
{
media
->
stop
();
media
->
pause
();
}
if
(
delegated
()
->
scene
())
media
->
play
();
delegated
()
->
scene
()
->
setModified
(
true
);
}
else
if
(
media
->
state
()
==
Phonon
::
LoadingState
)
{
}
delegated
()
->
mediaObject
()
->
setCurrentSource
(
delegated
()
->
mediaFileUrl
());
}
else
if
(
media
->
state
()
==
Phonon
::
PausedState
)
{
media
->
play
();
if
(
media
->
remainingTime
()
<=
0
)
{
}
else
if
(
media
->
state
()
==
Phonon
::
ErrorState
){
media
->
stop
();
qDebug
()
<<
"Error appeared."
<<
media
->
errorString
();
}
}
media
->
play
();
}
}
else
if
(
media
->
state
()
==
Phonon
::
LoadingState
)
{
}
delegated
()
->
mediaObject
()
->
setCurrentSource
(
delegated
()
->
mediaFileUrl
());
media
->
play
();
void
UBGraphicsVideoItemDelegate
::
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
)
}
else
if
(
media
->
state
()
==
Phonon
::
ErrorState
){
{
qDebug
()
<<
"Error appeared."
<<
media
->
errorString
();
Q_UNUSED
(
newstate
);
}
Q_UNUSED
(
oldstate
);
}
updatePlayPauseState
();
}
}
void
UBGraphicsVideoItemDelegate
::
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
)
{
void
UBGraphicsVideoItemDelegate
::
updatePlayPauseState
()
Q_UNUSED
(
newstate
);
{
Q_UNUSED
(
oldstate
);
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
updatePlayPauseState
();
}
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
mPlayPauseButton
->
setFileName
(
":/images/pause.svg"
);
else
void
UBGraphicsVideoItemDelegate
::
updatePlayPauseState
()
mPlayPauseButton
->
setFileName
(
":/images/play.svg"
);
{
}
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
void
UBGraphicsVideoItemDelegate
::
updateTicker
(
qint64
time
)
mPlayPauseButton
->
setFileName
(
":/images/pause.svg"
);
{
else
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
mPlayPauseButton
->
setFileName
(
":/images/play.svg"
);
mVideoControl
->
totalTimeChanged
(
media
->
totalTime
());
}
mVideoControl
->
updateTicker
(
time
);
}
void
UBGraphicsVideoItemDelegate
::
updateTicker
(
qint64
time
)
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
void
UBGraphicsVideoItemDelegate
::
totalTimeChanged
(
qint64
newTotalTime
)
mVideoControl
->
totalTimeChanged
(
media
->
totalTime
());
{
mVideoControl
->
totalTimeChanged
(
newTotalTime
);
mVideoControl
->
updateTicker
(
time
);
}
}
DelegateVideoControl
::
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
)
void
UBGraphicsVideoItemDelegate
::
totalTimeChanged
(
qint64
newTotalTime
)
:
QGraphicsRectItem
(
parent
)
{
,
mDelegate
(
pDelegated
)
mVideoControl
->
totalTimeChanged
(
newTotalTime
);
,
mDisplayCurrentTime
(
false
)
}
,
mAntiScale
(
1.0
)
,
mCurrentTimeInMs
(
0
)
,
mTotalTimeInMs
(
0
)
DelegateVideoControl
::
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
)
{
:
QGraphicsRectItem
(
parent
)
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
,
mDelegate
(
pDelegated
)
,
mDisplayCurrentTime
(
false
)
setBrush
(
QBrush
(
UBSettings
::
paletteColor
));
,
mAntiScale
(
1.0
)
setPen
(
Qt
::
NoPen
);
,
mCurrentTimeInMs
(
0
)
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
,
mTotalTimeInMs
(
0
)
}
,
mStartWidth
(
200
)
{
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
void
DelegateVideoControl
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
setBrush
(
QBrush
(
Qt
::
white
));
{
setPen
(
Qt
::
NoPen
);
Q_UNUSED
(
option
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
Q_UNUSED
(
widget
);
QRectF
rect
=
this
->
rect
();
painter
->
fillPath
(
shape
(),
brush
());
rect
.
setWidth
(
mStartWidth
);
this
->
setRect
(
rect
);
qreal
frameWidth
=
rect
().
height
()
/
2
;
}
int
position
=
frameWidth
;
if
(
mTotalTimeInMs
>
0
)
void
DelegateVideoControl
::
paint
(
QPainter
*
painter
,
{
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
position
=
frameWidth
+
(
rect
().
width
()
-
(
2
*
frameWidth
))
/
mTotalTimeInMs
*
mCurrentTimeInMs
;
{
}
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
int
radius
=
rect
().
height
()
/
6
;
QRectF
r
(
rect
().
x
()
+
position
-
radius
,
rect
().
y
()
+
(
rect
().
height
()
/
4
)
-
radius
,
radius
*
2
,
radius
*
2
);
painter
->
fillPath
(
shape
(),
brush
());
painter
->
setBrush
(
UBSettings
::
documentViewLightColor
);
qreal
frameWidth
=
rect
().
height
()
/
2
;
painter
->
drawEllipse
(
r
);
int
position
=
frameWidth
;
if
(
mDisplayCurrentTime
)
if
(
mTotalTimeInMs
>
0
)
{
{
painter
->
setBrush
(
UBSettings
::
paletteColor
);
position
=
frameWidth
+
(
rect
().
width
()
-
(
2
*
frameWidth
))
/
mTotalTimeInMs
*
mCurrentTimeInMs
;
painter
->
setPen
(
QPen
(
Qt
::
NoPen
));
}
QRectF
balloon
(
rect
().
x
()
+
position
-
frameWidth
,
rect
().
y
()
-
(
frameWidth
*
1.2
),
2
*
frameWidth
,
frameWidth
);
painter
->
drawRoundedRect
(
balloon
,
frameWidth
/
2
,
frameWidth
/
2
);
int
radius
=
rect
().
height
()
/
6
;
QRectF
r
(
rect
().
x
()
+
position
-
radius
,
rect
().
y
()
+
(
rect
().
height
()
/
4
)
-
radius
,
radius
*
2
,
radius
*
2
);
QTime
t
;
t
=
t
.
addMSecs
(
mCurrentTimeInMs
<
0
?
0
:
mCurrentTimeInMs
);
painter
->
setBrush
(
UBSettings
::
documentViewLightColor
);
QFont
f
=
painter
->
font
();
painter
->
drawEllipse
(
r
);
f
.
setPointSizeF
(
f
.
pointSizeF
()
*
mAntiScale
);
painter
->
setFont
(
f
);
if
(
mDisplayCurrentTime
)
painter
->
setPen
(
Qt
::
white
);
{
painter
->
drawText
(
balloon
,
Qt
::
AlignCenter
,
t
.
toString
(
"m:ss"
));
painter
->
setBrush
(
UBSettings
::
paletteColor
);
}
painter
->
setPen
(
QPen
(
Qt
::
NoPen
));
}
mBalloon
.
setRect
(
rect
().
x
()
+
position
-
frameWidth
,
rect
().
y
()
-
(
frameWidth
*
1.2
),
2
*
frameWidth
,
frameWidth
);
painter
->
drawRoundedRect
(
mBalloon
,
frameWidth
/
2
,
frameWidth
/
2
);
QPainterPath
DelegateVideoControl
::
shape
()
const
QTime
t
;
{
t
=
t
.
addMSecs
(
mCurrentTimeInMs
<
0
?
0
:
mCurrentTimeInMs
);
QPainterPath
path
;
QFont
f
=
painter
->
font
();
QRectF
r
=
rect
().
adjusted
(
0
,
0
,
0
,
-
rect
().
height
()
/
2
);
f
.
setPointSizeF
(
f
.
pointSizeF
()
*
mAntiScale
);
path
.
addRoundedRect
(
r
,
rect
().
height
()
/
4
,
rect
().
height
()
/
4
);
painter
->
setFont
(
f
);
return
path
;
painter
->
setPen
(
Qt
::
white
);
}
painter
->
drawText
(
mBalloon
,
Qt
::
AlignCenter
,
t
.
toString
(
"m:ss"
));
}
}
void
DelegateVideoControl
::
updateTicker
(
qint64
time
)
{
mCurrentTimeInMs
=
time
;
QPainterPath
DelegateVideoControl
::
shape
()
const
update
();
{
}
QPainterPath
path
;
QRectF
r
=
rect
().
adjusted
(
0
,
0
,
0
,
-
rect
().
height
()
/
2
);
path
.
addRoundedRect
(
r
,
rect
().
height
()
/
4
,
rect
().
height
()
/
4
);
void
DelegateVideoControl
::
totalTimeChanged
(
qint64
newTotalTime
)
return
path
;
{
}
mTotalTimeInMs
=
newTotalTime
;
update
();
}
void
DelegateVideoControl
::
updateTicker
(
qint64
time
)
{
mCurrentTimeInMs
=
time
;
void
DelegateVideoControl
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
update
();
{
}
mDisplayCurrentTime
=
true
;
seekToMousePos
(
event
->
pos
());
update
();
void
DelegateVideoControl
::
totalTimeChanged
(
qint64
newTotalTime
)
event
->
accept
();
{
}
mTotalTimeInMs
=
newTotalTime
;
update
();
}
void
DelegateVideoControl
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
seekToMousePos
(
event
->
pos
());
void
DelegateVideoControl
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
update
();
{
event
->
accept
();
mDisplayCurrentTime
=
true
;
}
seekToMousePos
(
event
->
pos
());
update
();
event
->
accept
();
void
DelegateVideoControl
::
seekToMousePos
(
QPointF
mousePos
)
}
{
qreal
minX
,
length
;
qreal
frameWidth
=
rect
().
height
()
/
2
;
void
DelegateVideoControl
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
minX
=
rect
().
x
()
+
frameWidth
;
if
(
shape
().
contains
(
event
->
pos
()
-
QPointF
(
mBalloon
.
width
()
/
2
,
0
))
length
=
rect
().
width
()
-
(
2
*
frameWidth
);
&&
shape
().
contains
(
event
->
pos
()
+
QPointF
(
mBalloon
.
width
()
/
2
,
0
)))
{
qreal
mouseX
=
mousePos
.
x
();
seekToMousePos
(
event
->
pos
());
update
();
if
(
mTotalTimeInMs
>
0
&&
length
>
0
&&
mDelegate
event
->
accept
();
&&
mDelegate
->
mediaObject
()
&&
mDelegate
->
mediaObject
()
->
isSeekable
())
}
{
}
qint64
tickPos
=
mTotalTimeInMs
/
length
*
(
mouseX
-
minX
);
mDelegate
->
mediaObject
()
->
seek
(
tickPos
);
void
DelegateVideoControl
::
seekToMousePos
(
QPointF
mousePos
)
//OSX is a bit lazy
{
updateTicker
(
tickPos
);
qreal
minX
,
length
;
}
qreal
frameWidth
=
rect
().
height
()
/
2
;
}
minX
=
rect
().
x
()
+
frameWidth
;
void
DelegateVideoControl
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
length
=
rect
().
width
()
-
(
2
*
frameWidth
);
{
mDisplayCurrentTime
=
false
;
qreal
mouseX
=
mousePos
.
x
();
update
();
event
->
accept
();
if
(
mTotalTimeInMs
>
0
&&
length
>
0
&&
mDelegate
}
&&
mDelegate
->
mediaObject
()
&&
mDelegate
->
mediaObject
()
->
isSeekable
())
{
qint64
tickPos
=
mTotalTimeInMs
/
length
*
(
mouseX
-
minX
);
mDelegate
->
mediaObject
()
->
seek
(
tickPos
);
//OSX is a bit lazy
updateTicker
(
tickPos
);
}
}
void
DelegateVideoControl
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mDisplayCurrentTime
=
false
;
update
();
event
->
accept
();
}
src/domain/UBGraphicsVideoItemDelegate.h
View file @
83212cc4
/*
/*
* This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_
#ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_
#define UBGRAPHICSVIDEOITEMDELEGATE_H_
#define UBGRAPHICSVIDEOITEMDELEGATE_H_
#include <QtGui>
#include <QtGui>
#include <phonon/MediaObject>
#include <phonon/MediaObject>
#include "core/UB.h"
#include "core/UB.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsItemDelegate.h"
class
QGraphicsSceneMouseEvent
;
class
QGraphicsSceneMouseEvent
;
class
QGraphicsItem
;
class
QGraphicsItem
;
class
UBGraphicsVideoItem
;
class
UBGraphicsVideoItem
;
class
DelegateVideoControl
:
public
QGraphicsRectItem
class
DelegateVideoControl
:
public
QGraphicsRectItem
{
{
public
:
public
:
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
);
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
);
virtual
~
DelegateVideoControl
()
virtual
~
DelegateVideoControl
()
{
{
// NOOP
// NOOP
}
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QWidget
*
widget
);
QPainterPath
shape
()
const
;
QPainterPath
shape
()
const
;
void
setAntiScale
(
qreal
antiScale
){
mAntiScale
=
antiScale
;
}
void
setAntiScale
(
qreal
antiScale
){
mAntiScale
=
antiScale
;
}
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
updateTicker
(
qint64
time
);
void
updateTicker
(
qint64
time
);
void
totalTimeChanged
(
qint64
newTotalTime
);
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
protected
:
void
seekToMousePos
(
QPointF
mousePos
);
void
seekToMousePos
(
QPointF
mousePos
);
UBGraphicsVideoItem
*
mDelegate
;
UBGraphicsVideoItem
*
mDelegate
;
bool
mDisplayCurrentTime
;
bool
mDisplayCurrentTime
;
qreal
mAntiScale
;
qreal
mAntiScale
;
qint64
mCurrentTimeInMs
;
qint64
mCurrentTimeInMs
;
qint64
mTotalTimeInMs
;
qint64
mTotalTimeInMs
;
};
private
:
int
mStartWidth
;
QRectF
mBalloon
;
class
UBGraphicsVideoItemDelegate
:
public
UBGraphicsItemDelegate
};
{
Q_OBJECT
class
UBGraphicsVideoItemDelegate
:
public
UBGraphicsItemDelegate
public
:
{
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
Q_OBJECT
virtual
~
UBGraphicsVideoItemDelegate
();
public
:
virtual
void
positionHandles
();
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsVideoItemDelegate
();
public
slots
:
virtual
void
positionHandles
();
void
toggleMute
();
void
updateTicker
(
qint64
time
);
public
slots
:
protected
slots
:
void
toggleMute
();
void
updateTicker
(
qint64
time
);
virtual
void
remove
(
bool
canUndo
=
true
);
protected
slots
:
void
togglePlayPause
();
virtual
void
remove
(
bool
canUndo
=
true
);
void
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
);
void
togglePlayPause
();
void
updatePlayPauseState
();
void
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
);
void
totalTimeChanged
(
qint64
newTotalTime
);
void
updatePlayPauseState
();
protected
:
void
totalTimeChanged
(
qint64
newTotalTime
);
virtual
void
buildButtons
();
protected
:
private
:
virtual
void
buildButtons
();
UBGraphicsVideoItem
*
delegated
();
private
:
DelegateButton
*
mPlayPauseButton
;
DelegateButton
*
mStopButton
;
UBGraphicsVideoItem
*
delegated
();
DelegateButton
*
mMuteButton
;
DelegateVideoControl
*
mVideoControl
;
DelegateButton
*
mPlayPauseButton
;
DelegateButton
*
mStopButton
;
Phonon
::
MediaObject
*
mMedia
;
DelegateButton
*
mMuteButton
;
DelegateVideoControl
*
mVideoControl
;
};
Phonon
::
MediaObject
*
mMedia
;
};
#endif
/* UBGRAPHICSVIDEOITEMDELEGATE_H_ */
#endif
/* UBGRAPHICSVIDEOITEMDELEGATE_H_ */
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