customwidgets.hpp 4.09 KB
Newer Older
Clément Stenac's avatar
Clément Stenac committed
1
/*****************************************************************************
Pere Orga's avatar
Pere Orga committed
2
 * customwidgets.hpp: Custom widgets
Clément Stenac's avatar
Clément Stenac committed
3 4 5
 ****************************************************************************
 * Copyright (C) 2006 the VideoLAN team
 * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
Pierre's avatar
Pierre committed
6
 * $Id$
Clément Stenac's avatar
Clément Stenac committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 * The "ClickLineEdit" control is based on code by  Daniel Molkentin
 * <molkentin@kde.org> for libkdepim
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
25
 *****************************************************************************/
Clément Stenac's avatar
Clément Stenac committed
26

27 28
#ifndef VLC_QT_CUSTOMWIDGETS_HPP_
#define VLC_QT_CUSTOMWIDGETS_HPP_
Clément Stenac's avatar
Clément Stenac committed
29 30

#include <QLineEdit>
31
#include <QPushButton>
Jakob Leben's avatar
Jakob Leben committed
32
#include <QLabel>
33
#include <QStackedWidget>
34
#include <QSpinBox>
35
#include <QCheckBox>
36
#include <QList>
37
#include <QToolButton>
38
#include <QDial>
39

40
#include "animators.hpp"
41
#include "qt.hpp"
42

43
class QWidget;
Clément Stenac's avatar
Clément Stenac committed
44

45
class QFramelessButton : public QPushButton
46
{
47
    Q_OBJECT
48
public:
49
    QFramelessButton( QWidget *parent = NULL );
50
    QSize sizeHint() const Q_DECL_OVERRIDE { return iconSize(); }
Jakob Leben's avatar
Jakob Leben committed
51
protected:
52
    void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
53
};
54

55 56 57 58 59 60
class VLCQDial : public QDial
{
    Q_OBJECT
public:
    VLCQDial( QWidget *parent = NULL );
protected:
61
    void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
62 63
};

64 65 66 67
class QToolButtonExt : public QToolButton
{
    Q_OBJECT
public:
68
    QToolButtonExt( QWidget *parent = 0, int ms = 0 );
69
private:
Cheng Sun's avatar
Cheng Sun committed
70
    bool shortClick;
71 72 73
    bool longClick;
private slots:
    void releasedSlot();
Cheng Sun's avatar
Cheng Sun committed
74
    void clickedSlot();
75 76 77 78
signals:
    void shortClicked();
    void longClicked();
};
79

80
class QElidingLabel : public QLabel
Jakob Leben's avatar
Jakob Leben committed
81 82
{
public:
83
    QElidingLabel( const QString &s = QString(),
Jakob Leben's avatar
Jakob Leben committed
84 85 86
                      Qt::TextElideMode mode = Qt::ElideRight,
                      QWidget * parent = NULL );
    void setElideMode( Qt::TextElideMode );
87
protected:
88
    void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
Jakob Leben's avatar
Jakob Leben committed
89 90 91 92
private:
    Qt::TextElideMode elideMode;
};

93

94 95 96 97 98 99 100 101 102 103
class QVLCStackedWidget : public QStackedWidget
{
public:
    QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
    QSize minimumSizeHint () const
    {
        return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
    }
};

104
class QVLCDebugLevelSpinBox : public QSpinBox
105 106 107
{
    Q_OBJECT
public:
108
    QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
109
protected:
110
    QString textFromValue( int ) const Q_DECL_OVERRIDE;
111
    /* QVLCDebugLevelSpinBox is read-only */
112
    int valueFromText( const QString& ) const Q_DECL_OVERRIDE { return -1; }
113 114
};

115 116 117 118
/** This spinning icon, to the colors of the VLC cone, will show
 * that there is some background activity running
 **/
class SpinningIcon : public QLabel
119 120 121 122
{
    Q_OBJECT

public:
123 124 125 126 127 128 129 130 131 132 133
    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;
134 135
};

136 137 138 139 140 141 142
class YesNoCheckBox : public QCheckBox
{
    Q_OBJECT
public:
    YesNoCheckBox( QWidget *parent );
};

143 144
/* VLC Key/Wheel hotkeys interactions */

145
class QKeyEvent;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
146
class QWheelEvent;
147
class QInputEvent;
148

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
149
int qtKeyModifiersToVLC( QInputEvent* e );
150
int qtEventToVLCKey( QKeyEvent *e );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
151
int qtWheelEventToVLCKey( QWheelEvent *e );
152
QString VLCKeyToString( unsigned val, bool );
153

154
#endif