|
|
@ -39,22 +39,19 @@ UBGraphicsVideoItemDelegate::UBGraphicsVideoItemDelegate(UBGraphicsVideoItem* pD |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsVideoItemDelegate::buildButtons() |
|
|
|
void UBGraphicsVideoItemDelegate::buildButtons() |
|
|
|
{ |
|
|
|
{ |
|
|
|
mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mFrame); |
|
|
|
mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
|
|
|
|
|
|
|
|
mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mFrame); |
|
|
|
mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
mStopButton->hide(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (delegated()->isMuted()) |
|
|
|
mVideoControl = new DelegateVideoControl(delegated(), mToolBarItem); |
|
|
|
mMuteButton = new DelegateButton(":/images/soundOff.svg", mDelegated, mFrame); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mFrame); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMuteButton->hide(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mVideoControl = new DelegateVideoControl(delegated(), mFrame); |
|
|
|
|
|
|
|
UBGraphicsItem::assignZValue(mVideoControl, delegated()->zValue()); |
|
|
|
UBGraphicsItem::assignZValue(mVideoControl, delegated()->zValue()); |
|
|
|
mVideoControl->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
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(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); |
|
|
|
connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop())); |
|
|
|
connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop())); |
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); |
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); |
|
|
@ -62,6 +59,10 @@ void UBGraphicsVideoItemDelegate::buildButtons() |
|
|
|
|
|
|
|
|
|
|
|
mButtons << mPlayPauseButton << mStopButton << mMuteButton; |
|
|
|
mButtons << mPlayPauseButton << mStopButton << mMuteButton; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QGraphicsItem*> itemsOnToolBar; |
|
|
|
|
|
|
|
itemsOnToolBar << mPlayPauseButton << mStopButton << mVideoControl << mMuteButton; |
|
|
|
|
|
|
|
mToolBarItem->setItemsOnToolBar(itemsOnToolBar); |
|
|
|
|
|
|
|
|
|
|
|
mMedia->setTickInterval(50); |
|
|
|
mMedia->setTickInterval(50); |
|
|
|
|
|
|
|
|
|
|
|
connect(mMedia, SIGNAL(stateChanged (Phonon::State, Phonon::State)), this, SLOT(mediaStateChanged (Phonon::State, Phonon::State))); |
|
|
|
connect(mMedia, SIGNAL(stateChanged (Phonon::State, Phonon::State)), this, SLOT(mediaStateChanged (Phonon::State, Phonon::State))); |
|
|
@ -69,6 +70,8 @@ void UBGraphicsVideoItemDelegate::buildButtons() |
|
|
|
connect(mMedia, SIGNAL(tick(qint64)), this, SLOT(updateTicker(qint64))); |
|
|
|
connect(mMedia, SIGNAL(tick(qint64)), this, SLOT(updateTicker(qint64))); |
|
|
|
connect(mMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); |
|
|
|
connect(mMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mToolBarItem->setVisibleOnBoard(true); |
|
|
|
|
|
|
|
mToolBarItem->setShifting(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -86,21 +89,24 @@ void UBGraphicsVideoItemDelegate::positionHandles() |
|
|
|
{ |
|
|
|
{ |
|
|
|
qreal scaledFrameWidth = mFrameWidth * mAntiScaleRatio; |
|
|
|
qreal scaledFrameWidth = mFrameWidth * mAntiScaleRatio; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int offset = 0; |
|
|
|
|
|
|
|
foreach (DelegateButton* button, mButtons) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (button->getSection() == Qt::TitleBarArea) |
|
|
|
|
|
|
|
offset += button->boundingRect().width() * mAntiScaleRatio; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
qreal width = mFrame->rect().width(); |
|
|
|
mVideoControl->setRect(mVideoControl->rect().x() |
|
|
|
qreal height = mFrame->rect().height(); |
|
|
|
, scaledFrameWidth/6 - 0.5 |
|
|
|
|
|
|
|
, (mToolBarItem->rect().width() - 35 - offset) / mAntiScaleRatio
|
|
|
|
qreal x = mFrame->rect().left(); |
|
|
|
, (2 * scaledFrameWidth) / mAntiScaleRatio); |
|
|
|
qreal y = mFrame->rect().top(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mVideoControl->setRect(x + 2 * scaledFrameWidth |
|
|
|
offset += (mVideoControl->rect().width() + 5) * mAntiScaleRatio; |
|
|
|
, y + height - 3 * scaledFrameWidth |
|
|
|
mMuteButton->setPos(offset, 0); |
|
|
|
, width - 4 * scaledFrameWidth |
|
|
|
|
|
|
|
, 2 * scaledFrameWidth); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mVideoControl->scene()) |
|
|
|
if (!mVideoControl->scene()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mVideoControl->setParentItem(mFrame);//update parent for the case the item has been previously removed from scene
|
|
|
|
mVideoControl->setParentItem(mToolBarItem);//update parent for the case the item has been previously removed from scene
|
|
|
|
mDelegated->scene()->addItem(mVideoControl); |
|
|
|
mDelegated->scene()->addItem(mVideoControl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -215,12 +221,17 @@ DelegateVideoControl::DelegateVideoControl(UBGraphicsVideoItem* pDelegated, QGra |
|
|
|
, mAntiScale(1.0) |
|
|
|
, mAntiScale(1.0) |
|
|
|
, mCurrentTimeInMs(0) |
|
|
|
, mCurrentTimeInMs(0) |
|
|
|
, mTotalTimeInMs(0) |
|
|
|
, mTotalTimeInMs(0) |
|
|
|
|
|
|
|
, mStartWidth(200) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setAcceptedMouseButtons(Qt::LeftButton); |
|
|
|
setAcceptedMouseButtons(Qt::LeftButton); |
|
|
|
|
|
|
|
|
|
|
|
setBrush(QBrush(UBSettings::paletteColor)); |
|
|
|
setBrush(QBrush(Qt::white)); |
|
|
|
setPen(Qt::NoPen); |
|
|
|
setPen(Qt::NoPen); |
|
|
|
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); |
|
|
|
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRectF rect = this->rect(); |
|
|
|
|
|
|
|
rect.setWidth(mStartWidth); |
|
|
|
|
|
|
|
this->setRect(rect); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -250,8 +261,8 @@ void DelegateVideoControl::paint(QPainter *painter, |
|
|
|
{ |
|
|
|
{ |
|
|
|
painter->setBrush(UBSettings::paletteColor); |
|
|
|
painter->setBrush(UBSettings::paletteColor); |
|
|
|
painter->setPen(QPen(Qt::NoPen)); |
|
|
|
painter->setPen(QPen(Qt::NoPen)); |
|
|
|
QRectF balloon(rect().x() + position - frameWidth, rect().y() - (frameWidth * 1.2), 2 * frameWidth, frameWidth); |
|
|
|
mBalloon.setRect(rect().x() + position - frameWidth, rect().y() - (frameWidth * 1.2), 2 * frameWidth, frameWidth); |
|
|
|
painter->drawRoundedRect(balloon, frameWidth/2, frameWidth/2); |
|
|
|
painter->drawRoundedRect(mBalloon, frameWidth/2, frameWidth/2); |
|
|
|
|
|
|
|
|
|
|
|
QTime t; |
|
|
|
QTime t; |
|
|
|
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); |
|
|
|
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); |
|
|
@ -259,7 +270,7 @@ void DelegateVideoControl::paint(QPainter *painter, |
|
|
|
f.setPointSizeF(f.pointSizeF() * mAntiScale); |
|
|
|
f.setPointSizeF(f.pointSizeF() * mAntiScale); |
|
|
|
painter->setFont(f); |
|
|
|
painter->setFont(f); |
|
|
|
painter->setPen(Qt::white); |
|
|
|
painter->setPen(Qt::white); |
|
|
|
painter->drawText(balloon, Qt::AlignCenter, t.toString("m:ss")); |
|
|
|
painter->drawText(mBalloon, Qt::AlignCenter, t.toString("m:ss")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -297,11 +308,15 @@ void DelegateVideoControl::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DelegateVideoControl::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
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()); |
|
|
|
seekToMousePos(event->pos()); |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DelegateVideoControl::seekToMousePos(QPointF mousePos) |
|
|
|
void DelegateVideoControl::seekToMousePos(QPointF mousePos) |
|
|
|