UBGraphicsVideoItemDelegate.h 2.35 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
/*
 * UBGraphicsVideoItemDelegate.h
 *
 *  Created on: June 15, 2009
 *      Author: Patrick
 */

#ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_
#define UBGRAPHICSVIDEOITEMDELEGATE_H_

#include <QtGui>
#include <phonon/MediaObject>

#include "core/UB.h"
#include "UBGraphicsItemDelegate.h"

class QGraphicsSceneMouseEvent;
class QGraphicsItem;
class UBGraphicsVideoItem;

class DelegateVideoControl: public QGraphicsRectItem
{
    public:

        DelegateVideoControl(UBGraphicsVideoItem* pDelegated, QGraphicsItem * parent = 0);

        virtual ~DelegateVideoControl()
        {
            // NOOP
        }

        void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                QWidget *widget);

        QPainterPath shape() const;

        void setAntiScale(qreal antiScale){ mAntiScale = antiScale; }

        virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
        virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
        virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

        void updateTicker(qint64 time);
        void totalTimeChanged( qint64 newTotalTime);

   protected:


        void seekToMousePos(QPointF mousePos);

        UBGraphicsVideoItem* mDelegate;
        bool mDisplayCurrentTime;

        qreal mAntiScale;
        qint64 mCurrentTimeInMs;
        qint64 mTotalTimeInMs;

};


class UBGraphicsVideoItemDelegate : public UBGraphicsItemDelegate
{
    Q_OBJECT;

    public:
        UBGraphicsVideoItemDelegate(UBGraphicsVideoItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent = 0);
        virtual ~UBGraphicsVideoItemDelegate();

        virtual void positionHandles();

    public slots:

        void toggleMute();
        void updateTicker(qint64 time);

    protected slots:

        virtual void remove(bool canUndo = true);

        void togglePlayPause();

        void mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate );

        void updatePlayPauseState();

        void totalTimeChanged( qint64 newTotalTime);

    protected:

        virtual void buildButtons();

    private:

        UBGraphicsVideoItem* delegated();

        DelegateButton* mPlayPauseButton;
        DelegateButton* mStopButton;
        DelegateButton* mMuteButton;
        DelegateVideoControl *mVideoControl;

        Phonon::MediaObject* mMedia;

};


#endif /* UBGRAPHICSVIDEOITEMDELEGATE_H_ */