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>
37 #include <QToolButton>
38 #include <QAbstractAnimation>
42 class QFramelessButton : public QPushButton
46 QFramelessButton( QWidget *parent = NULL );
47 virtual QSize sizeHint() const { return iconSize(); }
49 virtual void paintEvent( QPaintEvent * event );
52 class QToolButtonExt : public QToolButton
56 QToolButtonExt( QWidget *parent = 0, int ms = 0 );
68 class QElidingLabel : public QLabel
71 QElidingLabel( const QString &s = QString(),
72 Qt::TextElideMode mode = Qt::ElideRight,
73 QWidget * parent = NULL );
74 void setElideMode( Qt::TextElideMode );
76 virtual void paintEvent( QPaintEvent * event );
78 Qt::TextElideMode elideMode;
82 class QVLCStackedWidget : public QStackedWidget
85 QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
86 QSize minimumSizeHint () const
88 return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
92 class QVLCDebugLevelSpinBox : public QSpinBox
96 QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
98 virtual QString textFromValue( int ) const;
99 /* QVLCDebugLevelSpinBox is read-only */
100 virtual int valueFromText( const QString& ) const { return -1; }
103 /** An animated pixmap
104 * Use this widget to display an animated icon based on a series of
105 * pixmaps. The pixmaps will be stored in memory and should be kept small.
106 * First, create the widget, add frames and then start playing. Looping
109 class PixmapAnimator : public QAbstractAnimation
114 PixmapAnimator( QWidget *parent, QList<QString> _frames );
115 void setFps( int _fps ) { fps = _fps; interval = 1000.0 / fps; };
116 virtual int duration() const { return interval * pixmaps.count(); };
117 virtual ~PixmapAnimator() { while( pixmaps.count() ) pixmaps.erase( pixmaps.end() ); };
118 QPixmap *getPixmap() { return currentPixmap; }
120 virtual void updateCurrentTime ( int msecs );
121 QList<QPixmap *> pixmaps;
122 QPixmap *currentPixmap;
128 void pixmapReady( const QPixmap & );
131 /** This spinning icon, to the colors of the VLC cone, will show
132 * that there is some background activity running
134 class SpinningIcon : public QLabel
139 SpinningIcon( QWidget *parent );
140 void play( int loops = -1, int fps = 0 )
142 animator->setLoopCount( loops );
143 if ( fps ) animator->setFps( fps );
146 void stop() { animator->stop(); }
147 bool isPlaying() { return animator->state() == PixmapAnimator::Running; }
149 PixmapAnimator *animator;
152 /* VLC Key/Wheel hotkeys interactions */
158 int qtKeyModifiersToVLC( QInputEvent* e );
159 int qtEventToVLCKey( QKeyEvent *e );
160 int qtWheelEventToVLCKey( QWheelEvent *e );
161 QString VLCKeyToString( unsigned val );