-/* This file is part of the KDE project
- Copyright (C) 2007 Matthias Kretz <kretz@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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
+/*
+ SPDX-FileCopyrightText: 2007 Matthias Kretz <kretz@kde.org>
+ SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "phononwidget.h"
-#include <KIconLoader>
#include <KLocalizedString>
-#include <Phonon/AudioOutput>
-#include <Phonon/MediaObject>
-#include <Phonon/SeekSlider>
-#include <Phonon/VideoWidget>
+#include <phonon/AudioOutput>
+#include <phonon/MediaObject>
+#include <phonon/SeekSlider>
+#include <phonon/VideoWidget>
#include <QShowEvent>
+#include <QStyle>
#include <QToolButton>
#include <QVBoxLayout>
{
Q_OBJECT
- public:
- EmbeddedVideoPlayer(QWidget *parent = nullptr) :
- Phonon::VideoWidget(parent)
- {
- }
+public:
+ EmbeddedVideoPlayer(QWidget *parent = nullptr)
+ : Phonon::VideoWidget(parent)
+ {
+ }
- void setSizeHint(const QSize& size)
- {
- m_sizeHint = size;
- updateGeometry();
- }
+ void setSizeHint(const QSize &size)
+ {
+ m_sizeHint = size;
+ updateGeometry();
+ }
- QSize sizeHint() const override
- {
- return m_sizeHint.isValid() ? m_sizeHint : Phonon::VideoWidget::sizeHint();
- }
+ QSize sizeHint() const override
+ {
+ return m_sizeHint.isValid() ? m_sizeHint : Phonon::VideoWidget::sizeHint();
+ }
- private:
- QSize m_sizeHint;
+private:
+ QSize m_sizeHint;
};
PhononWidget::PhononWidget(QWidget *parent)
- : QWidget(parent),
- m_url(),
- m_playButton(nullptr),
- m_pauseButton(nullptr),
- m_topLayout(nullptr),
- m_media(nullptr),
- m_seekSlider(nullptr),
- m_audioOutput(nullptr),
- m_videoPlayer(nullptr)
+ : QWidget(parent)
+ , m_url()
+ , m_playButton(nullptr)
+ , m_pauseButton(nullptr)
+ , m_topLayout(nullptr)
+ , m_media(nullptr)
+ , m_seekSlider(nullptr)
+ , m_audioOutput(nullptr)
+ , m_videoPlayer(nullptr)
{
}
{
Q_UNUSED(object)
if (event->type() == QEvent::MouseButtonPress) {
- const QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton) {
// toggle playback
togglePlayback();
return false;
}
-void PhononWidget::setVideoSize(const QSize& size)
+void PhononWidget::setVideoSize(const QSize &size)
{
if (m_videoSize != size) {
m_videoSize = size;
m_topLayout->addLayout(controlsLayout);
- const int smallIconSize = IconSize(KIconLoader::Small);
+ const int smallIconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
const QSize buttonSize(smallIconSize, smallIconSize);
m_playButton->setToolTip(i18n("play"));
{
if (!m_media) {
m_media = new Phonon::MediaObject(this);
- connect(m_media, &Phonon::MediaObject::stateChanged,
- this, &PhononWidget::stateChanged);
- connect(m_media, &Phonon::MediaObject::finished,
- this, &PhononWidget::finished);
+ connect(m_media, &Phonon::MediaObject::stateChanged, this, &PhononWidget::stateChanged);
+ connect(m_media, &Phonon::MediaObject::finished, this, &PhononWidget::finished);
m_seekSlider->setMediaObject(m_media);
}
}
if (m_isVideo) {
- emit hasVideoChanged(true);
+ Q_EMIT hasVideoChanged(true);
}
if (m_url != m_media->currentSource().url()) {
{
if (m_isVideo) {
m_videoPlayer->hide();
- emit hasVideoChanged(false);
+ Q_EMIT hasVideoChanged(false);
}
}
if (m_media) {
m_media->stop();
m_videoPlayer->hide();
- emit hasVideoChanged(false);
+ Q_EMIT hasVideoChanged(false);
}
}
}
}
+#include "moc_phononwidget.cpp"
#include "phononwidget.moc"