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
be08d3ff
Commit
be08d3ff
authored
Mar 08, 2016
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Videos: show black rectangle also on OS X and Windows
(Solution from previous commit worked only on Linux)
parent
bb3f1310
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
UBGraphicsMediaItem.cpp
src/domain/UBGraphicsMediaItem.cpp
+39
-5
UBGraphicsMediaItem.h
src/domain/UBGraphicsMediaItem.h
+3
-0
No files found.
src/domain/UBGraphicsMediaItem.cpp
View file @
be08d3ff
...
...
@@ -117,6 +117,7 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte
:
UBGraphicsMediaItem
(
pMediaFileUrl
,
parent
)
{
haveLinkedImage
=
true
;
setPlaceholderVisible
(
true
);
Delegate
()
->
createControls
();
mVideoItem
=
new
QGraphicsVideoItem
(
this
);
...
...
@@ -136,6 +137,9 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte
connect
(
mMediaObject
,
SIGNAL
(
videoAvailableChanged
(
bool
)),
this
,
SLOT
(
hasVideoChanged
(
bool
)));
connect
(
mMediaObject
,
SIGNAL
(
stateChanged
(
QMediaPlayer
::
State
)),
this
,
SLOT
(
mediaStateChanged
(
QMediaPlayer
::
State
)));
setAcceptHoverEvents
(
true
);
update
();
...
...
@@ -530,12 +534,42 @@ void UBGraphicsVideoItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void
UBGraphicsVideoItem
::
hasVideoChanged
(
bool
hasVideo
)
{
if
(
hasVideo
)
{
setBrush
(
QColor
(
Qt
::
transparent
));
setPen
(
QColor
(
Qt
::
transparent
));
}
else
{
// On Linux, this is called (with hasVideo == true) when the video is first played
// and when it finishes (hasVideo == false). But on Windows and OS X, it isn't called when
// the video finishes, so those platforms require another solution to showing/hiding the
// placeholder black rectangle.
setPlaceholderVisible
(
!
hasVideo
);
}
void
UBGraphicsVideoItem
::
mediaStateChanged
(
QMediaPlayer
::
State
state
)
{
#if defined(Q_OS_OSX) || defined(Q_OS_WIN)
setPlaceholderVisible
((
state
==
QMediaPlayer
::
StoppedState
));
#else
Q_UNUSED
(
state
);
#endif
}
/**
* @brief Set the brush and fill to display a black rectangle
* @param visible If true, a black rectangle is displayed in place of the video
*
* Depending on platforms, when a video is finished or stopped, the video might be
* removed altogether. To avoid just having the controls bar visible at that point,
* we can display a "fake" black video frame in its place using this method.
*/
void
UBGraphicsVideoItem
::
setPlaceholderVisible
(
bool
visible
)
{
if
(
visible
)
{
setBrush
(
QColor
(
Qt
::
black
));
setPen
(
QColor
(
Qt
::
white
));
}
else
{
setBrush
(
QColor
(
Qt
::
transparent
));
setPen
(
QColor
(
Qt
::
transparent
));
}
}
src/domain/UBGraphicsMediaItem.h
View file @
be08d3ff
...
...
@@ -180,6 +180,7 @@ public:
public
slots
:
void
videoSizeChanged
(
QSizeF
newSize
);
void
hasVideoChanged
(
bool
hasVideo
);
void
mediaStateChanged
(
QMediaPlayer
::
State
state
);
protected
:
...
...
@@ -188,6 +189,8 @@ protected:
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
setPlaceholderVisible
(
bool
visible
);
};
...
...
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