Make AudioManager owned and instantiated by c++
This commit is contained in:
parent
1d20863834
commit
2eb1092f46
@ -38,7 +38,11 @@ class AudioManager : public QObject
|
|||||||
Q_PROPERTY(bool canGoNext READ canGoNext NOTIFY canGoNextChanged)
|
Q_PROPERTY(bool canGoNext READ canGoNext NOTIFY canGoNextChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AudioManager(QObject *parent = nullptr);
|
static AudioManager &instance()
|
||||||
|
{
|
||||||
|
static AudioManager _instance;
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
~AudioManager() override;
|
~AudioManager() override;
|
||||||
|
|
||||||
@ -163,6 +167,8 @@ private Q_SLOTS:
|
|||||||
void savePlayPosition(qint64 position);
|
void savePlayPosition(qint64 position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit AudioManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
friend class AudioManagerPrivate;
|
friend class AudioManagerPrivate;
|
||||||
|
|
||||||
std::unique_ptr<AudioManagerPrivate> d;
|
std::unique_ptr<AudioManagerPrivate> d;
|
||||||
|
@ -107,7 +107,6 @@ int main(int argc, char *argv[])
|
|||||||
qmlRegisterType<FeedsModel>("org.kde.kasts", 1, 0, "FeedsModel");
|
qmlRegisterType<FeedsModel>("org.kde.kasts", 1, 0, "FeedsModel");
|
||||||
qmlRegisterType<QueueModel>("org.kde.kasts", 1, 0, "QueueModel");
|
qmlRegisterType<QueueModel>("org.kde.kasts", 1, 0, "QueueModel");
|
||||||
qmlRegisterType<EpisodeModel>("org.kde.kasts", 1, 0, "EpisodeModel");
|
qmlRegisterType<EpisodeModel>("org.kde.kasts", 1, 0, "EpisodeModel");
|
||||||
qmlRegisterType<AudioManager>("org.kde.kasts", 1, 0, "AudioManager");
|
|
||||||
qmlRegisterType<Mpris2>("org.kde.kasts", 1, 0, "Mpris2");
|
qmlRegisterType<Mpris2>("org.kde.kasts", 1, 0, "Mpris2");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<EntriesModel>("org.kde.kasts", 1, 0, "EntriesModel", QStringLiteral("Get from Feed"));
|
qmlRegisterUncreatableType<EntriesModel>("org.kde.kasts", 1, 0, "EntriesModel", QStringLiteral("Get from Feed"));
|
||||||
@ -119,6 +118,8 @@ int main(int argc, char *argv[])
|
|||||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "SettingsManager", SettingsManager::self());
|
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "SettingsManager", SettingsManager::self());
|
||||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "DownloadProgressModel", &DownloadProgressModel::instance());
|
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "DownloadProgressModel", &DownloadProgressModel::instance());
|
||||||
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "ErrorLogModel", &ErrorLogModel::instance());
|
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "ErrorLogModel", &ErrorLogModel::instance());
|
||||||
|
qmlRegisterSingletonInstance("org.kde.kasts", 1, 0, "AudioManager", &AudioManager::instance());
|
||||||
|
|
||||||
|
|
||||||
qRegisterMetaType<Entry *>("const Entry*"); // "hack" to make qml understand Entry*
|
qRegisterMetaType<Entry *>("const Entry*"); // "hack" to make qml understand Entry*
|
||||||
|
|
||||||
|
@ -72,13 +72,13 @@ Kirigami.ScrollablePage {
|
|||||||
entry.enclosure.status === Enclosure.Downloadable ? i18n("Download") :
|
entry.enclosure.status === Enclosure.Downloadable ? i18n("Download") :
|
||||||
entry.enclosure.status === Enclosure.Downloading ? i18n("Cancel download") :
|
entry.enclosure.status === Enclosure.Downloading ? i18n("Cancel download") :
|
||||||
!entry.queueStatus ? i18n("Delete download") :
|
!entry.queueStatus ? i18n("Delete download") :
|
||||||
(audio.entry === entry && audio.playbackState === Audio.PlayingState) ? i18n("Pause") :
|
(AudioManager.entry === entry && AudioManager.playbackState === Audio.PlayingState) ? i18n("Pause") :
|
||||||
i18n("Play")
|
i18n("Play")
|
||||||
icon.name: !entry.enclosure ? "globe" :
|
icon.name: !entry.enclosure ? "globe" :
|
||||||
entry.enclosure.status === Enclosure.Downloadable ? "download" :
|
entry.enclosure.status === Enclosure.Downloadable ? "download" :
|
||||||
entry.enclosure.status === Enclosure.Downloading ? "edit-delete-remove" :
|
entry.enclosure.status === Enclosure.Downloading ? "edit-delete-remove" :
|
||||||
!entry.queueStatus ? "delete" :
|
!entry.queueStatus ? "delete" :
|
||||||
(audio.entry === entry && audio.playbackState === Audio.PlayingState) ? "media-playback-pause" :
|
(AudioManager.entry === entry && AudioManager.playbackState === Audio.PlayingState) ? "media-playback-pause" :
|
||||||
"media-playback-start"
|
"media-playback-start"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if(!entry.enclosure) Qt.openUrlExternally(entry.link)
|
if(!entry.enclosure) Qt.openUrlExternally(entry.link)
|
||||||
@ -87,11 +87,11 @@ Kirigami.ScrollablePage {
|
|||||||
else if(!entry.queueStatus) {
|
else if(!entry.queueStatus) {
|
||||||
entry.enclosure.deleteFile()
|
entry.enclosure.deleteFile()
|
||||||
} else {
|
} else {
|
||||||
if(audio.entry === entry && audio.playbackState === Audio.PlayingState) {
|
if(AudioManager.entry === entry && AudioManager.playbackState === Audio.PlayingState) {
|
||||||
audio.pause()
|
AudioManager.pause()
|
||||||
} else {
|
} else {
|
||||||
audio.entry = entry
|
AudioManager.entry = entry
|
||||||
audio.play()
|
AudioManager.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,8 +106,8 @@ Kirigami.ScrollablePage {
|
|||||||
entry.queueStatus = true
|
entry.queueStatus = true
|
||||||
} else {
|
} else {
|
||||||
// first change to next track if this one is playing
|
// first change to next track if this one is playing
|
||||||
if (entry.hasEnclosure && entry === audio.entry) {
|
if (entry.hasEnclosure && entry === AudioManager.entry) {
|
||||||
audio.next()
|
AudioManager.next()
|
||||||
}
|
}
|
||||||
entry.queueStatus = false
|
entry.queueStatus = false
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ Kirigami.SwipeListItem {
|
|||||||
Component {
|
Component {
|
||||||
id: subtitle
|
id: subtitle
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: audio.timeString(entry.enclosure.duration * 1000)
|
text: AudioManager.timeString(entry.enclosure.duration * 1000)
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font: Kirigami.Theme.smallFont
|
font: Kirigami.Theme.smallFont
|
||||||
@ -119,7 +119,7 @@ Kirigami.SwipeListItem {
|
|||||||
id: playProgress
|
id: playProgress
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: audio.timeString(entry.enclosure.playPosition)
|
text: AudioManager.timeString(entry.enclosure.playPosition)
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font: Kirigami.Theme.smallFont
|
font: Kirigami.Theme.smallFont
|
||||||
opacity: entry.read ? 0.4 : 0.7
|
opacity: entry.read ? 0.4 : 0.7
|
||||||
@ -132,7 +132,7 @@ Kirigami.SwipeListItem {
|
|||||||
opacity: entry.read ? 0.6 : 1
|
opacity: entry.read ? 0.6 : 1
|
||||||
}
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: audio.timeString(entry.enclosure.duration * 1000)
|
text: AudioManager.timeString(entry.enclosure.duration * 1000)
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font: Kirigami.Theme.smallFont
|
font: Kirigami.Theme.smallFont
|
||||||
opacity: entry.read ? 0.4 : 0.7
|
opacity: entry.read ? 0.4 : 0.7
|
||||||
@ -195,17 +195,17 @@ Kirigami.SwipeListItem {
|
|||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: i18n("Play")
|
text: i18n("Play")
|
||||||
icon.name: "media-playback-start"
|
icon.name: "media-playback-start"
|
||||||
visible: !isDownloads && entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && (audio.entry !== entry || audio.playbackState !== Audio.PlayingState)
|
visible: !isDownloads && entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && (AudioManager.entry !== entry || AudioManager.playbackState !== Audio.PlayingState)
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
audio.entry = entry
|
AudioManager.entry = entry
|
||||||
audio.play()
|
AudioManager.play()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: i18n("Pause")
|
text: i18n("Pause")
|
||||||
icon.name: "media-playback-pause"
|
icon.name: "media-playback-pause"
|
||||||
visible: !isDownloads && entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && audio.entry === entry && audio.playbackState === Audio.PlayingState
|
visible: !isDownloads && entry.queueStatus && entry.enclosure && entry.enclosure.status === Enclosure.Downloaded && AudioManager.entry === entry && AudioManager.playbackState === Audio.PlayingState
|
||||||
onTriggered: audio.pause()
|
onTriggered: AudioManager.pause()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ Item {
|
|||||||
property int buttonsize: Kirigami.Units.gridUnit * 2
|
property int buttonsize: Kirigami.Units.gridUnit * 2
|
||||||
height: miniplayerheight + progressbarheight
|
height: miniplayerheight + progressbarheight
|
||||||
|
|
||||||
visible: audio.entry
|
visible: AudioManager.entry
|
||||||
|
|
||||||
// Set background
|
// Set background
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@ -36,7 +36,7 @@ Item {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
height: parent.progressbarheight
|
height: parent.progressbarheight
|
||||||
color: Kirigami.Theme.highlightColor
|
color: Kirigami.Theme.highlightColor
|
||||||
width: parent.width * audio.position / audio.duration
|
width: parent.width * AudioManager.position / AudioManager.duration
|
||||||
visible: true
|
visible: true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
ImageWithFallback {
|
ImageWithFallback {
|
||||||
imageSource: audio.entry.cachedImage
|
imageSource: AudioManager.entry.cachedImage
|
||||||
Layout.preferredHeight: miniplayerheight
|
Layout.preferredHeight: miniplayerheight
|
||||||
Layout.preferredWidth: miniplayerheight
|
Layout.preferredWidth: miniplayerheight
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ Item {
|
|||||||
Layout.leftMargin: Kirigami.Units.smallSpacing
|
Layout.leftMargin: Kirigami.Units.smallSpacing
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
id: mainLabel
|
id: mainLabel
|
||||||
text: audio.entry.title
|
text: AudioManager.entry.title
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -77,7 +77,7 @@ Item {
|
|||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
id: feedLabel
|
id: feedLabel
|
||||||
text: audio.entry.feed.name
|
text: AudioManager.entry.feed.name
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -98,14 +98,14 @@ Item {
|
|||||||
}
|
}
|
||||||
Controls.Button {
|
Controls.Button {
|
||||||
id: playButton
|
id: playButton
|
||||||
icon.name: audio.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
|
icon.name: AudioManager.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
|
||||||
icon.height: parent.parent.buttonsize
|
icon.height: parent.parent.buttonsize
|
||||||
icon.width: parent.parent.buttonsize
|
icon.width: parent.parent.buttonsize
|
||||||
flat: true
|
flat: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.maximumHeight: parent.parent.miniplayerheight
|
Layout.maximumHeight: parent.parent.miniplayerheight
|
||||||
Layout.maximumWidth: height
|
Layout.maximumWidth: height
|
||||||
onClicked: audio.playbackState === Audio.PlayingState ? audio.pause() : audio.play()
|
onClicked: AudioManager.playbackState === Audio.PlayingState ? AudioManager.pause() : AudioManager.play()
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import org.kde.kasts 1.0
|
|||||||
Kirigami.Page {
|
Kirigami.Page {
|
||||||
id: playerControls
|
id: playerControls
|
||||||
|
|
||||||
title: audio.entry ? audio.entry.title : "No track loaded"
|
title: AudioManager.entry ? AudioManager.entry.title : "No track loaded"
|
||||||
clip: true
|
clip: true
|
||||||
Layout.margins: 0
|
Layout.margins: 0
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ Kirigami.Page {
|
|||||||
property int textMargin: Kirigami.Units.gridUnit // margin above and below the text below the image
|
property int textMargin: Kirigami.Units.gridUnit // margin above and below the text below the image
|
||||||
ImageWithFallback {
|
ImageWithFallback {
|
||||||
id: coverImage
|
id: coverImage
|
||||||
imageSource: audio.entry ? audio.entry.cachedImage : "no-image"
|
imageSource: AudioManager.entry ? AudioManager.entry.cachedImage : "no-image"
|
||||||
imageFillMode: Image.PreserveAspectCrop
|
imageFillMode: Image.PreserveAspectCrop
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
@ -67,13 +67,13 @@ Kirigami.Page {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.topMargin: parent.textMargin
|
anchors.topMargin: parent.textMargin
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: audio.entry ? audio.entry.title : "No title"
|
text: AudioManager.entry ? AudioManager.entry.title : "No title"
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.maximumWidth: parent.width
|
Layout.maximumWidth: parent.width
|
||||||
}
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: audio.entry ? audio.entry.feed.name : "No feed"
|
text: AudioManager.entry ? AudioManager.entry.feed.name : "No feed"
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.maximumWidth: parent.width
|
Layout.maximumWidth: parent.width
|
||||||
@ -90,7 +90,7 @@ Kirigami.Page {
|
|||||||
id: description
|
id: description
|
||||||
width: parent.width
|
width: parent.width
|
||||||
Kirigami.Heading {
|
Kirigami.Heading {
|
||||||
text: audio.entry ? audio.entry.title : "No track title"
|
text: AudioManager.entry ? AudioManager.entry.title : "No track title"
|
||||||
level: 3
|
level: 3
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -98,9 +98,9 @@ Kirigami.Page {
|
|||||||
}
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
id: text
|
id: text
|
||||||
text: audio.entry ? audio.entry.content : "No track loaded"
|
text: AudioManager.entry ? AudioManager.entry.content : "No track loaded"
|
||||||
verticalAlignment: Text.AlignTop
|
verticalAlignment: Text.AlignTop
|
||||||
baseUrl: audio.entry ? audio.entry.baseUrl : ""
|
baseUrl: AudioManager.entry ? AudioManager.entry.baseUrl : ""
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
@ -135,14 +135,14 @@ Kirigami.Page {
|
|||||||
anchors.margins: 0
|
anchors.margins: 0
|
||||||
|
|
||||||
Controls.Slider {
|
Controls.Slider {
|
||||||
enabled: audio.entry
|
enabled: AudioManager.entry
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: 0
|
Layout.margins: 0
|
||||||
padding: 0
|
padding: 0
|
||||||
from: 0
|
from: 0
|
||||||
to: audio.duration
|
to: AudioManager.duration
|
||||||
value: audio.position
|
value: AudioManager.position
|
||||||
onMoved: audio.seek(value)
|
onMoved: AudioManager.seek(value)
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: controls
|
id: controls
|
||||||
@ -150,7 +150,7 @@ Kirigami.Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
padding: Kirigami.Units.largeSpacing
|
padding: Kirigami.Units.largeSpacing
|
||||||
text: audio.timeString(audio.position)
|
text: AudioManager.timeString(AudioManager.position)
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -164,8 +164,8 @@ Kirigami.Page {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: (SettingsManager.toggleRemainingTime) ?
|
text: (SettingsManager.toggleRemainingTime) ?
|
||||||
"-" + audio.timeString(audio.duration-audio.position)
|
"-" + AudioManager.timeString(AudioManager.duration-AudioManager.position)
|
||||||
: audio.timeString(audio.duration)
|
: AudioManager.timeString(AudioManager.duration)
|
||||||
|
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@ -189,15 +189,15 @@ Kirigami.Page {
|
|||||||
// Use contentItem and a Label because using plain "text"
|
// Use contentItem and a Label because using plain "text"
|
||||||
// does not rescale automatically if the text changes
|
// does not rescale automatically if the text changes
|
||||||
contentItem: Controls.Label {
|
contentItem: Controls.Label {
|
||||||
text: audio.playbackRate + "x"
|
text: AudioManager.playbackRate + "x"
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(audio.playbackRate === 2.5)
|
if(AudioManager.playbackRate === 2.5)
|
||||||
audio.playbackRate = 1
|
AudioManager.playbackRate = 1
|
||||||
else
|
else
|
||||||
audio.playbackRate = audio.playbackRate + 0.25
|
AudioManager.playbackRate = AudioManager.playbackRate + 0.25
|
||||||
}
|
}
|
||||||
flat: true
|
flat: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
@ -212,19 +212,19 @@ Kirigami.Page {
|
|||||||
flat: true
|
flat: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.preferredWidth: parent.buttonSize
|
Layout.preferredWidth: parent.buttonSize
|
||||||
onClicked: audio.skipBackward()
|
onClicked: AudioManager.skipBackward()
|
||||||
enabled: audio.canSkipBackward
|
enabled: AudioManager.canSkipBackward
|
||||||
}
|
}
|
||||||
Controls.Button {
|
Controls.Button {
|
||||||
id: playButton
|
id: playButton
|
||||||
icon.name: audio.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
|
icon.name: AudioManager.playbackState === Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
|
||||||
icon.height: parent.iconSize
|
icon.height: parent.iconSize
|
||||||
icon.width: parent.iconSize
|
icon.width: parent.iconSize
|
||||||
flat: true
|
flat: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.preferredWidth: parent.buttonSize
|
Layout.preferredWidth: parent.buttonSize
|
||||||
onClicked: audio.playbackState === Audio.PlayingState ? audio.pause() : audio.play()
|
onClicked: AudioManager.playbackState === Audio.PlayingState ? AudioManager.pause() : AudioManager.play()
|
||||||
enabled: audio.canPlay
|
enabled: AudioManager.canPlay
|
||||||
}
|
}
|
||||||
Controls.Button {
|
Controls.Button {
|
||||||
icon.name: "media-seek-forward"
|
icon.name: "media-seek-forward"
|
||||||
@ -233,8 +233,8 @@ Kirigami.Page {
|
|||||||
flat: true
|
flat: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.preferredWidth: parent.buttonSize
|
Layout.preferredWidth: parent.buttonSize
|
||||||
onClicked: audio.skipForward()
|
onClicked: AudioManager.skipForward()
|
||||||
enabled: audio.canSkipForward
|
enabled: AudioManager.canSkipForward
|
||||||
}
|
}
|
||||||
Controls.Button {
|
Controls.Button {
|
||||||
icon.name: "media-skip-forward"
|
icon.name: "media-skip-forward"
|
||||||
@ -243,8 +243,8 @@ Kirigami.Page {
|
|||||||
flat: true
|
flat: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.preferredWidth: parent.buttonSize
|
Layout.preferredWidth: parent.buttonSize
|
||||||
onClicked: audio.next()
|
onClicked: AudioManager.next()
|
||||||
enabled: audio.canGoNext
|
enabled: AudioManager.canGoNext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ Kirigami.ScrollablePage {
|
|||||||
Controls.Label {
|
Controls.Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: i18np("1 episode", "%1 episodes", queueModel.rowCount()) + " · " + i18n("Time left") + ": " + audio.timeString(queueModel.timeLeft)
|
text: i18np("1 episode", "%1 episodes", queueModel.rowCount()) + " · " + i18n("Time left") + ": " + AudioManager.timeString(queueModel.timeLeft)
|
||||||
}
|
}
|
||||||
Kirigami.Separator {
|
Kirigami.Separator {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -70,7 +70,6 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
model: QueueModel {
|
model: QueueModel {
|
||||||
id: queueModel
|
id: queueModel
|
||||||
audioManager: audio
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Kirigami.DelegateRecycler {
|
delegate: Kirigami.DelegateRecycler {
|
||||||
|
@ -21,7 +21,7 @@ Kirigami.ApplicationWindow {
|
|||||||
|
|
||||||
property var miniplayerSize: Kirigami.Units.gridUnit * 3 + Kirigami.Units.gridUnit / 6
|
property var miniplayerSize: Kirigami.Units.gridUnit * 3 + Kirigami.Units.gridUnit / 6
|
||||||
property int tabBarHeight: Kirigami.Units.gridUnit * 2
|
property int tabBarHeight: Kirigami.Units.gridUnit * 2
|
||||||
property int bottomMessageSpacing: Kirigami.Units.largeSpacing * 9 + ( audio.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + tabBarActive * tabBarHeight
|
property int bottomMessageSpacing: Kirigami.Units.largeSpacing * 9 + ( AudioManager.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + tabBarActive * tabBarHeight
|
||||||
property int tabBarActive: 0
|
property int tabBarActive: 0
|
||||||
|
|
||||||
Kirigami.PagePool {
|
Kirigami.PagePool {
|
||||||
@ -46,8 +46,8 @@ Kirigami.ApplicationWindow {
|
|||||||
globalDrawer: Kirigami.GlobalDrawer {
|
globalDrawer: Kirigami.GlobalDrawer {
|
||||||
isMenu: false
|
isMenu: false
|
||||||
// make room at the bottom for miniplayer
|
// make room at the bottom for miniplayer
|
||||||
handle.anchors.bottomMargin: (audio.entry ? (footerLoader.item.contentY == 0 ? miniplayerSize : 0) : 0) + Kirigami.Units.smallSpacing + tabBarActive * tabBarHeight
|
handle.anchors.bottomMargin: (AudioManager.entry ? (footerLoader.item.contentY == 0 ? miniplayerSize : 0) : 0) + Kirigami.Units.smallSpacing + tabBarActive * tabBarHeight
|
||||||
handleVisible: !audio.entry || footerLoader.item.contentY === 0
|
handleVisible: !AudioManager.entry || footerLoader.item.contentY === 0
|
||||||
actions: [
|
actions: [
|
||||||
Kirigami.PagePoolAction {
|
Kirigami.PagePoolAction {
|
||||||
text: i18n("Queue")
|
text: i18n("Queue")
|
||||||
@ -117,19 +117,15 @@ Kirigami.ApplicationWindow {
|
|||||||
contextDrawer: Kirigami.ContextDrawer {
|
contextDrawer: Kirigami.ContextDrawer {
|
||||||
id: contextDrawer
|
id: contextDrawer
|
||||||
// make room at the bottom for miniplayer
|
// make room at the bottom for miniplayer
|
||||||
handle.anchors.bottomMargin: ( audio.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + Kirigami.Units.smallSpacing + tabBarActive * tabBarHeight
|
handle.anchors.bottomMargin: ( AudioManager.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + Kirigami.Units.smallSpacing + tabBarActive * tabBarHeight
|
||||||
handleVisible: !audio.entry || footerLoader.item.contentY == 0
|
handleVisible: !AudioManager.entry || footerLoader.item.contentY == 0
|
||||||
}
|
|
||||||
|
|
||||||
AudioManager {
|
|
||||||
id: audio
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Mpris2 {
|
Mpris2 {
|
||||||
id: mpris2Interface
|
id: mpris2Interface
|
||||||
|
|
||||||
playerName: 'kasts'
|
playerName: 'kasts'
|
||||||
audioPlayer: audio
|
audioPlayer: AudioManager
|
||||||
|
|
||||||
onRaisePlayer:
|
onRaisePlayer:
|
||||||
{
|
{
|
||||||
@ -139,13 +135,13 @@ Kirigami.ApplicationWindow {
|
|||||||
|
|
||||||
// create space at the bottom to show miniplayer without it hiding stuff
|
// create space at the bottom to show miniplayer without it hiding stuff
|
||||||
// underneath
|
// underneath
|
||||||
pageStack.anchors.bottomMargin: (audio.entry) ? miniplayerSize : 0
|
pageStack.anchors.bottomMargin: (AudioManager.entry) ? miniplayerSize : 0
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: footerLoader
|
id: footerLoader
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
active: audio.entry
|
active: AudioManager.entry
|
||||||
visible: active
|
visible: active
|
||||||
z: (!item || item.contentY === 0) ? -1 : 999
|
z: (!item || item.contentY === 0) ? -1 : 999
|
||||||
sourceComponent: FooterBar {
|
sourceComponent: FooterBar {
|
||||||
|
@ -35,6 +35,12 @@ QueueModel::QueueModel(QObject *parent)
|
|||||||
Q_EMIT timeLeftChanged();
|
Q_EMIT timeLeftChanged();
|
||||||
// qDebug() << "Removed entry at pos" << pos;
|
// qDebug() << "Removed entry at pos" << pos;
|
||||||
});
|
});
|
||||||
|
// Connect positionChanged to make sure that the remaining playing time in
|
||||||
|
// the queue header is up-to-date
|
||||||
|
connect(&AudioManager::instance(), &AudioManager::positionChanged, this, [this](qint64 position) {
|
||||||
|
Q_UNUSED(position)
|
||||||
|
Q_EMIT timeLeftChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QueueModel::data(const QModelIndex &index, int role) const
|
QVariant QueueModel::data(const QModelIndex &index, int role) const
|
||||||
@ -72,19 +78,3 @@ int QueueModel::timeLeft() const
|
|||||||
// qDebug() << "timeLeft is" << result;
|
// qDebug() << "timeLeft is" << result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioManager *QueueModel::audioManager()
|
|
||||||
{
|
|
||||||
return m_audio;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QueueModel::setAudioManager(AudioManager *audio)
|
|
||||||
{
|
|
||||||
// AudioManager is qml-owned; we need the pointer to the instance
|
|
||||||
// in order to connect to the positionChanged signal
|
|
||||||
m_audio = audio;
|
|
||||||
connect(m_audio, &AudioManager::positionChanged, this, [this](qint64 position) {
|
|
||||||
Q_UNUSED(position)
|
|
||||||
Q_EMIT timeLeftChanged();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -18,7 +18,6 @@ class QueueModel : public QAbstractListModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(int timeLeft READ timeLeft NOTIFY timeLeftChanged)
|
Q_PROPERTY(int timeLeft READ timeLeft NOTIFY timeLeftChanged)
|
||||||
Q_PROPERTY(AudioManager *audioManager READ audioManager WRITE setAudioManager)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QueueModel &instance()
|
static QueueModel &instance()
|
||||||
@ -33,9 +32,6 @@ public:
|
|||||||
int rowCount(const QModelIndex &parent) const override;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
int timeLeft() const;
|
int timeLeft() const;
|
||||||
|
|
||||||
AudioManager *audioManager();
|
|
||||||
void setAudioManager(AudioManager *audio);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void timeLeftChanged();
|
void timeLeftChanged();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user