Commit d5c88c44 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

fixes warnings reported by clazy checker tool

Summary: fixes warnings reported by clazy checker tool

Test Plan: automatic tests are still working

Reviewers: #elisa, astippich

Reviewed By: #elisa, astippich

Differential Revision: https://phabricator.kde.org/D10169
parent b7658aef
......@@ -60,7 +60,6 @@ qreal AudioWrapper::volume() const
{
auto realVolume = static_cast<qreal>(d->mPlayer.volume() / 100.0);
auto userVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::LogarithmicVolumeScale));
auto decibelVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::DecibelVolumeScale));
return userVolume * 100.0;
}
......@@ -117,7 +116,6 @@ void AudioWrapper::setMuted(bool muted)
void AudioWrapper::setVolume(qreal volume)
{
auto realVolume = static_cast<qreal>(QAudio::convertVolume(volume / 100.0, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale));
auto decibelVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::DecibelVolumeScale));
d->mPlayer.setVolume(qRound(realVolume * 100));
}
......
......@@ -101,7 +101,8 @@ void KCMElisaLocalFile::setRootPath(QStringList rootPath)
}
if (mRootPath.isEmpty()) {
for (const auto &musicPath : QStandardPaths::standardLocations(QStandardPaths::MusicLocation)) {
auto systemMusicPaths = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
for (const auto &musicPath : qAsConst(systemMusicPaths)) {
mRootPath.push_back(musicPath);
}
}
......
......@@ -242,14 +242,14 @@ public Q_SLOTS:
private Q_SLOTS:
bool rowHasHeader(int row) const;
void loadPlayListLoaded();
void loadPlayListLoadFailed();
private:
bool rowHasHeader(int row) const;
void resetCurrentTrack();
void notifyCurrentTrackChanged();
......
......@@ -49,12 +49,12 @@ bool MediaPlayer2::HasTrackList() const
return false;
}
void MediaPlayer2::Quit() const
void MediaPlayer2::Quit()
{
QCoreApplication::quit();
}
void MediaPlayer2::Raise() const
void MediaPlayer2::Raise()
{
emit raisePlayer();
}
......
......@@ -31,15 +31,15 @@ class MediaPlayer2 : public QDBusAbstractAdaptor
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2") // Docs: http://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html
Q_PROPERTY(bool CanQuit READ CanQuit)
Q_PROPERTY(bool CanRaise READ CanRaise)
Q_PROPERTY(bool HasTrackList READ HasTrackList)
Q_PROPERTY(bool CanQuit READ CanQuit CONSTANT)
Q_PROPERTY(bool CanRaise READ CanRaise CONSTANT)
Q_PROPERTY(bool HasTrackList READ HasTrackList CONSTANT)
Q_PROPERTY(QString Identity READ Identity)
Q_PROPERTY(QString DesktopEntry READ DesktopEntry)
Q_PROPERTY(QString Identity READ Identity CONSTANT)
Q_PROPERTY(QString DesktopEntry READ DesktopEntry CONSTANT)
Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes)
Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes)
Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes CONSTANT)
Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes CONSTANT)
public:
explicit MediaPlayer2(QObject* parent = nullptr);
......@@ -56,11 +56,11 @@ public:
QStringList SupportedMimeTypes() const;
public Q_SLOTS:
void Quit() const;
void Raise() const;
void Quit();
void Raise();
Q_SIGNALS:
void raisePlayer() const;
void raisePlayer();
};
......
......@@ -98,7 +98,7 @@ bool MediaPlayer2Player::CanGoNext() const
return m_canGoNext;
}
void MediaPlayer2Player::Next() const
void MediaPlayer2Player::Next()
{
emit next();
......@@ -112,7 +112,7 @@ bool MediaPlayer2Player::CanGoPrevious() const
return m_canGoPrevious;
}
void MediaPlayer2Player::Previous() const
void MediaPlayer2Player::Previous()
{
emit previous();
......@@ -126,7 +126,7 @@ bool MediaPlayer2Player::CanPause() const
return !m_canPlay;
}
void MediaPlayer2Player::Pause() const
void MediaPlayer2Player::Pause()
{
if (m_playListControler) {
m_manageAudioPlayer->playPause();
......@@ -142,7 +142,7 @@ void MediaPlayer2Player::PlayPause()
}
}
void MediaPlayer2Player::Stop() const
void MediaPlayer2Player::Stop()
{
emit stop();
}
......@@ -152,7 +152,7 @@ bool MediaPlayer2Player::CanPlay() const
return m_canPlay;
}
void MediaPlayer2Player::Play() const
void MediaPlayer2Player::Play()
{
if (m_playListControler) {
m_manageAudioPlayer->playPause();
......@@ -229,7 +229,7 @@ bool MediaPlayer2Player::CanControl() const
return true;
}
void MediaPlayer2Player::Seek(qlonglong Offset) const
void MediaPlayer2Player::Seek(qlonglong Offset)
{
if (mediaPlayerPresent()) {
int offset = (m_position + Offset) / 1000;
......@@ -242,14 +242,14 @@ void MediaPlayer2Player::emitSeeked(int pos)
emit Seeked(qlonglong(pos) * 1000);
}
void MediaPlayer2Player::SetPosition(const QDBusObjectPath &trackId, qlonglong pos) const
void MediaPlayer2Player::SetPosition(const QDBusObjectPath &trackId, qlonglong pos)
{
if (trackId.path() == m_currentTrackId) {
m_manageAudioPlayer->playerSeek(pos / 1000);
}
}
void MediaPlayer2Player::OpenUri(const QString &uri) const
void MediaPlayer2Player::OpenUri(const QString &uri)
{
Q_UNUSED(uri);
}
......@@ -273,6 +273,9 @@ void MediaPlayer2Player::playControlEnabledChanged()
signalPropertiesChange(QStringLiteral("CanPause"), CanPause());
signalPropertiesChange(QStringLiteral("CanPlay"), CanPlay());
emit canPauseChanged();
emit canPlayChanged();
}
void MediaPlayer2Player::skipBackwardControlEnabledChanged()
......@@ -284,6 +287,7 @@ void MediaPlayer2Player::skipBackwardControlEnabledChanged()
m_canGoPrevious = m_manageMediaPlayerControl->skipBackwardControlEnabled();
signalPropertiesChange(QStringLiteral("CanGoPrevious"), CanGoPrevious());
emit canGoPreviousChanged();
}
void MediaPlayer2Player::skipForwardControlEnabledChanged()
......@@ -295,11 +299,13 @@ void MediaPlayer2Player::skipForwardControlEnabledChanged()
m_canGoNext = m_manageMediaPlayerControl->skipForwardControlEnabled();
signalPropertiesChange(QStringLiteral("CanGoNext"), CanGoNext());
emit canGoNextChanged();
}
void MediaPlayer2Player::playerPlaybackStateChanged()
{
signalPropertiesChange(QStringLiteral("PlaybackStatus"), PlaybackStatus());
emit playbackStatusChanged();
playerIsSeekableChanged();
}
......@@ -309,6 +315,7 @@ void MediaPlayer2Player::playerIsSeekableChanged()
m_playerIsSeekableChanged = m_manageAudioPlayer->playerIsSeekable();
signalPropertiesChange(QStringLiteral("CanSeek"), CanSeek());
emit canSeekChanged();
}
void MediaPlayer2Player::audioPositionChanged()
......@@ -342,6 +349,8 @@ void MediaPlayer2Player::setCurrentTrack(int newTrackPosition)
{
m_currentTrack = m_manageAudioPlayer->playerSource().toString();
m_currentTrackId = QDBusObjectPath(QStringLiteral("/org/kde/elisa/playlist/") + QString::number(newTrackPosition)).path();
emit currentTrackChanged();
}
QVariantMap MediaPlayer2Player::getMetadataOfCurrentTrack()
......@@ -369,11 +378,16 @@ void MediaPlayer2Player::setMediaPlayerPresent(int status)
{
if (m_mediaPlayerPresent != status) {
m_mediaPlayerPresent = status;
emit mediaPlayerPresentChanged();
signalPropertiesChange(QStringLiteral("CanGoNext"), CanGoNext());
signalPropertiesChange(QStringLiteral("CanGoPrevious"), CanGoPrevious());
signalPropertiesChange(QStringLiteral("CanPause"), CanPause());
signalPropertiesChange(QStringLiteral("CanPlay"), CanPlay());
emit canGoNextChanged();
emit canGoPreviousChanged();
emit canPauseChanged();
emit canPlayChanged();
}
}
......
......@@ -38,21 +38,21 @@ class MediaPlayer2Player : public QDBusAbstractAdaptor
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.Player") // Docs: http://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html
Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus NOTIFY playbackStatusChanged)
Q_PROPERTY(double Rate READ Rate WRITE setRate NOTIFY rateChanged)
Q_PROPERTY(QVariantMap Metadata READ Metadata)
Q_PROPERTY(QVariantMap Metadata READ Metadata NOTIFY playbackStatusChanged)
Q_PROPERTY(double Volume READ Volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(qlonglong Position READ Position WRITE setPropertyPosition)
Q_PROPERTY(double MinimumRate READ MinimumRate)
Q_PROPERTY(double MaximumRate READ MaximumRate)
Q_PROPERTY(bool CanGoNext READ CanGoNext)
Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
Q_PROPERTY(bool CanPlay READ CanPlay)
Q_PROPERTY(bool CanPause READ CanPause)
Q_PROPERTY(bool CanControl READ CanControl)
Q_PROPERTY(bool CanSeek READ CanSeek)
Q_PROPERTY(int currentTrack READ currentTrack WRITE setCurrentTrack)
Q_PROPERTY(int mediaPlayerPresent READ mediaPlayerPresent WRITE setMediaPlayerPresent)
Q_PROPERTY(qlonglong Position READ Position WRITE setPropertyPosition NOTIFY playbackStatusChanged)
Q_PROPERTY(double MinimumRate READ MinimumRate CONSTANT)
Q_PROPERTY(double MaximumRate READ MaximumRate CONSTANT)
Q_PROPERTY(bool CanGoNext READ CanGoNext NOTIFY canGoNextChanged)
Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious NOTIFY canGoPreviousChanged)
Q_PROPERTY(bool CanPlay READ CanPlay NOTIFY canPlayChanged)
Q_PROPERTY(bool CanPause READ CanPause NOTIFY canPauseChanged)
Q_PROPERTY(bool CanControl READ CanControl NOTIFY canControlChanged)
Q_PROPERTY(bool CanSeek READ CanSeek NOTIFY canSeekChanged)
Q_PROPERTY(int currentTrack READ currentTrack WRITE setCurrentTrack NOTIFY currentTrackChanged)
Q_PROPERTY(int mediaPlayerPresent READ mediaPlayerPresent WRITE setMediaPlayerPresent NOTIFY mediaPlayerPresentChanged)
public:
explicit MediaPlayer2Player(MediaPlayList *playListControler,
......@@ -80,28 +80,37 @@ public:
int mediaPlayerPresent() const;
Q_SIGNALS:
void Seeked(qlonglong Position) const;
void rateChanged(double newRate) const;
void volumeChanged(double newVol) const;
void next() const;
void previous() const;
void playPause() const;
void stop() const;
void Seeked(qlonglong Position);
void rateChanged(double newRate);
void volumeChanged(double newVol);
void playbackStatusChanged();
void canGoNextChanged();
void canGoPreviousChanged();
void canPlayChanged();
void canPauseChanged();
void canControlChanged();
void canSeekChanged();
void currentTrackChanged();
void mediaPlayerPresentChanged();
void next();
void previous();
void playPause();
void stop();
public Q_SLOTS:
void emitSeeked(int pos);
void Next() const;
void Previous() const;
void Pause() const;
void Next();
void Previous();
void Pause();
void PlayPause();
void Stop() const;
void Play() const;
void Seek(qlonglong Offset) const;
void SetPosition(const QDBusObjectPath &trackId, qlonglong pos) const;
void OpenUri(const QString &uri) const;
void Stop();
void Play();
void Seek(qlonglong Offset);
void SetPosition(const QDBusObjectPath &trackId, qlonglong pos);
void OpenUri(const QString &uri);
private Q_SLOTS:
......
......@@ -109,7 +109,7 @@ public Q_SLOTS:
void setAudioPlayer(AudioWrapper* audioPlayer);
Q_SIGNALS:
void raisePlayer() const;
void raisePlayer();
void playerNameChanged();
......
......@@ -153,7 +153,8 @@ MusicListenersManager::MusicListenersManager(QObject *parent)
auto initialRootPath = Elisa::ElisaConfiguration::rootPath();
if (initialRootPath.isEmpty()) {
for (const auto &musicPath : QStandardPaths::standardLocations(QStandardPaths::MusicLocation)) {
auto systemMusicPaths = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
for (const auto &musicPath : qAsConst(systemMusicPaths)) {
initialRootPath.push_back(musicPath);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment