mirror of https://github.com/KDE/kasts.git
Make grace time configurable for marking episodes as played
BUG: 468687
This commit is contained in:
parent
441ef6d265
commit
21952c67e9
|
@ -274,12 +274,11 @@ void AudioManager::setEntry(Entry *entry)
|
|||
d->m_entry = nullptr;
|
||||
|
||||
// Check if the previous track needs to be marked as read
|
||||
// TODO: make grace time a setting in SettingsManager
|
||||
if (oldEntry && !signalDisconnect) {
|
||||
qCDebug(kastsAudio) << "Checking previous track";
|
||||
qCDebug(kastsAudio) << "Left time" << (duration() - position());
|
||||
qCDebug(kastsAudio) << "MediaStatus" << d->m_player.mediaStatus();
|
||||
if (((duration() > 0) && (position() > 0) && ((duration() - position()) < SKIP_TRACK_END))
|
||||
if (((duration() > 0) && (position() > 0) && ((duration() - position()) < SettingsManager::self()->markAsPlayedBeforeEnd() * 1000))
|
||||
|| (d->m_player.mediaStatus() == KMediaSession::EndOfMedia)) {
|
||||
qCDebug(kastsAudio) << "Mark as read:" << oldEntry->title();
|
||||
oldEntry->enclosure()->setPlayPosition(0);
|
||||
|
|
|
@ -51,8 +51,6 @@ class AudioManager : public QObject
|
|||
Q_PROPERTY(bool isStreaming READ isStreaming NOTIFY isStreamingChanged)
|
||||
|
||||
public:
|
||||
const qint64 SKIP_TRACK_END = 15000;
|
||||
|
||||
static AudioManager &instance()
|
||||
{
|
||||
static AudioManager _instance;
|
||||
|
|
|
@ -287,7 +287,25 @@ Kirigami.ScrollablePage {
|
|||
}
|
||||
}
|
||||
|
||||
MobileForm.FormDelegateSeparator { above: episodeBehavior; below: resetPositionOnPlayed }
|
||||
MobileForm.FormDelegateSeparator { above: episodeBehavior; below: markAsPlayedGracePeriod }
|
||||
|
||||
MobileForm.FormTextDelegate {
|
||||
id: markAsPlayedGracePeriod
|
||||
text: i18nc("@label:spinbox", "Mark episodes as played when the given time is remaining (in seconds)")
|
||||
textItem.wrapMode: Text.Wrap
|
||||
trailing: Controls.SpinBox {
|
||||
Layout.rightMargin: Kirigami.Units.gridUnit
|
||||
value: SettingsManager.markAsPlayedBeforeEnd
|
||||
from: 0
|
||||
to: 300
|
||||
onValueModified: {
|
||||
SettingsManager.markAsPlayedBeforeEnd = value;
|
||||
SettingsManager.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MobileForm.FormDelegateSeparator { above: markAsPlayedGracePeriod; below: resetPositionOnPlayed }
|
||||
|
||||
MobileForm.FormCheckDelegate {
|
||||
id: resetPositionOnPlayed
|
||||
|
|
|
@ -75,6 +75,10 @@
|
|||
</choices>
|
||||
<default>OnNextStartup</default>
|
||||
</entry>
|
||||
<entry name="markAsPlayedBeforeEnd" type="Int">
|
||||
<label>Amount of seconds before end of stream that the episode should already be marked as played</label>
|
||||
<default>15</default>
|
||||
</entry>
|
||||
<entry name="resetPositionOnPlayed" type="Bool">
|
||||
<label>Reset play position when episode is marked as played</label>
|
||||
<default>true</default>
|
||||
|
|
|
@ -862,9 +862,9 @@ void Sync::applyEpisodeActionsLocally(const QHash<QString, QHash<QString, Episod
|
|||
Entry *entry = DataManager::instance().getEntry(action.id);
|
||||
if (entry && entry->hasEnclosure()) {
|
||||
qCDebug(kastsSync) << action.position << action.total << static_cast<qint64>(action.position) << entry->enclosure()->duration()
|
||||
<< AudioManager::instance().SKIP_TRACK_END / 1000;
|
||||
if ((action.position >= action.total - AudioManager::instance().SKIP_TRACK_END / 1000
|
||||
|| static_cast<qint64>(action.position) >= entry->enclosure()->duration() - AudioManager::instance().SKIP_TRACK_END / 1000)
|
||||
<< SettingsManager::self()->markAsPlayedBeforeEnd();
|
||||
if ((action.position >= action.total - SettingsManager::self()->markAsPlayedBeforeEnd()
|
||||
|| static_cast<qint64>(action.position) >= entry->enclosure()->duration() - SettingsManager::self()->markAsPlayedBeforeEnd())
|
||||
&& action.total > 0) {
|
||||
// Episode has been played
|
||||
qCDebug(kastsSync) << "mark as played:" << entry->title();
|
||||
|
|
Loading…
Reference in New Issue