slideraction.cpp 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/**
 * Copyright (C) 2002-2004 Scott Wheeler <wheeler@kde.org>
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */
16

17 18
#include "slideraction.h"

19
#include <ktoolbar.h>
20
#include <klocale.h>
21
#include <kiconloader.h>
22
#include <kactioncollection.h>
23 24
#include <kdebug.h>

Laurent Montel's avatar
Laurent Montel committed
25 26 27 28
#include <QMouseEvent>
#include <QWheelEvent>
#include <QFocusEvent>
#include <QBoxLayout>
29

30 31 32 33 34 35
#include "volumepopupbutton.h"
#include "slider.h"
#include "playermanager.h"
#include "juk.h"

TrackPositionAction::TrackPositionAction(const QString &text, QObject *parent) :
36
    KAction(text, parent)
37
{
38

39 40
}

41 42 43 44 45
Slider *TrackPositionAction::slider() const
{
    return parent()->findChild<Slider *>("timeSlider");
}

46
QWidget *TrackPositionAction::createWidget(QWidget *parent)
47
{
48 49
    Slider *slider = new TimeSlider(parent);
    slider->setObjectName(QLatin1String("timeSlider"));
50

51
    PlayerManager *player = JuK::JuKInstance()->playerManager();
52

53
    connect(player, SIGNAL(tick(int)), slider, SLOT(setValue(int)));
54
    connect(player, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
55
    connect(player, SIGNAL(totalTimeChanged(int)), this, SLOT(totalTimeChanged(int)));
56
    connect(slider, SIGNAL(sliderMoved(int)), player, SLOT(seek(int)));
57

58
    return slider;
59 60
}

61
void TrackPositionAction::seekableChanged(bool seekable)
62
{
63 64
    slider()->setEnabled(seekable);
    slider()->setToolTip(seekable ?
65 66
                         QString() :
                         i18n("Seeking is not supported in this file with your audio settings."));
67 68
}

69 70 71 72 73
void TrackPositionAction::totalTimeChanged(int ms)
{
    slider()->setRange(0, ms);
}

74 75 76
VolumeAction::VolumeAction(const QString &text, QObject *parent) :
    KAction(text, parent),
    m_button(0)
77
{
78 79 80

}

81
QWidget *VolumeAction::createWidget(QWidget *parent)
82
{
83 84
    m_button = new VolumePopupButton(parent);
    return m_button;
85 86
}

87
// vim: set et sw=4 tw=0 sta: