media item no more resized on click. First try to fix the lcdwidget

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 954dfa60ba
commit f619a0f2f4
  1. 12
      src/domain/UBGraphicsItemDelegate.cpp
  2. 2
      src/domain/UBGraphicsItemDelegate.h
  3. 37
      src/domain/UBGraphicsMediaItemDelegate.cpp

@ -1312,12 +1312,11 @@ void DelegateMediaControl::positionHandles()
mDisplayFormat = "ss"; mDisplayFormat = "ss";
if (tTotal.minute() > 0)
{ //Explanation at least the second and minutes are diplayed
mDisplayFormat = "mm:" + mDisplayFormat; mDisplayFormat = "mm:" + mDisplayFormat;
digitsCount += 3; digitsCount += 3;
timerWidth += mLCDTimerArea.height()*0.5; timerWidth += mLCDTimerArea.height();
}
if (tTotal.hour() > 0) if (tTotal.hour() > 0)
{ {
@ -1348,6 +1347,7 @@ void DelegateMediaControl::update()
QTime tCurrent; QTime tCurrent;
tCurrent = tCurrent.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); tCurrent = tCurrent.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
lcdTimer->display(tCurrent.toString(mDisplayFormat)); lcdTimer->display(tCurrent.toString(mDisplayFormat));
QGraphicsRectItem::update(); QGraphicsRectItem::update();

@ -174,7 +174,6 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem
void positionHandles(); void positionHandles();
void updateTicker(qint64 time); void updateTicker(qint64 time);
void totalTimeChanged(qint64 newTotalTime); void totalTimeChanged(qint64 newTotalTime);
QSizeF lcdAreaSize() {return mLCDTimerArea.size();}
signals: signals:
void used(); void used();
@ -286,7 +285,6 @@ class UBGraphicsItemDelegate : public QObject
UBGraphicsFlags ubflags() const {return mFlags;} UBGraphicsFlags ubflags() const {return mFlags;}
bool testUBFlags(UBGraphicsFlags pf) const {return mFlags & pf;} bool testUBFlags(UBGraphicsFlags pf) const {return mFlags & pf;}
void setUBFlags(UBGraphicsFlags pf); void setUBFlags(UBGraphicsFlags pf);
// void addUBFlags(UBGraphicsFlags pf) {setUBFlags(ubflags() | pf);}
void setUBFlag(UBGraphicsFlags pf, bool set = true); void setUBFlag(UBGraphicsFlags pf, bool set = true);
signals: signals:

@ -73,6 +73,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();
@ -119,20 +120,16 @@ void UBGraphicsMediaItemDelegate::buildButtons()
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 +141,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 toolBarButtons= 0;
int mediaItemWidth = mToolBarItem->boundingRect().width();
foreach (DelegateButton* button, mToolBarButtons) foreach (DelegateButton* button, mToolBarButtons)
{ toolBarButtons += 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() - toolBarButtons);
mediaItemRect.setHeight(mToolBarItem->boundingRect().height()); mediaItemRect.setHeight(mToolBarItem->boundingRect().height());
mMediaControl->setRect(mediaItemRect); mMediaControl->setRect(mediaItemRect);

Loading…
Cancel
Save