That function requires access to variables that are initialized
in videoItem and audioItem constructors, so it can sometimes fail
when called from the superclass's constructor.
It might be an idea to avoid those calls altogether though
- Hovering over the video now makes the seek bar visible
- The size of the video item is no longer changed when the video
finishes playing
- Media errors are now handled by the mediaItem and displayed for the
user
- Code clean-up
- Removed inheritance of UBGraphicsProxyWidget; cleaned up related code
- Added two children classes: UBGraphicsVideoItem and
UBGraphicsAudioItem. UBGraphicsMediaItem is now an abstract class.
- Better encapsulation; the Scene and other external classes no longer
access the mediaObject directly
There is now less distinction between audio and video items to outside
code: apart from the UBSvgSubsetAdaptor, there is no need to know
whether a media item holds a video or audio file. Creation is handled
through the static function `UBGraphicsMediaItem::createMediaItem(URL,
parent)`
- When clicking a stroke, they aren't moved immediately anymore; a
certain drag distance is necessary, which makes it easy (again) to
select a stroke with a stylus (which tends to move a little as it is
clicked, hence the problem).
- Removed duplicate code; the movement is now managed by
QGraphicsItemGroup::mouseMoveEvent. This prevents use of the transform()
method to get the stroke's transformation matrix; so sceneTransform() is
used instead when copying a strokes group.
- Also fixed an oversight in UBBoardView: Media items couldn't be moved
directly anymore.
- Modified UBvgSubsetAdaptor to correctly save and load strokes, so the
transform matrices that were saved are now loaded correctly.
- Added handling of mousePress / Move / Release events to
UBGraphicsStrokesGroup, so that the transform matrix is calculated and
stored after moving a pen stroke directly (by clicking on it, and not on
its frame). Note: this duplicates quite a bit of code that is in
UBGraphicsDelegateFrame. It may be best to go back and modify both
classes so that the same functions can be called when moving a stroke.
Previously, duplication did not copy the transformation matrices of group
members correctly. This made grouped objects move away when saving and
re-opening a document.
This should now be fixed.
- Added an overload for setMatrix in UBGraphicsMediaItem, to propagate
matrix changes to the child videoItem
- Upon loading a video, the child videoItem is now added correctly, and
set to the right position
Simply added copying of zValue to the deep copy functions. As tested on
OSX, this does pose any problems when duplicating an item on-page (i.e
generating a new item with a zValue equal to its original).
QVideoWidget had to be abandoned in favour of QGraphicsVideoItem. This
is because UBGraphicsMediaItem, i.e the class representing a media
(audio or video) object on the board, is a QGraphicsProxyWidget, and is
used to embed a QWidget into the Scene.
With Phonon's video widget, it was possible to embed the video widget in
this ProxyWidget. This is no longer possible (except on Windows, for
some reason), so this commit is a workaround, to use a
QGraphicsVideoItem instead of a QVideoWidget while modifying the rest
of the class hierarchy as little as possible.
Ultimately, a cleaner solution (not making UBGraphicsMediaItem inherit
QGraphicsProxyWidget, for example) may be desirable.
- Removed commented out obsolete code that had been added
- Removed objects that were never used (mAudioOutput, audioFormat etc)
- Re-made changes that had been reverted since commit cdb5633
Long version:
UBGraphicsPolygonItem::shape() sometimes caused OpenBoard to crash due to
inifinite recursion. This is easily replicated by trying to use the
highlighting tool.
The reason is: shape() calls boundingRect(); this function's definition is:
QRectF QGraphicsPolygonItem::boundingRect() const
{
Q_D(const QGraphicsPolygonItem);
if (d->boundingRect.isNull()) {
qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
if (pw == 0.0)
d->boundingRect = d->polygon.boundingRect();
else
d->boundingRect = shape().controlPointRect();
}
return d->boundingRect;
}
In the case where pw != 0, the shape() function is called. However, it
is shape() from the derived class, not the base class, which is called.
In other words, UBGraphicsPolygonItem::shape() is called rather than
QGraphicsPolygonItem::shape().
This means that boundingRect() is called again from within shape(), and
so on, causing the program to crash.
The fix was simply to remove UBGraphicsPolygonItem::shape(), as it
appears to provide the same (or very similar) functionality to that of
the base class's shape() function.
In case this shape() function actually is needed, another workaround
should be implemented to prevent this infinite recursion.