Small boarder for possibility to move item and select it without rubber band added.

Audio items cannot be resized in vertical dimension because there are no useful content.

Audio and Video items has minimal dimensions.
preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 88f652245e
commit c36f903f0c
  1. 33
      src/domain/UBGraphicsDelegateFrame.cpp
  2. 2
      src/domain/UBGraphicsDelegateFrame.h
  3. 14
      src/domain/UBGraphicsMediaItem.cpp
  4. 34
      src/domain/UBGraphicsMediaItem.h
  5. 27
      src/domain/UBGraphicsMediaItemDelegate.cpp
  6. 26
      src/domain/UBGraphicsProxyWidget.cpp

@ -359,7 +359,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
}
else if (mOperationMode == Resizing)
else if (mOperationMode == Resizing || mOperationMode == ResizingHorizontally)
{
mTranslateX = moveX;
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated());
@ -675,19 +675,22 @@ void UBGraphicsDelegateFrame::positionHandles()
QVariant vLocked = delegated()->data(UBGraphicsItemData::ItemLocked);
bool isLocked = (vLocked.isValid() && vLocked.toBool());
mBottomRightResizeGripSvgItem->setVisible(!isLocked);
mBottomResizeGripSvgItem->setVisible(!isLocked);
mLeftResizeGripSvgItem->setVisible(!isLocked);
mRightResizeGripSvgItem->setVisible(!isLocked);
mTopResizeGripSvgItem->setVisible(!isLocked);
bool bShowHorizontalResizers = ResizingHorizontally == mOperationMode;
bool bShowVerticalResizers = ResizingHorizontally != mOperationMode;
bool bShowAllResizers = Resizing == mOperationMode || Scaling == mOperationMode ;
mBottomRightResizeGripSvgItem->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mLeftResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mRotateButton->setVisible(mDelegate->canRotate() && !isLocked);
mBottomRightResizeGrip->setVisible(!isLocked);
mBottomResizeGrip->setVisible(!isLocked);
mLeftResizeGrip->setVisible(!isLocked);
mRightResizeGrip->setVisible(!isLocked);
mTopResizeGrip->setVisible(!isLocked);
mBottomRightResizeGrip->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mLeftResizeGrip->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGrip->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
if (isLocked)
{
@ -714,9 +717,9 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
{
if(mDelegate->isLocked())
return None;
else if (bottomRightResizeGripRect().contains(pos))
else if (bottomRightResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode)
return ResizeBottomRight;
else if (bottomResizeGripRect().contains(pos)){
else if (bottomResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode){
if(mMirrorY){
return ResizeTop;
}else{
@ -738,7 +741,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
return ResizeRight;
}
}
else if (topResizeGripRect().contains(pos)){
else if (topResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode){
if(mMirrorY){
return ResizeBottom;
}else{

@ -46,7 +46,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
virtual void setAntiScale(qreal pAntiScale);
enum OperationMode {Scaling, Resizing};
enum OperationMode {Scaling, Resizing, ResizingHorizontally};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;}

@ -56,6 +56,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
if(mVideoWidget->sizeHint() == QSize(1,1)){
mVideoWidget->resize(320,240);
mVideoWidget->setMinimumSize(131,26);
}
setWidget(mVideoWidget);
haveLinkedImage = true;
@ -67,8 +68,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mMediaObject->setTickInterval(1000);
mAudioWidget = new QWidget();
mAudioWidget->resize(320,26);
mAudioWidget = new UBGraphicsMediaItem::UBAudioPresentationWidget();
int borderSize = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(mAudioWidget)->borderSize();
mAudioWidget->resize(320+2*borderSize,26+2*borderSize);
mAudioWidget->setMinimumSize(147,26+2*borderSize);
setWidget(mAudioWidget);
haveLinkedImage = false;
}
@ -82,7 +85,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
itemDelegate->init();
setDelegate(itemDelegate);
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
if (mediaType_Audio == mMediaType)
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
@ -284,4 +290,4 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept();
}
}

@ -27,6 +27,29 @@ class UBGraphicsMediaItem : public UBGraphicsProxyWidget
{
Q_OBJECT
public:
class UBAudioPresentationWidget : public QWidget
{
public:
UBAudioPresentationWidget::UBAudioPresentationWidget(QWidget *parent = NULL)
:QWidget(parent)
, mBorderSize(7)
{}
int borderSize(){return mBorderSize;}
private:
virtual void paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(rect(), QBrush(Qt::black));
QWidget::paintEvent(event);
}
int mBorderSize;
};
public:
typedef enum{
mediaType_Video,
@ -118,15 +141,6 @@ private:
QPointF mMouseMovePos;
bool haveLinkedImage;
QGraphicsPixmapItem *mLinkedImage;
QGraphicsPixmapItem *mLinkedImage;
};
class UBGraphicsUnitedMediaItem : public UBGraphicsMediaItem
{
public:
UBGraphicsUnitedMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent = 0);
};
#endif // UBGRAPHICSMEDIAITEM_H

@ -18,6 +18,7 @@
#include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsScene.h"
@ -125,19 +126,25 @@ void UBGraphicsMediaItemDelegate::positionHandles()
UBGraphicsMediaItem *mediaItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
if (mediaItem)
{
if (mediaItem->getMediaType() != UBGraphicsMediaItem::mediaType_Audio)
{
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()*AntiScaleRatio);
mToolBarItem->setScale(AntiScaleRatio);
QRectF toolBarRect = mToolBarItem->rect();
toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio);
mToolBarItem->setRect(toolBarRect);
}
else
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()*AntiScaleRatio);
mToolBarItem->setScale(AntiScaleRatio);
QRectF toolBarRect = mToolBarItem->rect();
toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio);
if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
{
mToolBarItem->setPos(0, 0);
int borderSize = 0;
UBGraphicsMediaItem::UBAudioPresentationWidget *audioWidget = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(delegated()->widget());
if (audioWidget)
borderSize = audioWidget->borderSize();
toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio-2*borderSize);
mToolBarItem->setPos(borderSize,borderSize);
mToolBarItem->show();
}
mToolBarItem->setRect(toolBarRect);
}
int mediaItemWidth = mToolBarItem->boundingRect().width();

@ -153,10 +153,30 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
{
if (pSize != size())
{
QGraphicsProxyWidget::setMaximumSize(pSize.width(), pSize.height());
QGraphicsProxyWidget::resize(pSize.width(), pSize.height());
qreal sizeX = 0;
qreal sizeY = 0;
if (widget())
{
QSizeF minimumItemSize(widget()->minimumSize());
if (minimumItemSize.width() > pSize.width())
sizeX = minimumItemSize.width();
else
sizeX = pSize.width();
if (minimumItemSize.height() > pSize.height())
sizeY = minimumItemSize.height();
else
sizeY = pSize.height();
}
QSizeF size(sizeX, sizeY);
QGraphicsProxyWidget::setMaximumSize(size.width(), size.height());
QGraphicsProxyWidget::resize(size.width(), size.height());
if (widget())
widget()->resize(pSize.width(), pSize.height());
widget()->resize(size.width(), size.height());
if (mDelegate)
mDelegate->positionHandles();
if (scene())

Loading…
Cancel
Save