Commit d6860f0e authored by Alexander Stippich's avatar Alexander Stippich
Browse files

move audiowrapper to c++

Summary: next step to construct objects in c++. manageaudioplayer is next

Test Plan: audio control is working like before

Reviewers: #elisa, mgallien

Reviewed By: #elisa, mgallien

Tags: #elisa

Differential Revision: https://phabricator.kde.org/D11217
parent f47cab36
......@@ -48,6 +48,7 @@ set(managemediaplayercontrolTest_SOURCES
../src/file/localfilelisting.cpp
../src/abstractfile/abstractfilelistener.cpp
../src/abstractfile/abstractfilelisting.cpp
../src/audiowrapper.cpp
managemediaplayercontroltest.cpp
)
......@@ -138,6 +139,7 @@ set(manageheaderbarTest_SOURCES
../src/file/localfilelisting.cpp
../src/abstractfile/abstractfilelistener.cpp
../src/abstractfile/abstractfilelisting.cpp
../src/audiowrapper.cpp
manageheaderbartest.cpp
)
......@@ -237,6 +239,7 @@ set(mediaplaylistTest_SOURCES
../src/file/localfilelisting.cpp
../src/abstractfile/abstractfilelistener.cpp
../src/abstractfile/abstractfilelisting.cpp
../src/audiowrapper.cpp
modeltest.cpp
mediaplaylisttest.cpp
)
......@@ -326,6 +329,7 @@ set(trackslistenertest_SOURCES
../src/file/localfilelisting.cpp
../src/abstractfile/abstractfilelistener.cpp
../src/abstractfile/abstractfilelisting.cpp
../src/audiowrapper.cpp
trackslistenertest.cpp
)
......@@ -482,6 +486,7 @@ if (KF5XmlGui_FOUND AND KF5KCMUtils_FOUND)
../src/notificationitem.cpp
../src/trackslistener.cpp
../src/mediaplaylist.cpp
../src/audiowrapper.cpp
../src/musicartist.cpp
../src/musicalbum.cpp
../src/musicaudiotrack.cpp
......
......@@ -260,6 +260,7 @@ set(elisaImport_SOURCES
abstractfile/abstractfilelisting.cpp
file/filelistener.cpp
file/localfilelisting.cpp
audiowrapper.cpp
)
if (KF5Baloo_FOUND)
......
......@@ -27,6 +27,7 @@
#include "models/singleartistproxymodel.h"
#include "models/singlealbumproxymodel.h"
#include "mediaplaylist.h"
#include "audiowrapper.h"
#include "elisa_settings.h"
#include <KConfigCore/KAuthorized>
......@@ -94,6 +95,8 @@ public:
std::unique_ptr<MediaPlayList> mMediaPlayList;
std::unique_ptr<AudioWrapper> mAudioWrapper;
};
ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::make_unique<ElisaApplicationPrivate>(this))
......@@ -262,6 +265,8 @@ void ElisaApplication::initialize()
Q_EMIT singleAlbumProxyModelChanged();
d->mMediaPlayList = std::make_unique<MediaPlayList>();
Q_EMIT mediaPlayListChanged();
d->mAudioWrapper = std::make_unique<AudioWrapper>();
Q_EMIT audioPlayerChanged();
d->mMusicManager->setElisaApplication(this);
......@@ -361,5 +366,9 @@ MediaPlayList *ElisaApplication::mediaPlayList() const
return d->mMediaPlayList.get();
}
AudioWrapper *ElisaApplication::audioPlayer() const
{
return d->mAudioWrapper.get();
}
#include "moc_elisaapplication.cpp"
......@@ -36,6 +36,7 @@ class AllTracksProxyModel;
class SingleArtistProxyModel;
class SingleAlbumProxyModel;
class MediaPlayList;
class AudioWrapper;
class ElisaApplicationPrivate;
class ElisaApplication : public QObject
......@@ -76,6 +77,10 @@ class ElisaApplication : public QObject
READ mediaPlayList
NOTIFY mediaPlayListChanged)
Q_PROPERTY(AudioWrapper *audioPlayer
READ audioPlayer
NOTIFY audioPlayerChanged)
public:
explicit ElisaApplication(QObject *parent = nullptr);
......@@ -101,6 +106,8 @@ public:
MediaPlayList *mediaPlayList() const;
AudioWrapper *audioPlayer() const;
Q_SIGNALS:
void argumentsChanged();
......@@ -119,6 +126,8 @@ Q_SIGNALS:
void mediaPlayListChanged();
void audioPlayerChanged();
void enqueue(const QStringList &files);
public Q_SLOTS:
......
......@@ -120,7 +120,7 @@ ApplicationWindow {
audioPlayerManager: manageAudioPlayer
headerBarManager: myHeaderBarManager
manageMediaPlayerControl: myPlayControlManager
player: audioPlayer
player: elisa.audioPlayer
onRaisePlayer:
{
......@@ -130,18 +130,12 @@ ApplicationWindow {
}
}
AudioWrapper {
id: audioPlayer
muted: headerBar.playerControl.muted
volume: headerBar.playerControl.volume
Connections {
target: elisa.audioPlayer
onVolumeChanged: headerBar.playerControl.volume = volume
onMutedChanged: headerBar.playerControl.muted = muted
source: manageAudioPlayer.playerSource
onPlaying: {
myPlayControlManager.playerPlaying()
}
......@@ -191,20 +185,20 @@ ApplicationWindow {
artistNameRole: MediaPlayList.ArtistRole
albumNameRole: MediaPlayList.AlbumRole
playerStatus: audioPlayer.status
playerPlaybackState: audioPlayer.playbackState
playerError: audioPlayer.error
audioDuration: audioPlayer.duration
playerIsSeekable: audioPlayer.seekable
playerPosition: audioPlayer.position
playerStatus: elisa.audioPlayer.status
playerPlaybackState: elisa.audioPlayer.playbackState
playerError: elisa.audioPlayer.error
audioDuration: elisa.audioPlayer.duration
playerIsSeekable: elisa.audioPlayer.seekable
playerPosition: elisa.audioPlayer.position
persistentState: persistentSettings.audioPlayerState
onPlayerPlay: audioPlayer.play()
onPlayerPause: audioPlayer.pause()
onPlayerStop: audioPlayer.stop()
onPlayerPlay: elisa.audioPlayer.play()
onPlayerPause: elisa.audioPlayer.pause()
onPlayerStop: elisa.audioPlayer.stop()
onSkipNextTrack: elisa.mediaPlayList.skipNextTrack()
onSeek: audioPlayer.seek(position)
onSeek: elisa.audioPlayer.seek(position)
onSourceInError:
{
elisa.mediaPlayList.trackInError(source, playerError)
......@@ -254,18 +248,18 @@ ApplicationWindow {
ratingVisible: false
playerControl.duration: audioPlayer.duration
playerControl.seekable: audioPlayer.seekable
playerControl.duration: elisa.audioPlayer.duration
playerControl.seekable: elisa.audioPlayer.seekable
playerControl.volume: persistentSettings.playControlItemVolume
playerControl.muted: persistentSettings.playControlItemMuted
playerControl.position: audioPlayer.position
playerControl.position: elisa.audioPlayer.position
playerControl.skipBackwardEnabled: myPlayControlManager.skipBackwardControlEnabled
playerControl.skipForwardEnabled: myPlayControlManager.skipForwardControlEnabled
playerControl.playEnabled: myPlayControlManager.playControlEnabled
playerControl.isPlaying: myPlayControlManager.musicPlaying
playerControl.onSeek: audioPlayer.seek(position)
playerControl.onSeek: elisa.audioPlayer.seek(position)
playerControl.onPlay: manageAudioPlayer.playPause()
playerControl.onPause: manageAudioPlayer.playPause()
......@@ -936,6 +930,12 @@ ApplicationWindow {
elisa.mediaPlayList.persistentState = persistentSettings.playListState
}
elisa.audioPlayer.muted = Qt.binding(function() { return headerBar.playerControl.muted })
elisa.audioPlayer.volume = Qt.binding(function() { return headerBar.playerControl.volume })
elisa.audioPlayer.source = Qt.binding(function() { return manageAudioPlayer.playerSource })
elisa.mediaPlayList.enqueue(elisa.arguments)
volume: headerBar.playerControl.volume
}
}
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