1 /*****************************************************************************
2 * customwidgets.hpp: Custom widgets
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
8 * Authors: Clément Stenac <zorglub@videolan.org>
9 * The "ClickLineEdit" control is based on code by Daniel Molkentin
10 * <molkentin@kde.org> for libkdepim
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifndef _CUSTOMWIDGETS_H_
28 #define _CUSTOMWIDGETS_H_
31 #include <QPushButton>
33 #include <QStackedWidget>
38 #include <QToolButton>
39 #include <QAbstractAnimation>
44 class QFramelessButton : public QPushButton
48 QFramelessButton( QWidget *parent = NULL );
49 virtual QSize sizeHint() const { return iconSize(); }
51 virtual void paintEvent( QPaintEvent * event );
54 class QToolButtonExt : public QToolButton
58 QToolButtonExt( QWidget *parent = 0, int ms = 0 );
70 class QElidingLabel : public QLabel
73 QElidingLabel( const QString &s = QString(),
74 Qt::TextElideMode mode = Qt::ElideRight,
75 QWidget * parent = NULL );
76 void setElideMode( Qt::TextElideMode );
78 virtual void paintEvent( QPaintEvent * event );
80 Qt::TextElideMode elideMode;
84 class QVLCStackedWidget : public QStackedWidget
87 QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
88 QSize minimumSizeHint () const
90 return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
94 class QVLCDebugLevelSpinBox : public QSpinBox
98 QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
100 virtual QString textFromValue( int ) const;
101 /* QVLCDebugLevelSpinBox is read-only */
102 virtual int valueFromText( const QString& ) const { return -1; }
105 /** An animated pixmap
106 * Use this widget to display an animated icon based on a series of
107 * pixmaps. The pixmaps will be stored in memory and should be kept small.
108 * First, create the widget, add frames and then start playing. Looping
111 class PixmapAnimator : public QAbstractAnimation
116 PixmapAnimator( QWidget *parent, QList<QString> _frames );
117 void setFps( int _fps ) { fps = _fps; interval = 1000.0 / fps; };
118 virtual int duration() const { return interval * pixmaps.count(); };
119 virtual ~PixmapAnimator() { qDeleteAll( pixmaps ); };
120 QPixmap *getPixmap() { return currentPixmap; }
122 virtual void updateCurrentTime ( int msecs );
123 QList<QPixmap *> pixmaps;
124 QPixmap *currentPixmap;
130 void pixmapReady( const QPixmap & );
133 /** This spinning icon, to the colors of the VLC cone, will show
134 * that there is some background activity running
136 class SpinningIcon : public QLabel
141 SpinningIcon( QWidget *parent );
142 void play( int loops = -1, int fps = 0 )
144 animator->setLoopCount( loops );
145 if ( fps ) animator->setFps( fps );
148 void stop() { animator->stop(); }
149 bool isPlaying() { return animator->state() == PixmapAnimator::Running; }
151 PixmapAnimator *animator;
154 class YesNoCheckBox : public QCheckBox
158 YesNoCheckBox( QWidget *parent );
161 /* VLC Key/Wheel hotkeys interactions */
167 int qtKeyModifiersToVLC( QInputEvent* e );
168 int qtEventToVLCKey( QKeyEvent *e );
169 int qtWheelEventToVLCKey( QWheelEvent *e );
170 QString VLCKeyToString( unsigned val );