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
90f03866
Commit
90f03866
authored
May 23, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Sankore/Sankore-3.1
Conflicts: src/adaptors/UBSvgSubsetAdaptor.cpp
parents
8dafb4d9
307c4566
Changes
47
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
1575 additions
and
1210 deletions
+1575
-1210
UBCFFSubsetAdaptor.cpp
src/adaptors/UBCFFSubsetAdaptor.cpp
+3
-4
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+26
-23
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+5
-6
UBThumbnailAdaptor.cpp
src/adaptors/UBThumbnailAdaptor.cpp
+38
-72
UBThumbnailAdaptor.h
src/adaptors/UBThumbnailAdaptor.h
+1
-0
UBBoardController.cpp
src/board/UBBoardController.cpp
+54
-26
UBBoardController.h
src/board/UBBoardController.h
+4
-2
UBBoardView.cpp
src/board/UBBoardView.cpp
+2
-4
UBLibraryController.cpp
src/board/UBLibraryController.cpp
+2
-2
UB.h
src/core/UB.h
+2
-2
UBSettings.cpp
src/core/UBSettings.cpp
+3
-0
UBSettings.h
src/core/UBSettings.h
+4
-1
UBGraphicsAudioItem.cpp
src/domain/UBGraphicsAudioItem.cpp
+0
-120
UBGraphicsAudioItem.h
src/domain/UBGraphicsAudioItem.h
+0
-65
UBGraphicsAudioItemDelegate.cpp
src/domain/UBGraphicsAudioItemDelegate.cpp
+0
-123
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+4
-1
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+587
-40
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+82
-8
UBGraphicsMediaItem.cpp
src/domain/UBGraphicsMediaItem.cpp
+165
-6
UBGraphicsMediaItem.h
src/domain/UBGraphicsMediaItem.h
+40
-0
UBGraphicsMediaItemDelegate.cpp
src/domain/UBGraphicsMediaItemDelegate.cpp
+231
-0
UBGraphicsMediaItemDelegate.h
src/domain/UBGraphicsMediaItemDelegate.h
+70
-0
UBGraphicsPDFItem.cpp
src/domain/UBGraphicsPDFItem.cpp
+5
-0
UBGraphicsPDFItem.h
src/domain/UBGraphicsPDFItem.h
+1
-0
UBGraphicsPixmapItem.cpp
src/domain/UBGraphicsPixmapItem.cpp
+6
-0
UBGraphicsPixmapItem.h
src/domain/UBGraphicsPixmapItem.h
+2
-0
UBGraphicsProxyWidget.cpp
src/domain/UBGraphicsProxyWidget.cpp
+5
-0
UBGraphicsProxyWidget.h
src/domain/UBGraphicsProxyWidget.h
+1
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+61
-112
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+7
-5
UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp
+6
-0
UBGraphicsStrokesGroup.h
src/domain/UBGraphicsStrokesGroup.h
+1
-0
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+31
-0
UBGraphicsTextItem.h
src/domain/UBGraphicsTextItem.h
+1
-0
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+36
-1
UBGraphicsVideoItem.cpp
src/domain/UBGraphicsVideoItem.cpp
+0
-141
UBGraphicsVideoItem.h
src/domain/UBGraphicsVideoItem.h
+0
-75
UBGraphicsVideoItemDelegate.cpp
src/domain/UBGraphicsVideoItemDelegate.cpp
+0
-351
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+16
-1
UBGraphicsWidgetItem.h
src/domain/UBGraphicsWidgetItem.h
+3
-0
domain.pri
src/domain/domain.pri
+5
-10
ubgraphicsgroupcontaineritem.cpp
src/domain/ubgraphicsgroupcontaineritem.cpp
+47
-0
ubgraphicsgroupcontaineritem.h
src/domain/ubgraphicsgroupcontaineritem.h
+6
-0
ubgraphicsgroupcontaineritemdelegate.cpp
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
+1
-1
UBCoreGraphicsScene.cpp
src/frameworks/UBCoreGraphicsScene.cpp
+2
-7
UBGraphicsCurtainItem.cpp
src/tools/UBGraphicsCurtainItem.cpp
+6
-0
UBGraphicsCurtainItem.h
src/tools/UBGraphicsCurtainItem.h
+3
-1
No files found.
src/adaptors/UBCFFSubsetAdaptor.cpp
View file @
90f03866
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItemDelegate.h"
#include "domain/UBGraphicsTextItemDelegate.h"
...
@@ -823,7 +822,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgAudio(const QDomElement &ele
...
@@ -823,7 +822,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgAudio(const QDomElement &ele
->
addAudioFileToDocument
(
mCurrentScene
->
document
(),
concreteUrl
.
toLocalFile
(),
uuid
));
->
addAudioFileToDocument
(
mCurrentScene
->
document
(),
concreteUrl
.
toLocalFile
(),
uuid
));
#endif
#endif
UBGraphics
Audio
Item
*
audioItem
=
mCurrentScene
->
addAudio
(
concreteUrl
,
false
);
UBGraphics
Media
Item
*
audioItem
=
mCurrentScene
->
addAudio
(
concreteUrl
,
false
);
QTransform
transform
;
QTransform
transform
;
QString
textTransform
=
parentOfAudio
.
attribute
(
aTransform
);
QString
textTransform
=
parentOfAudio
.
attribute
(
aTransform
);
...
@@ -866,7 +865,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVideo(const QDomElement &ele
...
@@ -866,7 +865,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVideo(const QDomElement &ele
->
addVideoFileToDocument
(
mCurrentScene
->
document
(),
concreteUrl
.
toLocalFile
(),
uuid
));
->
addVideoFileToDocument
(
mCurrentScene
->
document
(),
concreteUrl
.
toLocalFile
(),
uuid
));
#endif
#endif
UBGraphics
Video
Item
*
videoItem
=
mCurrentScene
->
addVideo
(
concreteUrl
,
false
);
UBGraphics
Media
Item
*
videoItem
=
mCurrentScene
->
addVideo
(
concreteUrl
,
false
);
QTransform
transform
;
QTransform
transform
;
QString
textTransform
=
element
.
attribute
(
aTransform
);
QString
textTransform
=
element
.
attribute
(
aTransform
);
...
...
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
90f03866
...
@@ -22,8 +22,7 @@
...
@@ -22,8 +22,7 @@
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
...
@@ -640,7 +639,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
...
@@ -640,7 +639,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
}
}
else
if
(
mXmlReader
.
name
()
==
"audio"
)
else
if
(
mXmlReader
.
name
()
==
"audio"
)
{
{
UBGraphics
Audio
Item
*
audioItem
=
audioItemFromSvg
();
UBGraphics
Media
Item
*
audioItem
=
audioItemFromSvg
();
if
(
audioItem
)
if
(
audioItem
)
{
{
...
@@ -661,7 +660,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
...
@@ -661,7 +660,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
}
}
else
if
(
mXmlReader
.
name
()
==
"video"
)
else
if
(
mXmlReader
.
name
()
==
"video"
)
{
{
UBGraphics
Video
Item
*
videoItem
=
videoItemFromSvg
();
UBGraphics
Media
Item
*
videoItem
=
videoItemFromSvg
();
if
(
videoItem
)
if
(
videoItem
)
{
{
...
@@ -1154,18 +1153,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1154,18 +1153,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
continue
;
continue
;
}
}
// Is the Item a video?
UBGraphicsMediaItem
*
mediaItem
=
qgraphicsitem_cast
<
UBGraphicsMediaItem
*>
(
item
);
UBGraphicsVideoItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsVideoItem
*>
(
item
);
if
(
videoItem
&&
videoItem
->
isVisible
())
{
videoItemToLinkedVideo
(
videoItem
);
continue
;
}
// Is the item an audio?
if
(
mediaItem
&&
mediaItem
->
isVisible
())
UBGraphicsAudioItem
*
audioItem
=
qgraphicsitem_cast
<
UBGraphicsAudioItem
*>
(
item
);
{
if
(
audioItem
&&
audioItem
->
isVisible
())
{
if
(
UBGraphicsMediaItem
::
mediaType_Video
==
mediaItem
->
getMediaType
())
audioItemToLinkedAudio
(
audioItem
);
videoItemToLinkedVideo
(
mediaItem
);
else
audioItemToLinkedAudio
(
mediaItem
);
continue
;
continue
;
}
}
...
@@ -1973,7 +1968,7 @@ UBGraphicsPDFItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::pdfItemFromPDF()
...
@@ -1973,7 +1968,7 @@ UBGraphicsPDFItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::pdfItemFromPDF()
return
pdfItem
;
return
pdfItem
;
}
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
audioItemToLinkedAudio
(
UBGraphics
Audio
Item
*
audioItem
)
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
audioItemToLinkedAudio
(
UBGraphics
Media
Item
*
audioItem
)
{
{
mXmlWriter
.
writeStartElement
(
"audio"
);
mXmlWriter
.
writeStartElement
(
"audio"
);
...
@@ -1985,13 +1980,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsAud
...
@@ -1985,13 +1980,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsAud
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"position"
,
QString
(
"%1"
).
arg
(
pos
));
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"position"
,
QString
(
"%1"
).
arg
(
pos
));
}
}
QString
audioFileHref
=
audioItem
->
mediaFileUrl
().
to
String
();
QString
audioFileHref
=
audioItem
->
mediaFileUrl
().
to
LocalFile
();
mXmlWriter
.
writeAttribute
(
nsXLink
,
"href"
,
audioFileHref
);
mXmlWriter
.
writeAttribute
(
nsXLink
,
"href"
,
audioFileHref
);
mXmlWriter
.
writeEndElement
();
mXmlWriter
.
writeEndElement
();
}
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
videoItemToLinkedVideo
(
UBGraphics
Video
Item
*
videoItem
)
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
videoItemToLinkedVideo
(
UBGraphics
Media
Item
*
videoItem
)
{
{
/* w3c sample
/* w3c sample
*
*
...
@@ -2010,12 +2005,12 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::videoItemToLinkedVideo(UBGraphicsVid
...
@@ -2010,12 +2005,12 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::videoItemToLinkedVideo(UBGraphicsVid
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"position"
,
QString
(
"%1"
).
arg
(
pos
));
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"position"
,
QString
(
"%1"
).
arg
(
pos
));
}
}
QString
videoFileHref
=
videoItem
->
mediaFileUrl
().
to
String
();
QString
videoFileHref
=
videoItem
->
mediaFileUrl
().
to
LocalFile
();
mXmlWriter
.
writeAttribute
(
nsXLink
,
"href"
,
videoFileHref
);
mXmlWriter
.
writeAttribute
(
nsXLink
,
"href"
,
videoFileHref
);
mXmlWriter
.
writeEndElement
();
mXmlWriter
.
writeEndElement
();
}
}
UBGraphics
Audio
Item
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
audioItemFromSvg
()
UBGraphics
Media
Item
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
audioItemFromSvg
()
{
{
QStringRef
audioHref
=
mXmlReader
.
attributes
().
value
(
nsXLink
,
"href"
);
QStringRef
audioHref
=
mXmlReader
.
attributes
().
value
(
nsXLink
,
"href"
);
...
@@ -2035,7 +2030,11 @@ UBGraphicsAudioItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::audioItemFromSvg()
...
@@ -2035,7 +2030,11 @@ UBGraphicsAudioItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::audioItemFromSvg()
href
=
mDocumentPath
+
"/"
+
href
.
right
(
href
.
length
()
-
indexOfAudioDirectory
);
href
=
mDocumentPath
+
"/"
+
href
.
right
(
href
.
length
()
-
indexOfAudioDirectory
);
}
}
UBGraphicsAudioItem
*
audioItem
=
new
UBGraphicsAudioItem
(
QUrl
::
fromLocalFile
(
href
));
UBGraphicsMediaItem
*
audioItem
=
new
UBGraphicsMediaItem
(
QUrl
::
fromLocalFile
(
href
));
if
(
audioItem
){
audioItem
->
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneChanged
()),
audioItem
,
SLOT
(
activeSceneChanged
()));
}
graphicsItemFromSvg
(
audioItem
);
graphicsItemFromSvg
(
audioItem
);
QStringRef
ubPos
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"position"
);
QStringRef
ubPos
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"position"
);
...
@@ -2049,7 +2048,7 @@ UBGraphicsAudioItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::audioItemFromSvg()
...
@@ -2049,7 +2048,7 @@ UBGraphicsAudioItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::audioItemFromSvg()
return
audioItem
;
return
audioItem
;
}
}
UBGraphics
Video
Item
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
videoItemFromSvg
()
UBGraphics
Media
Item
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
videoItemFromSvg
()
{
{
QStringRef
videoHref
=
mXmlReader
.
attributes
().
value
(
nsXLink
,
"href"
);
QStringRef
videoHref
=
mXmlReader
.
attributes
().
value
(
nsXLink
,
"href"
);
...
@@ -2069,7 +2068,11 @@ UBGraphicsVideoItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::videoItemFromSvg()
...
@@ -2069,7 +2068,11 @@ UBGraphicsVideoItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::videoItemFromSvg()
href
=
mDocumentPath
+
"/"
+
href
.
right
(
href
.
length
()
-
indexOfAudioDirectory
);
href
=
mDocumentPath
+
"/"
+
href
.
right
(
href
.
length
()
-
indexOfAudioDirectory
);
}
}
UBGraphicsVideoItem
*
videoItem
=
new
UBGraphicsVideoItem
(
href
);
UBGraphicsMediaItem
*
videoItem
=
new
UBGraphicsMediaItem
(
QUrl
::
fromLocalFile
(
href
));
if
(
videoItem
){
videoItem
->
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneChanged
()),
videoItem
,
SLOT
(
activeSceneChanged
()));
}
graphicsItemFromSvg
(
videoItem
);
graphicsItemFromSvg
(
videoItem
);
QStringRef
ubPos
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"position"
);
QStringRef
ubPos
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"position"
);
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
90f03866
...
@@ -26,8 +26,7 @@ class UBGraphicsPolygonItem;
...
@@ -26,8 +26,7 @@ class UBGraphicsPolygonItem;
class
UBGraphicsPixmapItem
;
class
UBGraphicsPixmapItem
;
class
UBGraphicsPDFItem
;
class
UBGraphicsPDFItem
;
class
UBGraphicsWidgetItem
;
class
UBGraphicsWidgetItem
;
class
UBGraphicsVideoItem
;
class
UBGraphicsMediaItem
;
class
UBGraphicsAudioItem
;
class
UBGraphicsAppleWidgetItem
;
class
UBGraphicsAppleWidgetItem
;
class
UBGraphicsW3CWidgetItem
;
class
UBGraphicsW3CWidgetItem
;
class
UBGraphicsTextItem
;
class
UBGraphicsTextItem
;
...
@@ -119,9 +118,9 @@ class UBSvgSubsetAdaptor
...
@@ -119,9 +118,9 @@ class UBSvgSubsetAdaptor
UBGraphicsPDFItem
*
pdfItemFromPDF
();
UBGraphicsPDFItem
*
pdfItemFromPDF
();
UBGraphics
Video
Item
*
videoItemFromSvg
();
UBGraphics
Media
Item
*
videoItemFromSvg
();
UBGraphics
Audio
Item
*
audioItemFromSvg
();
UBGraphics
Media
Item
*
audioItemFromSvg
();
UBGraphicsAppleWidgetItem
*
graphicsAppleWidgetFromSvg
();
UBGraphicsAppleWidgetItem
*
graphicsAppleWidgetFromSvg
();
...
@@ -218,8 +217,8 @@ class UBSvgSubsetAdaptor
...
@@ -218,8 +217,8 @@ class UBSvgSubsetAdaptor
void
pixmapItemToLinkedImage
(
UBGraphicsPixmapItem
*
pixmapItem
);
void
pixmapItemToLinkedImage
(
UBGraphicsPixmapItem
*
pixmapItem
);
void
svgItemToLinkedSvg
(
UBGraphicsSvgItem
*
svgItem
);
void
svgItemToLinkedSvg
(
UBGraphicsSvgItem
*
svgItem
);
void
pdfItemToLinkedPDF
(
UBGraphicsPDFItem
*
pdfItem
);
void
pdfItemToLinkedPDF
(
UBGraphicsPDFItem
*
pdfItem
);
void
videoItemToLinkedVideo
(
UBGraphics
Video
Item
*
videoItem
);
void
videoItemToLinkedVideo
(
UBGraphics
Media
Item
*
videoItem
);
void
audioItemToLinkedAudio
(
UBGraphics
AudioItem
*
audioItem
);
void
audioItemToLinkedAudio
(
UBGraphics
MediaItem
*
audioItem
);
void
graphicsItemToSvg
(
QGraphicsItem
*
item
);
void
graphicsItemToSvg
(
QGraphicsItem
*
item
);
void
graphicsAppleWidgetToSvg
(
UBGraphicsAppleWidgetItem
*
item
);
void
graphicsAppleWidgetToSvg
(
UBGraphicsAppleWidgetItem
*
item
);
void
graphicsW3CWidgetToSvg
(
UBGraphicsW3CWidgetItem
*
item
);
void
graphicsW3CWidgetToSvg
(
UBGraphicsW3CWidgetItem
*
item
);
...
...
src/adaptors/UBThumbnailAdaptor.cpp
View file @
90f03866
...
@@ -33,29 +33,23 @@
...
@@ -33,29 +33,23 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
QList
<
QPixmap
>
UBThumbnailAdaptor
::
load
(
UBDocumentProxy
*
proxy
)
void
UBThumbnailAdaptor
::
generateMissingThumbnails
(
UBDocumentProxy
*
proxy
)
{
{
QList
<
QPixmap
>
thumbnails
;
if
(
!
proxy
||
proxy
->
persistencePath
().
isEmpty
())
return
thumbnails
;
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
int
existingPageCount
=
proxy
->
pageCount
();
int
existingPageCount
=
proxy
->
pageCount
();
QString
thumbFileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
existingPageCount
);
for
(
int
iPageNo
=
0
;
iPageNo
<
existingPageCount
;
++
iPageNo
)
QFile
thumbFile
(
thumbFileName
);
if
(
!
thumbFile
.
exists
())
{
{
bool
displayMessage
=
(
existingPageCount
>
5
);
QString
thumbFileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
iPageNo
);
int
thumbCount
=
0
;
QFile
thumbFile
(
thumbFileName
)
;
for
(
int
i
=
0
;
i
<
existingPageCount
;
i
++
)
if
(
!
thumbFile
.
exists
()
)
{
{
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
i
);
bool
displayMessage
=
(
existingPageCount
>
5
);
int
thumbCount
=
0
;
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
iPageNo
);
if
(
scene
)
if
(
scene
)
{
{
...
@@ -64,24 +58,25 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
...
@@ -64,24 +58,25 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
if
(
displayMessage
&&
thumbCount
==
1
)
if
(
displayMessage
&&
thumbCount
==
1
)
UBApplication
::
showMessage
(
tr
(
"Generating preview thumbnails ..."
));
UBApplication
::
showMessage
(
tr
(
"Generating preview thumbnails ..."
));
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
PageNo
);
}
}
else
{
if
(
i
==
0
){
// we are working a document without zero page but on a system that enable it
// we have to create an empty zero scene
scene
=
new
UBGraphicsScene
(
proxy
);
UBSvgSubsetAdaptor
::
persistScene
(
proxy
,
scene
,
0
);
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
thumbCount
++
;
}
}
}
if
(
displayMessage
&&
thumbCount
>
0
)
if
(
displayMessage
&&
thumbCount
>
0
)
UBApplication
::
showMessage
(
tr
(
"%1 thumbnails generated ..."
).
arg
(
thumbCount
));
UBApplication
::
showMessage
(
tr
(
"%1 thumbnails generated ..."
).
arg
(
thumbCount
));
}
}
}
}
QList
<
QPixmap
>
UBThumbnailAdaptor
::
load
(
UBDocumentProxy
*
proxy
)
{
QList
<
QPixmap
>
thumbnails
;
if
(
!
proxy
||
proxy
->
persistencePath
().
isEmpty
())
return
thumbnails
;
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
generateMissingThumbnails
(
proxy
);
//end compatibility with older format
//end compatibility with older format
...
@@ -113,56 +108,27 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
...
@@ -113,56 +108,27 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
{
{
int
existingPageCount
=
proxy
->
pageCount
();
int
existingPageCount
=
proxy
->
pageCount
();
if
(
!
proxy
||
proxy
->
persistencePath
().
size
()
==
0
||
index
<
0
||
index
>
=
existingPageCount
)
if
(
!
proxy
||
proxy
->
persistencePath
().
size
()
==
0
||
index
<
0
||
index
>
existingPageCount
)
return
QPixmap
();
return
QPixmap
();
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
generateMissingThumbnails
(
proxy
);
QString
thumbFileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
existingPageCount
);
QFile
thumbFile
(
thumbFileName
);
if
(
!
thumbFile
.
exists
())
{
bool
displayMessage
=
(
existingPageCount
>
5
);
int
thumbCount
=
0
;
for
(
int
i
=
0
;
i
<
existingPageCount
;
i
++
)
{
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
i
);
if
(
scene
)
{
thumbCount
++
;
if
(
displayMessage
&&
thumbCount
==
1
)
UBApplication
::
showMessage
(
tr
(
"Generating preview thumbnails ..."
));
persistScene
(
proxy
->
persistencePath
(),
scene
,
i
);
}
}
if
(
displayMessage
&&
thumbCount
>
0
)
UBApplication
::
showMessage
(
tr
(
"%1 thumbnails generated ..."
).
arg
(
thumbCount
));
}
//end compatibility with older format
//end compatibility with older format
QString
fileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
index
);
QString
fileName
=
proxy
->
persistencePath
()
+
UBFileSystemUtils
::
digitFileFormat
(
"/page%1.thumbnail.jpg"
,
index
);
QFile
file
(
fileName
);
QFile
file
(
fileName
);
if
(
file
.
exists
())
if
(
file
.
exists
())
{
{
QPixmap
pix
;
QPixmap
pix
;
//Warning. Works only with modified Qt
//Warning. Works only with modified Qt
#ifdef Q_WS_X11
#ifdef Q_WS_X11
pix
.
load
(
fileName
,
0
,
Qt
::
AutoColor
);
pix
.
load
(
fileName
,
0
,
Qt
::
AutoColor
);
#else
#else
pix
.
load
(
fileName
,
0
,
Qt
::
AutoColor
,
false
);
pix
.
load
(
fileName
,
0
,
Qt
::
AutoColor
,
false
);
#endif
#endif
return
pix
;
return
pix
;
}
}
return
QPixmap
();
return
QPixmap
();
}
}
void
UBThumbnailAdaptor
::
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
int
pageIndex
,
bool
overrideModified
)
void
UBThumbnailAdaptor
::
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
int
pageIndex
,
bool
overrideModified
)
...
...
src/adaptors/UBThumbnailAdaptor.h
View file @
90f03866
...
@@ -29,6 +29,7 @@ private: UBThumbnailAdaptor() {}
...
@@ -29,6 +29,7 @@ private: UBThumbnailAdaptor() {}
public
:
public
:
static
void
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
int
pageIndex
,
bool
overrideModified
=
false
);
static
void
persistScene
(
const
QString
&
pDocPath
,
UBGraphicsScene
*
pScene
,
int
pageIndex
,
bool
overrideModified
=
false
);
static
void
generateMissingThumbnails
(
UBDocumentProxy
*
proxy
);
static
QList
<
QPixmap
>
load
(
UBDocumentProxy
*
proxy
);
static
QList
<
QPixmap
>
load
(
UBDocumentProxy
*
proxy
);
static
QPixmap
load
(
UBDocumentProxy
*
proxy
,
int
index
);
static
QPixmap
load
(
UBDocumentProxy
*
proxy
,
int
index
);
...
...
src/board/UBBoardController.cpp
View file @
90f03866
...
@@ -44,12 +44,12 @@
...
@@ -44,12 +44,12 @@
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBW3CWidget.h"
#include "domain/UBW3CWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBPageSizeUndoCommand.h"
#include "domain/UBPageSizeUndoCommand.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "tools/UBToolsManager.h"
#include "tools/UBToolsManager.h"
...
@@ -140,6 +140,8 @@ void UBBoardController::init()
...
@@ -140,6 +140,8 @@ void UBBoardController::init()
setActiveDocumentScene
(
doc
);
setActiveDocumentScene
(
doc
);
connect
(
UBApplication
::
mainWindow
->
actionGroupItems
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
groupButtonClicked
()));
undoRedoStateChange
(
true
);
undoRedoStateChange
(
true
);
}
}
...
@@ -760,6 +762,32 @@ void UBBoardController::lastScene()
...
@@ -760,6 +762,32 @@ void UBBoardController::lastScene()
emit
pageChanged
();
emit
pageChanged
();
}
}
void
UBBoardController
::
groupButtonClicked
()
{
QAction
*
groupAction
=
UBApplication
::
mainWindow
->
actionGroupItems
;
QList
<
QGraphicsItem
*>
selItems
=
activeScene
()
->
selectedItems
();
if
(
!
selItems
.
count
())
{
qDebug
()
<<
"Got grouping request when there is no any selected item on the scene"
;
return
;
}
if
(
groupAction
->
text
()
==
UBSettings
::
settings
()
->
actionGroupText
)
{
//The only way to get information from item, considering using smth else
UBGraphicsGroupContainerItem
*
groupItem
=
activeScene
()
->
createGroup
(
selItems
);
groupItem
->
setSelected
(
true
);
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
}
else
if
(
groupAction
->
text
()
==
UBSettings
::
settings
()
->
actionUngroupText
)
{
//Considering one selected item and it's a group
if
(
selItems
.
count
()
>
1
)
{
qDebug
()
<<
"can't make sense of ungrouping more then one item. Grouping action should be performed for that purpose"
;
return
;
}
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
selItems
.
first
());
if
(
currentGroup
)
{
currentGroup
->
destroy
();
}
}
}
void
UBBoardController
::
downloadURL
(
const
QUrl
&
url
,
const
QPointF
&
pPos
,
const
QSize
&
pSize
,
bool
isBackground
)
void
UBBoardController
::
downloadURL
(
const
QUrl
&
url
,
const
QPointF
&
pPos
,
const
QSize
&
pSize
,
bool
isBackground
)
{
{
...
@@ -922,27 +950,27 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
...
@@ -922,27 +950,27 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{
{
qDebug
()
<<
"accepting mime type"
<<
mimeType
<<
"as video"
;
qDebug
()
<<
"accepting mime type"
<<
mimeType
<<
"as video"
;
UBGraphics
VideoItem
*
v
ideoItem
=
0
;
UBGraphics
MediaItem
*
mediaV
ideoItem
=
0
;
if
(
pData
.
length
()
>
0
)
if
(
pData
.
length
()
>
0
)
{
{
QUuid
uuid
=
QUuid
::
createUuid
();
QUuid
uuid
=
QUuid
::
createUuid
();
QUrl
url
=
QUrl
::
fromLocalFile
(
UBPersistenceManager
::
persistenceManager
()
QUrl
url
=
QUrl
::
fromLocalFile
(
UBPersistenceManager
::
persistenceManager
()
->
addVideoFileToDocument
(
mActiveDocument
,
sourceUrl
,
pData
,
uuid
));
->
addVideoFileToDocument
(
mActiveDocument
,
sourceUrl
,
pData
,
uuid
));
videoItem
=
mActiveScene
->
addVideo
(
url
,
false
,
pPos
);
mediaVideoItem
=
mActiveScene
->
addMedia
(
url
,
false
,
pPos
);
v
ideoItem
->
setSourceUrl
(
sourceUrl
);
mediaV
ideoItem
->
setSourceUrl
(
sourceUrl
);
v
ideoItem
->
setUuid
(
uuid
);
mediaV
ideoItem
->
setUuid
(
uuid
);
}
}
else
else
{
{
v
ideoItem
=
addVideo
(
sourceUrl
,
false
,
pPos
);
mediaV
ideoItem
=
addVideo
(
sourceUrl
,
false
,
pPos
);
}
}
if
(
v
ideoItem
){
if
(
mediaV
ideoItem
){
connect
(
this
,
SIGNAL
(
activeSceneChanged
()),
v
ideoItem
,
SLOT
(
activeSceneChanged
()));
connect
(
this
,
SIGNAL
(
activeSceneChanged
()),
mediaV
ideoItem
,
SLOT
(
activeSceneChanged
()));
}
}
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
...
@@ -951,27 +979,27 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
...
@@ -951,27 +979,27 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{
{
qDebug
()
<<
"accepting mime type"
<<
mimeType
<<
"as audio"
;
qDebug
()
<<
"accepting mime type"
<<
mimeType
<<
"as audio"
;
UBGraphics
AudioItem
*
audio
Item
=
0
;
UBGraphics
MediaItem
*
audioMedia
Item
=
0
;
if
(
pData
.
length
()
>
0
)
if
(
pData
.
length
()
>
0
)
{
{
QUuid
uuid
=
QUuid
::
createUuid
();
QUuid
uuid
=
QUuid
::
createUuid
();
QUrl
url
=
QUrl
::
fromLocalFile
(
UBPersistenceManager
::
persistenceManager
()
QUrl
url
=
QUrl
::
fromLocalFile
(
UBPersistenceManager
::
persistenceManager
()
->
addAudi
oFileToDocument
(
mActiveDocument
,
sourceUrl
,
pData
,
uuid
));
->
addVide
oFileToDocument
(
mActiveDocument
,
sourceUrl
,
pData
,
uuid
));
audio
Item
=
mActiveScene
->
addAudio
(
url
,
false
,
pPos
);
audio
MediaItem
=
mActiveScene
->
addMedia
(
url
,
false
,
pPos
);
audioItem
->
setSourceUrl
(
sourceUrl
);
audio
Media
Item
->
setSourceUrl
(
sourceUrl
);
audioItem
->
setUuid
(
uuid
);
audio
Media
Item
->
setUuid
(
uuid
);
}
}
else
else
{
{
audioItem
=
addAudio
(
sourceUrl
,
false
,
pPos
);
audio
Media
Item
=
addAudio
(
sourceUrl
,
false
,
pPos
);
}
}
if
(
audioItem
){
if
(
audio
Media
Item
){
connect
(
this
,
SIGNAL
(
activeSceneChanged
()),
audioItem
,
SLOT
(
activeSceneChanged
()));
connect
(
this
,
SIGNAL
(
activeSceneChanged
()),
audio
Media
Item
,
SLOT
(
activeSceneChanged
()));
}
}
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
...
@@ -1776,7 +1804,7 @@ void UBBoardController::controlViewShown()
...
@@ -1776,7 +1804,7 @@ void UBBoardController::controlViewShown()
}
}
UBGraphics
Video
Item
*
UBBoardController
::
addVideo
(
const
QUrl
&
pSourceUrl
,
bool
startPlay
,
const
QPointF
&
pos
)
UBGraphics
Media
Item
*
UBBoardController
::
addVideo
(
const
QUrl
&
pSourceUrl
,
bool
startPlay
,
const
QPointF
&
pos
)
{
{
QUuid
uuid
=
QUuid
::
createUuid
();
QUuid
uuid
=
QUuid
::
createUuid
();
QUrl
concreteUrl
=
pSourceUrl
;
QUrl
concreteUrl
=
pSourceUrl
;
...
@@ -1789,7 +1817,7 @@ UBGraphicsVideoItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool st
...
@@ -1789,7 +1817,7 @@ UBGraphicsVideoItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool st
->
addVideoFileToDocument
(
mActiveDocument
,
pSourceUrl
.
toLocalFile
(),
uuid
));
->
addVideoFileToDocument
(
mActiveDocument
,
pSourceUrl
.
toLocalFile
(),
uuid
));
#endif
#endif
UBGraphics
VideoItem
*
vi
=
mActiveScene
->
addVideo
(
concreteUrl
,
startPlay
,
pos
);
UBGraphics
MediaItem
*
vi
=
mActiveScene
->
addMedia
(
concreteUrl
,
startPlay
,
pos
);
mActiveDocument
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
mActiveDocument
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
if
(
vi
)
{
if
(
vi
)
{
...
@@ -1801,7 +1829,7 @@ UBGraphicsVideoItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool st
...
@@ -1801,7 +1829,7 @@ UBGraphicsVideoItem* UBBoardController::addVideo(const QUrl& pSourceUrl, bool st
}
}
UBGraphics
Audio
Item
*
UBBoardController
::
addAudio
(
const
QUrl
&
pSourceUrl
,
bool
startPlay
,
const
QPointF
&
pos
)
UBGraphics
Media
Item
*
UBBoardController
::
addAudio
(
const
QUrl
&
pSourceUrl
,
bool
startPlay
,
const
QPointF
&
pos
)
{
{
QUuid
uuid
=
QUuid
::
createUuid
();
QUuid
uuid
=
QUuid
::
createUuid
();
QUrl
concreteUrl
=
pSourceUrl
;
QUrl
concreteUrl
=
pSourceUrl
;
...
@@ -1814,15 +1842,15 @@ UBGraphicsAudioItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool st
...
@@ -1814,15 +1842,15 @@ UBGraphicsAudioItem* UBBoardController::addAudio(const QUrl& pSourceUrl, bool st
->
addAudioFileToDocument
(
mActiveDocument
,
pSourceUrl
.
toLocalFile
(),
uuid
));
->
addAudioFileToDocument
(
mActiveDocument
,
pSourceUrl
.
toLocalFile
(),
uuid
));
#endif
#endif
UBGraphics
AudioItem
*
vi
=
mActiveScene
->
addAudio
(
concreteUrl
,
startPlay
,
pos
);
UBGraphics
MediaItem
*
ai
=
mActiveScene
->
addMedia
(
concreteUrl
,
startPlay
,
pos
);
mActiveDocument
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
mActiveDocument
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
if
(
v
i
){
if
(
a
i
){
v
i
->
setUuid
(
uuid
);
a
i
->
setUuid
(
uuid
);
v
i
->
setSourceUrl
(
pSourceUrl
);
a
i
->
setSourceUrl
(
pSourceUrl
);
}
}
return
v
i
;
return
a
i
;
}
}
...
...
src/board/UBBoardController.h
View file @
90f03866
...
@@ -33,6 +33,7 @@ class UBToolWidget;
...
@@ -33,6 +33,7 @@ class UBToolWidget;
class
UBVersion
;
class
UBVersion
;
class
UBSoftwareUpdate
;
class
UBSoftwareUpdate
;
class
UBSoftwareUpdateDialog
;
class
UBSoftwareUpdateDialog
;
class
UBGraphicsMediaItem
;
class
UBGraphicsVideoItem
;
class
UBGraphicsVideoItem
;
class
UBGraphicsAudioItem
;
class
UBGraphicsAudioItem
;
class
UBGraphicsWidgetItem
;
class
UBGraphicsWidgetItem
;
...
@@ -184,6 +185,7 @@ class UBBoardController : public QObject
...
@@ -184,6 +185,7 @@ class UBBoardController : public QObject
void
nextScene
();
void
nextScene
();
void
firstScene
();
void
firstScene
();
void
lastScene
();
void
lastScene
();
void
groupButtonClicked
();
void
downloadURL
(
const
QUrl
&
url
,
const
QPointF
&
pPos
=
QPointF
(
0
.
0
,
0
.
0
),
const
QSize
&
pSize
=
QSize
(),
bool
isBackground
=
false
);
void
downloadURL
(
const
QUrl
&
url
,
const
QPointF
&
pPos
=
QPointF
(
0
.
0
,
0
.
0
),
const
QSize
&
pSize
=
QSize
(),
bool
isBackground
=
false
);
void
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
=
false
);
void
downloadFinished
(
bool
pSuccess
,
QUrl
sourceUrl
,
QString
pHeader
,
QByteArray
pData
,
QPointF
pPos
,
QSize
pSize
,
bool
isBackground
=
false
);
void
changeBackground
(
bool
isDark
,
bool
isCrossed
);
void
changeBackground
(
bool
isDark
,
bool
isCrossed
);
...
@@ -203,8 +205,8 @@ class UBBoardController : public QObject
...
@@ -203,8 +205,8 @@ class UBBoardController : public QObject
void
grabScene
(
const
QRectF
&
pSceneRect
);
void
grabScene
(
const
QRectF
&
pSceneRect
);
void
controlViewHidden
();
void
controlViewHidden
();
void
controlViewShown
();
void
controlViewShown
();
UBGraphics
Video
Item
*
addVideo
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
);
UBGraphics
Media
Item
*
addVideo
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
);
UBGraphics
Audio
Item
*
addAudio
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
);
UBGraphics
Media
Item
*
addAudio
(
const
QUrl
&
pUrl
,
bool
startPlay
,
const
QPointF
&
pos
);
UBGraphicsWidgetItem
*
addW3cWidget
(
const
QUrl
&
pUrl
,
const
QPointF
&
pos
);
UBGraphicsWidgetItem
*
addW3cWidget
(
const
QUrl
&
pUrl
,
const
QPointF
&
pos
);
void
cut
();
void
cut
();
...
...
src/board/UBBoardView.cpp
View file @
90f03866
...
@@ -47,8 +47,7 @@
...
@@ -47,8 +47,7 @@
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsPDFItem.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBGraphicsPolygonItem.h"
#include "domain/UBItem.h"
#include "domain/UBItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsStrokesGroup.h"
...
@@ -560,8 +559,7 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -560,8 +559,7 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
if
(
item
->
type
()
==
UBGraphicsW3CWidgetItem
::
Type
if
(
item
->
type
()
==
UBGraphicsW3CWidgetItem
::
Type
||
item
->
type
()
==
UBGraphicsPixmapItem
::
Type
||
item
->
type
()
==
UBGraphicsPixmapItem
::
Type
||
item
->
type
()
==
UBGraphicsVideoItem
::
Type
||
item
->
type
()
==
UBGraphicsMediaItem
::
Type
||
item
->
type
()
==
UBGraphicsAudioItem
::
Type
||
item
->
type
()
==
UBGraphicsSvgItem
::
Type
||
item
->
type
()
==
UBGraphicsSvgItem
::
Type
||
item
->
type
()
==
UBGraphicsTextItem
::
Type
||
item
->
type
()
==
UBGraphicsTextItem
::
Type
||
item
->
type
()
==
UBGraphicsStrokesGroup
::
Type
)
{
||
item
->
type
()
==
UBGraphicsStrokesGroup
::
Type
)
{
...
...
src/board/UBLibraryController.cpp
View file @
90f03866
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphics
Video
Item.h"
#include "domain/UBGraphics
Media
Item.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "tools/UBToolsManager.h"
#include "tools/UBToolsManager.h"
...
@@ -698,7 +698,7 @@ void UBLibraryController::addVideosToCurrentPage(const QList<QUrl>& videos)
...
@@ -698,7 +698,7 @@ void UBLibraryController::addVideosToCurrentPage(const QList<QUrl>& videos)
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
++
;
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
mLastItemOffsetIndex
=
qMin
(
mLastItemOffsetIndex
,
5
);
UBGraphics
Video
Item
*
itemInScene
=
UBApplication
::
boardController
->
addVideo
(
url
,
false
,
pos
);
UBGraphics
Media
Item
*
itemInScene
=
UBApplication
::
boardController
->
addVideo
(
url
,
false
,
pos
);
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
50
*
mLastItemOffsetIndex
,
pos
.
y
()
+
50
*
mLastItemOffsetIndex
));
itemInScene
->
setPos
(
QPoint
(
pos
.
x
()
+
50
*
mLastItemOffsetIndex
,
pos
.
y
()
+
50
*
mLastItemOffsetIndex
));
}
}
}
}
...
...
src/core/UB.h
View file @
90f03866
...
@@ -98,6 +98,7 @@ struct UBGraphicsItemData
...
@@ -98,6 +98,7 @@ struct UBGraphicsItemData
,
ItemEditable
//for text only
,
ItemEditable
//for text only
,
ItemOwnZValue
,
ItemOwnZValue
,
itemLayerType
//use instead of deprecated ItemLayerType
,
itemLayerType
//use instead of deprecated ItemLayerType
,
ItemUuid
//storing uuid in QGraphicsItem for fast finding operations
};
};
};
};
...
@@ -110,8 +111,7 @@ struct UBGraphicsItemType
...
@@ -110,8 +111,7 @@ struct UBGraphicsItemType
PolygonItemType
=
QGraphicsItem
::
UserType
+
1
,
PolygonItemType
=
QGraphicsItem
::
UserType
+
1
,
PixmapItemType
,
PixmapItemType
,
SvgItemType
,
SvgItemType
,
VideoItemType
,
MediaItemType
,
AudioItemType
,
AppleWidgetItemType
,
AppleWidgetItemType
,
PDFItemType
,
PDFItemType
,
TextItemType
,
TextItemType
,
...
...
src/core/UBSettings.cpp
View file @
90f03866
...
@@ -384,6 +384,9 @@ void UBSettings::init()
...
@@ -384,6 +384,9 @@ void UBSettings::init()
historyLimit
=
new
UBSetting
(
this
,
"Web"
,
"HistoryLimit"
,
15
);
historyLimit
=
new
UBSetting
(
this
,
"Web"
,
"HistoryLimit"
,
15
);
teacherGuidePageZeroActivated
=
new
UBSetting
(
this
,
"DockPalette"
,
"TeacherGuideActivatePageZero"
,
true
);
teacherGuidePageZeroActivated
=
new
UBSetting
(
this
,
"DockPalette"
,
"TeacherGuideActivatePageZero"
,
true
);
teacherGuideLessonPagesActivated
=
new
UBSetting
(
this
,
"DockPalette"
,
"TeacherGuideActivateLessonPages"
,
true
);
teacherGuideLessonPagesActivated
=
new
UBSetting
(
this
,
"DockPalette"
,
"TeacherGuideActivateLessonPages"
,
true
);
actionGroupText
=
"Group items"
;
actionUngroupText
=
"Ungroup items"
;
}
}
...
...
src/core/UBSettings.h
View file @
90f03866
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
class
UBSettings
:
public
QObject
class
UBSettings
:
public
QObject
{
{
Q_OBJECT
;
Q_OBJECT
public
:
public
:
...
@@ -206,6 +206,9 @@ class UBSettings : public QObject
...
@@ -206,6 +206,9 @@ class UBSettings : public QObject
QString
softwareHomeUrl
;
QString
softwareHomeUrl
;
QString
actionGroupText
;
QString
actionUngroupText
;
UBSetting
*
appToolBarPositionedAtTop
;
UBSetting
*
appToolBarPositionedAtTop
;
UBSetting
*
appToolBarDisplayText
;
UBSetting
*
appToolBarDisplayText
;
UBSetting
*
appEnableAutomaticSoftwareUpdates
;
UBSetting
*
appEnableAutomaticSoftwareUpdates
;
...
...
src/domain/UBGraphicsAudioItem.cpp
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBGraphicsAudioItem.h"
#include "UBGraphicsAudioItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsAudioItem
::
UBGraphicsAudioItem
(
const
QUrl
&
pAudioFileUrl
,
QGraphicsItem
*
parent
)
:
UBGraphicsMediaItem
(
pAudioFileUrl
,
parent
)
{
update
();
mAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
MusicCategory
,
this
);
mMediaObject
=
new
Phonon
::
MediaObject
(
this
);
mMediaObject
->
setTickInterval
(
1000
);
Phonon
::
createPath
(
mMediaObject
,
mAudioOutput
);
mMediaObject
->
clearQueue
();
mSource
=
Phonon
::
MediaSource
(
pAudioFileUrl
);
mMediaObject
->
setCurrentSource
(
mSource
);
connect
(
mMediaObject
,
SIGNAL
(
tick
(
qint64
)
),
this
,
SLOT
(
tick
(
qint64
)
)
);
connect
(
mMediaObject
,
SIGNAL
(
stateChanged
(
Phonon
::
State
,
Phonon
::
State
)),
this
,
SLOT
(
onStateChanged
(
Phonon
::
State
,
Phonon
::
State
)));
mAudioWidget
=
new
QWidget
();
mSeekSlider
=
new
Phonon
::
SeekSlider
(
mAudioWidget
);
mSeekSlider
->
setMediaObject
(
mMediaObject
);
QPalette
palette
;
palette
.
setBrush
(
QPalette
::
Light
,
Qt
::
darkGray
);
mTimeLcd
=
new
QLCDNumber
;
mTimeLcd
->
setPalette
(
palette
);
mTimeLcd
->
display
(
"00:00"
);
QHBoxLayout
*
seekerLayout
=
new
QHBoxLayout
;
seekerLayout
->
addWidget
(
mSeekSlider
);
seekerLayout
->
addWidget
(
mTimeLcd
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
seekerLayout
);
mAudioWidget
->
setLayout
(
mainLayout
);
setWidget
(
mAudioWidget
);
UBGraphicsAudioItemDelegate
*
delegate
=
new
UBGraphicsAudioItemDelegate
(
this
,
mMediaObject
);
delegate
->
init
();
setDelegate
(
delegate
);
mDelegate
->
frame
()
->
setOperationMode
(
UBGraphicsDelegateFrame
::
Resizing
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
void
UBGraphicsAudioItem
::
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
)
{
qDebug
()
<<
"STATE CHANGED!"
;
qDebug
()
<<
"old state:"
<<
oldState
;
qDebug
()
<<
"new state:"
<<
newState
;
if
(
oldState
==
Phonon
::
ErrorState
)
{
qDebug
()
<<
"ERROR! : "
<<
mMediaObject
->
errorString
();
}
else
if
(
newState
==
Phonon
::
LoadingState
)
{
int
itotaltime
=
mMediaObject
->
totalTime
();
qDebug
()
<<
"[Loading State entered!] Total time : "
<<
itotaltime
;
}
}
UBGraphicsAudioItem
::~
UBGraphicsAudioItem
()
{
//NOOP
}
UBItem
*
UBGraphicsAudioItem
::
deepCopy
()
const
{
QUrl
audioUrl
=
this
->
mediaFileUrl
();
UBGraphicsAudioItem
*
copy
=
new
UBGraphicsAudioItem
(
audioUrl
,
parentItem
());
copy
->
setPos
(
this
->
pos
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
copy
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
copy
->
setData
(
UBGraphicsItemData
::
ItemLocked
,
this
->
data
(
UBGraphicsItemData
::
ItemLocked
));
copy
->
setUuid
(
this
->
uuid
());
// this is OK as long as Videos are imutable
copy
->
setSourceUrl
(
this
->
sourceUrl
());
copy
->
resize
(
this
->
size
());
// TODO UB 4.7 complete all members
return
copy
;
}
void
UBGraphicsAudioItem
::
tick
(
qint64
time
)
{
QTime
displayTime
(
0
,
(
time
/
60000
)
%
60
,
(
time
/
1000
)
%
60
);
mTimeLcd
->
display
(
displayTime
.
toString
(
"mm:ss"
)
);
}
src/domain/UBGraphicsAudioItem.h
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSAUDIOITEM_H
#define UBGRAPHICSAUDIOITEM_H
#include "UBGraphicsMediaItem.h"
#include "phonon/seekslider.h"
#include "phonon/mediasource.h"
#include "core/UB.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
class
UBGraphicsAudioItem
:
public
UBGraphicsMediaItem
{
Q_OBJECT
public
:
UBGraphicsAudioItem
(
const
QUrl
&
pAudioFileUrl
,
QGraphicsItem
*
parent
=
0
);
~
UBGraphicsAudioItem
();
enum
{
Type
=
UBGraphicsItemType
::
AudioItemType
};
virtual
int
type
()
const
{
return
Type
;
}
virtual
UBItem
*
deepCopy
()
const
;
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
()
{
UBGraphicsMediaItem
::
clearSource
();
}
private
slots
:
void
tick
(
qint64
time
);
void
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
);
protected
:
QWidget
*
mAudioWidget
;
QLCDNumber
*
mTimeLcd
;
Phonon
::
SeekSlider
*
mSeekSlider
;
private
:
Phonon
::
MediaSource
mSource
;
};
#endif // UBGRAPHICSAUDIOITEM_H
src/domain/UBGraphicsAudioItemDelegate.cpp
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBGraphicsAudioItemDelegate.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsDelegateFrame.h"
#include "UBGraphicsScene.h"
#include "core/memcheck.h"
UBGraphicsAudioItemDelegate
::
UBGraphicsAudioItemDelegate
(
UBGraphicsAudioItem
*
pDelegated
,
QObject
*
parent
)
:
UBGraphicsItemDelegate
(
pDelegated
,
parent
)
,
mDelegated
(
pDelegated
)
{
//NOOP
}
UBGraphicsAudioItemDelegate
::~
UBGraphicsAudioItemDelegate
()
{
//NNOP
}
void
UBGraphicsAudioItemDelegate
::
buildButtons
()
{
mPlayPauseButton
=
new
DelegateButton
(
":/images/play.svg"
,
mDelegated
,
mFrame
);
mStopButton
=
new
DelegateButton
(
":/images/stop.svg"
,
mDelegated
,
mFrame
);
mStopButton
->
hide
();
if
(
mDelegated
->
isMuted
()
)
mMuteButton
=
new
DelegateButton
(
":/images/soundOff.svg"
,
mDelegated
,
mFrame
);
else
mMuteButton
=
new
DelegateButton
(
":/images/soundOn.svg"
,
mDelegated
,
mFrame
);
mMuteButton
->
hide
();
connect
(
mPlayPauseButton
,
SIGNAL
(
clicked
(
bool
)
),
this
,
SLOT
(
togglePlayPause
()
)
);
connect
(
mStopButton
,
SIGNAL
(
clicked
(
bool
)
),
mDelegated
->
mediaObject
(),
SLOT
(
stop
()
)
);
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)
),
mDelegated
,
SLOT
(
toggleMute
()
)
);
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)
),
this
,
SLOT
(
toggleMute
()
)
);
connect
(
mDelegated
->
mediaObject
(),
SIGNAL
(
stateChanged
(
Phonon
::
State
,
Phonon
::
State
)
),
this
,
SLOT
(
mediaStateChanged
(
Phonon
::
State
,
Phonon
::
State
)
)
);
connect
(
mDelegated
->
mediaObject
(),
SIGNAL
(
finished
()
),
this
,
SLOT
(
updatePlayPauseState
()
)
);
mButtons
<<
mPlayPauseButton
<<
mStopButton
<<
mMuteButton
;
}
void
UBGraphicsAudioItemDelegate
::
togglePlayPause
()
{
if
(
mDelegated
&&
mDelegated
->
mediaObject
()
)
{
Phonon
::
MediaObject
*
media
=
mDelegated
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
StoppedState
)
{
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
{
if
(
media
->
remainingTime
()
<=
0
)
{
media
->
stop
();
media
->
play
();
}
else
{
media
->
pause
();
if
(
mDelegated
->
scene
()
)
mDelegated
->
scene
()
->
setModified
(
true
);
}
}
else
if
(
media
->
state
()
==
Phonon
::
PausedState
)
{
if
(
media
->
remainingTime
()
<=
0
)
{
media
->
stop
();
}
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
LoadingState
)
{
mDelegated
->
mediaObject
()
->
setCurrentSource
(
mDelegated
->
mediaFileUrl
());
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
ErrorState
){
qDebug
()
<<
"Error appeared."
<<
media
->
errorString
();
}
}
}
void
UBGraphicsAudioItemDelegate
::
toggleMute
()
{
if
(
mDelegated
->
isMuted
()
)
mMuteButton
->
setFileName
(
":/images/soundOff.svg"
);
else
mMuteButton
->
setFileName
(
":/images/soundOn.svg"
);
}
void
UBGraphicsAudioItemDelegate
::
updatePlayPauseState
()
{
Phonon
::
MediaObject
*
media
=
mDelegated
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
mPlayPauseButton
->
setFileName
(
":/images/pause.svg"
);
else
mPlayPauseButton
->
setFileName
(
":/images/play.svg"
);
}
void
UBGraphicsAudioItemDelegate
::
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
)
{
Q_UNUSED
(
newstate
);
Q_UNUSED
(
oldstate
);
updatePlayPauseState
();
}
void
UBGraphicsAudioItemDelegate
::
remove
(
bool
canUndo
)
{
mDelegated
->
mediaObject
()
->
stop
();
UBGraphicsItemDelegate
::
remove
(
canUndo
);
}
src/domain/UBGraphicsDelegateFrame.cpp
View file @
90f03866
...
@@ -585,7 +585,10 @@ void UBGraphicsDelegateFrame::positionHandles()
...
@@ -585,7 +585,10 @@ void UBGraphicsDelegateFrame::positionHandles()
if
(
mDelegate
->
getToolBarItem
()
->
isVisibleOnBoard
()
if
(
mDelegate
->
getToolBarItem
()
->
isVisibleOnBoard
()
&&
mDelegate
->
getToolBarItem
()
->
isShifting
())
&&
mDelegate
->
getToolBarItem
()
->
isShifting
())
itemRect
.
setHeight
(
itemRect
.
height
()
+
mDelegate
->
getToolBarItem
()
->
rect
().
height
()
*
mDelegate
->
antiScaleRatio
()
*
1.1
);
{
QPointF
graphicsItemPosition
=
itemRect
.
topLeft
();
itemRect
.
setTopLeft
(
graphicsItemPosition
-
QPointF
(
0
,
mDelegate
->
getToolBarItem
()
->
boundingRect
().
height
()
*
mDelegate
->
antiScaleRatio
()));
}
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
QTransform
itemTransform
=
delegated
()
->
sceneTransform
();
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
QPointF
topLeft
=
itemTransform
.
map
(
itemRect
.
topLeft
());
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
90f03866
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <QDrag>
#include <QDrag>
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemUndoCommand.h"
...
@@ -38,8 +39,7 @@
...
@@ -38,8 +39,7 @@
#include "domain/UBAbstractWidget.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "web/UBWebController.h"
#include "web/UBWebController.h"
...
@@ -112,13 +112,14 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
...
@@ -112,13 +112,14 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
,
mRespectRatio
(
respectRatio
)
,
mRespectRatio
(
respectRatio
)
,
mMimeData
(
NULL
)
,
mMimeData
(
NULL
)
,
mFlippable
(
false
)
,
mFlippable
(
false
)
,
mToolBarItem
(
NULL
)
{
{
// NOOP
// NOOP
}
}
void
UBGraphicsItemDelegate
::
init
()
void
UBGraphicsItemDelegate
::
init
()
{
{
mToolBarItem
=
new
UBGraphicsToolBarItem
(
delegated
()
);
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
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
();
...
@@ -152,11 +153,11 @@ void UBGraphicsItemDelegate::init()
...
@@ -152,11 +153,11 @@ void UBGraphicsItemDelegate::init()
{
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
{
button
->
hide
();
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
}
}
}
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
...
@@ -335,8 +336,9 @@ void UBGraphicsItemDelegate::positionHandles()
...
@@ -335,8 +336,9 @@ void UBGraphicsItemDelegate::positionHandles()
if
(
mToolBarItem
->
isVisibleOnBoard
())
if
(
mToolBarItem
->
isVisibleOnBoard
())
{
{
updateToolBar
();
mToolBarItem
->
positionHandles
();
mToolBarItem
->
show
();
mToolBarItem
->
update
();
mToolBarItem
->
show
();
}
}
}
else
{
}
else
{
foreach
(
DelegateButton
*
button
,
mButtons
)
foreach
(
DelegateButton
*
button
,
mButtons
)
...
@@ -518,6 +520,10 @@ void UBGraphicsItemDelegate::commitUndoStep()
...
@@ -518,6 +520,10 @@ void UBGraphicsItemDelegate::commitUndoStep()
}
}
void
UBGraphicsItemDelegate
::
buildButtons
()
{
}
void
UBGraphicsItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
void
UBGraphicsItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
{
{
mLockAction
=
menu
->
addAction
(
tr
(
"Locked"
),
this
,
SLOT
(
lock
(
bool
)));
mLockAction
=
menu
->
addAction
(
tr
(
"Locked"
),
this
,
SLOT
(
lock
(
bool
)));
...
@@ -650,36 +656,6 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
...
@@ -650,36 +656,6 @@ 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
){
...
@@ -687,19 +663,41 @@ void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
...
@@ -687,19 +663,41 @@ void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
}
}
}
}
UBGraphicsToolBarItem
::
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
)
:
UBGraphicsToolBarItem
::
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
)
:
QGraphicsRectItem
(
parent
),
QGraphicsRectItem
(
parent
),
mShifting
(
true
),
mShifting
(
true
),
mVisible
(
false
),
mVisible
(
false
),
mMinWidth
(
200
)
mMinWidth
(
200
),
mInitialHeight
(
26
)
{
{
QRectF
rect
=
this
->
rect
();
QRectF
rect
=
this
->
rect
();
rect
.
setHeight
(
26
);
rect
.
setHeight
(
mInitialHeight
);
rect
.
setWidth
(
parent
->
boundingRect
().
width
());
this
->
setRect
(
rect
);
this
->
setRect
(
rect
);
setBrush
(
QColor
(
UBSettings
::
paletteColor
));
setBrush
(
QColor
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
setPen
(
Qt
::
NoPen
);
hide
();
hide
();
update
();
}
void
UBGraphicsToolBarItem
::
positionHandles
()
{
int
itemXOffset
=
0
;
foreach
(
QGraphicsItem
*
item
,
mItemsOnToolBar
)
{
item
->
setPos
(
itemXOffset
,
0
);
itemXOffset
+=
(
item
->
boundingRect
().
width
());
item
->
show
();
}
}
void
UBGraphicsToolBarItem
::
update
()
{
QGraphicsRectItem
::
update
();
}
}
void
UBGraphicsToolBarItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
UBGraphicsToolBarItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
...
@@ -712,3 +710,552 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI
...
@@ -712,3 +710,552 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI
painter
->
fillPath
(
path
,
brush
());
painter
->
fillPath
(
path
,
brush
());
}
}
MediaTimer
::
MediaTimer
(
QGraphicsItem
*
parent
)
:
QGraphicsRectItem
(
parent
)
{}
MediaTimer
::~
MediaTimer
()
{}
void
MediaTimer
::
drawString
(
const
QString
&
s
,
QPainter
&
p
,
QBitArray
*
newPoints
,
bool
newString
)
{
QPoint
pos
;
int
digitSpace
=
smallPoint
?
2
:
1
;
int
xSegLen
=
(
rect
().
width
()
/
1
)
*
5
/
(
ndigits
*
(
5
+
digitSpace
)
+
digitSpace
);
int
ySegLen
=
rect
().
height
()
*
5
/
12
;
int
segLen
=
ySegLen
>
xSegLen
?
xSegLen
:
ySegLen
;
int
xAdvance
=
segLen
*
(
5
+
digitSpace
)
/
5
;
int
xOffset
=
rect
().
x
()
+
(
rect
().
width
()
/
1
-
ndigits
*
xAdvance
+
segLen
/
5
)
/
2
;
int
yOffset
=
(
rect
().
height
()
-
segLen
*
2
)
/
2
;
for
(
int
i
=
0
;
i
<
ndigits
;
i
++
)
{
pos
=
QPoint
(
xOffset
+
xAdvance
*
i
,
yOffset
);
if
(
newString
)
drawDigit
(
pos
,
p
,
segLen
,
s
[
i
].
toLatin1
(),
digitStr
[
i
].
toLatin1
());
else
drawDigit
(
pos
,
p
,
segLen
,
s
[
i
].
toLatin1
());
if
(
newPoints
)
{
char
newPoint
=
newPoints
->
testBit
(
i
)
?
'.'
:
' '
;
if
(
newString
)
{
char
oldPoint
=
points
.
testBit
(
i
)
?
'.'
:
' '
;
drawDigit
(
pos
,
p
,
segLen
,
newPoint
,
oldPoint
);
}
else
{
drawDigit
(
pos
,
p
,
segLen
,
newPoint
);
}
}
}
if
(
newString
)
{
digitStr
=
s
;
digitStr
.
truncate
(
ndigits
);
if
(
newPoints
)
points
=
*
newPoints
;
}
}
void
MediaTimer
::
drawDigit
(
const
QPoint
&
pos
,
QPainter
&
p
,
int
segLen
,
char
newCh
,
char
oldCh
)
{
char
updates
[
18
][
2
];
// can hold 2 times number of segments, only
// first 9 used if segment table is correct
int
nErases
;
int
nUpdates
;
const
char
*
segs
;
int
i
,
j
;
const
char
erase
=
0
;
const
char
draw
=
1
;
const
char
leaveAlone
=
2
;
segs
=
getSegments
(
oldCh
);
for
(
nErases
=
0
;
segs
[
nErases
]
!=
99
;
nErases
++
)
{
updates
[
nErases
][
0
]
=
erase
;
// get segments to erase to
updates
[
nErases
][
1
]
=
segs
[
nErases
];
// remove old char
}
nUpdates
=
nErases
;
segs
=
getSegments
(
newCh
);
for
(
i
=
0
;
segs
[
i
]
!=
99
;
i
++
)
{
for
(
j
=
0
;
j
<
nErases
;
j
++
)
if
(
segs
[
i
]
==
updates
[
j
][
1
])
{
// same segment ?
updates
[
j
][
0
]
=
leaveAlone
;
// yes, already on screen
break
;
}
if
(
j
==
nErases
)
{
// if not already on screen
updates
[
nUpdates
][
0
]
=
draw
;
updates
[
nUpdates
][
1
]
=
segs
[
i
];
nUpdates
++
;
}
}
for
(
i
=
0
;
i
<
nUpdates
;
i
++
)
{
if
(
updates
[
i
][
0
]
==
draw
)
drawSegment
(
pos
,
updates
[
i
][
1
],
p
,
segLen
);
if
(
updates
[
i
][
0
]
==
erase
)
drawSegment
(
pos
,
updates
[
i
][
1
],
p
,
segLen
,
true
);
}
}
char
*
MediaTimer
::
getSegments
(
char
ch
)
// gets list of segments for ch
{
char
segments
[
30
][
8
]
=
{
{
0
,
1
,
2
,
4
,
5
,
6
,
99
,
0
},
// 0 0
{
2
,
5
,
99
,
0
,
0
,
0
,
0
,
0
},
// 1 1
{
0
,
2
,
3
,
4
,
6
,
99
,
0
,
0
},
// 2 2
{
0
,
2
,
3
,
5
,
6
,
99
,
0
,
0
},
// 3 3
{
1
,
2
,
3
,
5
,
99
,
0
,
0
,
0
},
// 4 4
{
0
,
1
,
3
,
5
,
6
,
99
,
0
,
0
},
// 5 5
{
0
,
1
,
3
,
4
,
5
,
6
,
99
,
0
},
// 6 6
{
0
,
2
,
5
,
99
,
0
,
0
,
0
,
0
},
// 7 7
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
99
},
// 8 8
{
0
,
1
,
2
,
3
,
5
,
6
,
99
,
0
},
// 9 9
{
8
,
9
,
99
,
0
,
0
,
0
,
0
,
0
},
// 10 :
{
99
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
// 11 empty
};
int
n
;
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
return
segments
[
ch
-
'0'
];
if
(
ch
==
':'
)
n
=
10
;
if
(
ch
==
' '
)
n
=
11
;
return
segments
[
n
];
}
void
MediaTimer
::
drawSegment
(
const
QPoint
&
pos
,
char
segmentNo
,
QPainter
&
p
,
int
segLen
,
bool
erase
)
{
Q_UNUSED
(
erase
);
QPoint
ppt
;
QPoint
pt
=
pos
;
int
width
=
segLen
/
5
;
#define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y)))
#define LIGHT
#define DARK
if
(
fill
)
{
QPolygon
a
(
0
);
switch
(
segmentNo
)
{
case
0
:
ppt
=
pt
;
LIGHT
;
LINETO
(
segLen
-
1
,
0
);
DARK
;
LINETO
(
segLen
-
width
-
1
,
width
);
LINETO
(
width
,
width
);
LINETO
(
0
,
0
);
break
;
case
1
:
pt
+=
QPoint
(
0
,
1
);
ppt
=
pt
;
LIGHT
;
LINETO
(
width
,
width
);
DARK
;
LINETO
(
width
,
segLen
-
width
/
2
-
2
);
LINETO
(
0
,
segLen
-
2
);
LIGHT
;
LINETO
(
0
,
0
);
break
;
case
2
:
pt
+=
QPoint
(
segLen
-
1
,
1
);
ppt
=
pt
;
DARK
;
LINETO
(
0
,
segLen
-
2
);
LINETO
(
-
width
,
segLen
-
width
/
2
-
2
);
LIGHT
;
LINETO
(
-
width
,
width
);
LINETO
(
0
,
0
);
break
;
case
3
:
pt
+=
QPoint
(
0
,
segLen
);
ppt
=
pt
;
LIGHT
;
LINETO
(
width
,
-
width
/
2
);
LINETO
(
segLen
-
width
-
1
,
-
width
/
2
);
LINETO
(
segLen
-
1
,
0
);
DARK
;
if
(
width
&
1
)
{
// adjust for integer division error
LINETO
(
segLen
-
width
-
3
,
width
/
2
+
1
);
LINETO
(
width
+
2
,
width
/
2
+
1
);
}
else
{
LINETO
(
segLen
-
width
-
1
,
width
/
2
);
LINETO
(
width
,
width
/
2
);
}
LINETO
(
0
,
0
);
break
;
case
4
:
pt
+=
QPoint
(
0
,
segLen
+
1
);
ppt
=
pt
;
LIGHT
;
LINETO
(
width
,
width
/
2
);
DARK
;
LINETO
(
width
,
segLen
-
width
-
2
);
LINETO
(
0
,
segLen
-
2
);
LIGHT
;
LINETO
(
0
,
0
);
break
;
case
5
:
pt
+=
QPoint
(
segLen
-
1
,
segLen
+
1
);
ppt
=
pt
;
DARK
;
LINETO
(
0
,
segLen
-
2
);
LINETO
(
-
width
,
segLen
-
width
-
2
);
LIGHT
;
LINETO
(
-
width
,
width
/
2
);
LINETO
(
0
,
0
);
break
;
case
6
:
pt
+=
QPoint
(
0
,
segLen
*
2
);
ppt
=
pt
;
LIGHT
;
LINETO
(
width
,
-
width
);
LINETO
(
segLen
-
width
-
1
,
-
width
);
LINETO
(
segLen
-
1
,
0
);
DARK
;
LINETO
(
0
,
0
);
break
;
case
7
:
pt
+=
QPoint
(
segLen
/
2
,
segLen
*
2
);
ppt
=
pt
;
DARK
;
LINETO
(
width
,
0
);
LINETO
(
width
,
-
width
);
LIGHT
;
LINETO
(
0
,
-
width
);
LINETO
(
0
,
0
);
break
;
case
8
:
pt
+=
QPoint
(
segLen
/
2
-
width
/
2
+
1
,
segLen
/
2
+
width
);
ppt
=
pt
;
DARK
;
LINETO
(
width
,
0
);
LINETO
(
width
,
-
width
);
LIGHT
;
LINETO
(
0
,
-
width
);
LINETO
(
0
,
0
);
break
;
case
9
:
pt
+=
QPoint
(
segLen
/
2
-
width
/
2
+
1
,
3
*
segLen
/
2
+
width
);
ppt
=
pt
;
DARK
;
LINETO
(
width
,
0
);
LINETO
(
width
,
-
width
);
LIGHT
;
LINETO
(
0
,
-
width
);
LINETO
(
0
,
0
);
break
;
default
:
break
;
}
// End exact copy
p
.
setPen
(
Qt
::
white
);
p
.
setBrush
(
Qt
::
white
);
p
.
drawPolygon
(
a
);
p
.
setBrush
(
Qt
::
NoBrush
);
pt
=
pos
;
}
#undef LINETO
#undef LIGHT
#undef DARK
}
void
MediaTimer
::
addPoint
(
QPolygon
&
a
,
const
QPoint
&
p
)
{
uint
n
=
a
.
size
();
a
.
resize
(
n
+
1
);
a
.
setPoint
(
n
,
p
);
}
void
MediaTimer
::
paint
(
QPainter
*
p
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
QFont
f
=
p
->
font
();
f
.
setPointSizeF
(
f
.
pointSizeF
());
p
->
setFont
(
f
);
if
(
smallPoint
)
drawString
(
digitStr
,
*
p
,
&
points
,
false
);
else
drawString
(
digitStr
,
*
p
,
0
,
false
);
}
void
MediaTimer
::
internalSetString
(
const
QString
&
s
)
{
QString
buffer
;
int
i
;
int
len
=
s
.
length
();
QBitArray
newPoints
(
ndigits
);
if
(
!
smallPoint
)
{
if
(
len
==
ndigits
)
buffer
=
s
;
else
buffer
=
s
.
right
(
ndigits
).
rightJustified
(
ndigits
,
QLatin1Char
(
' '
));
}
else
{
int
index
=
-
1
;
bool
lastWasPoint
=
true
;
newPoints
.
clearBit
(
0
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
s
[
i
]
==
QLatin1Char
(
'.'
))
{
if
(
lastWasPoint
)
{
// point already set for digit?
if
(
index
==
ndigits
-
1
)
// no more digits
break
;
index
++
;
buffer
[
index
]
=
QLatin1Char
(
' '
);
// 2 points in a row, add space
}
newPoints
.
setBit
(
index
);
// set decimal point
lastWasPoint
=
true
;
}
else
{
if
(
index
==
ndigits
-
1
)
break
;
index
++
;
buffer
[
index
]
=
s
[
i
];
newPoints
.
clearBit
(
index
);
// decimal point default off
lastWasPoint
=
false
;
}
}
if
(
index
<
((
int
)
ndigits
)
-
1
)
{
for
(
i
=
index
;
i
>=
0
;
i
--
)
{
buffer
[
ndigits
-
1
-
index
+
i
]
=
buffer
[
i
];
newPoints
.
setBit
(
ndigits
-
1
-
index
+
i
,
newPoints
.
testBit
(
i
));
}
for
(
i
=
0
;
i
<
ndigits
-
index
-
1
;
i
++
)
{
buffer
[
i
]
=
QLatin1Char
(
' '
);
newPoints
.
clearBit
(
i
);
}
}
}
if
(
buffer
==
digitStr
)
return
;
digitStr
=
buffer
;
if
(
smallPoint
)
points
=
newPoints
;
update
();
}
void
MediaTimer
::
init
()
{
val
=
0
;
smallPoint
=
false
;
setNumDigits
(
4
);
}
void
MediaTimer
::
display
(
const
QString
&
s
)
{
val
=
0
;
bool
ok
=
false
;
double
v
=
s
.
toDouble
(
&
ok
);
if
(
ok
)
val
=
v
;
internalSetString
(
s
);
}
void
MediaTimer
::
setNumDigits
(
int
numDigits
)
{
if
(
numDigits
>
99
)
{
qWarning
(
"QLCDNumber::setNumDigits: (%s) Max 99 digits allowed"
);
numDigits
=
99
;
}
if
(
numDigits
<
0
)
{
qWarning
(
"QLCDNumber::setNumDigits: (%s) Min 0 digits allowed"
);
numDigits
=
0
;
}
if
(
digitStr
.
isNull
())
{
// from constructor
ndigits
=
numDigits
;
digitStr
.
fill
(
QLatin1Char
(
' '
),
ndigits
);
points
.
fill
(
0
,
ndigits
);
digitStr
[
ndigits
-
1
]
=
QLatin1Char
(
'0'
);
// "0" is the default number
}
else
{
if
(
numDigits
==
ndigits
)
// no change
return
;
register
int
i
;
int
dif
;
if
(
numDigits
>
ndigits
)
{
// expand
dif
=
numDigits
-
ndigits
;
QString
buf
;
buf
.
fill
(
QLatin1Char
(
' '
),
dif
);
digitStr
.
insert
(
0
,
buf
);
points
.
resize
(
numDigits
);
for
(
i
=
numDigits
-
1
;
i
>=
dif
;
i
--
)
points
.
setBit
(
i
,
points
.
testBit
(
i
-
dif
));
for
(
i
=
0
;
i
<
dif
;
i
++
)
points
.
clearBit
(
i
);
}
else
{
// shrink
dif
=
ndigits
-
numDigits
;
digitStr
=
digitStr
.
right
(
numDigits
);
QBitArray
tmpPoints
=
points
;
points
.
resize
(
numDigits
);
for
(
i
=
0
;
i
<
(
int
)
numDigits
;
i
++
)
points
.
setBit
(
i
,
tmpPoints
.
testBit
(
i
+
dif
));
}
ndigits
=
numDigits
;
update
();
}
}
DelegateMediaControl
::
DelegateMediaControl
(
UBGraphicsMediaItem
*
pDelegated
,
QGraphicsItem
*
parent
)
:
QGraphicsRectItem
(
parent
)
,
mDelegate
(
pDelegated
)
,
mDisplayCurrentTime
(
false
)
,
mCurrentTimeInMs
(
0
)
,
mTotalTimeInMs
(
0
)
,
mStartWidth
(
200
)
{
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
setBrush
(
QBrush
(
Qt
::
white
));
setPen
(
Qt
::
NoPen
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
lcdTimer
=
new
MediaTimer
(
this
);
lcdTimer
->
init
();
update
();
}
void
DelegateMediaControl
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
QPainterPath
path
;
mLCDTimerArea
.
setHeight
(
rect
().
height
());
mLCDTimerArea
.
setWidth
(
rect
().
height
());
mSeecArea
=
rect
();
mSeecArea
.
setWidth
(
rect
().
width
()
-
mLCDTimerArea
.
width
());
path
.
addRoundedRect
(
mSeecArea
,
mSeecArea
.
height
()
/
2
,
mSeecArea
.
height
()
/
2
);
painter
->
fillPath
(
path
,
brush
());
qreal
frameWidth
=
rect
().
height
()
/
2
;
int
position
=
frameWidth
;
if
(
mTotalTimeInMs
>
0
)
{
position
=
frameWidth
+
((
mSeecArea
.
width
()
-
(
2
*
frameWidth
))
/
mTotalTimeInMs
)
*
mCurrentTimeInMs
;
}
int
clearance
=
2
;
int
radius
=
frameWidth
-
clearance
;
QRectF
r
(
position
-
radius
,
clearance
,
radius
*
2
,
radius
*
2
);
painter
->
setBrush
(
UBSettings
::
documentViewLightColor
);
painter
->
drawEllipse
(
r
);
}
QPainterPath
DelegateMediaControl
::
shape
()
const
{
QPainterPath
path
;
path
.
addRoundedRect
(
rect
(),
rect
().
height
()
/
2
,
rect
().
height
()
/
2
);
return
path
;
}
void
DelegateMediaControl
::
positionHandles
()
{
mLCDTimerArea
.
setWidth
(
parentItem
()
->
boundingRect
().
height
());
mLCDTimerArea
.
setHeight
(
parentItem
()
->
boundingRect
().
height
());
lcdTimer
->
setRect
(
mLCDTimerArea
);
lcdTimer
->
setPos
(
mSeecArea
.
width
()
-
mLCDTimerArea
.
width
(),
0
);
mSeecArea
.
setWidth
(
rect
().
width
()
-
mLCDTimerArea
.
width
());
QRectF
selfRect
=
rect
();
selfRect
.
setHeight
(
parentItem
()
->
boundingRect
().
height
());
setRect
(
selfRect
);
lcdTimer
->
setPos
(
rect
().
width
()
-
mLCDTimerArea
.
width
(),
0
);
}
void
DelegateMediaControl
::
update
()
{
QTime
t
;
t
=
t
.
addMSecs
(
mCurrentTimeInMs
<
0
?
0
:
mCurrentTimeInMs
);
lcdTimer
->
display
(
t
.
toString
(
"m:ss"
));
QGraphicsRectItem
::
update
();
}
void
DelegateMediaControl
::
updateTicker
(
qint64
time
)
{
mCurrentTimeInMs
=
time
;
update
();
}
void
DelegateMediaControl
::
totalTimeChanged
(
qint64
newTotalTime
)
{
mTotalTimeInMs
=
newTotalTime
;
update
();
}
void
DelegateMediaControl
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
qreal
frameWidth
=
mSeecArea
.
height
()
/
2
;
if
(
boundingRect
().
contains
(
event
->
pos
()
-
QPointF
(
frameWidth
,
0
))
&&
boundingRect
().
contains
(
event
->
pos
()
+
QPointF
(
frameWidth
,
0
)))
{
mDisplayCurrentTime
=
true
;
seekToMousePos
(
event
->
pos
());
this
->
update
();
event
->
accept
();
}
}
void
DelegateMediaControl
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
qreal
frameWidth
=
rect
().
height
()
/
2
;
if
(
boundingRect
().
contains
(
event
->
pos
()
-
QPointF
(
frameWidth
,
0
))
&&
boundingRect
().
contains
(
event
->
pos
()
+
QPointF
(
frameWidth
,
0
)))
{
seekToMousePos
(
event
->
pos
());
this
->
update
();
event
->
accept
();
}
}
void
DelegateMediaControl
::
seekToMousePos
(
QPointF
mousePos
)
{
qreal
minX
,
length
;
qreal
frameWidth
=
rect
().
height
()
/
2
;
minX
=
frameWidth
;
length
=
mSeecArea
.
width
()
-
lcdTimer
->
rect
().
width
();
qreal
mouseX
=
mousePos
.
x
();
if
(
mouseX
>=
(
mSeecArea
.
width
()
-
mSeecArea
.
height
()
/
2
))
mouseX
=
mSeecArea
.
width
()
-
mSeecArea
.
height
()
/
2
;
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
DelegateMediaControl
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mDisplayCurrentTime
=
false
;
this
->
update
();
event
->
accept
();
}
src/domain/UBGraphicsItemDelegate.h
View file @
90f03866
...
@@ -29,6 +29,7 @@ class UBGraphicsScene;
...
@@ -29,6 +29,7 @@ class UBGraphicsScene;
class
UBGraphicsProxyWidget
;
class
UBGraphicsProxyWidget
;
class
UBGraphicsDelegateFrame
;
class
UBGraphicsDelegateFrame
;
class
UBGraphicsWidgetItem
;
class
UBGraphicsWidgetItem
;
class
UBGraphicsMediaItem
;
class
DelegateButton
:
public
QGraphicsSvgItem
class
DelegateButton
:
public
QGraphicsSvgItem
{
{
...
@@ -70,29 +71,105 @@ class DelegateButton: public QGraphicsSvgItem
...
@@ -70,29 +71,105 @@ class DelegateButton: public QGraphicsSvgItem
};
};
class
MediaTimer
:
public
QGraphicsRectItem
{
public
:
MediaTimer
(
QGraphicsItem
*
parent
=
0
);
~
MediaTimer
();
char
*
getSegments
(
char
);
void
addPoint
(
QPolygon
&
,
const
QPoint
&
);
void
init
();
void
internalSetString
(
const
QString
&
s
);
void
drawString
(
const
QString
&
s
,
QPainter
&
,
QBitArray
*
=
0
,
bool
=
true
);
void
drawDigit
(
const
QPoint
&
,
QPainter
&
,
int
,
char
,
char
=
' '
);
void
drawSegment
(
const
QPoint
&
,
char
,
QPainter
&
,
int
,
bool
=
false
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
display
(
const
QString
&
str
);
void
setNumDigits
(
int
nDigits
);
private
:
int
ndigits
;
QString
digitStr
;
QBitArray
points
;
double
val
;
uint
fill
:
1
;
uint
shadow
:
1
;
uint
smallPoint
:
1
;
};
class
DelegateMediaControl
:
public
QGraphicsRectItem
{
public
:
DelegateMediaControl
(
UBGraphicsMediaItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
);
virtual
~
DelegateMediaControl
()
{
// NOOP
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPainterPath
shape
()
const
;
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
update
();
void
positionHandles
();
void
updateTicker
(
qint64
time
);
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
void
seekToMousePos
(
QPointF
mousePos
);
UBGraphicsMediaItem
*
mDelegate
;
bool
mDisplayCurrentTime
;
qint64
mCurrentTimeInMs
;
qint64
mTotalTimeInMs
;
private
:
int
mStartWidth
;
QRectF
mSeecArea
;
QRectF
mLCDTimerArea
;
MediaTimer
*
lcdTimer
;
};
class
UBGraphicsToolBarItem
:
public
QGraphicsRectItem
,
public
QObject
class
UBGraphicsToolBarItem
:
public
QGraphicsRectItem
,
public
QObject
{
{
public
:
public
:
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
=
0
);
virtual
~
UBGraphicsToolBarItem
()
{
};
virtual
~
UBGraphicsToolBarItem
()
{
;}
bool
isVisibleOnBoard
()
const
{
return
mVisible
;
}
bool
isVisibleOnBoard
()
const
{
return
mVisible
;
}
void
setVisibleOnBoard
(
bool
visible
)
{
mVisible
=
visible
;
}
void
setVisibleOnBoard
(
bool
visible
)
{
mVisible
=
visible
;
}
bool
isShifting
()
const
{
return
mShifting
;
}
bool
isShifting
()
const
{
return
mShifting
;
}
void
setShifting
(
bool
shifting
)
{
mShifting
=
shifting
;
}
void
setShifting
(
bool
shifting
)
{
mShifting
=
shifting
;
}
int
offsetOnToolBar
()
const
{
return
mOffsetOnToolBar
;
}
void
setOffsetOnToolBar
(
int
pOffset
)
{
mOffsetOnToolBar
=
pOffset
;
}
QList
<
QGraphicsItem
*>
itemsOnToolBar
()
const
{
return
mItemsOnToolBar
;
}
QList
<
QGraphicsItem
*>
itemsOnToolBar
()
const
{
return
mItemsOnToolBar
;
}
void
setItemsOnToolBar
(
QList
<
QGraphicsItem
*>
itemsOnToolBar
)
{
mItemsOnToolBar
=
itemsOnToolBar
;}
void
setItemsOnToolBar
(
QList
<
QGraphicsItem
*>
itemsOnToolBar
)
{
mItemsOnToolBar
=
itemsOnToolBar
;}
int
minWidth
()
{
return
mMinWidth
;
}
int
minWidth
()
{
return
mMinWidth
;
}
void
positionHandles
();
void
update
();
private
:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QWidget
*
widget
);
private
:
private
:
bool
mShifting
;
bool
mShifting
;
bool
mVisible
;
bool
mVisible
;
int
mOffsetOnToolBar
;
int
mMinWidth
;
int
mMinWidth
;
int
mInitialHeight
;
QList
<
QGraphicsItem
*>
mItemsOnToolBar
;
QList
<
QGraphicsItem
*>
mItemsOnToolBar
;
};
};
...
@@ -168,7 +245,7 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -168,7 +245,7 @@ class UBGraphicsItemDelegate : public QObject
void
increaseZlevelBottom
();
void
increaseZlevelBottom
();
protected
:
protected
:
virtual
void
buildButtons
()
{;}
virtual
void
buildButtons
()
;
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
updateMenuActionState
();
virtual
void
updateMenuActionState
();
...
@@ -203,9 +280,6 @@ protected slots:
...
@@ -203,9 +280,6 @@ protected slots:
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/UBGraphicsMediaItem.cpp
View file @
90f03866
...
@@ -13,18 +13,15 @@
...
@@ -13,18 +13,15 @@
* 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 "UBGraphicsGroupContainerItem.h"
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsDelegateFrame.h"
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentProxy.h"
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
bool
UBGraphicsMediaItem
::
sIsMutedByDefault
=
false
;
bool
UBGraphicsMediaItem
::
sIsMutedByDefault
=
false
;
...
@@ -35,8 +32,63 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
...
@@ -35,8 +32,63 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
,
mMutedByUserAction
(
sIsMutedByDefault
)
,
mMutedByUserAction
(
sIsMutedByDefault
)
,
mMediaFileUrl
(
pMediaFileUrl
)
,
mMediaFileUrl
(
pMediaFileUrl
)
,
mInitialPos
(
0
)
,
mInitialPos
(
0
)
,
mVideoWidget
(
NULL
)
,
mAudioWidget
(
NULL
)
{
{
//NOOP
update
();
QString
s
=
pMediaFileUrl
.
toLocalFile
();
mMediaObject
=
new
Phonon
::
MediaObject
(
this
);
if
(
pMediaFileUrl
.
toLocalFile
().
contains
(
"videos"
))
{
mMediaType
=
mediaType_Video
;
mAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
VideoCategory
,
this
);
mMediaObject
->
setTickInterval
(
50
);
mVideoWidget
=
new
Phonon
::
VideoWidget
();
// owned and destructed by the scene ...
Phonon
::
createPath
(
mMediaObject
,
mVideoWidget
);
/*
* The VideoVidget should recover the size from the original movie, but this is not always true expecially on
* windows and linux os. I don't know why?
* In this case the wiget size is equal to QSize(1,1).
*/
if
(
mVideoWidget
->
sizeHint
()
==
QSize
(
1
,
1
)){
mVideoWidget
->
resize
(
320
,
240
);
}
setWidget
(
mVideoWidget
);
}
else
if
(
pMediaFileUrl
.
toLocalFile
().
contains
(
"audios"
))
{
mMediaType
=
mediaType_Audio
;
mAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
MusicCategory
,
this
);
mMediaObject
->
setTickInterval
(
1000
);
mAudioWidget
=
new
QWidget
();
mAudioWidget
->
resize
(
320
,
26
);
setWidget
(
mAudioWidget
);
}
Phonon
::
createPath
(
mMediaObject
,
mAudioOutput
);
mSource
=
Phonon
::
MediaSource
(
pMediaFileUrl
);
mMediaObject
->
setCurrentSource
(
mSource
);
UBGraphicsMediaItemDelegate
*
itemDelegate
=
new
UBGraphicsMediaItemDelegate
(
this
,
mMediaObject
);
itemDelegate
->
init
();
setDelegate
(
itemDelegate
);
mDelegate
->
frame
()
->
setOperationMode
(
UBGraphicsDelegateFrame
::
Resizing
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
connect
(
mDelegate
,
SIGNAL
(
showOnDisplayChanged
(
bool
)),
this
,
SLOT
(
showOnDisplayChanged
(
bool
)));
connect
(
mMediaObject
,
SIGNAL
(
hasVideoChanged
(
bool
)),
this
,
SLOT
(
hasMediaChanged
(
bool
)));
}
}
...
@@ -106,8 +158,14 @@ void UBGraphicsMediaItem::toggleMute()
...
@@ -106,8 +158,14 @@ void UBGraphicsMediaItem::toggleMute()
void
UBGraphicsMediaItem
::
hasMediaChanged
(
bool
hasMedia
)
void
UBGraphicsMediaItem
::
hasMediaChanged
(
bool
hasMedia
)
{
{
if
(
hasMedia
&&
mMediaObject
->
isSeekable
())
{
Q_UNUSED
(
hasMedia
);
Q_UNUSED
(
hasMedia
);
mMediaObject
->
seek
(
mInitialPos
);
mMediaObject
->
seek
(
mInitialPos
);
UBGraphicsMediaItemDelegate
*
med
=
dynamic_cast
<
UBGraphicsMediaItemDelegate
*>
(
mDelegate
);
if
(
med
)
med
->
updateTicker
(
initialPos
());
}
}
}
...
@@ -139,3 +197,104 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
...
@@ -139,3 +197,104 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
mAudioOutput
->
setMuted
(
mMuted
);
mAudioOutput
->
setMuted
(
mMuted
);
}
}
}
}
UBItem
*
UBGraphicsMediaItem
::
deepCopy
()
const
{
QUrl
url
=
this
->
mediaFileUrl
();
UBGraphicsMediaItem
*
copy
;
copy
=
new
UBGraphicsMediaItem
(
url
,
parentItem
());
copy
->
setPos
(
this
->
pos
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
copy
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
copy
->
setData
(
UBGraphicsItemData
::
ItemLocked
,
this
->
data
(
UBGraphicsItemData
::
ItemLocked
));
copy
->
setUuid
(
this
->
uuid
());
// this is OK as long as Videos are imutable
copy
->
setSourceUrl
(
this
->
sourceUrl
());
copy
->
resize
(
this
->
size
());
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneChanged
()),
copy
,
SLOT
(
activeSceneChanged
()));
// TODO UB 4.7 complete all members
return
copy
;
}
void
UBGraphicsMediaItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
// QDrag* mDrag = new QDrag(event->widget());
// QMimeData* pMime = new QMimeData();
// mDrag->setMimeData(pMime);
// mDrag->start();
// UBApplication::boardController->activeScene()->setActiveItem(this);
if
(
mDelegate
)
{
mDelegate
->
mousePressEvent
(
event
);
if
(
mDelegate
&&
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
parentItem
()
->
type
())
{
UBGraphicsGroupContainerItem
*
group
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
parentItem
());
if
(
group
)
{
QGraphicsItem
*
curItem
=
group
->
getCurrentItem
();
if
(
curItem
&&
this
!=
curItem
)
{
group
->
deselectCurrentItem
();
}
group
->
setCurrentItem
(
this
);
this
->
setSelected
(
true
);
mDelegate
->
positionHandles
();
}
}
else
{
mDelegate
->
getToolBarItem
()
->
show
();
}
}
if
(
parentItem
()
&&
parentItem
()
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
mShouldMove
=
false
;
if
(
!
Delegate
()
->
mousePressEvent
(
event
))
{
event
->
accept
();
}
}
else
{
mShouldMove
=
(
event
->
buttons
()
&
Qt
::
LeftButton
);
mMousePressPos
=
event
->
scenePos
();
mMouseMovePos
=
mMousePressPos
;
event
->
accept
();
setSelected
(
true
);
}
}
void
UBGraphicsMediaItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
mShouldMove
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
))
{
QPointF
offset
=
event
->
scenePos
()
-
mMousePressPos
;
if
(
offset
.
toPoint
().
manhattanLength
()
>
QApplication
::
startDragDistance
())
{
QPointF
mouseMovePos
=
mapFromScene
(
mMouseMovePos
);
QPointF
eventPos
=
mapFromScene
(
event
->
scenePos
());
QPointF
translation
=
eventPos
-
mouseMovePos
;
translate
(
translation
.
x
(),
translation
.
y
());
}
mMouseMovePos
=
event
->
scenePos
();
}
event
->
accept
();
}
src/domain/UBGraphicsMediaItem.h
View file @
90f03866
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "UBGraphicsProxyWidget.h"
#include "UBGraphicsProxyWidget.h"
#include <phonon/AudioOutput>
#include <phonon/AudioOutput>
#include <phonon/MediaObject>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "board/UBBoardController.h"
...
@@ -27,10 +28,21 @@ class UBGraphicsMediaItem : public UBGraphicsProxyWidget
...
@@ -27,10 +28,21 @@ class UBGraphicsMediaItem : public UBGraphicsProxyWidget
Q_OBJECT
Q_OBJECT
public
:
public
:
typedef
enum
{
mediaType_Video
,
mediaType_Audio
}
mediaType
;
UBGraphicsMediaItem
(
const
QUrl
&
pMediaFileUrl
,
QGraphicsItem
*
parent
=
0
);
UBGraphicsMediaItem
(
const
QUrl
&
pMediaFileUrl
,
QGraphicsItem
*
parent
=
0
);
~
UBGraphicsMediaItem
();
~
UBGraphicsMediaItem
();
enum
{
Type
=
UBGraphicsItemType
::
MediaItemType
};
virtual
int
type
()
const
{
return
Type
;
}
void
hasMediaChanged
(
bool
hasMedia
);
void
hasMediaChanged
(
bool
hasMedia
);
void
showOnDisplayChanged
(
bool
shown
);
void
showOnDisplayChanged
(
bool
shown
);
...
@@ -56,8 +68,17 @@ public:
...
@@ -56,8 +68,17 @@ public:
return
mMuted
;
return
mMuted
;
}
}
Phonon
::
VideoWidget
*
videoWidget
()
const
{
return
mVideoWidget
;
}
mediaType
getMediaType
()
{
return
mMediaType
;
}
virtual
UBGraphicsScene
*
scene
();
virtual
UBGraphicsScene
*
scene
();
virtual
UBItem
*
deepCopy
()
const
;
public
slots
:
public
slots
:
void
toggleMute
();
void
toggleMute
();
...
@@ -66,11 +87,16 @@ public slots:
...
@@ -66,11 +87,16 @@ public slots:
protected
:
protected
:
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
clearSource
();
virtual
void
clearSource
();
Phonon
::
MediaObject
*
mMediaObject
;
Phonon
::
MediaObject
*
mMediaObject
;
Phonon
::
VideoWidget
*
mVideoWidget
;
Phonon
::
AudioOutput
*
mAudioOutput
;
Phonon
::
AudioOutput
*
mAudioOutput
;
Phonon
::
MediaSource
mSource
;
QWidget
*
mAudioWidget
;
private
:
private
:
...
@@ -83,6 +109,20 @@ private:
...
@@ -83,6 +109,20 @@ private:
qint64
mInitialPos
;
qint64
mInitialPos
;
mediaType
mMediaType
;
bool
mShouldMove
;
QPointF
mMousePressPos
;
QPointF
mMouseMovePos
;
};
class
UBGraphicsUnitedMediaItem
:
public
UBGraphicsMediaItem
{
public
:
UBGraphicsUnitedMediaItem
(
const
QUrl
&
pMediaFileUrl
,
QGraphicsItem
*
parent
=
0
);
};
};
#endif // UBGRAPHICSMEDIAITEM_H
#endif // UBGRAPHICSMEDIAITEM_H
src/domain/UBGraphicsMediaItemDelegate.cpp
0 → 100644
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include <QtSvg>
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsScene.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "core/UBApplicationController.h"
#include "core/UBDisplayManager.h"
#include "domain/UBGraphicsMediaItem.h"
#include "core/memcheck.h"
UBGraphicsMediaItemDelegate
::
UBGraphicsMediaItemDelegate
(
UBGraphicsMediaItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
)
:
UBGraphicsItemDelegate
(
pDelegated
,
parent
,
true
,
false
)
,
mMedia
(
pMedia
)
{
QPalette
palette
;
palette
.
setBrush
(
QPalette
::
Light
,
Qt
::
darkGray
);
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
(
tick
(
qint64
)),
this
,
SLOT
(
updateTicker
(
qint64
)));
connect
(
mMedia
,
SIGNAL
(
totalTimeChanged
(
qint64
)),
this
,
SLOT
(
totalTimeChanged
(
qint64
)));
}
bool
UBGraphicsMediaItemDelegate
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
Q_UNUSED
(
event
);
mToolBarItem
->
show
();
return
UBGraphicsItemDelegate
::
mousePressEvent
(
event
);
}
void
UBGraphicsMediaItemDelegate
::
buildButtons
()
{
mPlayPauseButton
=
new
DelegateButton
(
":/images/play.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
connect
(
mPlayPauseButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
togglePlayPause
()));
mStopButton
=
new
DelegateButton
(
":/images/stop.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
connect
(
mStopButton
,
SIGNAL
(
clicked
(
bool
)),
mMedia
,
SLOT
(
stop
()));
mMediaControl
=
new
DelegateMediaControl
(
delegated
(),
mToolBarItem
);
mMediaControl
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
UBGraphicsItem
::
assignZValue
(
mMediaControl
,
delegated
()
->
zValue
());
if
(
delegated
()
->
isMuted
())
mMuteButton
=
new
DelegateButton
(
":/images/soundOff.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
else
mMuteButton
=
new
DelegateButton
(
":/images/soundOn.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
delegated
(),
SLOT
(
toggleMute
()));
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
toggleMute
()));
// for changing button image
mButtons
<<
mPlayPauseButton
<<
mStopButton
<<
mMuteButton
;
mToolBarItem
->
setItemsOnToolBar
(
QList
<
QGraphicsItem
*>
()
<<
mPlayPauseButton
<<
mStopButton
<<
mMediaControl
<<
mMuteButton
);
mToolBarItem
->
setVisibleOnBoard
(
true
);
mToolBarItem
->
setShifting
(
false
);
UBGraphicsMediaItem
*
audioItem
=
dynamic_cast
<
UBGraphicsMediaItem
*>
(
mDelegated
);
if
(
audioItem
)
{
if
(
audioItem
->
getMediaType
()
==
UBGraphicsMediaItem
::
mediaType_Audio
)
{
positionHandles
();
}
}
}
UBGraphicsMediaItemDelegate
::~
UBGraphicsMediaItemDelegate
()
{
//NOOP
}
void
UBGraphicsMediaItemDelegate
::
positionHandles
()
{
UBGraphicsItemDelegate
::
positionHandles
();
qreal
AntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
UBGraphicsMediaItem
*
mediaItem
=
dynamic_cast
<
UBGraphicsMediaItem
*>
(
mDelegated
);
if
(
mediaItem
)
{
if
(
mediaItem
->
getMediaType
()
!=
UBGraphicsMediaItem
::
mediaType_Audio
)
{
mToolBarItem
->
setPos
(
0
,
delegated
()
->
boundingRect
().
height
()
-
mToolBarItem
->
rect
().
height
()
*
AntiScaleRatio
);
mToolBarItem
->
setScale
(
AntiScaleRatio
);
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
/
AntiScaleRatio
);
mToolBarItem
->
setRect
(
toolBarRect
);
}
else
{
mToolBarItem
->
setPos
(
0
,
0
);
mToolBarItem
->
show
();
}
}
int
mediaItemWidth
=
mToolBarItem
->
boundingRect
().
width
();
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
==
Qt
::
TitleBarArea
)
mediaItemWidth
-=
button
->
boundingRect
().
width
();
}
QRectF
mediaItemRect
=
mMediaControl
->
rect
();
mediaItemRect
.
setWidth
(
mediaItemWidth
);
mediaItemRect
.
setHeight
(
mToolBarItem
->
boundingRect
().
height
());
mMediaControl
->
setRect
(
mediaItemRect
);
mToolBarItem
->
positionHandles
();
mMediaControl
->
positionHandles
();
if
(
mediaItem
)
{
if
(
mediaItem
->
getMediaType
()
==
UBGraphicsMediaItem
::
mediaType_Audio
)
{
mToolBarItem
->
show
();
}
}
}
void
UBGraphicsMediaItemDelegate
::
remove
(
bool
canUndo
)
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
delegated
()
->
mediaObject
()
->
stop
();
QGraphicsScene
*
scene
=
mDelegated
->
scene
();
scene
->
removeItem
(
mMediaControl
);
UBGraphicsItemDelegate
::
remove
(
canUndo
);
}
void
UBGraphicsMediaItemDelegate
::
toggleMute
()
{
if
(
delegated
()
->
isMuted
())
mMuteButton
->
setFileName
(
":/images/soundOff.svg"
);
else
mMuteButton
->
setFileName
(
":/images/soundOn.svg"
);
}
UBGraphicsMediaItem
*
UBGraphicsMediaItemDelegate
::
delegated
()
{
return
dynamic_cast
<
UBGraphicsMediaItem
*>
(
mDelegated
);
}
void
UBGraphicsMediaItemDelegate
::
togglePlayPause
()
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
StoppedState
)
{
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
{
if
(
media
->
remainingTime
()
<=
0
)
{
media
->
stop
();
media
->
play
();
}
else
{
media
->
pause
();
if
(
delegated
()
->
scene
())
delegated
()
->
scene
()
->
setModified
(
true
);
}
}
else
if
(
media
->
state
()
==
Phonon
::
PausedState
)
{
if
(
media
->
remainingTime
()
<=
0
)
{
media
->
stop
();
}
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
LoadingState
)
{
delegated
()
->
mediaObject
()
->
setCurrentSource
(
delegated
()
->
mediaFileUrl
());
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
ErrorState
){
qDebug
()
<<
"Error appeared."
<<
media
->
errorString
();
}
}
}
void
UBGraphicsMediaItemDelegate
::
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
)
{
Q_UNUSED
(
newstate
);
Q_UNUSED
(
oldstate
);
updatePlayPauseState
();
}
void
UBGraphicsMediaItemDelegate
::
updatePlayPauseState
()
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
mPlayPauseButton
->
setFileName
(
":/images/pause.svg"
);
else
mPlayPauseButton
->
setFileName
(
":/images/play.svg"
);
}
void
UBGraphicsMediaItemDelegate
::
updateTicker
(
qint64
time
)
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
mMediaControl
->
totalTimeChanged
(
media
->
totalTime
());
mMediaControl
->
updateTicker
(
time
);
}
void
UBGraphicsMediaItemDelegate
::
totalTimeChanged
(
qint64
newTotalTime
)
{
mMediaControl
->
totalTimeChanged
(
newTotalTime
);
}
\ No newline at end of file
src/domain/UBGraphicsMediaItemDelegate.h
0 → 100644
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSMEDIAITEMDELEGATE_H_
#define UBGRAPHICSMEDIAITEMDELEGATE_H_
#include <QtGui>
#include <phonon/MediaObject>
#include "core/UB.h"
#include "UBGraphicsItemDelegate.h"
class
QGraphicsSceneMouseEvent
;
class
QGraphicsItem
;
class
UBGraphicsMediaItemDelegate
:
public
UBGraphicsItemDelegate
{
Q_OBJECT
public
:
UBGraphicsMediaItemDelegate
(
UBGraphicsMediaItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsMediaItemDelegate
();
virtual
void
positionHandles
();
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
public
slots
:
void
toggleMute
();
void
updateTicker
(
qint64
time
);
protected
slots
:
virtual
void
remove
(
bool
canUndo
=
true
);
void
togglePlayPause
();
void
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
);
void
updatePlayPauseState
();
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
virtual
void
buildButtons
();
UBGraphicsMediaItem
*
delegated
();
DelegateButton
*
mPlayPauseButton
;
DelegateButton
*
mStopButton
;
DelegateButton
*
mMuteButton
;
DelegateMediaControl
*
mMediaControl
;
Phonon
::
MediaObject
*
mMedia
;
};
#endif
/* UBGRAPHICSMEDIAITEMDELEGATE_H_ */
\ No newline at end of file
src/domain/UBGraphicsPDFItem.cpp
View file @
90f03866
...
@@ -46,6 +46,11 @@ QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant
...
@@ -46,6 +46,11 @@ QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant
return
GraphicsPDFItem
::
itemChange
(
change
,
newValue
);
return
GraphicsPDFItem
::
itemChange
(
change
,
newValue
);
}
}
void
UBGraphicsPDFItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
}
void
UBGraphicsPDFItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsPDFItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
...
...
src/domain/UBGraphicsPDFItem.h
View file @
90f03866
...
@@ -51,6 +51,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
...
@@ -51,6 +51,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
(){;}
virtual
void
clearSource
(){;}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
protected
:
protected
:
...
...
src/domain/UBGraphicsPixmapItem.cpp
View file @
90f03866
...
@@ -52,6 +52,12 @@ QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVari
...
@@ -52,6 +52,12 @@ QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVari
return
QGraphicsPixmapItem
::
itemChange
(
change
,
newValue
);
return
QGraphicsPixmapItem
::
itemChange
(
change
,
newValue
);
}
}
void
UBGraphicsPixmapItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
}
void
UBGraphicsPixmapItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsPixmapItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
QMimeData
*
pMime
=
new
QMimeData
();
QMimeData
*
pMime
=
new
QMimeData
();
...
...
src/domain/UBGraphicsPixmapItem.h
View file @
90f03866
...
@@ -52,6 +52,8 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
...
@@ -52,6 +52,8 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
(){;}
virtual
void
clearSource
(){;}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
protected
:
protected
:
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
src/domain/UBGraphicsProxyWidget.cpp
View file @
90f03866
...
@@ -67,6 +67,11 @@ QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVar
...
@@ -67,6 +67,11 @@ QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVar
return
QGraphicsProxyWidget
::
itemChange
(
change
,
newValue
);
return
QGraphicsProxyWidget
::
itemChange
(
change
,
newValue
);
}
}
void
UBGraphicsProxyWidget
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsProxyWidget
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsProxyWidget
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
...
...
src/domain/UBGraphicsProxyWidget.h
View file @
90f03866
...
@@ -44,6 +44,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
...
@@ -44,6 +44,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
(){;}
virtual
void
clearSource
(){;}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
protected
:
protected
:
...
...
src/domain/UBGraphicsScene.cpp
View file @
90f03866
...
@@ -50,8 +50,7 @@
...
@@ -50,8 +50,7 @@
#include "UBGraphicsPixmapItem.h"
#include "UBGraphicsPixmapItem.h"
#include "UBGraphicsSvgItem.h"
#include "UBGraphicsSvgItem.h"
#include "UBGraphicsPolygonItem.h"
#include "UBGraphicsPolygonItem.h"
#include "UBGraphicsVideoItem.h"
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsAudioItem.h"
#include "UBGraphicsWidgetItem.h"
#include "UBGraphicsWidgetItem.h"
#include "UBGraphicsPDFItem.h"
#include "UBGraphicsPDFItem.h"
#include "UBGraphicsTextItem.h"
#include "UBGraphicsTextItem.h"
...
@@ -65,9 +64,6 @@
...
@@ -65,9 +64,6 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
const
QString
groupText
=
"Group items"
;
const
QString
ungroupText
=
"Ungroup items"
;
qreal
UBZLayerController
::
errorNumber
=
-
20000001.0
;
qreal
UBZLayerController
::
errorNumber
=
-
20000001.0
;
UBZLayerController
::
UBZLayerController
(
QGraphicsScene
*
scene
)
:
UBZLayerController
::
UBZLayerController
(
QGraphicsScene
*
scene
)
:
...
@@ -296,14 +292,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
...
@@ -296,14 +292,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
// Just for debug. Do not delete please
// Just for debug. Do not delete please
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
updateGroupButtonState
()));
connect
(
this
,
SIGNAL
(
selectionChanged
()),
this
,
SLOT
(
updateGroupButtonState
()));
// just a stub don't treat as a result code
// static int i = 0;
// i++;
// if (i == 1) {
connect
(
UBApplication
::
mainWindow
->
actionGroupItems
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
groupButtonClicked
()));
// qDebug() << "the connect is accepted";
// }
}
}
UBGraphicsScene
::~
UBGraphicsScene
()
UBGraphicsScene
::~
UBGraphicsScene
()
...
@@ -324,7 +312,7 @@ void UBGraphicsScene::selectionChangedProcessing()
...
@@ -324,7 +312,7 @@ void UBGraphicsScene::selectionChangedProcessing()
+
QString
::
number
(
selectedItems
().
first
()
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
(),
'f'
));
+
QString
::
number
(
selectedItems
().
first
()
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
(),
'f'
));
}
}
}
}
void
UBGraphicsScene
::
updateGroupButtonState
()
void
UBGraphicsScene
::
updateGroupButtonState
()
{
{
QAction
*
groupAction
=
UBApplication
::
mainWindow
->
actionGroupItems
;
QAction
*
groupAction
=
UBApplication
::
mainWindow
->
actionGroupItems
;
...
@@ -333,66 +321,21 @@ void UBGraphicsScene::updateGroupButtonState()
...
@@ -333,66 +321,21 @@ void UBGraphicsScene::updateGroupButtonState()
if
(
selCount
<
1
)
{
if
(
selCount
<
1
)
{
groupAction
->
setEnabled
(
false
);
groupAction
->
setEnabled
(
false
);
groupAction
->
setText
(
g
roupText
);
groupAction
->
setText
(
UBSettings
::
settings
()
->
actionG
roupText
);
}
else
if
(
selCount
==
1
)
{
}
else
if
(
selCount
==
1
)
{
if
(
selItems
.
first
()
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
if
(
selItems
.
first
()
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
groupAction
->
setEnabled
(
true
);
groupAction
->
setEnabled
(
true
);
groupAction
->
setText
(
u
ngroupText
);
groupAction
->
setText
(
UBSettings
::
settings
()
->
actionU
ngroupText
);
}
else
{
}
else
{
groupAction
->
setEnabled
(
false
);
groupAction
->
setEnabled
(
false
);
}
}
}
else
if
(
selCount
>
1
)
{
}
else
if
(
selCount
>
1
)
{
groupAction
->
setEnabled
(
true
);
groupAction
->
setEnabled
(
true
);
groupAction
->
setText
(
g
roupText
);
groupAction
->
setText
(
UBSettings
::
settings
()
->
actionG
roupText
);
}
}
}
}
void
UBGraphicsScene
::
groupButtonClicked
()
{
QAction
*
groupAction
=
UBApplication
::
mainWindow
->
actionGroupItems
;
QList
<
QGraphicsItem
*>
selItems
=
selectedItems
();
if
(
!
selItems
.
count
())
{
qDebug
()
<<
"Got grouping request when there is no any selected item on the scene"
;
return
;
}
if
(
groupAction
->
text
()
==
groupText
)
{
//The only way to get information from item, considering using smth else
UBGraphicsGroupContainerItem
*
groupItem
=
new
UBGraphicsGroupContainerItem
();
foreach
(
QGraphicsItem
*
item
,
selItems
)
{
if
(
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
QList
<
QGraphicsItem
*>
childItems
=
item
->
childItems
();
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
currentGroup
)
{
currentGroup
->
destroy
();
}
foreach
(
QGraphicsItem
*
chItem
,
childItems
)
{
groupItem
->
addToGroup
(
chItem
);
}
}
else
{
groupItem
->
addToGroup
(
item
);
}
}
addItem
(
groupItem
);
groupItem
->
setVisible
(
true
);
groupItem
->
setFocus
();
}
else
if
(
groupAction
->
text
()
==
ungroupText
)
{
//Considering one selected item and it's a group
if
(
selItems
.
count
()
>
1
)
{
qDebug
()
<<
"can't make sense of ungrouping more then one item. Grouping action should be performed for that purpose"
;
return
;
}
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
selItems
.
first
());
if
(
currentGroup
)
{
currentGroup
->
destroy
();
}
}
}
bool
UBGraphicsScene
::
inputDevicePress
(
const
QPointF
&
scenePos
,
const
qreal
&
pressure
)
bool
UBGraphicsScene
::
inputDevicePress
(
const
QPointF
&
scenePos
,
const
qreal
&
pressure
)
{
{
...
@@ -1388,67 +1331,48 @@ void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem)
...
@@ -1388,67 +1331,48 @@ void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem)
UBApplication
::
undoStack
->
push
(
uc
);
UBApplication
::
undoStack
->
push
(
uc
);
}
}
}
}
UBGraphicsMediaItem
*
UBGraphicsScene
::
addMedia
(
const
QUrl
&
pMediaFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
)
UBGraphicsVideoItem
*
UBGraphicsScene
::
addVideo
(
const
QUrl
&
pVideoFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
)
{
{
UBGraphicsVideoItem
*
videoItem
=
new
UBGraphicsVideoItem
(
pVideoFileUrl
);
UBGraphicsMediaItem
*
mediaItem
=
new
UBGraphicsMediaItem
(
pMediaFileUrl
);
if
(
mediaItem
){
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneChanged
()),
mediaItem
,
SLOT
(
activeSceneChanged
()));
}
video
Item
->
setPos
(
pPos
);
media
Item
->
setPos
(
pPos
);
video
Item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
media
Item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
video
Item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
media
Item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
addItem
(
video
Item
);
addItem
(
media
Item
);
video
Item
->
show
();
media
Item
->
show
();
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
video
Item
);
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
media
Item
);
UBApplication
::
undoStack
->
push
(
uc
);
UBApplication
::
undoStack
->
push
(
uc
);
}
}
video
Item
->
mediaObject
()
->
play
();
media
Item
->
mediaObject
()
->
play
();
if
(
!
shouldPlayAsap
)
if
(
!
shouldPlayAsap
)
{
{
video
Item
->
mediaObject
()
->
pause
();
media
Item
->
mediaObject
()
->
pause
();
video
Item
->
mediaObject
()
->
seek
(
0
);
media
Item
->
mediaObject
()
->
seek
(
0
);
}
}
setDocumentUpdated
();
setDocumentUpdated
();
return
video
Item
;
return
media
Item
;
}
}
UBGraphics
AudioItem
*
UBGraphicsScene
::
addAudio
(
const
QUrl
&
pAudi
oFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
)
UBGraphics
MediaItem
*
UBGraphicsScene
::
addVideo
(
const
QUrl
&
pVide
oFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
)
{
{
UBGraphicsAudioItem
*
audioItem
=
new
UBGraphicsAudioItem
(
pAudioFileUrl
);
return
addMedia
(
pVideoFileUrl
,
shouldPlayAsap
,
pPos
);
}
audioItem
->
setPos
(
pPos
);
audioItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
audioItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
addItem
(
audioItem
);
audioItem
->
show
();
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
audioItem
);
UBApplication
::
undoStack
->
push
(
uc
);
}
audioItem
->
mediaObject
()
->
play
();
if
(
!
shouldPlayAsap
)
{
audioItem
->
mediaObject
()
->
pause
();
audioItem
->
mediaObject
()
->
seek
(
0
);
}
setDocumentUpdated
();
return
audioItem
;
UBGraphicsMediaItem
*
UBGraphicsScene
::
addAudio
(
const
QUrl
&
pAudioFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
)
{
return
addMedia
(
pAudioFileUrl
,
shouldPlayAsap
,
pPos
);
}
}
UBGraphicsWidgetItem
*
UBGraphicsScene
::
addWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
)
UBGraphicsWidgetItem
*
UBGraphicsScene
::
addWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
)
...
@@ -1543,6 +1467,39 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, con
...
@@ -1543,6 +1467,39 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, con
return
widget
;
return
widget
;
}
}
UBGraphicsGroupContainerItem
*
UBGraphicsScene
::
createGroup
(
QList
<
QGraphicsItem
*>
items
)
{
UBGraphicsGroupContainerItem
*
groupItem
=
new
UBGraphicsGroupContainerItem
();
foreach
(
QGraphicsItem
*
item
,
items
)
{
if
(
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
QList
<
QGraphicsItem
*>
childItems
=
item
->
childItems
();
UBGraphicsGroupContainerItem
*
currentGroup
=
dynamic_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
currentGroup
)
{
currentGroup
->
destroy
();
}
foreach
(
QGraphicsItem
*
chItem
,
childItems
)
{
groupItem
->
addToGroup
(
chItem
);
}
}
else
{
groupItem
->
addToGroup
(
item
);
}
}
addItem
(
groupItem
);
groupItem
->
setVisible
(
true
);
groupItem
->
setFocus
();
if
(
enableUndoRedoStack
)
{
//should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand
*
uc
=
new
UBGraphicsItemUndoCommand
(
this
,
0
,
groupItem
);
UBApplication
::
undoStack
->
push
(
uc
);
}
setDocumentUpdated
();
return
groupItem
;
}
UBGraphicsSvgItem
*
UBGraphicsScene
::
addSvg
(
const
QUrl
&
pSvgFileUrl
,
const
QPointF
&
pPos
)
UBGraphicsSvgItem
*
UBGraphicsScene
::
addSvg
(
const
QUrl
&
pSvgFileUrl
,
const
QPointF
&
pPos
)
{
{
QString
path
=
pSvgFileUrl
.
toLocalFile
();
QString
path
=
pSvgFileUrl
.
toLocalFile
();
...
@@ -1605,7 +1562,7 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
...
@@ -1605,7 +1562,7 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
textItem
->
setPos
(
QPointF
(
-
size
.
width
()
/
2.0
,
-
size
.
height
()
/
2.0
));
textItem
->
setPos
(
QPointF
(
-
size
.
width
()
/
2.0
,
-
size
.
height
()
/
2.0
));
return
textItem
;
return
textItem
;
}
}
UBGraphicsTextItem
*
UBGraphicsScene
::
addTextWithFont
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
UBGraphicsTextItem
*
UBGraphicsScene
::
addTextWithFont
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
,
int
pointSize
,
const
QString
&
fontFamily
,
bool
bold
,
bool
italic
)
,
int
pointSize
,
const
QString
&
fontFamily
,
bool
bold
,
bool
italic
)
{
{
...
@@ -2091,7 +2048,7 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
...
@@ -2091,7 +2048,7 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
while
(
itItems
.
hasNext
())
while
(
itItems
.
hasNext
())
{
{
UBGraphics
VideoItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsVideo
Item
*>
(
itItems
.
next
());
UBGraphics
MediaItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsMedia
Item
*>
(
itItems
.
next
());
if
(
videoItem
&&
videoItem
->
mediaFileUrl
().
isRelative
())
if
(
videoItem
&&
videoItem
->
mediaFileUrl
().
isRelative
())
{
{
...
@@ -2140,14 +2097,6 @@ void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item)
...
@@ -2140,14 +2097,6 @@ void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item)
item
->
setZValue
(
item
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
item
->
setZValue
(
item
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
}
}
void
UBGraphicsScene
::
groupItems
(
QList
<
QGraphicsItem
*>
&
itemList
)
{
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
qDebug
()
<<
"selected item found"
;
item
->
setSelected
(
false
);
}
}
qreal
UBGraphicsScene
::
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
)
qreal
UBGraphicsScene
::
changeZLevelTo
(
QGraphicsItem
*
item
,
UBZLayerController
::
moveDestination
dest
)
{
{
return
mZLayerController
->
changeZLevelTo
(
item
,
dest
);
return
mZLayerController
->
changeZLevelTo
(
item
,
dest
);
...
...
src/domain/UBGraphicsScene.h
View file @
90f03866
...
@@ -29,6 +29,7 @@ class UBGraphicsPixmapItem;
...
@@ -29,6 +29,7 @@ class UBGraphicsPixmapItem;
class
UBGraphicsProxyWidget
;
class
UBGraphicsProxyWidget
;
class
UBGraphicsSvgItem
;
class
UBGraphicsSvgItem
;
class
UBGraphicsPolygonItem
;
class
UBGraphicsPolygonItem
;
class
UBGraphicsMediaItem
;
class
UBGraphicsVideoItem
;
class
UBGraphicsVideoItem
;
class
UBGraphicsAudioItem
;
class
UBGraphicsAudioItem
;
class
UBGraphicsWidgetItem
;
class
UBGraphicsWidgetItem
;
...
@@ -46,6 +47,7 @@ class UBGraphicsStroke;
...
@@ -46,6 +47,7 @@ class UBGraphicsStroke;
class
UBMagnifierParams
;
class
UBMagnifierParams
;
class
UBMagnifier
;
class
UBMagnifier
;
class
UBGraphicsCache
;
class
UBGraphicsCache
;
class
UBGraphicsGroupContainerItem
;
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
...
@@ -129,8 +131,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -129,8 +131,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsW3CWidgetItem
*
addW3CWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
int
widgetType
=
UBGraphicsItemType
::
W3CWidgetItemType
);
UBGraphicsW3CWidgetItem
*
addW3CWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
int
widgetType
=
UBGraphicsItemType
::
W3CWidgetItemType
);
void
addGraphicsWidget
(
UBGraphicsWidgetItem
*
graphicsWidget
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
void
addGraphicsWidget
(
UBGraphicsWidgetItem
*
graphicsWidget
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsVideoItem
*
addVideo
(
const
QUrl
&
pVideoFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addMedia
(
const
QUrl
&
pMediaFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsAudioItem
*
addAudio
(
const
QUrl
&
pAudioFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addVideo
(
const
QUrl
&
pVideoFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addAudio
(
const
QUrl
&
pAudioFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsSvgItem
*
addSvg
(
const
QUrl
&
pSvgFileUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsSvgItem
*
addSvg
(
const
QUrl
&
pSvgFileUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsTextItem
*
addText
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
=
QPointF
(
0
,
0
));
UBGraphicsTextItem
*
addText
(
const
QString
&
pString
,
const
QPointF
&
pTopLeft
=
QPointF
(
0
,
0
));
UBGraphicsTextItem
*
textForObjectName
(
const
QString
&
pString
,
const
QString
&
objectName
=
"UBTGZeroPageSessionTitle"
);
UBGraphicsTextItem
*
textForObjectName
(
const
QString
&
pString
,
const
QString
&
objectName
=
"UBTGZeroPageSessionTitle"
);
...
@@ -141,6 +144,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -141,6 +144,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsW3CWidgetItem
*
addOEmbed
(
const
QUrl
&
pContentUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsW3CWidgetItem
*
addOEmbed
(
const
QUrl
&
pContentUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsGroupContainerItem
*
createGroup
(
QList
<
QGraphicsItem
*>
items
);
QGraphicsItem
*
setAsBackgroundObject
(
QGraphicsItem
*
item
,
bool
pAdaptTransformation
=
false
,
bool
expand
=
false
);
QGraphicsItem
*
setAsBackgroundObject
(
QGraphicsItem
*
item
,
bool
pAdaptTransformation
=
false
,
bool
expand
=
false
);
QGraphicsItem
*
backgroundObject
()
const
QGraphicsItem
*
backgroundObject
()
const
...
@@ -289,7 +294,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -289,7 +294,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
setSelectedZLevel
(
QGraphicsItem
*
item
);
void
setSelectedZLevel
(
QGraphicsItem
*
item
);
void
setOwnZlevel
(
QGraphicsItem
*
item
);
void
setOwnZlevel
(
QGraphicsItem
*
item
);
void
groupItems
(
QList
<
QGraphicsItem
*>
&
itemList
);
public
slots
:
public
slots
:
void
hideEraser
();
void
hideEraser
();
...
@@ -307,8 +311,6 @@ public slots:
...
@@ -307,8 +311,6 @@ public slots:
void
selectionChangedProcessing
();
void
selectionChangedProcessing
();
void
updateGroupButtonState
();
void
updateGroupButtonState
();
void
groupButtonClicked
();
void
moveMagnifier
(
QPoint
newPos
);
void
moveMagnifier
(
QPoint
newPos
);
void
closeMagnifier
();
void
closeMagnifier
();
void
zoomInMagnifier
();
void
zoomInMagnifier
();
...
...
src/domain/UBGraphicsStrokesGroup.cpp
View file @
90f03866
...
@@ -22,6 +22,12 @@ UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
...
@@ -22,6 +22,12 @@ UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
}
}
}
}
void
UBGraphicsStrokesGroup
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsStrokesGroup
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsStrokesGroup
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
mDelegate
->
mousePressEvent
(
event
))
if
(
mDelegate
->
mousePressEvent
(
event
))
...
...
src/domain/UBGraphicsStrokesGroup.h
View file @
90f03866
...
@@ -21,6 +21,7 @@ public:
...
@@ -21,6 +21,7 @@ public:
{
{
return
Type
;
return
Type
;
}
}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
protected
:
protected
:
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
90f03866
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include <QtGui>
#include <QtGui>
#include "UBGraphicsGroupContainerItem.h"
#include "UBGraphicsTextItem.h"
#include "UBGraphicsTextItem.h"
#include "UBGraphicsTextItemDelegate.h"
#include "UBGraphicsTextItemDelegate.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsScene.h"
...
@@ -97,8 +98,32 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
...
@@ -97,8 +98,32 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
mDelegate
)
if
(
mDelegate
)
{
mDelegate
->
mousePressEvent
(
event
);
mDelegate
->
mousePressEvent
(
event
);
if
(
mDelegate
&&
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
parentItem
()
->
type
())
{
UBGraphicsGroupContainerItem
*
group
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
parentItem
());
if
(
group
)
{
QGraphicsItem
*
curItem
=
group
->
getCurrentItem
();
if
(
curItem
&&
this
!=
curItem
)
{
group
->
deselectCurrentItem
();
}
group
->
setCurrentItem
(
this
);
this
->
setSelected
(
true
);
mDelegate
->
positionHandles
();
}
}
else
{
mDelegate
->
getToolBarItem
()
->
show
();
}
}
if
(
!
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
())
if
(
!
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
())
return
;
return
;
...
@@ -296,6 +321,12 @@ QSizeF UBGraphicsTextItem::size() const
...
@@ -296,6 +321,12 @@ QSizeF UBGraphicsTextItem::size() const
return
QSizeF
(
textWidth
(),
textHeight
());
return
QSizeF
(
textWidth
(),
textHeight
());
}
}
void
UBGraphicsTextItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsTextItem
::
undoCommandAdded
()
void
UBGraphicsTextItem
::
undoCommandAdded
()
{
{
...
...
src/domain/UBGraphicsTextItem.h
View file @
90f03866
...
@@ -81,6 +81,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
...
@@ -81,6 +81,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
(){;}
virtual
void
clearSource
(){;}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
signals
:
signals
:
void
textUndoCommandAdded
(
UBGraphicsTextItem
*
textItem
);
void
textUndoCommandAdded
(
UBGraphicsTextItem
*
textItem
);
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
90f03866
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#include <QtGui>
#include <QtGui>
#include <QtSvg>
#include <QtSvg>
#include "core/UBApplication.h"
#include "UBGraphicsGroupContainerItem.h"
#include "UBGraphicsTextItemDelegate.h"
#include "UBGraphicsTextItemDelegate.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsScene.h"
#include "gui/UBResources.h"
#include "gui/UBResources.h"
...
@@ -108,7 +110,7 @@ void UBGraphicsTextItemDelegate::buildButtons()
...
@@ -108,7 +110,7 @@ void UBGraphicsTextItemDelegate::buildButtons()
QList
<
QGraphicsItem
*>
itemsOnToolBar
;
QList
<
QGraphicsItem
*>
itemsOnToolBar
;
itemsOnToolBar
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
itemsOnToolBar
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
mToolBarItem
->
setItemsOnToolBar
(
itemsOnToolBar
);
mToolBarItem
->
setItemsOnToolBar
(
itemsOnToolBar
);
mToolBarItem
->
setShifting
(
true
);
mToolBarItem
->
setVisibleOnBoard
(
true
);
mToolBarItem
->
setVisibleOnBoard
(
true
);
}
}
...
@@ -281,6 +283,39 @@ void UBGraphicsTextItemDelegate::updateMenuActionState()
...
@@ -281,6 +283,39 @@ void UBGraphicsTextItemDelegate::updateMenuActionState()
void
UBGraphicsTextItemDelegate
::
positionHandles
()
void
UBGraphicsTextItemDelegate
::
positionHandles
()
{
{
UBGraphicsItemDelegate
::
positionHandles
();
UBGraphicsItemDelegate
::
positionHandles
();
if
(
mDelegated
->
isSelected
()
||
(
mDelegated
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
mDelegated
->
parentItem
()
->
type
()))
{
if
(
mToolBarItem
->
isVisibleOnBoard
())
{
qreal
AntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
mToolBarItem
->
setScale
(
AntiScaleRatio
);
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
/
AntiScaleRatio
);
mToolBarItem
->
setRect
(
toolBarRect
);
mToolBarItem
->
positionHandles
();
mToolBarItem
->
update
();
if
(
mToolBarItem
->
isShifting
())
mToolBarItem
->
setPos
(
0
,
-
mToolBarItem
->
boundingRect
().
height
()
*
AntiScaleRatio
);
else
mToolBarItem
->
setPos
(
0
,
0
);
UBGraphicsGroupContainerItem
*
group
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
mDelegated
->
parentItem
());
mToolBarItem
->
hide
();
if
(
group
&&
group
->
getCurrentItem
()
==
mDelegated
&&
group
->
isSelected
())
mToolBarItem
->
show
();
if
(
!
group
)
mToolBarItem
->
show
();
}
}
else
{
mToolBarItem
->
hide
();
}
setEditable
(
isEditable
());
setEditable
(
isEditable
());
}
}
...
...
src/domain/UBGraphicsVideoItem.cpp
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBGraphicsVideoItem.h"
#include "UBGraphicsVideoItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsVideoItem
::
UBGraphicsVideoItem
(
const
QUrl
&
pVideoFileUrl
,
QGraphicsItem
*
parent
)
:
UBGraphicsMediaItem
(
pVideoFileUrl
,
parent
)
,
mShouldMove
(
false
)
{
update
();
mMediaObject
=
new
Phonon
::
MediaObject
(
this
);
mVideoWidget
=
new
Phonon
::
VideoWidget
();
// owned and destructed by the scene ...
Phonon
::
createPath
(
mMediaObject
,
mVideoWidget
);
mAudioOutput
=
new
Phonon
::
AudioOutput
(
Phonon
::
VideoCategory
,
this
);
Phonon
::
createPath
(
mMediaObject
,
mAudioOutput
);
/*
* The VideoVidget should recover the size from the original movie, but this is not always true expecially on
* windows and linux os. I don't know why?
* In this case the wiget size is equal to QSize(1,1).
*/
if
(
mVideoWidget
->
sizeHint
()
==
QSize
(
1
,
1
)){
mVideoWidget
->
resize
(
320
,
240
);
}
setWidget
(
mVideoWidget
);
UBGraphicsVideoItemDelegate
*
delegate
=
new
UBGraphicsVideoItemDelegate
(
this
,
mMediaObject
);
delegate
->
init
();
setDelegate
(
delegate
);
mDelegate
->
frame
()
->
setOperationMode
(
UBGraphicsDelegateFrame
::
Resizing
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
connect
(
mDelegate
,
SIGNAL
(
showOnDisplayChanged
(
bool
)),
this
,
SLOT
(
showOnDisplayChanged
(
bool
)));
connect
(
mMediaObject
,
SIGNAL
(
hasVideoChanged
(
bool
)),
this
,
SLOT
(
hasVideoChanged
(
bool
)));
}
UBGraphicsVideoItem
::~
UBGraphicsVideoItem
()
{
//NOOP
}
UBItem
*
UBGraphicsVideoItem
::
deepCopy
()
const
{
QUrl
videoUrl
=
this
->
mediaFileUrl
();
UBGraphicsVideoItem
*
copy
=
new
UBGraphicsVideoItem
(
videoUrl
,
parentItem
());
copy
->
setPos
(
this
->
pos
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
copy
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
copy
->
setData
(
UBGraphicsItemData
::
ItemLocked
,
this
->
data
(
UBGraphicsItemData
::
ItemLocked
));
copy
->
setUuid
(
this
->
uuid
());
// this is OK as long as Videos are imutable
copy
->
setSourceUrl
(
this
->
sourceUrl
());
copy
->
resize
(
this
->
size
());
// TODO UB 4.7 complete all members
return
copy
;
}
void
UBGraphicsVideoItem
::
hasVideoChanged
(
bool
hasVideo
)
{
if
(
hasVideo
&&
mMediaObject
->
isSeekable
())
{
hasMediaChanged
(
hasVideo
);
UBGraphicsVideoItemDelegate
*
vid
=
dynamic_cast
<
UBGraphicsVideoItemDelegate
*>
(
mDelegate
);
if
(
vid
)
vid
->
updateTicker
(
initialPos
());
}
}
void
UBGraphicsVideoItem
::
showOnDisplayChanged
(
bool
shown
)
{
UBGraphicsMediaItem
::
showOnDisplayChanged
(
shown
);
UBGraphicsVideoItemDelegate
*
vid
=
dynamic_cast
<
UBGraphicsVideoItemDelegate
*>
(
mDelegate
);
if
(
vid
)
vid
->
toggleMute
();
}
void
UBGraphicsVideoItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mShouldMove
=
(
event
->
buttons
()
&
Qt
::
LeftButton
);
mMousePressPos
=
event
->
scenePos
();
mMouseMovePos
=
mMousePressPos
;
event
->
accept
();
setSelected
(
true
);
}
void
UBGraphicsVideoItem
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
mShouldMove
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
))
{
QPointF
offset
=
event
->
scenePos
()
-
mMousePressPos
;
if
(
offset
.
toPoint
().
manhattanLength
()
>
QApplication
::
startDragDistance
())
{
QPointF
mouseMovePos
=
mapFromScene
(
mMouseMovePos
);
QPointF
eventPos
=
mapFromScene
(
event
->
scenePos
());
QPointF
translation
=
eventPos
-
mouseMovePos
;
translate
(
translation
.
x
(),
translation
.
y
());
}
mMouseMovePos
=
event
->
scenePos
();
}
event
->
accept
();
}
src/domain/UBGraphicsVideoItem.h
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSVIDEOITEM_H
#define UBGRAPHICSVIDEOITEM_H
#include <phonon/VideoWidget>
#include "UBGraphicsMediaItem.h"
#include "core/UB.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
class
UBGraphicsVideoItem
:
public
UBGraphicsMediaItem
{
Q_OBJECT
;
public
:
UBGraphicsVideoItem
(
const
QUrl
&
pMediaFileUrl
,
QGraphicsItem
*
parent
=
0
);
~
UBGraphicsVideoItem
();
enum
{
Type
=
UBGraphicsItemType
::
VideoItemType
};
virtual
int
type
()
const
{
return
Type
;
}
virtual
UBItem
*
deepCopy
()
const
;
Phonon
::
VideoWidget
*
videoWidget
()
const
{
return
mVideoWidget
;
}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
()
{
UBGraphicsMediaItem
::
clearSource
();
}
public
slots
:
void
hasVideoChanged
(
bool
hasVideo
);
protected
:
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
Phonon
::
VideoWidget
*
mVideoWidget
;
private
slots
:
void
showOnDisplayChanged
(
bool
shown
);
private
:
bool
mShouldMove
;
QPointF
mMousePressPos
;
QPointF
mMouseMovePos
;
};
#endif // UBGRAPHICSVIDEOITEM_H
src/domain/UBGraphicsVideoItemDelegate.cpp
View file @
90f03866
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include <QtSvg>
#include "UBGraphicsVideoItemDelegate.h"
#include "UBGraphicsScene.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "core/UBApplicationController.h"
#include "core/UBDisplayManager.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsVideoItemDelegate
::
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
)
:
UBGraphicsItemDelegate
(
pDelegated
,
parent
,
true
,
false
)
,
mMedia
(
pMedia
)
{
// NOOP
}
void
UBGraphicsVideoItemDelegate
::
buildButtons
()
{
mPlayPauseButton
=
new
DelegateButton
(
":/images/play.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
mStopButton
=
new
DelegateButton
(
":/images/stop.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
mVideoControl
=
new
DelegateVideoControl
(
delegated
(),
mToolBarItem
);
UBGraphicsItem
::
assignZValue
(
mVideoControl
,
delegated
()
->
zValue
());
mVideoControl
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
if
(
delegated
()
->
isMuted
())
mMuteButton
=
new
DelegateButton
(
":/images/soundOff.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
else
mMuteButton
=
new
DelegateButton
(
":/images/soundOn.svg"
,
mDelegated
,
mToolBarItem
,
Qt
::
TitleBarArea
);
connect
(
mPlayPauseButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
togglePlayPause
()));
connect
(
mStopButton
,
SIGNAL
(
clicked
(
bool
)),
mMedia
,
SLOT
(
stop
()));
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
delegated
(),
SLOT
(
toggleMute
()));
connect
(
mMuteButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
toggleMute
()));
mButtons
<<
mPlayPauseButton
<<
mStopButton
<<
mMuteButton
;
QList
<
QGraphicsItem
*>
itemsOnToolBar
;
itemsOnToolBar
<<
mPlayPauseButton
<<
mStopButton
<<
mVideoControl
<<
mMuteButton
;
mToolBarItem
->
setItemsOnToolBar
(
itemsOnToolBar
);
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
(
tick
(
qint64
)),
this
,
SLOT
(
updateTicker
(
qint64
)));
connect
(
mMedia
,
SIGNAL
(
totalTimeChanged
(
qint64
)),
this
,
SLOT
(
totalTimeChanged
(
qint64
)));
mToolBarItem
->
setVisibleOnBoard
(
true
);
mToolBarItem
->
setShifting
(
false
);
}
UBGraphicsVideoItemDelegate
::~
UBGraphicsVideoItemDelegate
()
{
//NOOP
}
void
UBGraphicsVideoItemDelegate
::
positionHandles
()
{
UBGraphicsItemDelegate
::
positionHandles
();
if
(
mDelegated
->
isSelected
())
{
qreal
scaledFrameWidth
=
mFrameWidth
*
mAntiScaleRatio
;
int
offset
=
0
;
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
==
Qt
::
TitleBarArea
)
offset
+=
button
->
boundingRect
().
width
()
*
mAntiScaleRatio
;
}
mVideoControl
->
setRect
(
mVideoControl
->
rect
().
x
()
,
scaledFrameWidth
/
6
-
0.5
,
(
mToolBarItem
->
rect
().
width
()
-
35
-
offset
)
/
mAntiScaleRatio
,
(
2
*
scaledFrameWidth
)
/
mAntiScaleRatio
);
offset
+=
(
mVideoControl
->
rect
().
width
()
+
5
)
*
mAntiScaleRatio
;
mMuteButton
->
setPos
(
offset
,
0
);
if
(
!
mVideoControl
->
scene
())
{
mVideoControl
->
setParentItem
(
mToolBarItem
);
//update parent for the case the item has been previously removed from scene
mDelegated
->
scene
()
->
addItem
(
mVideoControl
);
}
mVideoControl
->
setAntiScale
(
mAntiScaleRatio
);
mVideoControl
->
setZValue
(
delegated
()
->
zValue
());
mVideoControl
->
show
();
}
else
{
mVideoControl
->
hide
();
}
}
void
UBGraphicsVideoItemDelegate
::
remove
(
bool
canUndo
)
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
delegated
()
->
mediaObject
()
->
stop
();
QGraphicsScene
*
scene
=
mDelegated
->
scene
();
scene
->
removeItem
(
mVideoControl
);
UBGraphicsItemDelegate
::
remove
(
canUndo
);
}
void
UBGraphicsVideoItemDelegate
::
toggleMute
()
{
if
(
delegated
()
->
isMuted
())
mMuteButton
->
setFileName
(
":/images/soundOff.svg"
);
else
mMuteButton
->
setFileName
(
":/images/soundOn.svg"
);
}
UBGraphicsVideoItem
*
UBGraphicsVideoItemDelegate
::
delegated
()
{
return
static_cast
<
UBGraphicsVideoItem
*>
(
mDelegated
);
}
void
UBGraphicsVideoItemDelegate
::
togglePlayPause
()
{
if
(
delegated
()
&&
delegated
()
->
mediaObject
())
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
StoppedState
)
{
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
{
if
(
media
->
remainingTime
()
<=
0
)
{
media
->
stop
();
media
->
play
();
}
else
{
media
->
pause
();
if
(
delegated
()
->
scene
())
delegated
()
->
scene
()
->
setModified
(
true
);
}
}
else
if
(
media
->
state
()
==
Phonon
::
PausedState
)
{
if
(
media
->
remainingTime
()
<=
0
)
{
media
->
stop
();
}
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
LoadingState
)
{
delegated
()
->
mediaObject
()
->
setCurrentSource
(
delegated
()
->
mediaFileUrl
());
media
->
play
();
}
else
if
(
media
->
state
()
==
Phonon
::
ErrorState
){
qDebug
()
<<
"Error appeared."
<<
media
->
errorString
();
}
}
}
void
UBGraphicsVideoItemDelegate
::
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
)
{
Q_UNUSED
(
newstate
);
Q_UNUSED
(
oldstate
);
updatePlayPauseState
();
}
void
UBGraphicsVideoItemDelegate
::
updatePlayPauseState
()
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
if
(
media
->
state
()
==
Phonon
::
PlayingState
)
mPlayPauseButton
->
setFileName
(
":/images/pause.svg"
);
else
mPlayPauseButton
->
setFileName
(
":/images/play.svg"
);
}
void
UBGraphicsVideoItemDelegate
::
updateTicker
(
qint64
time
)
{
Phonon
::
MediaObject
*
media
=
delegated
()
->
mediaObject
();
mVideoControl
->
totalTimeChanged
(
media
->
totalTime
());
mVideoControl
->
updateTicker
(
time
);
}
void
UBGraphicsVideoItemDelegate
::
totalTimeChanged
(
qint64
newTotalTime
)
{
mVideoControl
->
totalTimeChanged
(
newTotalTime
);
}
DelegateVideoControl
::
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
)
:
QGraphicsRectItem
(
parent
)
,
mDelegate
(
pDelegated
)
,
mDisplayCurrentTime
(
false
)
,
mAntiScale
(
1.0
)
,
mCurrentTimeInMs
(
0
)
,
mTotalTimeInMs
(
0
)
,
mStartWidth
(
200
)
{
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
setBrush
(
QBrush
(
Qt
::
white
));
setPen
(
Qt
::
NoPen
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
QRectF
rect
=
this
->
rect
();
rect
.
setWidth
(
mStartWidth
);
this
->
setRect
(
rect
);
}
void
DelegateVideoControl
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
painter
->
fillPath
(
shape
(),
brush
());
qreal
frameWidth
=
rect
().
height
()
/
2
;
int
position
=
frameWidth
;
if
(
mTotalTimeInMs
>
0
)
{
position
=
frameWidth
+
(
rect
().
width
()
-
(
2
*
frameWidth
))
/
mTotalTimeInMs
*
mCurrentTimeInMs
;
}
int
radius
=
rect
().
height
()
/
6
;
QRectF
r
(
rect
().
x
()
+
position
-
radius
,
rect
().
y
()
+
(
rect
().
height
()
/
4
)
-
radius
,
radius
*
2
,
radius
*
2
);
painter
->
setBrush
(
UBSettings
::
documentViewLightColor
);
painter
->
drawEllipse
(
r
);
if
(
mDisplayCurrentTime
)
{
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
);
QTime
t
;
t
=
t
.
addMSecs
(
mCurrentTimeInMs
<
0
?
0
:
mCurrentTimeInMs
);
QFont
f
=
painter
->
font
();
f
.
setPointSizeF
(
f
.
pointSizeF
()
*
mAntiScale
);
painter
->
setFont
(
f
);
painter
->
setPen
(
Qt
::
white
);
painter
->
drawText
(
mBalloon
,
Qt
::
AlignCenter
,
t
.
toString
(
"m:ss"
));
}
}
QPainterPath
DelegateVideoControl
::
shape
()
const
{
QPainterPath
path
;
QRectF
r
=
rect
().
adjusted
(
0
,
0
,
0
,
-
rect
().
height
()
/
2
);
path
.
addRoundedRect
(
r
,
rect
().
height
()
/
4
,
rect
().
height
()
/
4
);
return
path
;
}
void
DelegateVideoControl
::
updateTicker
(
qint64
time
)
{
mCurrentTimeInMs
=
time
;
update
();
}
void
DelegateVideoControl
::
totalTimeChanged
(
qint64
newTotalTime
)
{
mTotalTimeInMs
=
newTotalTime
;
update
();
}
void
DelegateVideoControl
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mDisplayCurrentTime
=
true
;
seekToMousePos
(
event
->
pos
());
update
();
event
->
accept
();
}
void
DelegateVideoControl
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
shape
().
contains
(
event
->
pos
()
-
QPointF
(
mBalloon
.
width
()
/
2
,
0
))
&&
shape
().
contains
(
event
->
pos
()
+
QPointF
(
mBalloon
.
width
()
/
2
,
0
)))
{
seekToMousePos
(
event
->
pos
());
update
();
event
->
accept
();
}
}
void
DelegateVideoControl
::
seekToMousePos
(
QPointF
mousePos
)
{
qreal
minX
,
length
;
qreal
frameWidth
=
rect
().
height
()
/
2
;
minX
=
rect
().
x
()
+
frameWidth
;
length
=
rect
().
width
()
-
(
2
*
frameWidth
);
qreal
mouseX
=
mousePos
.
x
();
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/UBGraphicsWidgetItem.cpp
View file @
90f03866
...
@@ -58,6 +58,11 @@ void UBGraphicsWidgetItem::javaScriptWindowObjectCleared()
...
@@ -58,6 +58,11 @@ void UBGraphicsWidgetItem::javaScriptWindowObjectCleared()
}
}
void
UBGraphicsWidgetItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsWidgetItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsWidgetItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
...
@@ -340,7 +345,11 @@ UBItem* UBGraphicsAppleWidgetItem::deepCopy() const
...
@@ -340,7 +345,11 @@ UBItem* UBGraphicsAppleWidgetItem::deepCopy() const
return
appleWidget
;
return
appleWidget
;
}
}
void
UBGraphicsAppleWidgetItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
UBGraphicsW3CWidgetItem
::
UBGraphicsW3CWidgetItem
(
const
QUrl
&
pWidgetUrl
,
QGraphicsItem
*
parent
,
int
widgetType
)
UBGraphicsW3CWidgetItem
::
UBGraphicsW3CWidgetItem
(
const
QUrl
&
pWidgetUrl
,
QGraphicsItem
*
parent
,
int
widgetType
)
:
UBGraphicsWidgetItem
(
parent
,
widgetType
)
:
UBGraphicsWidgetItem
(
parent
,
widgetType
)
...
@@ -389,6 +398,12 @@ void UBGraphicsW3CWidgetItem::paint(QPainter * painter, const QStyleOptionGraphi
...
@@ -389,6 +398,12 @@ void UBGraphicsW3CWidgetItem::paint(QPainter * painter, const QStyleOptionGraphi
}
}
}
}
void
UBGraphicsW3CWidgetItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsW3CWidgetItem
::
javaScriptWindowObjectCleared
()
void
UBGraphicsW3CWidgetItem
::
javaScriptWindowObjectCleared
()
{
{
UBGraphicsWidgetItem
::
javaScriptWindowObjectCleared
();
UBGraphicsWidgetItem
::
javaScriptWindowObjectCleared
();
...
...
src/domain/UBGraphicsWidgetItem.h
View file @
90f03866
...
@@ -78,6 +78,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
...
@@ -78,6 +78,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual
QUrl
getSnapshotPath
(){
return
SnapshotFile
;}
virtual
QUrl
getSnapshotPath
(){
return
SnapshotFile
;}
virtual
void
clearSource
();
virtual
void
clearSource
();
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
protected
:
protected
:
...
@@ -129,6 +130,7 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
...
@@ -129,6 +130,7 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
}
}
virtual
UBItem
*
deepCopy
()
const
;
virtual
UBItem
*
deepCopy
()
const
;
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
};
};
...
@@ -155,6 +157,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
...
@@ -155,6 +157,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
UBW3CWidget
*
w3cWidget
()
const
;
UBW3CWidget
*
w3cWidget
()
const
;
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
private
slots
:
private
slots
:
...
...
src/domain/domain.pri
View file @
90f03866
...
@@ -10,7 +10,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
...
@@ -10,7 +10,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsPolygonItem.h \
src/domain/UBGraphicsPolygonItem.h \
src/domain/UBItem.h \
src/domain/UBItem.h \
src/domain/UBGraphicsVideoItem.h \
src/domain/UBGraphicsWidgetItem.h \
src/domain/UBGraphicsWidgetItem.h \
src/domain/UBAppleWidget.h \
src/domain/UBAppleWidget.h \
src/domain/UBGraphicsPDFItem.h \
src/domain/UBGraphicsPDFItem.h \
...
@@ -20,8 +19,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
...
@@ -20,8 +19,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBResizableGraphicsItem.h \
src/domain/UBResizableGraphicsItem.h \
src/domain/UBGraphicsStroke.h \
src/domain/UBGraphicsStroke.h \
src/domain/UBGraphicsMediaItem.h \
src/domain/UBGraphicsMediaItem.h \
src/domain/UBGraphicsAudioItem.h \
src/domain/UBGraphicsAudioItemDelegate.h \
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h \
src/domain/UBAngleWidget.h \
src/domain/ubgraphicsgroupcontaineritem.h \
src/domain/ubgraphicsgroupcontaineritem.h \
...
@@ -29,10 +26,10 @@ HEADERS += src/domain/UBGraphicsScene.h \
...
@@ -29,10 +26,10 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsStrokesGroup.h
src/domain/UBGraphicsStrokesGroup.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \
HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsVideoItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsWidgetItemDelegate.h
src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsMediaItemDelegate.h
SOURCES += src/domain/UBGraphicsScene.cpp \
SOURCES += src/domain/UBGraphicsScene.cpp \
...
@@ -56,8 +53,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
...
@@ -56,8 +53,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBResizableGraphicsItem.cpp \
src/domain/UBResizableGraphicsItem.cpp \
src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBGraphicsAudioItem.cpp \
src/domain/UBGraphicsAudioItemDelegate.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp \
src/domain/UBAngleWidget.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
...
@@ -65,8 +60,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
...
@@ -65,8 +60,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsVideo
ItemDelegate.cpp \
src/domain/UBGraphicsText
ItemDelegate.cpp \
src/domain/UBGraphicsText
ItemDelegate.cpp \
src/domain/UBGraphicsMedia
ItemDelegate.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp
src/domain/UBGraphicsWidgetItemDelegate.cpp
\
src/domain/ubgraphicsgroupcontaineritem.cpp
View file @
90f03866
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#include <QtGui>
#include <QtGui>
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsTextItem.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/ubgraphicsgroupcontaineritemdelegate.h"
#include "domain/ubgraphicsgroupcontaineritemdelegate.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsScene.h"
...
@@ -10,6 +12,7 @@
...
@@ -10,6 +12,7 @@
UBGraphicsGroupContainerItem
::
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
)
UBGraphicsGroupContainerItem
::
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
)
:
QGraphicsItem
(
parent
)
:
QGraphicsItem
(
parent
)
,
mCurrentItem
(
NULL
)
{
{
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
...
@@ -128,6 +131,29 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
...
@@ -128,6 +131,29 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
itemsBoundingRect
=
childrenBoundingRect
();
itemsBoundingRect
=
childrenBoundingRect
();
}
}
void
UBGraphicsGroupContainerItem
::
deselectCurrentItem
()
{
if
(
mCurrentItem
)
{
switch
(
mCurrentItem
->
type
())
{
case
UBGraphicsTextItem
:
:
Type
:
{
dynamic_cast
<
UBGraphicsTextItem
*>
(
mCurrentItem
)
->
Delegate
()
->
getToolBarItem
()
->
hide
();
}
break
;
case
UBGraphicsMediaItem
:
:
Type
:
{
dynamic_cast
<
UBGraphicsMediaItem
*>
(
mCurrentItem
)
->
Delegate
()
->
getToolBarItem
()
->
hide
();
}
break
;
}
mCurrentItem
->
setSelected
(
false
);
mCurrentItem
=
NULL
;
}
}
QRectF
UBGraphicsGroupContainerItem
::
boundingRect
()
const
QRectF
UBGraphicsGroupContainerItem
::
boundingRect
()
const
{
{
return
itemsBoundingRect
;
return
itemsBoundingRect
;
...
@@ -180,6 +206,12 @@ void UBGraphicsGroupContainerItem::remove()
...
@@ -180,6 +206,12 @@ void UBGraphicsGroupContainerItem::remove()
mDelegate
->
remove
();
mDelegate
->
remove
();
}
}
void
UBGraphicsGroupContainerItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsGroupContainerItem
::
destroy
()
{
void
UBGraphicsGroupContainerItem
::
destroy
()
{
foreach
(
QGraphicsItem
*
item
,
childItems
())
{
foreach
(
QGraphicsItem
*
item
,
childItems
())
{
...
@@ -228,5 +260,20 @@ void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e
...
@@ -228,5 +260,20 @@ void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e
QVariant
UBGraphicsGroupContainerItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
QVariant
UBGraphicsGroupContainerItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
{
QVariant
newValue
=
mDelegate
->
itemChange
(
change
,
value
);
QVariant
newValue
=
mDelegate
->
itemChange
(
change
,
value
);
foreach
(
QGraphicsItem
*
child
,
children
())
{
UBGraphicsItem
*
item
=
dynamic_cast
<
UBGraphicsItem
*>
(
child
);
if
(
item
)
{
item
->
Delegate
()
->
positionHandles
();
}
}
if
(
QGraphicsItem
::
ItemSelectedChange
==
change
)
{
deselectCurrentItem
();
}
return
QGraphicsItem
::
itemChange
(
change
,
newValue
);
return
QGraphicsItem
::
itemChange
(
change
,
newValue
);
}
}
src/domain/ubgraphicsgroupcontaineritem.h
View file @
90f03866
...
@@ -13,6 +13,10 @@ public:
...
@@ -13,6 +13,10 @@ public:
void
addToGroup
(
QGraphicsItem
*
item
);
void
addToGroup
(
QGraphicsItem
*
item
);
void
removeFromGroup
(
QGraphicsItem
*
item
);
void
removeFromGroup
(
QGraphicsItem
*
item
);
void
setCurrentItem
(
QGraphicsItem
*
item
){
mCurrentItem
=
item
;}
QGraphicsItem
*
getCurrentItem
()
const
{
return
mCurrentItem
;}
void
deselectCurrentItem
();
QRectF
boundingRect
()
const
;
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
...
@@ -28,6 +32,7 @@ public:
...
@@ -28,6 +32,7 @@ public:
return
Type
;
return
Type
;
}
}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
void
destroy
();
void
destroy
();
...
@@ -40,6 +45,7 @@ protected:
...
@@ -40,6 +45,7 @@ protected:
private
:
private
:
QRectF
itemsBoundingRect
;
QRectF
itemsBoundingRect
;
QGraphicsItem
*
mCurrentItem
;
};
};
...
...
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
View file @
90f03866
...
@@ -50,7 +50,7 @@ void UBGraphicsGroupContainerItemDelegate::buildButtons()
...
@@ -50,7 +50,7 @@ void UBGraphicsGroupContainerItemDelegate::buildButtons()
bool
UBGraphicsGroupContainerItemDelegate
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
bool
UBGraphicsGroupContainerItemDelegate
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
Q_UNUSED
(
event
)
Q_UNUSED
(
event
)
delegated
()
->
deselectCurrentItem
();
return
false
;
return
false
;
}
}
...
...
src/frameworks/UBCoreGraphicsScene.cpp
View file @
90f03866
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
#include "UBCoreGraphicsScene.h"
#include "UBCoreGraphicsScene.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsWidgetItem.h"
...
@@ -66,11 +64,8 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
...
@@ -66,11 +64,8 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
UBGraphicsItem
*
item_casted
=
0
;
UBGraphicsItem
*
item_casted
=
0
;
switch
(
item
->
type
())
switch
(
item
->
type
())
{
{
case
UBGraphicsAudioItem
:
:
Type
:
case
UBGraphicsMediaItem
:
:
Type
:
item_casted
=
dynamic_cast
<
UBGraphicsAudioItem
*>
(
item
);
item_casted
=
dynamic_cast
<
UBGraphicsMediaItem
*>
(
item
);
break
;
case
UBGraphicsVideoItem
:
:
Type
:
item_casted
=
dynamic_cast
<
UBGraphicsVideoItem
*>
(
item
);
break
;
break
;
case
UBGraphicsW3CWidgetItem
:
:
Type
:
case
UBGraphicsW3CWidgetItem
:
:
Type
:
item_casted
=
dynamic_cast
<
UBGraphicsWidgetItem
*>
(
item
);
item_casted
=
dynamic_cast
<
UBGraphicsWidgetItem
*>
(
item
);
...
...
src/tools/UBGraphicsCurtainItem.cpp
View file @
90f03866
...
@@ -71,6 +71,12 @@ QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVar
...
@@ -71,6 +71,12 @@ QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVar
return
QGraphicsRectItem
::
itemChange
(
change
,
newValue
);
return
QGraphicsRectItem
::
itemChange
(
change
,
newValue
);
}
}
void
UBGraphicsCurtainItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsCurtainItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsCurtainItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
mDelegate
->
mousePressEvent
(
event
))
if
(
mDelegate
->
mousePressEvent
(
event
))
...
...
src/tools/UBGraphicsCurtainItem.h
View file @
90f03866
...
@@ -48,7 +48,9 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
...
@@ -48,7 +48,9 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
//TODO UB 4.x not nice ...
//TODO UB 4.x not nice ...
void
triggerRemovedSignal
();
void
triggerRemovedSignal
();
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
void
clearSource
(){};
virtual
void
clearSource
(){;}
virtual
void
setUuid
(
const
QUuid
&
pUuid
);
signals
:
signals
:
...
...
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