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>
40 #include "animators.hpp"
46 class QFramelessButton : public QPushButton
50 QFramelessButton( QWidget *parent = NULL );
51 QSize sizeHint() const Q_DECL_OVERRIDE { return iconSize(); }
53 void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
56 class VLCQDial : public QDial
60 VLCQDial( QWidget *parent = NULL );
62 void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
65 class QToolButtonExt : public QToolButton
69 QToolButtonExt( QWidget *parent = 0, int ms = 0 );
81 class QElidingLabel : public QLabel
84 QElidingLabel( const QString &s = QString(),
85 Qt::TextElideMode mode = Qt::ElideRight,
86 QWidget * parent = NULL );
87 void setElideMode( Qt::TextElideMode );
89 void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
91 Qt::TextElideMode elideMode;
95 class QVLCStackedWidget : public QStackedWidget
98 QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
99 QSize minimumSizeHint () const
101 return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
105 class QVLCDebugLevelSpinBox : public QSpinBox
109 QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
111 QString textFromValue( int ) const Q_DECL_OVERRIDE;
112 /* QVLCDebugLevelSpinBox is read-only */
113 int valueFromText( const QString& ) const Q_DECL_OVERRIDE { return -1; }
116 /** This spinning icon, to the colors of the VLC cone, will show
117 * that there is some background activity running
119 class SpinningIcon : public QLabel
124 SpinningIcon( QWidget *parent );
125 void play( int loops = -1, int fps = 0 )
127 animator->setLoopCount( loops );
128 if ( fps ) animator->setFps( fps );
131 void stop() { animator->stop(); }
132 bool isPlaying() { return animator->state() == PixmapAnimator::Running; }
134 PixmapAnimator *animator;
137 class YesNoCheckBox : public QCheckBox
141 YesNoCheckBox( QWidget *parent );
144 /* VLC Key/Wheel hotkeys interactions */
150 int qtKeyModifiersToVLC( QInputEvent* e );
151 int qtEventToVLCKey( QKeyEvent *e );
152 int qtWheelEventToVLCKey( QWheelEvent *e );
153 QString VLCKeyToString( unsigned val, bool );