]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/customwidgets.hpp
Qt: move animators code
[vlc] / modules / gui / qt4 / util / customwidgets.hpp
index 4b12ff3e1cc64b24874371adba271324454f9c5f..e1e6c6d38f4c97b243b84fe316a0d11afa1b49a3 100644 (file)
@@ -1,9 +1,9 @@
 /*****************************************************************************
- * customwidgets.h: Custom widgets
+ * customwidgets.hpp: Custom widgets
  ****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
  * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
- * $Id: qvlcframe.hpp 16283 2006-08-17 18:16:09Z zorglub $
+ * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  * The "ClickLineEdit" control is based on code by  Daniel Molkentin
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
 
 #ifndef _CUSTOMWIDGETS_H_
 #define _CUSTOMWIDGETS_H_
 
 #include <QLineEdit>
+#include <QPushButton>
+#include <QLabel>
+#include <QStackedWidget>
+#include <QSpinBox>
+#include <QCheckBox>
+#include <QList>
+#include <QToolButton>
+#include <QDial>
 
-/**
-  This class provides a QLineEdit which contains a greyed-out hinting
-  text as long as the user didn't enter any text
+#include "animators.hpp"
 
-  @short LineEdit with customizable "Click here" text
-  @author Daniel Molkentin
-*/
-class ClickLineEdit : public QLineEdit
+class QPixmap;
+class QWidget;
+
+class QFramelessButton : public QPushButton
+{
+    Q_OBJECT
+public:
+    QFramelessButton( QWidget *parent = NULL );
+    virtual QSize sizeHint() const { return iconSize(); }
+protected:
+    virtual void paintEvent( QPaintEvent * event );
+};
+
+class VLCQDial : public QDial
+{
+    Q_OBJECT
+public:
+    VLCQDial( QWidget *parent = NULL );
+protected:
+    virtual void paintEvent( QPaintEvent * event );
+};
+
+class QToolButtonExt : public QToolButton
 {
     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 );
+    QToolButtonExt( QWidget *parent = 0, int ms = 0 );
+private:
+    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 *e );
-    virtual void dropEvent( QDropEvent *ev );
-    virtual void focusInEvent( QFocusEvent *ev );
-    virtual void focusOutEvent( QFocusEvent *ev );
+    virtual void paintEvent( QPaintEvent * event );
 private:
-    QString mClickMessage;
-    bool mDrawClickMsg;
+    Qt::TextElideMode elideMode;
 };
 
-/*****************************************************************
- * Custom views
- *****************************************************************/
-#include <QMouseEvent>
-#include <QTreeView>
-#include <QCursor>
-#include <QPoint>
-#include <QModelIndex>
 
-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();
+    }
+};
+
+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; }
+};
+
+/** 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
 
-    void mouseReleaseEvent(QMouseEvent* e )
+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;
+};
+
+class YesNoCheckBox : public QCheckBox
+{
+    Q_OBJECT
+public:
+    YesNoCheckBox( QWidget *parent );
 };
 
+/* 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, bool );
 
 #endif