Make context fonts configurable

Fixes #362
This commit is contained in:
Jonas Kvinge
2020-04-28 01:11:00 +02:00
parent 1a4f0dcf5a
commit 760aacca26
7 changed files with 249 additions and 21 deletions

View File

@@ -28,6 +28,7 @@
#include <QUrl>
#include <QImage>
#include <QIcon>
#include <QFont>
#include <QSize>
#include <QSizePolicy>
#include <QMenu>
@@ -244,6 +245,8 @@ ContextView::ContextView(QWidget *parent) :
label_play_lyrics_->setWordWrap(true);
label_play_lyrics_->setTextInteractionFlags(Qt::TextSelectableByMouse);
label_play_albums_->setWordWrap(true);
layout_play_->setContentsMargins(5, 0, 40, 0);
layout_play_->addWidget(widget_play_output_);
layout_play_->addSpacerItem(spacer_play_output_);
@@ -255,6 +258,30 @@ ContextView::ContextView(QWidget *parent) :
layout_play_->addWidget(label_play_lyrics_);
layout_play_->addSpacerItem(spacer_play_bottom_);
labels_play_ << label_engine_title_
<< label_device_title_
<< label_filetype_title_
<< label_length_title_
<< label_samplerate_title_
<< label_bitdepth_title_
<< label_bitrate_title_
<< label_play_albums_
<< label_play_lyrics_;
labels_play_data_ << label_engine_icon_
<< label_engine_
<< label_device_
<< label_device_icon_
<< label_filetype_
<< label_length_
<< label_samplerate_
<< label_bitdepth_
<< label_bitrate_
<< label_play_albums_
<< label_play_lyrics_;
labels_play_all_ = labels_play_ << labels_play_data_;
QFontDatabase::addApplicationFont(":/fonts/HumongousofEternitySt.ttf");
connect(widget_album_, SIGNAL(FadeStopFinished()), SLOT(FadeStopFinished()));
@@ -343,8 +370,14 @@ void ContextView::ReloadSettings() {
action_show_albums_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ALBUMS_BY_ARTIST], false).toBool());
action_show_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS], true).toBool());
action_search_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS], true).toBool());
font_headline_ = s.value("font_headline", font().family()).toString();
font_normal_ = s.value("font_normal", font().family()).toString();
font_size_headline_ = s.value("font_size_headline", ContextSettingsPage::kDefaultFontSizeHeadline).toReal();
font_size_normal_ = s.value("font_size_normal", font().pointSizeF()).toReal();
s.endGroup();
UpdateFonts();
if (widget_stacked_->currentWidget() == widget_stop_) {
NoSong();
}
@@ -435,14 +468,23 @@ void ContextView::NoSong() {
else html += tr("%1 albums").arg(collectionview_->TotalAlbums());
html += "<br />";
label_stop_summary_->setStyleSheet("font: 12pt; font-weight: regular;");
label_stop_summary_->setStyleSheet(QString("font: %1pt \"%2\"; font-weight: regular;").arg(font_size_normal_).arg(font_normal_));
label_stop_summary_->setText(html);
}
void ContextView::UpdateFonts() {
for (QLabel *l: labels_play_all_) {
l->setStyleSheet(QString("font: %2pt \"%1\"; font-weight: regular;").arg(font_normal_).arg(font_size_normal_));
}
label_play_albums_->setStyleSheet(QString("background-color: #3DADE8; color: rgb(255, 255, 255); font: %1pt \"%2\"; font-weight: regular;").arg(font_size_normal_).arg(font_normal_));
}
void ContextView::SetSong() {
label_top_->setStyleSheet("font: 11pt; font-weight: regular;");
label_top_->setStyleSheet(QString("font: %2pt \"%1\"; font-weight: regular;").arg(font_headline_).arg(font_size_headline_));
label_top_->setText(QString("<b>%1</b><br/>%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "<br/>"), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "<br/>")));
label_stop_summary_->clear();
@@ -565,7 +607,6 @@ void ContextView::SetSong() {
label_play_albums_->show();
widget_albums_->show();
label_play_albums_->setText("<b>" + tr("Albums by %1").arg( song_playing_.artist().toHtmlEscaped()) + "</b>");
label_play_albums_->setStyleSheet("background-color: #3DADE8; color: rgb(255, 255, 255); font: 11pt;");
for (CollectionBackend::Album album : albumlist) {
SongList songs = app_->collection_backend()->GetSongs(song_playing_.artist(), album.album_name, opt);
widget_albums_->albums_model()->AddSongs(songs);
@@ -662,21 +703,7 @@ void ContextView::UpdateSong(const Song &song) {
void ContextView::ResetSong() {
QList <QLabel *> labels_play_data;
labels_play_data << label_engine_icon_
<< label_engine_
<< label_device_
<< label_device_icon_
<< label_filetype_
<< label_length_
<< label_samplerate_
<< label_bitdepth_
<< label_bitrate_
<< label_play_albums_
<< label_play_lyrics_;
for (QLabel *l: labels_play_data) {
for (QLabel *l: labels_play_data_) {
l->clear();
}