1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2012 Teo Mrnjavac <teo@kde.org>
4
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
6
* Tomahawk is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Tomahawk is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
20
#ifndef SLIDESWITCHBUTTON_H
21
#define SLIDESWITCHBUTTON_H
23
#include <QPushButton>
27
#include <QWeakPointer>
31
class QPropertyAnimation;
33
class SlideSwitchButton : public QPushButton
36
Q_PROPERTY( qreal knobX READ knobX WRITE setKnobX )
37
Q_PROPERTY( QColor baseColorTop READ baseColorTop WRITE setBaseColorTop )
38
Q_PROPERTY( QColor baseColorBottom READ baseColorBottom WRITE setBaseColorBottom )
40
explicit SlideSwitchButton( QWidget* parent = 0 );
41
explicit SlideSwitchButton( const QString& checkedText,
42
const QString& uncheckedText,
43
QWidget* parent = 0 );
47
virtual QSize sizeHint() const;
48
virtual QSize minimumSizeHint() const;
50
//the back check-state cannot be changed by the user, only programmatically
51
//to notify that the user-requested operation has completed
52
void setBackChecked( bool state );
53
bool backChecked() const;
55
void setKnobX( qreal x );
58
void setBaseColorTop( const QColor& color );
59
QColor baseColorTop() const;
61
void setBaseColorBottom( const QColor& color );
62
QColor baseColorBottom() const;
65
void paintEvent( QPaintEvent* event );
67
virtual void mousePressEvent( QMouseEvent* e );
68
virtual void mouseReleaseEvent( QMouseEvent* e );
69
virtual void mouseMoveEvent(QMouseEvent* e);
71
void onCheckedStateChanged();
78
QString m_checkedText;
79
QString m_uncheckedText;
80
QColor m_baseColorTop, m_baseColorBottom;
82
QColor m_backUncheckedColorTop, m_backUncheckedColorBottom;
83
QColor m_backCheckedColorTop, m_backCheckedColorBottom;
84
QFont m_textFont; //needed for sizeHint
88
QPoint m_mouseDownPos;
90
QWeakPointer<QPropertyAnimation> m_backTopAnimation;
91
QWeakPointer<QPropertyAnimation> m_backBottomAnimation;
92
QWeakPointer<QPropertyAnimation> m_knobAnimation;
95
#endif // SLIDESWITCHBUTTON_H