|
|
@ -44,6 +44,7 @@ UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pD |
|
|
|
| GF_RESPECT_RATIO |
|
|
|
| GF_RESPECT_RATIO |
|
|
|
| GF_TOOLBAR_USED |
|
|
|
| GF_TOOLBAR_USED |
|
|
|
| GF_SHOW_CONTENT_SOURCE) |
|
|
|
| GF_SHOW_CONTENT_SOURCE) |
|
|
|
|
|
|
|
, mPlayPauseButton(NULL) |
|
|
|
, mMedia(pMedia) |
|
|
|
, mMedia(pMedia) |
|
|
|
, mToolBarShowTimer(NULL) |
|
|
|
, mToolBarShowTimer(NULL) |
|
|
|
, m_iToolBarShowingInterval(5000) |
|
|
|
, m_iToolBarShowingInterval(5000) |
|
|
@ -73,6 +74,7 @@ bool UBGraphicsMediaItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *even |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(event); |
|
|
|
Q_UNUSED(event); |
|
|
|
mToolBarItem->show(); |
|
|
|
mToolBarItem->show(); |
|
|
|
|
|
|
|
positionHandles(); |
|
|
|
|
|
|
|
|
|
|
|
if (mToolBarShowTimer) |
|
|
|
if (mToolBarShowTimer) |
|
|
|
mToolBarShowTimer->start(); |
|
|
|
mToolBarShowTimer->start(); |
|
|
@ -87,52 +89,50 @@ void UBGraphicsMediaItemDelegate::hideToolBar() |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsMediaItemDelegate::buildButtons() |
|
|
|
void UBGraphicsMediaItemDelegate::buildButtons() |
|
|
|
{ |
|
|
|
{ |
|
|
|
mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
if(!mPlayPauseButton){ |
|
|
|
connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); |
|
|
|
mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
|
|
|
|
connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); |
|
|
|
|
|
|
|
|
|
|
|
mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop())); |
|
|
|
connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop())); |
|
|
|
|
|
|
|
|
|
|
|
mMediaControl = new DelegateMediaControl(delegated(), mToolBarItem); |
|
|
|
mMediaControl = new DelegateMediaControl(delegated(), mToolBarItem); |
|
|
|
mMediaControl->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
mMediaControl->setFlag(QGraphicsItem::ItemIsSelectable, true); |
|
|
|
UBGraphicsItem::assignZValue(mMediaControl, delegated()->zValue()); |
|
|
|
UBGraphicsItem::assignZValue(mMediaControl, delegated()->zValue()); |
|
|
|
|
|
|
|
|
|
|
|
if (delegated()->isMuted()) |
|
|
|
if (delegated()->isMuted()) |
|
|
|
mMuteButton = new DelegateButton(":/images/soundOff.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
mMuteButton = new DelegateButton(":/images/soundOff.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
else |
|
|
|
else |
|
|
|
mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mToolBarItem, Qt::TitleBarArea); |
|
|
|
|
|
|
|
|
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); |
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); |
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute())); // for changing button image
|
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute())); // for changing button image
|
|
|
|
|
|
|
|
|
|
|
|
mToolBarButtons << mPlayPauseButton << mStopButton << mMuteButton; |
|
|
|
mToolBarButtons << mPlayPauseButton << mStopButton << mMuteButton; |
|
|
|
|
|
|
|
|
|
|
|
mToolBarItem->setItemsOnToolBar(QList<QGraphicsItem*>() << mPlayPauseButton << mStopButton << mMediaControl << mMuteButton); |
|
|
|
mToolBarItem->setItemsOnToolBar(QList<QGraphicsItem*>() << mPlayPauseButton << mStopButton << mMediaControl << mMuteButton ); |
|
|
|
mToolBarItem->setVisibleOnBoard(true); |
|
|
|
mToolBarItem->setVisibleOnBoard(true); |
|
|
|
mToolBarItem->setShifting(false); |
|
|
|
mToolBarItem->setShifting(false); |
|
|
|
|
|
|
|
|
|
|
|
if (mToolBarShowTimer) |
|
|
|
if (mToolBarShowTimer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
connect(mPlayPauseButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mPlayPauseButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mStopButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mStopButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mMediaControl, SIGNAL(used()), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mMediaControl, SIGNAL(used()), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); |
|
|
|
connect(mMuteButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// UBGraphicsMediaItem *audioItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
|
|
|
|
|
|
|
|
// if (audioItem)
|
|
|
|
positionHandles(); |
|
|
|
// {
|
|
|
|
} |
|
|
|
// if (audioItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
positionHandles(); |
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsMediaItemDelegate::~UBGraphicsMediaItemDelegate() |
|
|
|
UBGraphicsMediaItemDelegate::~UBGraphicsMediaItemDelegate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mToolBarShowTimer) |
|
|
|
if (mToolBarShowTimer){ |
|
|
|
delete mToolBarShowTimer; |
|
|
|
delete mToolBarShowTimer; |
|
|
|
|
|
|
|
mToolBarShowTimer = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsMediaItemDelegate::positionHandles() |
|
|
|
void UBGraphicsMediaItemDelegate::positionHandles() |
|
|
@ -144,32 +144,20 @@ void UBGraphicsMediaItemDelegate::positionHandles() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QRectF toolBarRect = mToolBarItem->rect(); |
|
|
|
QRectF toolBarRect = mToolBarItem->rect(); |
|
|
|
|
|
|
|
|
|
|
|
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()); |
|
|
|
mToolBarItem->setPos(0, mediaItem->boundingRect().height()-mToolBarItem->rect().height()); |
|
|
|
|
|
|
|
|
|
|
|
toolBarRect.setWidth(delegated()->boundingRect().width()); |
|
|
|
toolBarRect.setWidth(mediaItem->boundingRect().width()); |
|
|
|
mToolBarItem->show(); |
|
|
|
mToolBarItem->show(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mToolBarItem->setRect(toolBarRect); |
|
|
|
mToolBarItem->setRect(toolBarRect); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int toolBarMinimumWidth = 0; |
|
|
|
int toolBarButtonsWidth = 0; |
|
|
|
int mediaItemWidth = mToolBarItem->boundingRect().width(); |
|
|
|
|
|
|
|
foreach (DelegateButton* button, mToolBarButtons) |
|
|
|
foreach (DelegateButton* button, mToolBarButtons) |
|
|
|
{ |
|
|
|
toolBarButtonsWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding(); |
|
|
|
mediaItemWidth -= button->boundingRect().width() + mToolBarItem->getElementsPadding(); |
|
|
|
|
|
|
|
toolBarMinimumWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
toolBarMinimumWidth += mToolBarItem->boundingRect().height(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* pAudioWidget = delegated()->widget(); |
|
|
|
|
|
|
|
if (pAudioWidget) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pAudioWidget->setMinimumSize(toolBarMinimumWidth + (int)mMediaControl->lcdAreaSize().width() + (int)mMediaControl->rect().height(),26); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRectF mediaItemRect = mMediaControl->rect(); |
|
|
|
QRectF mediaItemRect = mMediaControl->rect(); |
|
|
|
mediaItemRect.setWidth(mediaItemWidth); |
|
|
|
mediaItemRect.setWidth(mediaItem->boundingRect().width() - toolBarButtonsWidth); |
|
|
|
mediaItemRect.setHeight(mToolBarItem->boundingRect().height()); |
|
|
|
mediaItemRect.setHeight(mToolBarItem->boundingRect().height()); |
|
|
|
mMediaControl->setRect(mediaItemRect); |
|
|
|
mMediaControl->setRect(mediaItemRect); |
|
|
|
|
|
|
|
|
|
|
|