X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/eaec53a7af4e098acd957a274f059920d569e0be..5360bc3ab328c8b1161b0c5df9c5785829a3e880:/src/panels/information/phononwidget.cpp diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp index e301df270..fa4b9e226 100644 --- a/src/panels/information/phononwidget.cpp +++ b/src/panels/information/phononwidget.cpp @@ -1,26 +1,11 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - 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 + SPDX-License-Identifier: GPL-2.0-or-later */ #include "phononwidget.h" -#include #include #include #include @@ -28,6 +13,7 @@ #include #include +#include #include #include @@ -60,7 +46,7 @@ PhononWidget::PhononWidget(QWidget *parent) : QWidget(parent), m_url(), m_playButton(nullptr), - m_stopButton(nullptr), + m_pauseButton(nullptr), m_topLayout(nullptr), m_media(nullptr), m_seekSlider(nullptr), @@ -100,6 +86,15 @@ void PhononWidget::clearUrl() m_url.clear(); } +void PhononWidget::togglePlayback() +{ + if (m_media && m_media->state() == Phonon::State::PlayingState) { + m_media->pause(); + } else { + play(); + } +} + bool PhononWidget::eventFilter(QObject *object, QEvent *event) { Q_UNUSED(object) @@ -107,11 +102,7 @@ bool PhononWidget::eventFilter(QObject *object, QEvent *event) const QMouseEvent *mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::LeftButton) { // toggle playback - if (m_media && m_media->state() == Phonon::State::PlayingState) { - m_media->pause(); - } else { - play(); - } + togglePlayback(); return true; } } @@ -147,16 +138,16 @@ void PhononWidget::showEvent(QShowEvent *event) controlsLayout->setSpacing(0); m_playButton = new QToolButton(this); - m_stopButton = new QToolButton(this); + m_pauseButton = new QToolButton(this); m_seekSlider = new Phonon::SeekSlider(this); controlsLayout->addWidget(m_playButton); - controlsLayout->addWidget(m_stopButton); + controlsLayout->addWidget(m_pauseButton); controlsLayout->addWidget(m_seekSlider); 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")); @@ -165,12 +156,12 @@ void PhononWidget::showEvent(QShowEvent *event) m_playButton->setAutoRaise(true); connect(m_playButton, &QToolButton::clicked, this, &PhononWidget::play); - m_stopButton->setToolTip(i18n("stop")); - m_stopButton->setIconSize(buttonSize); - m_stopButton->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-stop"))); - m_stopButton->setAutoRaise(true); - m_stopButton->hide(); - connect(m_stopButton, &QToolButton::clicked, this, &PhononWidget::stop); + m_pauseButton->setToolTip(i18n("pause")); + m_pauseButton->setIconSize(buttonSize); + m_pauseButton->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-pause"))); + m_pauseButton->setAutoRaise(true); + m_pauseButton->hide(); + connect(m_pauseButton, &QToolButton::clicked, this, &PhononWidget::togglePlayback); m_seekSlider->setIconVisible(false); @@ -196,10 +187,10 @@ void PhononWidget::stateChanged(Phonon::State newstate) case Phonon::PlayingState: case Phonon::BufferingState: m_playButton->hide(); - m_stopButton->show(); + m_pauseButton->show(); break; default: - m_stopButton->hide(); + m_pauseButton->hide(); m_playButton->show(); break; }