1
/*  This file is part of the KDE project
2
    Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
3
4
    This library is free software; you can redistribute it and/or
5
    modify it under the terms of the GNU Lesser General Public
6
    License as published by the Free Software Foundation; either
7
    version 2.1 of the License, or (at your option) version 3, or any
8
    later version accepted by the membership of KDE e.V. (or its
9
    successor approved by the membership of KDE e.V.), Nokia Corporation 
10
    (or its successors, if any) and the KDE Free Qt Foundation, which shall
11
    act as a proxy defined in Section 6 of version 3 of the license.
12
13
    This library is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
    Lesser General Public License for more details.
17
18
    You should have received a copy of the GNU Lesser General Public 
19
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
21
*/
22
23
#ifndef SEEKSLIDER_P_H
24
#define SEEKSLIDER_P_H
25
26
#include "seekslider.h"
27
#include "swiftslider_p.h"
28
#include <QtGui/QBoxLayout>
29
#include <QtGui/QLabel>
30
#include <QtGui/QPixmap>
31
#include <QtGui/QIcon>
32
#include <QtGui/QStyle>
33
#include "factory_p.h"
34
#include <QtCore/QPointer>
35
#include "platform_p.h"
36
37
QT_BEGIN_NAMESPACE
38
39
#ifndef QT_NO_PHONON_SEEKSLIDER
40
41
namespace Phonon
42
{
43
class MediaObject;
44
class SeekSliderPrivate
45
{
46
    Q_DECLARE_PUBLIC(SeekSlider)
47
    protected:
48
        SeekSliderPrivate(SeekSlider *parent)
49
            : layout(QBoxLayout::LeftToRight, parent),
50
            slider(Qt::Horizontal, parent),
51
            iconLabel(parent),
52
            ticking(false)
53
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
54
            ,icon(Platform::icon(QLatin1String("player-time"), parent->style()))
55
#endif //QT_NO_PHONON_PLATFORMPLUGIN
56
        {
57
            const int e = parent->style()->pixelMetric(QStyle::PM_ButtonIconSize);
58
            iconSize = QSize(e, e);
59
60
            slider.setPageStep(5000); // 5 sec
61
            slider.setSingleStep(500); // 0.5 sec
62
63
            layout.setMargin(0);
64
            layout.setSpacing(2);
65
            layout.addWidget(&iconLabel, 0, Qt::AlignVCenter);
66
            layout.addWidget(&slider, 0, Qt::AlignVCenter);
67
68
            setEnabled(false);
69
70
            if (icon.isNull()) {
71
                iconLabel.setVisible(false);
72
            }
73
        }
74
75
        SeekSlider *q_ptr;
76
77
    private:
78
        void setEnabled(bool);
79
        void _k_stateChanged(Phonon::State);
80
        void _k_seek(int);
81
        void _k_tick(qint64);
82
        void _k_length(qint64);
83
        void _k_seekableChanged(bool);
84
        void _k_currentSourceChanged();
85
86
        QBoxLayout layout;
87
        SwiftSlider slider;
88
        QLabel iconLabel;
89
        QPointer<MediaObject> media;
90
        bool ticking;
91
        QIcon icon;
92
        QSize iconSize;
93
};
94
} // namespace Phonon
95
96
#endif //QT_NO_PHONON_SEEKSLIDER
97
98
QT_END_NAMESPACE
99
100
#endif // SEEKSLIDER_P_H
101
// vim: sw=4 ts=4 tw=80