]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/customwidgets.hpp
Qt: Menu: change icon quit(cross) -> exit
[vlc] / modules / gui / qt4 / util / customwidgets.hpp
index 238591099a853c9b3fff33e6676be0498446f6b1..535161788cc3857cde7256d0911a78a11a3fbc46 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * customwidgets.h: Custom widgets
+ * customwidgets.hpp: Custom widgets
  ****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
  * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
 #include <QLabel>
 #include <QStackedWidget>
 #include <QSpinBox>
+#include <QCheckBox>
+#include <QList>
+#include <QTimer>
+#include <QToolButton>
+#include <QAbstractAnimation>
 
-class QVLCFramelessButton : public QPushButton
+class QPixmap;
+class QWidget;
+
+class QFramelessButton : public QPushButton
 {
     Q_OBJECT
 public:
-    QVLCFramelessButton( QWidget *parent = NULL );
+    QFramelessButton( QWidget *parent = NULL );
     virtual QSize sizeHint() const { return iconSize(); }
 protected:
     virtual void paintEvent( QPaintEvent * event );
 };
 
+class QToolButtonExt : public QToolButton
+{
+    Q_OBJECT
+public:
+    QToolButtonExt( QWidget *parent = 0, int ms = 0 );
+private:
+    bool shortClick;
+    bool longClick;
+private slots:
+    void releasedSlot();
+    void clickedSlot();
+signals:
+    void shortClicked();
+    void longClicked();
+};
 
-class QVLCElidingLabel : public QLabel
+class QElidingLabel : public QLabel
 {
 public:
-    QVLCElidingLabel( const QString &s = QString(),
+    QElidingLabel( const QString &s = QString(),
                       Qt::TextElideMode mode = Qt::ElideRight,
                       QWidget * parent = NULL );
     void setElideMode( Qt::TextElideMode );
@@ -68,17 +91,73 @@ public:
     }
 };
 
-class DebugLevelSpinBox : public QSpinBox
+class QVLCDebugLevelSpinBox : public QSpinBox
 {
     Q_OBJECT
 public:
-    DebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
+    QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
 protected:
     virtual QString textFromValue( int ) const;
-    /* DebugLevelSpinBox is read-only */
+    /* 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<QString> _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<QPixmap *> 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 )
+    {
+        animator->setLoopCount( loops );
+        if ( fps ) animator->setFps( fps );
+        animator->start();
+    }
+    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;
@@ -88,7 +167,6 @@ class QInputEvent;
 int qtKeyModifiersToVLC( QInputEvent* e );
 int qtEventToVLCKey( QKeyEvent *e );
 int qtWheelEventToVLCKey( QWheelEvent *e );
-QString VLCKeyToString( int val );
+QString VLCKeyToString( unsigned val );
 
 #endif
-