some cleaning on video audio graphics widget and restored video

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 3b51d09898
commit 6549641fe1
  1. 48
      src/domain/UBGraphicsMediaItem.cpp
  2. 19
      src/domain/UBGraphicsMediaItem.h
  3. 41
      src/domain/UBGraphicsMediaItemDelegate.cpp
  4. 7
      src/domain/UBGraphicsProxyWidget.cpp

@ -31,29 +31,6 @@
#include "board/UBBoardController.h"
#include "core/memcheck.h"
UBAudioPresentationWidget::UBAudioPresentationWidget(QWidget *parent)
: QWidget(parent)
, mBorderSize(10)
{
}
void UBAudioPresentationWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(rect(), QBrush(Qt::white));
QPen borderPen;
borderPen.setWidth(2);
borderPen.setColor(QColor(Qt::black));
painter.setPen(borderPen);
painter.drawRect(0,0, width(), height());
QWidget::paintEvent(event);
}
bool UBGraphicsMediaItem::sIsMutedByDefault = false;
UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent)
@ -97,14 +74,9 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mMediaObject->setTickInterval(1000);
mAudioWidget = new UBAudioPresentationWidget();
int borderSize = 0;
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(mAudioWidget);
if (pAudioWidget)
borderSize = pAudioWidget->borderSize();
mAudioWidget->resize(320,26+2*borderSize); //3*border size with enabled title
mAudioWidget->setMinimumSize(150,26+borderSize);
mAudioWidget = new QWidget();
mAudioWidget->resize(320,26);
mAudioWidget->setMinimumSize(150,26);
haveLinkedImage = false;
}
@ -117,10 +89,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
// we should create delegate after media objects because delegate uses his properties at creation.
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject));
// TODO claudio remove this because in contrast with the fact the frame should be created on demand.
// but without without forcing the control creation we do not have the frame and all the calculation
// for the different element of the interface will fail
Delegate()->createControls();
// delegate should be created earler because we setWidget calls resize event for graphics proxy widgt.
// resize uses delegate.
@ -130,6 +99,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
setWidget(mAudioWidget);
// media widget should be created and placed on proxy widget here.
// TODO claudio remove this because in contrast with the fact the frame should be created on demand.
// but without forcing the control creation we do not have the frame and all the calculation
// for the different element of the interface will fail
Delegate()->createControls();
if (mediaType_Audio == mMediaType)
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else
@ -196,11 +169,6 @@ void UBGraphicsMediaItem::clearSource()
qDebug() << "cannot delete file: " << path;
}
void UBGraphicsMediaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
UBGraphicsProxyWidget::paint(painter, option, widget);
}
void UBGraphicsMediaItem::toggleMute()
{
mMuted = !mMuted;

@ -32,22 +32,6 @@
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h"
class UBAudioPresentationWidget : public QWidget
{
public:
UBAudioPresentationWidget(QWidget *parent = NULL);
int borderSize() {return mBorderSize;}
void setTitle(QString title = QString()){mTitle = title;}
QString getTitle(){return mTitle;}
private:
virtual void paintEvent(QPaintEvent *event);
int mBorderSize;
QString mTitle;
};
class UBGraphicsMediaItem : public UBGraphicsProxyWidget
{
Q_OBJECT
@ -121,7 +105,6 @@ protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Phonon::MediaObject *mMediaObject;
Phonon::VideoWidget *mVideoWidget;
@ -145,7 +128,7 @@ private:
QPointF mMouseMovePos;
bool haveLinkedImage;
QGraphicsPixmapItem *mLinkedImage;
QGraphicsPixmapItem *mLinkedImage;
qint64 mInitialPos;
};

@ -119,14 +119,14 @@ void UBGraphicsMediaItemDelegate::buildButtons()
connect(mMuteButton, SIGNAL(clicked(bool)), mToolBarShowTimer, SLOT(start()));
}
UBGraphicsMediaItem *audioItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
if (audioItem)
{
if (audioItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
{
// UBGraphicsMediaItem *audioItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
// if (audioItem)
// {
// if (audioItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
// {
positionHandles();
}
}
// }
// }
}
UBGraphicsMediaItemDelegate::~UBGraphicsMediaItemDelegate()
@ -143,23 +143,12 @@ void UBGraphicsMediaItemDelegate::positionHandles()
if (mediaItem)
{
QRectF toolBarRect = mToolBarItem->rect();
if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video)
{
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height());
toolBarRect.setWidth(delegated()->boundingRect().width());
}
else if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
{
int borderSize = 0;
UBAudioPresentationWidget *audioWidget = dynamic_cast<UBAudioPresentationWidget*>(delegated()->widget());
if (audioWidget)
borderSize = audioWidget->borderSize();
mToolBarItem->setPos(borderSize,delegated()->boundingRect().height()-(mToolBarItem->rect().height() + borderSize));
toolBarRect.setWidth((delegated()->boundingRect().width()-2*borderSize));
mToolBarItem->show();
}
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height());
toolBarRect.setWidth(delegated()->boundingRect().width());
mToolBarItem->show();
mToolBarItem->setRect(toolBarRect);
}
@ -173,10 +162,10 @@ void UBGraphicsMediaItemDelegate::positionHandles()
}
toolBarMinimumWidth += mToolBarItem->boundingRect().height();
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(delegated()->widget());
QWidget* pAudioWidget = delegated()->widget();
if (pAudioWidget)
{
pAudioWidget->setMinimumSize(toolBarMinimumWidth + (int)mMediaControl->lcdAreaSize().width() + (int)mMediaControl->rect().height(),26+pAudioWidget->borderSize());
pAudioWidget->setMinimumSize(toolBarMinimumWidth + (int)mMediaControl->lcdAreaSize().width() + (int)mMediaControl->rect().height(),26);
}
QRectF mediaItemRect = mMediaControl->rect();
@ -187,7 +176,7 @@ void UBGraphicsMediaItemDelegate::positionHandles()
mToolBarItem->positionHandles();
mMediaControl->positionHandles();
if (mediaItem && mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
if (mediaItem)
mToolBarItem->show();
}

@ -37,10 +37,6 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
//UBGraphicsItemDelegate* delegate = new UBGraphicsItemDelegate(this,0, true, false, false);
//delegate->init();
//setDelegate(delegate);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsProxyWidget::setAcceptHoverEvents(true);
@ -53,6 +49,7 @@ UBGraphicsProxyWidget::~UBGraphicsProxyWidget()
void UBGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsProxyWidget::paint(painter,option,widget);
Delegate()->postpaint(painter, option, widget);
}
@ -158,7 +155,7 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
if (widget())
{
QSizeF minimumItemSize(widget()->minimumSize());
if (minimumItemSize.width() > pSize.width())
sizeX = minimumItemSize.width();

Loading…
Cancel
Save