diff --git a/src/domain/UBGraphicsMediaItem.h b/src/domain/UBGraphicsMediaItem.h index 98897dff..3eb6e26d 100644 --- a/src/domain/UBGraphicsMediaItem.h +++ b/src/domain/UBGraphicsMediaItem.h @@ -83,6 +83,8 @@ public: qint64 mediaPosition() const; QMediaPlayer::State playerState() const; + bool isPlaying() const { return (mMediaObject->state() == QMediaPlayer::PlayingState); } + bool isPaused() const { return (mMediaObject->state() == QMediaPlayer::PausedState); } QRectF boundingRect() const; diff --git a/src/domain/UBGraphicsMediaItemDelegate.cpp b/src/domain/UBGraphicsMediaItemDelegate.cpp index f04ee641..7a6061d5 100644 --- a/src/domain/UBGraphicsMediaItemDelegate.cpp +++ b/src/domain/UBGraphicsMediaItemDelegate.cpp @@ -74,13 +74,23 @@ bool UBGraphicsMediaItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *even /** * @brief Show the toolbar (play/pause, seek, mute). * - * The toolbar then auto-hides after a set amount of time. + * The toolbar then auto-hides after a set amount of time, if the video is currently + * playing or is paused. */ void UBGraphicsMediaItemDelegate::showToolBar() { mToolBarItem->show(); - if (mToolBarShowTimer) - mToolBarShowTimer->start(); + if (mToolBarShowTimer) { + + if (delegated()->isPlaying() || delegated()->isPaused()) + mToolBarShowTimer->start(); + else + mToolBarShowTimer->stop(); + + // Don't hide the toolbar if we're at the beginning of the video + if (delegated()->mediaPosition() == delegated()->initialPos()) + mToolBarShowTimer->stop(); + } } void UBGraphicsMediaItemDelegate::hideToolBar()