Show black rectangle in place of video when vid. not available

preferencesAboutTextFull
Craig Watson 9 years ago
parent 3ab6d01acc
commit bb3f1310dd
  1. 37
      src/domain/UBGraphicsMediaItem.cpp
  2. 4
      src/domain/UBGraphicsMediaItem.h

@ -94,9 +94,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
connect(Delegate(), SIGNAL(showOnDisplayChanged(bool)), connect(Delegate(), SIGNAL(showOnDisplayChanged(bool)),
this, SLOT(showOnDisplayChanged(bool))); this, SLOT(showOnDisplayChanged(bool)));
connect(mMediaObject, SIGNAL(videoAvailableChanged(bool)),
this, SLOT(hasMediaChanged(bool)));
connect(mMediaObject, static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error), connect(mMediaObject, static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error),
this, &UBGraphicsMediaItem::mediaError); this, &UBGraphicsMediaItem::mediaError);
} }
@ -136,6 +133,8 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl &pMediaFileUrl, QGraphicsIte
connect(mVideoItem, SIGNAL(nativeSizeChanged(QSizeF)), connect(mVideoItem, SIGNAL(nativeSizeChanged(QSizeF)),
this, SLOT(videoSizeChanged(QSizeF))); this, SLOT(videoSizeChanged(QSizeF)));
connect(mMediaObject, SIGNAL(videoAvailableChanged(bool)),
this, SLOT(hasVideoChanged(bool)));
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
@ -186,7 +185,7 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
void UBGraphicsMediaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsMediaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
painter->save(); painter->save();
painter->setCompositionMode(QPainter::CompositionMode_SourceOver); //painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
Delegate()->postpaint(painter, option, widget); Delegate()->postpaint(painter, option, widget);
painter->restore(); painter->restore();
} }
@ -290,19 +289,6 @@ void UBGraphicsMediaItem::setMute(bool bMute)
sIsMutedByDefault = mMuted; sIsMutedByDefault = mMuted;
} }
void UBGraphicsMediaItem::hasMediaChanged(bool hasMedia)
{
if(hasMedia && mMediaObject->isSeekable()) {
mMediaObject->setPosition(mInitialPos);
UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(Delegate());
if (med)
med->updateTicker(initialPos());
}
}
UBGraphicsScene* UBGraphicsMediaItem::scene() UBGraphicsScene* UBGraphicsMediaItem::scene()
{ {
return qobject_cast<UBGraphicsScene*>(QGraphicsItem::scene()); return qobject_cast<UBGraphicsScene*>(QGraphicsItem::scene());
@ -517,7 +503,12 @@ void UBGraphicsVideoItem::videoSizeChanged(QSizeF newSize)
Delegate()->showToolBar(false); Delegate()->showToolBar(false);
} }
void UBGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsRectItem::paint(painter, option, widget);
UBGraphicsMediaItem::paint(painter, option, widget);
}
void UBGraphicsVideoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsVideoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
@ -536,3 +527,15 @@ void UBGraphicsVideoItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
QGraphicsRectItem::hoverLeaveEvent(event); QGraphicsRectItem::hoverLeaveEvent(event);
} }
void UBGraphicsVideoItem::hasVideoChanged(bool hasVideo)
{
if (hasVideo) {
setBrush(QColor(Qt::transparent));
setPen(QColor(Qt::transparent));
}
else {
setBrush(QColor(Qt::black));
setPen(QColor(Qt::white));
}
}

@ -111,7 +111,6 @@ public slots:
void toggleMute(); void toggleMute();
void setMute(bool bMute); void setMute(bool bMute);
void activeSceneChanged(); void activeSceneChanged();
void hasMediaChanged(bool hasMedia);
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
virtual void play(); virtual void play();
@ -176,8 +175,11 @@ public:
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
public slots: public slots:
void videoSizeChanged(QSizeF newSize); void videoSizeChanged(QSizeF newSize);
void hasVideoChanged(bool hasVideo);
protected: protected:

Loading…
Cancel
Save