Add Now Playing widget option: No Song Details

This commit is contained in:
Fletcher Dostie 2015-01-26 13:11:19 -05:00
parent 9dbd58276b
commit 5fc4be803b
2 changed files with 30 additions and 1 deletions

View File

@ -99,6 +99,8 @@ NowPlayingWidget::NowPlayingWidget(QWidget* parent)
CreateModeAction(LargeSongDetailsBelow, CreateModeAction(LargeSongDetailsBelow,
tr("Large album cover (details below)"), mode_group, tr("Large album cover (details below)"), mode_group,
mode_mapper); mode_mapper);
CreateModeAction(LargeNoSongDetails, tr("Large album cover (no details)"), mode_group,
mode_mapper);
menu_->addActions(mode_group->actions()); menu_->addActions(mode_group->actions());
@ -210,6 +212,7 @@ void NowPlayingWidget::UpdateHeight() {
break; break;
case LargeSongDetails: case LargeSongDetails:
case LargeNoSongDetails:
if (fit_width_) { if (fit_width_) {
cover_loader_options_.desired_height_ = width(); cover_loader_options_.desired_height_ = width();
} else { } else {
@ -251,6 +254,7 @@ void NowPlayingWidget::UpdateDetailsText() {
switch (mode_) { switch (mode_) {
case SmallSongDetails: case SmallSongDetails:
case LargeNoSongDetails:
details_->setTextWidth(-1); details_->setTextWidth(-1);
details_->setDefaultStyleSheet(""); details_->setDefaultStyleSheet("");
html += "<p>"; html += "<p>";
@ -436,6 +440,30 @@ void NowPlayingWidget::DrawContents(QPainter* p) {
break; break;
} }
case LargeNoSongDetails: {
const int total_size =
fit_width_ ? width() : qMin(kMaxCoverSize, width());
const int x_offset =
(width() - cover_loader_options_.desired_height_) / 2;
// Draw the black background
p->fillRect(QRect(0, kTopBorder, width(), height() - kTopBorder),
Qt::black);
// Draw the cover
if (hypnotoad_) {
p->drawPixmap(x_offset, kTopBorder, total_size, total_size,
hypnotoad_->currentPixmap());
} else {
p->drawPixmap(x_offset, kTopBorder, total_size, total_size, cover_);
if (downloading_covers_) {
p->drawPixmap(x_offset + 45, 35, 16, 16,
spinner_animation_->currentPixmap());
}
}
break;
}
case LargeSongDetailsBelow: case LargeSongDetailsBelow:
// Work out how high the text is going to be // Work out how high the text is going to be
const int text_height = details_->size().height(); const int text_height = details_->size().height();
@ -500,7 +528,7 @@ void NowPlayingWidget::SetMode(int mode) {
void NowPlayingWidget::resizeEvent(QResizeEvent* e) { void NowPlayingWidget::resizeEvent(QResizeEvent* e) {
if (visible_ && e->oldSize() != e->size()) { if (visible_ && e->oldSize() != e->size()) {
if (mode_ == LargeSongDetails || mode_ == LargeSongDetailsBelow) { if (mode_ == LargeSongDetails || mode_ == LargeNoSongDetails || mode_ == LargeSongDetailsBelow) {
UpdateHeight(); UpdateHeight();
UpdateDetailsText(); UpdateDetailsText();
} }

View File

@ -58,6 +58,7 @@ class NowPlayingWidget : public QWidget {
SmallSongDetails = 0, SmallSongDetails = 0,
LargeSongDetails = 1, LargeSongDetails = 1,
LargeSongDetailsBelow = 2, LargeSongDetailsBelow = 2,
LargeNoSongDetails = 3,
}; };
void SetApplication(Application* app); void SetApplication(Application* app);