]>
cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/phononwidget.cpp
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "phononwidget.h"
23 #include <Phonon/Global>
24 #include <Phonon/MediaObject>
25 #include <Phonon/SeekSlider>
26 #include <QtGui/QHBoxLayout>
27 #include <QtGui/QToolButton>
32 PhononWidget::PhononWidget(QWidget
*parent
)
36 QHBoxLayout
*innerLayout
= new QHBoxLayout(this);
37 innerLayout
->setMargin(0);
38 innerLayout
->setSpacing(0);
39 m_playButton
= new QToolButton(this);
40 m_stopButton
= new QToolButton(this);
41 m_seekSlider
= new Phonon::SeekSlider(this);
42 innerLayout
->addWidget(m_playButton
);
43 innerLayout
->addWidget(m_stopButton
);
44 innerLayout
->addWidget(m_seekSlider
);
46 m_playButton
->setToolTip(i18n("play"));
47 m_playButton
->setIconSize(QSize(16, 16));
48 m_playButton
->setIcon(KIcon("media-playback-start"));
49 m_stopButton
->setToolTip(i18n("stop"));
50 m_stopButton
->setIconSize(QSize(16, 16));
51 m_stopButton
->setIcon(KIcon("media-playback-stop"));
53 m_seekSlider
->setIconVisible(false);
56 void PhononWidget::setUrl(const KUrl
&url
)
59 m_media
->setCurrentSource(url
);
61 m_media
= Phonon::createPlayer(Phonon::MusicCategory
, url
);
62 m_media
->setParent(this);
63 connect(m_playButton
, SIGNAL(clicked()), m_media
, SLOT(play()));
64 connect(m_stopButton
, SIGNAL(clicked()), m_media
, SLOT(stop()));
65 connect(m_media
, SIGNAL(stateChanged(Phonon::State
, Phonon::State
)), SLOT(stateChanged(Phonon::State
)));
66 m_seekSlider
->setMediaObject(m_media
);
70 void PhononWidget::stateChanged(Phonon::State newstate
)
72 setUpdatesEnabled(false);
74 case Phonon::PlayingState
:
75 case Phonon::BufferingState
:
84 setUpdatesEnabled(true);