From 0ebfa10d32873bc8fd36a091bfb9adfc3e51463e Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 14 May 2020 19:29:34 +0200 Subject: [PATCH] Update details in playing widget --- src/widgets/playingwidget.cpp | 30 +++++++++++++++++++++++------- src/widgets/playingwidget.h | 1 - 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/widgets/playingwidget.cpp b/src/widgets/playingwidget.cpp index 36cf46cb9..751946057 100644 --- a/src/widgets/playingwidget.cpp +++ b/src/widgets/playingwidget.cpp @@ -156,17 +156,21 @@ void PlayingWidget::SetEnabled(bool enabled) { } void PlayingWidget::SetEnabled() { + enabled_ = true; if (active_ && (!visible_ || (timeline_show_hide_->state() == QTimeLine::Running && timeline_show_hide_->currentFrame() <= 2))) { SetVisible(true); } + } void PlayingWidget::SetDisabled() { + enabled_ = false; if (visible_ || (timeline_show_hide_->state() == QTimeLine::Running && timeline_show_hide_->currentFrame() > 2 && total_height_ - timeline_show_hide_->currentFrame() <= 2)) { SetVisible(false); } + } void PlayingWidget::SetVisible(bool visible) { @@ -236,25 +240,31 @@ void PlayingWidget::FitCoverWidth(bool fit) { QSettings s; s.beginGroup(kSettingsGroup); s.setValue("fit_cover_width", fit_width_); + s.endGroup(); + } void PlayingWidget::ShowAboveStatusBar(bool above) { + QSettings s; s.beginGroup(kSettingsGroup); s.setValue("above_status_bar", above); - emit ShowAboveStatusBarChanged(above); s.endGroup(); + + emit ShowAboveStatusBarChanged(above); + } -void PlayingWidget::Playing() { -} +void PlayingWidget::Playing() {} void PlayingWidget::Stopped() { + playing_ = false; active_ = false; - song_playing_ = song_empty_; - song_ = song_empty_; + song_playing_ = Song(); + song_ = Song(); SetVisible(false); + } void PlayingWidget::Error() { @@ -262,9 +272,15 @@ void PlayingWidget::Error() { } void PlayingWidget::SongChanged(const Song &song) { + + bool changed = (song.artist() != song_playing_.artist() || song.album() != song_playing_.album() || song.title() != song_playing_.title()); + playing_ = true; song_playing_ = song; song_ = song; + + if (changed) UpdateDetailsText(); + } void PlayingWidget::AlbumCoverLoaded(const Song &song, const QImage &image) { @@ -362,7 +378,7 @@ void PlayingWidget::UpdateHeight() { void PlayingWidget::UpdateDetailsText() { - QString html(""); + QString html; details_->setDefaultStyleSheet("p { font-size: small; font-weight: bold; }"); switch (mode_) { case SmallSongDetails: @@ -376,8 +392,8 @@ void PlayingWidget::UpdateDetailsText() { } html += QString("%1
%2
%3").arg(song_.PrettyTitle().toHtmlEscaped(), song_.artist().toHtmlEscaped(), song_.album().toHtmlEscaped()); - html += "

"; + details_->setHtml(html); // if something spans multiple lines the height needs to change diff --git a/src/widgets/playingwidget.h b/src/widgets/playingwidget.h index c97c3b2a1..03b19f2b5 100644 --- a/src/widgets/playingwidget.h +++ b/src/widgets/playingwidget.h @@ -137,7 +137,6 @@ class PlayingWidget : public QWidget { Song song_; Song song_playing_; - Song song_empty_; QImage image_original_; QPixmap pixmap_cover_; QPixmap pixmap_previous_track_;