Refactor use of sort tags

This commit is contained in:
Jonas Kvinge
2025-08-09 19:08:51 +02:00
parent 65d9b6a9e9
commit c4646531b0
10 changed files with 244 additions and 352 deletions

View File

@@ -2,7 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
* Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -83,15 +83,9 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog,
ui_->setupUi(this);
ui_->list->setItemDelegate(new NativeSeparatorsDelegate(this));
// Icons
setWindowIcon(IconLoader::Load(u"library-music"_s, true, 0, 32));
ui_->add_directory->setIcon(IconLoader::Load(u"document-open-folder"_s));
ui_->combobox_sort->setItemData(0, static_cast<int>(SortBehaviour::AsIs));
ui_->combobox_sort->setItemData(1, static_cast<int>(SortBehaviour::SkipArticles));
ui_->combobox_sort->setItemData(2, static_cast<int>(SortBehaviour::UseSortTagForSort));
ui_->combobox_sort->setItemData(3, static_cast<int>(SortBehaviour::UseSortTagForDisplayAndSort));
ui_->combobox_cache_size->addItem(u"KB"_s, static_cast<int>(CacheSizeUnit::KB));
ui_->combobox_cache_size->addItem(u"MB"_s, static_cast<int>(CacheSizeUnit::MB));
@@ -153,21 +147,24 @@ void CollectionSettingsPage::Load() {
Settings s;
s.beginGroup(kSettingsGroup);
ui_->auto_open->setChecked(s.value(kAutoOpen, true).toBool());
ui_->show_dividers->setChecked(s.value(kShowDividers, true).toBool());
ui_->pretty_covers->setChecked(s.value(kPrettyCovers, true).toBool());
ui_->various_artists->setChecked(s.value(kVariousArtists, true).toBool());
ui_->combobox_sort->setCurrentIndex(ui_->combobox_sort->findData(s.value(kSortBehaviour, static_cast<int>(SortBehaviour::SkipArticles)).toInt()));
ui_->startup_scan->setChecked(s.value(kStartupScan, true).toBool());
ui_->monitor->setChecked(s.value(kMonitor, true).toBool());
ui_->song_tracking->setChecked(s.value(kSongTracking, false).toBool());
ui_->song_ebur128_loudness_analysis->setChecked(s.value(kSongENUR128LoudnessAnalysis, false).toBool());
ui_->mark_songs_unavailable->setChecked(ui_->song_tracking->isChecked() ? true : s.value(kMarkSongsUnavailable, true).toBool());
ui_->song_ebur128_loudness_analysis->setChecked(s.value(kSongENUR128LoudnessAnalysis, false).toBool());
ui_->expire_unavailable_songs_days->setValue(s.value(kExpireUnavailableSongs, 60).toInt());
QStringList filters = s.value(kCoverArtPatterns, QStringList() << u"front"_s << u"cover"_s).toStringList();
ui_->cover_art_patterns->setText(filters.join(u','));
ui_->auto_open->setChecked(s.value(kAutoOpen, true).toBool());
ui_->show_dividers->setChecked(s.value(kShowDividers, true).toBool());
ui_->pretty_covers->setChecked(s.value(kPrettyCovers, true).toBool());
ui_->various_artists->setChecked(s.value(kVariousArtists, true).toBool());
ui_->checkbox_skip_articles_for_artists->setChecked(s.value(kSkipArticlesForArtists, true).toBool());
ui_->checkbox_skip_articles_for_albums->setChecked(s.value(kSkipArticlesForAlbums, false).toBool());
ui_->spinbox_cache_size->setValue(s.value(kSettingsCacheSize, kSettingsCacheSizeDefault).toInt());
ui_->combobox_cache_size->setCurrentIndex(ui_->combobox_cache_size->findData(s.value(kSettingsCacheSizeUnit, static_cast<int>(CacheSizeUnit::MB)).toInt()));
ui_->checkbox_disk_cache->setChecked(s.value(kSettingsDiskCacheEnable, false).toBool());
@@ -197,24 +194,23 @@ void CollectionSettingsPage::Save() {
Settings s;
s.beginGroup(kSettingsGroup);
s.setValue(kStartupScan, ui_->startup_scan->isChecked());
s.setValue(kMonitor, ui_->monitor->isChecked());
s.setValue(kSongTracking, ui_->song_tracking->isChecked());
s.setValue(kMarkSongsUnavailable, ui_->song_tracking->isChecked() ? true : ui_->mark_songs_unavailable->isChecked());
s.setValue(kSongENUR128LoudnessAnalysis, ui_->song_ebur128_loudness_analysis->isChecked());
s.setValue(kExpireUnavailableSongs, ui_->expire_unavailable_songs_days->value());
const QString filter_text = ui_->cover_art_patterns->text();
s.setValue(kCoverArtPatterns, filter_text.split(u',', Qt::SkipEmptyParts));
s.setValue(kAutoOpen, ui_->auto_open->isChecked());
s.setValue(kShowDividers, ui_->show_dividers->isChecked());
s.setValue(kPrettyCovers, ui_->pretty_covers->isChecked());
s.setValue(kVariousArtists, ui_->various_artists->isChecked());
const SortBehaviour menu_sort = static_cast<SortBehaviour>(ui_->combobox_sort->currentData().toInt());
s.setValue(kSortBehaviour, static_cast<int>(menu_sort));
s.setValue(kStartupScan, ui_->startup_scan->isChecked());
s.setValue(kMonitor, ui_->monitor->isChecked());
s.setValue(kSongTracking, ui_->song_tracking->isChecked());
s.setValue(kSongENUR128LoudnessAnalysis, ui_->song_ebur128_loudness_analysis->isChecked());
s.setValue(kMarkSongsUnavailable, ui_->song_tracking->isChecked() ? true : ui_->mark_songs_unavailable->isChecked());
s.setValue(kExpireUnavailableSongs, ui_->expire_unavailable_songs_days->value());
QString filter_text = ui_->cover_art_patterns->text();
const QStringList filters = filter_text.split(u',', Qt::SkipEmptyParts);
s.setValue(kCoverArtPatterns, filters);
s.setValue(kSkipArticlesForArtists, ui_->checkbox_skip_articles_for_artists->isChecked());
s.setValue(kSkipArticlesForAlbums, ui_->checkbox_skip_articles_for_albums->isChecked());
s.setValue(kSettingsCacheSize, ui_->spinbox_cache_size->value());
s.setValue(kSettingsCacheSizeUnit, ui_->combobox_cache_size->currentData().toInt());

View File

@@ -2,7 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
* Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>604</width>
<height>1035</height>
<height>1112</height>
</rect>
</property>
<property name="windowTitle">
@@ -235,37 +235,18 @@ If there are no matches then it will use the largest image in the directory.</st
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_sort">
<property name="title">
<string>When sorting names like &quot;The Beatles&quot;...</string>
</property>
<layout class="QVBoxLayout" name="layout_sort">
<item>
<widget class="QComboBox" name="combobox_sort">
<item>
<property name="text">
<string>Sort and show name as is</string>
</property>
</item>
<item>
<property name="text">
<string>Skip articles &quot;The, A, An&quot; for sorting but show name as is</string>
</property>
</item>
<item>
<property name="text">
<string>Use sort tag for sorting and show name as is</string>
</property>
</item>
<item>
<property name="text">
<string>Use sort tag for sorting and display</string>
</property>
</item>
<widget class="QCheckBox" name="checkbox_skip_articles_for_artists">
<property name="text">
<string>Skip leading articles (&quot;the&quot;, &quot;a&quot;, &quot;an&quot;) when sorting artists, composers and performers</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_skip_articles_for_albums">
<property name="text">
<string>Skip leading articles (&quot;the&quot;, &quot;a&quot;, &quot;an&quot;) when sorting albums</string>
</property>
</widget>
</item>
</layout>
@@ -551,7 +532,8 @@ If there are no matches then it will use the largest image in the directory.</st
<tabstop>show_dividers</tabstop>
<tabstop>pretty_covers</tabstop>
<tabstop>various_artists</tabstop>
<tabstop>combobox_sort</tabstop>
<tabstop>checkbox_skip_articles_for_artists</tabstop>
<tabstop>checkbox_skip_articles_for_albums</tabstop>
<tabstop>spinbox_cache_size</tabstop>
<tabstop>combobox_cache_size</tabstop>
<tabstop>checkbox_disk_cache</tabstop>