mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Add option to show year next to album name in library and global search.
This commit is contained in:
parent
d32c3236ef
commit
e17fc06be1
@ -27,7 +27,8 @@ GlobalSearchModel::GlobalSearchModel(GlobalSearch* engine, QObject* parent)
|
||||
proxy_(nullptr),
|
||||
use_pretty_covers_(true),
|
||||
artist_icon_(":/icons/22x22/x-clementine-artist.png"),
|
||||
album_icon_(":/icons/22x22/x-clementine-album.png") {
|
||||
album_icon_(":/icons/22x22/x-clementine-album.png"),
|
||||
show_album_year_(false) {
|
||||
group_by_[0] = LibraryModel::GroupBy_Artist;
|
||||
group_by_[1] = LibraryModel::GroupBy_Album;
|
||||
group_by_[2] = LibraryModel::GroupBy_None;
|
||||
@ -137,7 +138,11 @@ QStandardItem* GlobalSearchModel::BuildContainers(const Song& s,
|
||||
case LibraryModel::GroupBy_Album:
|
||||
unique_tag = s.album_id();
|
||||
if (display_text.isNull()) {
|
||||
display_text = s.album();
|
||||
if (show_album_year_) {
|
||||
display_text = QString("%1 (%2)").arg(s.album()).arg(s.year());
|
||||
} else {
|
||||
display_text = s.album();
|
||||
}
|
||||
}
|
||||
// fallthrough
|
||||
case LibraryModel::GroupBy_AlbumArtist:
|
||||
|
@ -51,6 +51,7 @@ class GlobalSearchModel : public QStandardItemModel {
|
||||
provider_order_ = provider_order;
|
||||
}
|
||||
void SetGroupBy(const LibraryModel::Grouping& grouping, bool regroup_now);
|
||||
void set_show_album_year(bool show) { show_album_year_ = show; }
|
||||
|
||||
void Clear();
|
||||
|
||||
@ -87,6 +88,7 @@ class GlobalSearchModel : public QStandardItemModel {
|
||||
QIcon artist_icon_;
|
||||
QIcon album_icon_;
|
||||
QPixmap no_cover_icon_;
|
||||
bool show_album_year_;
|
||||
};
|
||||
|
||||
inline uint qHash(const GlobalSearchModel::ContainerKey& key) {
|
||||
|
@ -80,6 +80,8 @@ void GlobalSearchSettingsPage::Load() {
|
||||
|
||||
ui_->show_providers->setChecked(s.value("show_providers", true).toBool());
|
||||
ui_->show_suggestions->setChecked(s.value("show_suggestions", true).toBool());
|
||||
|
||||
ui_->show_album_year->setChecked(s.value("show_album_year", false).toBool());
|
||||
}
|
||||
|
||||
void GlobalSearchSettingsPage::AddProviderItem(GlobalSearch* engine,
|
||||
@ -143,6 +145,8 @@ void GlobalSearchSettingsPage::Save() {
|
||||
s.setValue("provider_order", provider_order);
|
||||
s.setValue("show_providers", ui_->show_providers->isChecked());
|
||||
s.setValue("show_suggestions", ui_->show_suggestions->isChecked());
|
||||
|
||||
s.setValue("show_album_year", ui_->show_album_year->isChecked());
|
||||
}
|
||||
|
||||
void GlobalSearchSettingsPage::MoveUp() { MoveCurrentItem(-1); }
|
||||
|
@ -131,6 +131,22 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="display_gorup">
|
||||
<property name="title">
|
||||
<string>Display options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="show_album_year">
|
||||
<property name="text">
|
||||
<string>Show year next to album</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
@ -65,7 +65,8 @@ GlobalSearchView::GlobalSearchView(Application* app, QWidget* parent)
|
||||
search_icon_(IconLoader::Load("search")),
|
||||
warning_icon_(IconLoader::Load("dialog-warning")),
|
||||
show_providers_(true),
|
||||
show_suggestions_(true) {
|
||||
show_suggestions_(true),
|
||||
show_album_year_(false) {
|
||||
ui_->setupUi(this);
|
||||
|
||||
front_model_->set_proxy(front_proxy_);
|
||||
@ -203,6 +204,9 @@ void GlobalSearchView::ReloadSettings() {
|
||||
back_model_->set_provider_order(provider_order);
|
||||
show_providers_ = s.value("show_providers", true).toBool();
|
||||
show_suggestions_ = s.value("show_suggestions", true).toBool();
|
||||
show_album_year_ = s.value("show_album_year", false).toBool();
|
||||
front_model_->set_show_album_year(show_album_year_);
|
||||
back_model_->set_show_album_year(show_album_year_);
|
||||
SetGroupBy(LibraryModel::Grouping(
|
||||
LibraryModel::GroupBy(
|
||||
s.value("group_by1", int(LibraryModel::GroupBy_Artist)).toInt()),
|
||||
|
@ -128,6 +128,8 @@ signals:
|
||||
|
||||
bool show_providers_;
|
||||
bool show_suggestions_;
|
||||
|
||||
bool show_album_year_;
|
||||
};
|
||||
|
||||
#endif // GLOBALSEARCHVIEW_H
|
||||
|
@ -83,6 +83,7 @@ LibraryModel::LibraryModel(LibraryBackend* backend, Application* app,
|
||||
dir_model_(new LibraryDirectoryModel(backend, this)),
|
||||
show_smart_playlists_(false),
|
||||
show_various_artists_(true),
|
||||
show_album_year_(false),
|
||||
total_song_count_(0),
|
||||
artist_icon_(":/icons/22x22/x-clementine-artist.png"),
|
||||
album_icon_(":/icons/22x22/x-clementine-album.png"),
|
||||
@ -757,6 +758,10 @@ void LibraryModel::BeginReset() {
|
||||
// Smart playlists?
|
||||
if (show_smart_playlists_ && query_options_.filter().isEmpty())
|
||||
CreateSmartPlaylists();
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(LibraryView::kSettingsGroup);
|
||||
show_album_year_ = s.value("show_album_year", false).toBool();
|
||||
}
|
||||
|
||||
void LibraryModel::Reset() {
|
||||
@ -775,7 +780,7 @@ void LibraryModel::InitQuery(GroupBy type, LibraryQuery* q) {
|
||||
q->SetColumnSpec("DISTINCT artist");
|
||||
break;
|
||||
case GroupBy_Album:
|
||||
q->SetColumnSpec("DISTINCT album");
|
||||
q->SetColumnSpec("DISTINCT album, MAX(year)");
|
||||
break;
|
||||
case GroupBy_Composer:
|
||||
q->SetColumnSpec("DISTINCT composer");
|
||||
@ -914,11 +919,21 @@ LibraryItem* LibraryModel::ItemFromQuery(GroupBy type, bool signal,
|
||||
item->sort_text = SortTextForYear(year) + " ";
|
||||
break;
|
||||
|
||||
case GroupBy_Album:
|
||||
item->key = row.value(0).toString();
|
||||
year = qMax(0, row.value(1).toInt());
|
||||
if (show_album_year_ && year != 0) {
|
||||
item->display_text = QString("%1 (%2)").arg(TextOrUnknown(item->key)).arg(year);
|
||||
} else {
|
||||
item->display_text = TextOrUnknown(item->key);
|
||||
}
|
||||
item->sort_text = SortTextForArtist(item->key);
|
||||
break;
|
||||
|
||||
case GroupBy_Composer:
|
||||
case GroupBy_Performer:
|
||||
case GroupBy_Grouping:
|
||||
case GroupBy_Genre:
|
||||
case GroupBy_Album:
|
||||
case GroupBy_AlbumArtist:
|
||||
item->key = row.value(0).toString();
|
||||
item->display_text = TextOrUnknown(item->key);
|
||||
|
@ -256,6 +256,7 @@ signals:
|
||||
bool show_smart_playlists_;
|
||||
DefaultGenerators default_smart_playlists_;
|
||||
bool show_various_artists_;
|
||||
bool show_album_year_;
|
||||
|
||||
int total_song_count_;
|
||||
|
||||
|
@ -88,6 +88,7 @@ void LibrarySettingsPage::Save() {
|
||||
s.setValue("auto_open", ui_->auto_open->isChecked());
|
||||
s.setValue("pretty_covers", ui_->pretty_covers->isChecked());
|
||||
s.setValue("show_dividers", ui_->show_dividers->isChecked());
|
||||
s.setValue("show_album_year", ui_->show_album_year->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(LibraryWatcher::kSettingsGroup);
|
||||
@ -128,6 +129,7 @@ void LibrarySettingsPage::Load() {
|
||||
ui_->auto_open->setChecked(s.value("auto_open", true).toBool());
|
||||
ui_->pretty_covers->setChecked(s.value("pretty_covers", true).toBool());
|
||||
ui_->show_dividers->setChecked(s.value("show_dividers", true).toBool());
|
||||
ui_->show_album_year->setChecked(s.value("show_album_year", false).toBool());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(LibraryWatcher::kSettingsGroup);
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>452</height>
|
||||
<height>486</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -181,6 +181,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="show_album_year">
|
||||
<property name="text">
|
||||
<string>Show year next to album</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user