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. 17
      src/domain/UBGraphicsMediaItem.h
  3. 35
      src/domain/UBGraphicsMediaItemDelegate.cpp
  4. 5
      src/domain/UBGraphicsProxyWidget.cpp

@ -31,29 +31,6 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.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; bool UBGraphicsMediaItem::sIsMutedByDefault = false;
UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent) UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent)
@ -97,14 +74,9 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mMediaObject->setTickInterval(1000); mMediaObject->setTickInterval(1000);
mAudioWidget = new UBAudioPresentationWidget(); mAudioWidget = new QWidget();
int borderSize = 0; mAudioWidget->resize(320,26);
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(mAudioWidget); mAudioWidget->setMinimumSize(150,26);
if (pAudioWidget)
borderSize = pAudioWidget->borderSize();
mAudioWidget->resize(320,26+2*borderSize); //3*border size with enabled title
mAudioWidget->setMinimumSize(150,26+borderSize);
haveLinkedImage = false; 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. // we should create delegate after media objects because delegate uses his properties at creation.
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject)); 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. // delegate should be created earler because we setWidget calls resize event for graphics proxy widgt.
// resize uses delegate. // resize uses delegate.
@ -130,6 +99,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
setWidget(mAudioWidget); setWidget(mAudioWidget);
// media widget should be created and placed on proxy widget here. // 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) if (mediaType_Audio == mMediaType)
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else else
@ -196,11 +169,6 @@ void UBGraphicsMediaItem::clearSource()
qDebug() << "cannot delete file: " << path; qDebug() << "cannot delete file: " << path;
} }
void UBGraphicsMediaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
UBGraphicsProxyWidget::paint(painter, option, widget);
}
void UBGraphicsMediaItem::toggleMute() void UBGraphicsMediaItem::toggleMute()
{ {
mMuted = !mMuted; mMuted = !mMuted;

@ -32,22 +32,6 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.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 class UBGraphicsMediaItem : public UBGraphicsProxyWidget
{ {
Q_OBJECT Q_OBJECT
@ -121,7 +105,6 @@ protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource(); virtual void clearSource();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Phonon::MediaObject *mMediaObject; Phonon::MediaObject *mMediaObject;
Phonon::VideoWidget *mVideoWidget; Phonon::VideoWidget *mVideoWidget;

@ -119,14 +119,14 @@ 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); // UBGraphicsMediaItem *audioItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
if (audioItem) // if (audioItem)
{ // {
if (audioItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio) // if (audioItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
{ // {
positionHandles(); positionHandles();
} // }
} // }
} }
UBGraphicsMediaItemDelegate::~UBGraphicsMediaItemDelegate() UBGraphicsMediaItemDelegate::~UBGraphicsMediaItemDelegate()
@ -143,23 +143,12 @@ void UBGraphicsMediaItemDelegate::positionHandles()
if (mediaItem) if (mediaItem)
{ {
QRectF toolBarRect = mToolBarItem->rect(); QRectF toolBarRect = mToolBarItem->rect();
if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video)
{
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()); mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height());
toolBarRect.setWidth(delegated()->boundingRect().width()); 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->show();
}
mToolBarItem->setRect(toolBarRect); mToolBarItem->setRect(toolBarRect);
} }
@ -173,10 +162,10 @@ void UBGraphicsMediaItemDelegate::positionHandles()
} }
toolBarMinimumWidth += mToolBarItem->boundingRect().height(); toolBarMinimumWidth += mToolBarItem->boundingRect().height();
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(delegated()->widget()); QWidget* pAudioWidget = delegated()->widget();
if (pAudioWidget) 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(); QRectF mediaItemRect = mMediaControl->rect();
@ -187,7 +176,7 @@ void UBGraphicsMediaItemDelegate::positionHandles()
mToolBarItem->positionHandles(); mToolBarItem->positionHandles();
mMediaControl->positionHandles(); mMediaControl->positionHandles();
if (mediaItem && mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio) if (mediaItem)
mToolBarItem->show(); mToolBarItem->show();
} }

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

Loading…
Cancel
Save