mirror of https://github.com/KDE/kasts.git
Mark fully played episodes as read
This commit is contained in:
parent
2f389e02aa
commit
b2ba953a33
|
@ -164,9 +164,22 @@ QMediaPlayer::MediaStatus AudioManager::status() const
|
||||||
void AudioManager::setEntry(Entry* entry)
|
void AudioManager::setEntry(Entry* entry)
|
||||||
{
|
{
|
||||||
if (entry != nullptr) {
|
if (entry != nullptr) {
|
||||||
// TODO: here is a good spot to check if the previous track was (nearly) finished, so it can be removed if needed
|
|
||||||
qDebug() << "Going to change source";
|
|
||||||
d->m_lockPositionSaving = true;
|
d->m_lockPositionSaving = true;
|
||||||
|
// First check if the previous track needs to be marked as read
|
||||||
|
// TODO: make grace time a setting in SettingsManager
|
||||||
|
if (d->m_entry) {
|
||||||
|
qDebug() << "Checking previous track";
|
||||||
|
qDebug() << "Left time" << (duration()-position());
|
||||||
|
qDebug() << "MediaStatus" << d->m_player.mediaStatus();
|
||||||
|
if (( (duration()-position()) < 15000)
|
||||||
|
|| (d->m_player.mediaStatus() == QMediaPlayer::EndOfMedia) ) {
|
||||||
|
qDebug() << "Mark as read:" << d->m_entry->title();
|
||||||
|
d->m_entry->setRead(true);
|
||||||
|
d->m_entry->enclosure()->setPlayPosition(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Going to change source";
|
||||||
d->m_entry = entry;
|
d->m_entry = entry;
|
||||||
d->m_player.setMedia(QUrl(QStringLiteral("file://")+d->m_entry->enclosure()->path()));
|
d->m_player.setMedia(QUrl(QStringLiteral("file://")+d->m_entry->enclosure()->path()));
|
||||||
// save the current playing track in the settingsfile for restoring on startup
|
// save the current playing track in the settingsfile for restoring on startup
|
||||||
|
@ -324,6 +337,7 @@ void AudioManager::skipBackward()
|
||||||
|
|
||||||
bool AudioManager::canGoNext() const
|
bool AudioManager::canGoNext() const
|
||||||
{
|
{
|
||||||
|
// TODO: extend with streaming capability
|
||||||
int index = DataManager::instance().getQueue().indexOf(d->m_entry->id());
|
int index = DataManager::instance().getQueue().indexOf(d->m_entry->id());
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
// check if there is a next track
|
// check if there is a next track
|
||||||
|
@ -342,8 +356,6 @@ bool AudioManager::canGoNext() const
|
||||||
void AudioManager::next()
|
void AudioManager::next()
|
||||||
{
|
{
|
||||||
QMediaPlayer::State currentState = playbackState();
|
QMediaPlayer::State currentState = playbackState();
|
||||||
// TODO: needs to be more complicated; what if track has not been downloaded and streaming is not allowed; probably needs a canGoNext routine
|
|
||||||
// go to next track in playlist
|
|
||||||
int index = DataManager::instance().getQueue().indexOf(d->m_entry->id());
|
int index = DataManager::instance().getQueue().indexOf(d->m_entry->id());
|
||||||
if (canGoNext()) {
|
if (canGoNext()) {
|
||||||
setEntry(DataManager::instance().getEntry(DataManager::instance().getQueue()[index+1]));
|
setEntry(DataManager::instance().getEntry(DataManager::instance().getQueue()[index+1]));
|
||||||
|
@ -359,7 +371,7 @@ void AudioManager::mediaStatusChanged()
|
||||||
|
|
||||||
// File has reached the end and has stopped
|
// File has reached the end and has stopped
|
||||||
if (d->m_player.mediaStatus() == QMediaPlayer::EndOfMedia) {
|
if (d->m_player.mediaStatus() == QMediaPlayer::EndOfMedia) {
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ void Enclosure::setPlayPosition(const qint64 &position)
|
||||||
qDebug() << "save playPosition" << position << m_entry->title();
|
qDebug() << "save playPosition" << position << m_entry->title();
|
||||||
|
|
||||||
// let's only save the play position to the database every 15 seconds
|
// let's only save the play position to the database every 15 seconds
|
||||||
if (abs(m_playposition - m_playposition_dbsave) > 15000) {
|
if ((abs(m_playposition - m_playposition_dbsave) > 15000) || position == 0) {
|
||||||
qDebug() << "save playPosition to database" << position << m_entry->title();
|
qDebug() << "save playPosition to database" << position << m_entry->title();
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare(QStringLiteral("UPDATE Enclosures SET playposition=:playposition WHERE id=:id AND feed=:feed"));
|
query.prepare(QStringLiteral("UPDATE Enclosures SET playposition=:playposition WHERE id=:id AND feed=:feed"));
|
||||||
|
|
|
@ -59,7 +59,7 @@ Kirigami.SwipeListItem {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.weight: Font.Normal
|
font.weight: Font.Normal
|
||||||
opacity: 1
|
opacity: (entry.read) ? 0.6 : 1
|
||||||
}
|
}
|
||||||
Loader {
|
Loader {
|
||||||
sourceComponent: entry.enclosure && entry.enclosure.status === Enclosure.Downloading ? downloadProgress : subtitle
|
sourceComponent: entry.enclosure && entry.enclosure.status === Enclosure.Downloading ? downloadProgress : subtitle
|
||||||
|
|
Loading…
Reference in New Issue