/*****************************************************************************
- * customwidgets.h: Custom widgets
+ * customwidgets.hpp: Custom widgets
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
#define _CUSTOMWIDGETS_H_
#include <QLineEdit>
-
-/**
- This class provides a QLineEdit which contains a greyed-out hinting
- text as long as the user didn't enter any text
-
- @short LineEdit with customizable "Click here" text
- @author Daniel Molkentin
-*/
-class ClickLineEdit : public QLineEdit
+#include <QPushButton>
+#include <QLabel>
+#include <QStackedWidget>
+#include <QSpinBox>
+#include <QCheckBox>
+#include <QList>
+#include <QToolButton>
+#include <QDial>
+
+#include "animators.hpp"
+#include "qt4.hpp"
+
+class QPixmap;
+class QWidget;
+
+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 );
+ QSize sizeHint() const Q_DECL_OVERRIDE { return iconSize(); }
protected:
- virtual void paintEvent( QPaintEvent *e );
- virtual void dropEvent( QDropEvent *ev );
- virtual void focusInEvent( QFocusEvent *ev );
- virtual void focusOutEvent( QFocusEvent *ev );
-private:
- QString mClickMessage;
- bool mDrawClickMsg;
+ void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
};
-class QToolButton;
-class SearchLineEdit : public QFrame
+class VLCQDial : public QDial
{
Q_OBJECT
public:
- SearchLineEdit( QWidget *parent );
+ VLCQDial( QWidget *parent = NULL );
+protected:
+ void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
+};
+class QToolButtonExt : public QToolButton
+{
+ Q_OBJECT
+public:
+ QToolButtonExt( QWidget *parent = 0, int ms = 0 );
private:
- ClickLineEdit *searchLine;
- QToolButton *clearButton;
-
+ bool shortClick;
+ bool longClick;
private slots:
- void updateText( const QString );
-
+ void releasedSlot();
+ void clickedSlot();
signals:
- void textChanged( const QString );
+ void shortClicked();
+ void longClicked();
};
-/*****************************************************************
- * Custom views
- *****************************************************************/
-#include <QMouseEvent>
-#include <QTreeView>
-#include <QCursor>
-#include <QPoint>
-#include <QModelIndex>
-
-/**
- Special QTreeView that can emit rightClicked()
- */
-class QVLCTreeView : public QTreeView
+class QElidingLabel : public QLabel
{
- Q_OBJECT;
public:
- void mouseReleaseEvent( QMouseEvent* e )
+ QElidingLabel( const QString &s = QString(),
+ Qt::TextElideMode mode = Qt::ElideRight,
+ QWidget * parent = NULL );
+ void setElideMode( Qt::TextElideMode );
+protected:
+ void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
+private:
+ Qt::TextElideMode elideMode;
+};
+
+
+class QVLCStackedWidget : public QStackedWidget
+{
+public:
+ QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
+ QSize minimumSizeHint () const
{
- if( e->button() & Qt::RightButton )
- {
- emit rightClicked( indexAt( QPoint( e->x(), e->y() ) ),
- QCursor::pos() );
- }
- QTreeView::mouseReleaseEvent( e );
+ return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
}
+};
- void mousePressEvent( QMouseEvent* e )
+class QVLCDebugLevelSpinBox : public QSpinBox
+{
+ Q_OBJECT
+public:
+ QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
+protected:
+ QString textFromValue( int ) const Q_DECL_OVERRIDE;
+ /* QVLCDebugLevelSpinBox is read-only */
+ int valueFromText( const QString& ) const Q_DECL_OVERRIDE { 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
+
+public:
+ SpinningIcon( QWidget *parent );
+ void play( int loops = -1, int fps = 0 )
{
- if( e->button() & Qt::LeftButton )
- {
- if( !indexAt( QPoint( e->x(), e->y() ) ).isValid() )
- clearSelection();
- }
- QTreeView::mousePressEvent( e );
+ animator->setLoopCount( loops );
+ if ( fps ) animator->setFps( fps );
+ animator->start();
}
+ void stop() { animator->stop(); }
+ bool isPlaying() { return animator->state() == PixmapAnimator::Running; }
+private:
+ PixmapAnimator *animator;
+};
-signals:
- void rightClicked( QModelIndex, QPoint );
+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
-