1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-16 10:38:53 +01:00

Add option for overwriting database rating

This commit is contained in:
Jonas Kvinge 2021-10-31 23:24:32 +01:00
parent b41957ce5c
commit ca10920bb5
7 changed files with 17 additions and 6 deletions

View File

@ -150,6 +150,7 @@ void CollectionWatcher::ReloadSettings() {
song_tracking_ = s.value("song_tracking", false).toBool();
mark_songs_unavailable_ = song_tracking_ ? true : s.value("mark_songs_unavailable", true).toBool();
expire_unavailable_songs_days_ = s.value("expire_unavailable_songs", 60).toInt();
overwrite_rating_ = s.value("overwrite_rating", false).toBool();
s.endGroup();
best_image_filters_.clear();
@ -726,7 +727,7 @@ void CollectionWatcher::UpdateCueAssociatedSongs(const QString &file,
const Song matching_cue_song = sections_map[new_cue_song.beginning_nanosec()];
new_cue_song.set_id(matching_cue_song.id());
if (!new_cue_song.has_embedded_cover()) new_cue_song.set_art_automatic(image);
new_cue_song.MergeUserSetData(matching_cue_song);
new_cue_song.MergeUserSetData(matching_cue_song, true);
AddChangedSong(file, matching_cue_song, new_cue_song, t);
used_ids.insert(matching_cue_song.id());
}
@ -769,7 +770,7 @@ void CollectionWatcher::UpdateNonCueAssociatedSong(const QString &file,
song_on_disk.set_id(matching_song.id());
song_on_disk.set_fingerprint(fingerprint);
if (!song_on_disk.has_embedded_cover()) song_on_disk.set_art_automatic(image);
song_on_disk.MergeUserSetData(matching_song);
song_on_disk.MergeUserSetData(matching_song, !overwrite_rating_);
AddChangedSong(file, matching_song, song_on_disk, t);
}

View File

@ -213,6 +213,7 @@ class CollectionWatcher : public QObject {
bool song_tracking_;
bool mark_songs_unavailable_;
int expire_unavailable_songs_days_;
bool overwrite_rating_;
bool stop_requested_;
bool rescan_in_progress_; // True if RescanTracksNow() has been called and is working.

View File

@ -1680,13 +1680,13 @@ void Song::ToXesam(QVariantMap *map) const {
}
void Song::MergeUserSetData(const Song &other) {
void Song::MergeUserSetData(const Song &other, const bool merge_rating) {
if (other.playcount() > 0) {
set_playcount(other.playcount());
}
if (other.rating() > 0) {
if (merge_rating && other.rating() > 0.0F) {
set_rating(other.rating());
}

View File

@ -187,7 +187,7 @@ class Song {
// Copies important statistics from the other song to this one, overwriting any data that already exists.
// Useful when you want updated tags from disk but you want to keep user stats.
void MergeUserSetData(const Song &other);
void MergeUserSetData(const Song &other, const bool merge_rating);
// Save
void BindToQuery(SqlQuery *query) const;

View File

@ -393,7 +393,7 @@ QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList &songs) {
Song copy(song);
TagReaderClient::Instance()->ReadFileBlocking(copy.url().toLocalFile(), &copy);
if (copy.is_valid()) {
copy.MergeUserSetData(song);
copy.MergeUserSetData(song, false);
ret << Data(copy);
}
}

View File

@ -212,6 +212,7 @@ void CollectionSettingsPage::Load() {
ui_->checkbox_save_playcounts->setChecked(s.value("save_playcounts", false).toBool());
ui_->checkbox_save_ratings->setChecked(s.value("save_ratings", false).toBool());
ui_->checkbox_overwrite_rating->setChecked(s.value("overwrite_rating", false).toBool());
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
ui_->checkbox_delete_files->setChecked(s.value("delete_files", false).toBool());
@ -279,6 +280,7 @@ void CollectionSettingsPage::Save() {
s.setValue("save_playcounts", ui_->checkbox_save_playcounts->isChecked());
s.setValue("save_ratings", ui_->checkbox_save_ratings->isChecked());
s.setValue("overwrite_rating", ui_->checkbox_overwrite_rating->isChecked());
s.setValue("delete_files", ui_->checkbox_delete_files->isChecked());

View File

@ -560,6 +560,13 @@ If there are no matches then it will use the largest image in the directory.</st
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_overwrite_rating">
<property name="text">
<string>Overwrite database rating when songs are re-read from disk</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_statistics_button">
<item>