X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Futil%2Fcustomwidgets.hpp;h=c984f85c3d7f7fd0ad67eb04796b952745311463;hb=1085ee39332b53761770d5a532d1b0eeb1c7ae8c;hp=5f2279cd8f47ac8df2e036889b026779176e2c5f;hpb=dbddc5ae452252807b520abdb803cf5f231bbdf0;p=vlc diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp index 5f2279cd8f..c984f85c3d 100644 --- a/modules/gui/qt4/util/customwidgets.hpp +++ b/modules/gui/qt4/util/customwidgets.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * customwidgets.h: Custom widgets + * customwidgets.hpp: Custom widgets **************************************************************************** * Copyright (C) 2006 the VideoLAN team * Copyright (C) 2004 Daniel Molkentin @@ -28,70 +28,136 @@ #define _CUSTOMWIDGETS_H_ #include +#include +#include +#include +#include +#include +#include +#include +#include -/** - This class provides a QLineEdit which contains a greyed-out hinting - text as long as the user didn't enter any text +class QPixmap; - @short LineEdit with customizable "Click here" text - @author Daniel Molkentin -*/ -class ClickLineEdit : public QLineEdit +class QFramelessButton : public QPushButton { Q_OBJECT - Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage ) public: - ClickLineEdit( const QString &msg, QWidget *parent ); - virtual ~ClickLineEdit() {}; - void setClickMessage( const QString &msg ); - QString clickMessage() const { return mClickMessage; } - virtual void setText( const QString& txt ); + QFramelessButton( QWidget *parent = NULL ); + virtual QSize sizeHint() const { return iconSize(); } protected: - virtual void paintEvent( QPaintEvent *e ); - virtual void dropEvent( QDropEvent *ev ); - virtual void focusInEvent( QFocusEvent *ev ); - virtual void focusOutEvent( QFocusEvent *ev ); + virtual void paintEvent( QPaintEvent * event ); +}; + +class QToolButtonExt : public QToolButton +{ + Q_OBJECT +public: + QToolButtonExt( QWidget *parent = 0, int ms = 0 ); private: - QString mClickMessage; - bool mDrawClickMsg; + bool shortClick; + bool longClick; +private slots: + void releasedSlot(); + void clickedSlot(); +signals: + void shortClicked(); + void longClicked(); }; +class QElidingLabel : public QLabel +{ +public: + QElidingLabel( const QString &s = QString(), + Qt::TextElideMode mode = Qt::ElideRight, + QWidget * parent = NULL ); + void setElideMode( Qt::TextElideMode ); +protected: + virtual void paintEvent( QPaintEvent * event ); +private: + Qt::TextElideMode elideMode; +}; -/***************************************************************** - * Custom views - *****************************************************************/ -#include -#include -#include -#include -#include -class QVLCTreeView : public QTreeView +class QVLCStackedWidget : public QStackedWidget { - Q_OBJECT; public: - QVLCTreeView( QWidget * parent ) : QTreeView( parent ) + QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { } + QSize minimumSizeHint () const { - }; - virtual ~QVLCTreeView() {}; + return currentWidget() ? currentWidget()->minimumSizeHint() : QSize(); + } +}; - void mouseReleaseEvent(QMouseEvent* e ) +class QVLCDebugLevelSpinBox : public QSpinBox +{ + Q_OBJECT +public: + QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { }; +protected: + virtual QString textFromValue( int ) const; + /* QVLCDebugLevelSpinBox is read-only */ + virtual int valueFromText( const QString& ) const { return -1; } +}; + +/** An animated pixmap + * Use this widget to display an animated icon based on a series of + * pixmaps. The pixmaps will be stored in memory and should be kept small. + * First, create the widget, add frames and then start playing. Looping + * is supported. + **/ +class PixmapAnimator : public QAbstractAnimation +{ + Q_OBJECT + +public: + PixmapAnimator( QWidget *parent, QList _frames ); + void setFps( int _fps ) { fps = _fps; interval = 1000.0 / fps; }; + virtual int duration() const { return interval * pixmaps.count(); }; + virtual ~PixmapAnimator() { while( pixmaps.count() ) pixmaps.erase( pixmaps.end() ); }; + QPixmap *getPixmap() { return currentPixmap; } +protected: + virtual void updateCurrentTime ( int msecs ); + QList pixmaps; + QPixmap *currentPixmap; + int fps; + int interval; + int lastframe_msecs; + int current_frame; +signals: + void pixmapReady( const QPixmap & ); +}; + +/** This spinning icon, to the colors of the VLC cone, will show + * that there is some background activity running + **/ +class SpinningIcon : public QLabel +{ + Q_OBJECT + +public: + SpinningIcon( QWidget *parent ); + void play( int loops = -1, int fps = 0 ) { - if( e->button() & Qt::RightButton ) - { - emit rightClicked( indexAt( QPoint( e->x(), e->y() ) ), - QCursor::pos() ); - } + animator->setLoopCount( loops ); + if ( fps ) animator->setFps( fps ); + animator->start(); } -signals: - void rightClicked( QModelIndex, QPoint ); + void stop() { animator->stop(); } + bool isPlaying() { return animator->state() == PixmapAnimator::Running; } +private: + PixmapAnimator *animator; }; +/* VLC Key/Wheel hotkeys interactions */ + class QKeyEvent; class QWheelEvent; +class QInputEvent; + int qtKeyModifiersToVLC( QInputEvent* e ); int qtEventToVLCKey( QKeyEvent *e ); int qtWheelEventToVLCKey( QWheelEvent *e ); -QString VLCKeyToString( int val ); +QString VLCKeyToString( unsigned val ); #endif