2010-06-17 00:00:39 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-17 00:00:39 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nowplayingwidget.h"
|
|
|
|
|
2020-01-04 21:18:12 +01:00
|
|
|
#include <QGuiApplication>
|
2010-06-17 23:38:03 +02:00
|
|
|
#include <QMenu>
|
Fixes issu...
,'``.._ ,'``.
:,--._:)\,:,._,.: All Glory to
:`--,'' :`...';\ the HYPNO TOAD!
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/
2010-07-12 21:51:23 +02:00
|
|
|
#include <QMovie>
|
2010-06-17 00:00:39 +02:00
|
|
|
#include <QPaintEvent>
|
2020-01-04 21:24:31 +01:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QScreen>
|
2010-06-18 00:31:22 +02:00
|
|
|
#include <QSettings>
|
2010-06-17 00:00:39 +02:00
|
|
|
#include <QTextDocument>
|
|
|
|
#include <QTimeLine>
|
2020-01-04 21:24:31 +01:00
|
|
|
#include <QWindow>
|
2010-06-17 00:00:39 +02:00
|
|
|
#include <QtDebug>
|
|
|
|
|
2016-02-15 18:35:45 +01:00
|
|
|
#include "core/application.h"
|
|
|
|
#include "core/logging.h"
|
|
|
|
#include "covers/albumcoverloader.h"
|
|
|
|
#include "covers/coverproviders.h"
|
|
|
|
#include "covers/currentartloader.h"
|
|
|
|
#include "covers/kittenloader.h"
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "fullscreenhypnotoad.h"
|
2016-02-15 18:35:45 +01:00
|
|
|
#include "library/librarybackend.h"
|
|
|
|
#include "networkremote/networkremote.h"
|
|
|
|
#include "ui/albumcoverchoicecontroller.h"
|
|
|
|
#include "ui/iconloader.h"
|
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
const char* NowPlayingWidget::kSettingsGroup = "NowPlayingWidget";
|
|
|
|
|
Fixes issu...
,'``.._ ,'``.
:,--._:)\,:,._,.: All Glory to
:`--,'' :`...';\ the HYPNO TOAD!
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/
2010-07-12 21:51:23 +02:00
|
|
|
const char* NowPlayingWidget::kHypnotoadPath = ":/hypnotoad.gif";
|
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
// Space between the cover and the details in small mode
|
2010-06-18 02:24:09 +02:00
|
|
|
const int NowPlayingWidget::kPadding = 2;
|
2010-06-17 00:00:39 +02:00
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
// Width of the transparent to black gradient above and below the text in large
|
|
|
|
// mode
|
2010-06-17 23:38:03 +02:00
|
|
|
const int NowPlayingWidget::kGradientHead = 40;
|
|
|
|
const int NowPlayingWidget::kGradientTail = 20;
|
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
// Maximum height of the cover in large mode, and offset between the
|
2010-06-17 23:38:03 +02:00
|
|
|
// bottom of the cover and bottom of the widget
|
|
|
|
const int NowPlayingWidget::kMaxCoverSize = 260;
|
|
|
|
const int NowPlayingWidget::kBottomOffset = 0;
|
|
|
|
|
2010-06-18 02:24:09 +02:00
|
|
|
// Border for large mode
|
|
|
|
const int NowPlayingWidget::kTopBorder = 4;
|
|
|
|
|
2011-07-23 20:34:41 +02:00
|
|
|
NowPlayingWidget::NowPlayingWidget(QWidget* parent)
|
2014-02-07 16:34:20 +01:00
|
|
|
: QWidget(parent),
|
|
|
|
app_(nullptr),
|
|
|
|
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
|
|
|
|
mode_(SmallSongDetails),
|
|
|
|
menu_(new QMenu(this)),
|
|
|
|
above_statusbar_action_(nullptr),
|
2014-05-15 22:02:46 +02:00
|
|
|
fit_cover_width_action_(nullptr),
|
2014-02-07 16:34:20 +01:00
|
|
|
visible_(false),
|
|
|
|
small_ideal_height_(0),
|
2014-05-17 22:35:52 +02:00
|
|
|
fit_width_(false),
|
2014-02-07 16:34:20 +01:00
|
|
|
show_hide_animation_(new QTimeLine(500, this)),
|
|
|
|
fade_animation_(new QTimeLine(1000, this)),
|
|
|
|
details_(new QTextDocument(this)),
|
|
|
|
previous_track_opacity_(0.0),
|
|
|
|
bask_in_his_glory_action_(nullptr),
|
|
|
|
downloading_covers_(false),
|
|
|
|
aww_(false),
|
|
|
|
kittens_(nullptr),
|
|
|
|
pending_kitten_(0) {
|
2010-06-18 00:31:22 +02:00
|
|
|
// Load settings
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup);
|
|
|
|
mode_ = Mode(s.value("mode", SmallSongDetails).toInt());
|
2014-02-07 16:34:20 +01:00
|
|
|
album_cover_choice_controller_->search_cover_auto_action()->setChecked(
|
|
|
|
s.value("search_for_cover_auto", false).toBool());
|
2014-05-15 22:02:46 +02:00
|
|
|
fit_width_ = s.value("fit_cover_width", false).toBool();
|
2010-06-18 00:31:22 +02:00
|
|
|
|
2011-03-14 21:01:27 +01:00
|
|
|
// Accept drops for setting album art
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
// Context menu
|
2010-06-17 23:38:03 +02:00
|
|
|
QActionGroup* mode_group = new QActionGroup(this);
|
2019-11-10 15:07:12 +01:00
|
|
|
CreateModeAction(SmallSongDetails, tr("Small album cover"), mode_group);
|
|
|
|
CreateModeAction(LargeSongDetails, tr("Large album cover"), mode_group);
|
2019-11-10 15:16:39 +01:00
|
|
|
CreateModeAction(LargeSongDetailsBelow,
|
|
|
|
tr("Large album cover (details below)"), mode_group);
|
|
|
|
CreateModeAction(LargeNoSongDetails, tr("Large album cover (no details)"),
|
|
|
|
mode_group);
|
2010-06-18 02:06:59 +02:00
|
|
|
|
2010-06-17 23:38:03 +02:00
|
|
|
menu_->addActions(mode_group->actions());
|
2014-05-15 22:02:46 +02:00
|
|
|
|
|
|
|
fit_cover_width_action_ = menu_->addAction(tr("Fit cover to width"));
|
|
|
|
|
|
|
|
fit_cover_width_action_->setCheckable(true);
|
2019-02-22 18:44:39 +01:00
|
|
|
fit_cover_width_action_->setEnabled(mode_ != SmallSongDetails);
|
2014-05-15 22:02:46 +02:00
|
|
|
connect(fit_cover_width_action_, SIGNAL(toggled(bool)),
|
|
|
|
SLOT(FitCoverWidth(bool)));
|
|
|
|
fit_cover_width_action_->setChecked(fit_width_);
|
2010-06-18 02:06:59 +02:00
|
|
|
menu_->addSeparator();
|
2011-01-24 01:09:57 +01:00
|
|
|
|
2011-01-26 00:33:27 +01:00
|
|
|
QList<QAction*> actions = album_cover_choice_controller_->GetAllActions();
|
2011-01-24 19:32:09 +01:00
|
|
|
|
2013-12-30 23:50:57 +01:00
|
|
|
// Here we add the search automatically action, too!
|
|
|
|
actions.append(album_cover_choice_controller_->search_cover_auto_action());
|
|
|
|
|
2011-01-26 00:33:27 +01:00
|
|
|
connect(album_cover_choice_controller_->cover_from_file_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
|
2011-02-02 17:22:04 +01:00
|
|
|
connect(album_cover_choice_controller_->cover_to_file_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(SaveCoverToFile()));
|
2011-01-26 00:33:27 +01:00
|
|
|
connect(album_cover_choice_controller_->cover_from_url_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
|
|
|
|
connect(album_cover_choice_controller_->search_for_cover_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(SearchForCover()));
|
|
|
|
connect(album_cover_choice_controller_->unset_cover_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(UnsetCover()));
|
|
|
|
connect(album_cover_choice_controller_->show_cover_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(ShowCover()));
|
2013-12-30 23:50:57 +01:00
|
|
|
connect(album_cover_choice_controller_->search_cover_auto_action(),
|
|
|
|
SIGNAL(triggered()), this, SLOT(SearchCoverAutomatically()));
|
2011-01-24 19:32:09 +01:00
|
|
|
|
|
|
|
menu_->addActions(actions);
|
2010-12-26 18:16:40 +01:00
|
|
|
menu_->addSeparator();
|
2010-06-18 02:06:59 +02:00
|
|
|
above_statusbar_action_ = menu_->addAction(tr("Show above status bar"));
|
2011-01-24 19:32:09 +01:00
|
|
|
|
2010-06-18 02:06:59 +02:00
|
|
|
above_statusbar_action_->setCheckable(true);
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(above_statusbar_action_, SIGNAL(toggled(bool)),
|
|
|
|
SLOT(ShowAboveStatusBar(bool)));
|
|
|
|
above_statusbar_action_->setChecked(
|
|
|
|
s.value("above_status_bar", false).toBool());
|
2010-06-17 23:38:03 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
bask_in_his_glory_action_ =
|
|
|
|
menu_->addAction(tr("ALL GLORY TO THE HYPNOTOAD"));
|
2011-03-13 23:46:25 +01:00
|
|
|
bask_in_his_glory_action_->setVisible(false);
|
|
|
|
connect(bask_in_his_glory_action_, SIGNAL(triggered()), SLOT(Bask()));
|
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
// Animations
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(show_hide_animation_, SIGNAL(frameChanged(int)),
|
|
|
|
SLOT(SetHeight(int)));
|
2010-06-17 00:00:39 +02:00
|
|
|
setMaximumHeight(0);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(fade_animation_, SIGNAL(valueChanged(qreal)),
|
|
|
|
SLOT(FadePreviousTrack(qreal)));
|
|
|
|
fade_animation_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
|
2010-06-17 00:00:39 +02:00
|
|
|
|
2014-05-15 04:06:02 +02:00
|
|
|
// add placeholder text to get the correct height
|
|
|
|
if (mode_ == LargeSongDetailsBelow) {
|
|
|
|
details_->setDefaultStyleSheet(
|
2014-05-15 22:02:46 +02:00
|
|
|
"p {"
|
|
|
|
" font-size: small;"
|
|
|
|
" color: white;"
|
|
|
|
"}");
|
2014-05-15 04:06:02 +02:00
|
|
|
details_->setHtml(QString("<p align=center><i></i><br/><br/></p>"));
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
UpdateHeight();
|
2013-12-30 23:50:57 +01:00
|
|
|
|
|
|
|
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()),
|
|
|
|
this, SLOT(AutomaticCoverSearchDone()));
|
2011-01-23 21:24:17 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
NowPlayingWidget::~NowPlayingWidget() {}
|
2011-03-13 23:46:25 +01:00
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
void NowPlayingWidget::SetApplication(Application* app) {
|
|
|
|
app_ = app;
|
|
|
|
|
|
|
|
album_cover_choice_controller_->SetApplication(app_);
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(app_->current_art_loader(), SIGNAL(ArtLoaded(Song, QString, QImage)),
|
|
|
|
SLOT(AlbumArtLoaded(Song, QString, QImage)));
|
2011-07-23 20:34:41 +02:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void NowPlayingWidget::CreateModeAction(Mode mode, const QString& text,
|
2019-11-10 15:07:12 +01:00
|
|
|
QActionGroup* group) {
|
2010-06-17 23:38:03 +02:00
|
|
|
QAction* action = new QAction(text, group);
|
|
|
|
action->setCheckable(true);
|
2019-11-10 15:16:39 +01:00
|
|
|
connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); });
|
2010-06-17 23:38:03 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
if (mode == mode_) action->setChecked(true);
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
|
|
|
|
2010-06-17 00:00:39 +02:00
|
|
|
void NowPlayingWidget::set_ideal_height(int height) {
|
2010-06-17 23:38:03 +02:00
|
|
|
small_ideal_height_ = height;
|
2012-02-13 21:44:04 +01:00
|
|
|
UpdateHeight();
|
2010-06-17 00:00:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize NowPlayingWidget::sizeHint() const {
|
2012-02-13 21:44:04 +01:00
|
|
|
return QSize(cover_loader_options_.desired_height_, total_height_);
|
2010-06-17 00:00:39 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
void NowPlayingWidget::UpdateHeight() {
|
2010-06-17 23:38:03 +02:00
|
|
|
switch (mode_) {
|
2014-02-07 16:34:20 +01:00
|
|
|
case SmallSongDetails:
|
|
|
|
cover_loader_options_.desired_height_ = small_ideal_height_;
|
|
|
|
total_height_ = small_ideal_height_;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LargeSongDetails:
|
2015-01-26 19:11:19 +01:00
|
|
|
case LargeNoSongDetails:
|
2014-05-15 22:02:46 +02:00
|
|
|
if (fit_width_) {
|
|
|
|
cover_loader_options_.desired_height_ = width();
|
|
|
|
} else {
|
|
|
|
cover_loader_options_.desired_height_ = qMin(kMaxCoverSize, width());
|
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
total_height_ =
|
|
|
|
kTopBorder + cover_loader_options_.desired_height_ + kBottomOffset;
|
|
|
|
break;
|
2014-05-15 01:07:53 +02:00
|
|
|
|
|
|
|
case LargeSongDetailsBelow:
|
2014-05-15 22:02:46 +02:00
|
|
|
if (fit_width_) {
|
|
|
|
cover_loader_options_.desired_height_ = width();
|
|
|
|
} else {
|
|
|
|
cover_loader_options_.desired_height_ = qMin(kMaxCoverSize, width());
|
|
|
|
}
|
2014-05-15 01:07:53 +02:00
|
|
|
total_height_ = kTopBorder + cover_loader_options_.desired_height_ +
|
|
|
|
kBottomOffset + details_->size().height();
|
|
|
|
break;
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the animation settings and resize the widget now if we're visible
|
|
|
|
show_hide_animation_->setFrameRange(0, total_height_);
|
|
|
|
if (visible_ && show_hide_animation_->state() != QTimeLine::Running)
|
|
|
|
setMaximumHeight(total_height_);
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
// Re-scale the current image
|
|
|
|
if (metadata_.is_valid()) {
|
|
|
|
ScaleCover();
|
|
|
|
}
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
// Tell Qt we've changed size
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void NowPlayingWidget::Stopped() { SetVisible(false); }
|
2010-06-17 00:00:39 +02:00
|
|
|
|
2010-06-17 23:38:03 +02:00
|
|
|
void NowPlayingWidget::UpdateDetailsText() {
|
|
|
|
QString html;
|
|
|
|
|
|
|
|
switch (mode_) {
|
|
|
|
case SmallSongDetails:
|
2015-01-26 19:11:19 +01:00
|
|
|
case LargeNoSongDetails:
|
2010-06-17 23:38:03 +02:00
|
|
|
details_->setTextWidth(-1);
|
|
|
|
details_->setDefaultStyleSheet("");
|
|
|
|
html += "<p>";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LargeSongDetails:
|
2012-02-13 21:44:04 +01:00
|
|
|
details_->setTextWidth(cover_loader_options_.desired_height_);
|
2014-02-07 16:34:20 +01:00
|
|
|
details_->setDefaultStyleSheet(
|
|
|
|
"p {"
|
2010-06-17 23:38:03 +02:00
|
|
|
" font-size: small;"
|
|
|
|
" color: white;"
|
|
|
|
"}");
|
|
|
|
html += "<p align=center>";
|
|
|
|
break;
|
2014-05-15 01:07:53 +02:00
|
|
|
|
|
|
|
case LargeSongDetailsBelow:
|
|
|
|
details_->setTextWidth(cover_loader_options_.desired_height_);
|
2014-05-15 22:39:32 +02:00
|
|
|
if (fit_width_) {
|
2014-06-24 12:15:46 +02:00
|
|
|
details_->setDefaultStyleSheet(
|
2014-05-16 00:39:08 +02:00
|
|
|
"p {"
|
|
|
|
" font-size: small;"
|
|
|
|
"}");
|
2014-05-15 22:39:32 +02:00
|
|
|
} else {
|
|
|
|
details_->setDefaultStyleSheet(
|
|
|
|
"p {"
|
|
|
|
" font-size: small;"
|
|
|
|
" color: white;"
|
|
|
|
"}");
|
|
|
|
}
|
2014-05-15 01:07:53 +02:00
|
|
|
html += "<p align=center>";
|
|
|
|
break;
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Make this configurable
|
2020-09-18 16:15:19 +02:00
|
|
|
html += QString("<i>%1</i><br/>%2<br/>%3")
|
|
|
|
.arg(metadata_.PrettyTitle().toHtmlEscaped(),
|
|
|
|
metadata_.artist().toHtmlEscaped(),
|
|
|
|
metadata_.album().toHtmlEscaped());
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
html += "</p>";
|
|
|
|
details_->setHtml(html);
|
2014-05-15 04:10:39 +02:00
|
|
|
|
|
|
|
// if something spans multiple lines the height needs to change
|
|
|
|
if (mode_ == LargeSongDetailsBelow) {
|
|
|
|
UpdateHeight();
|
|
|
|
}
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
void NowPlayingWidget::ScaleCover() {
|
|
|
|
cover_ = QPixmap::fromImage(
|
2014-02-07 16:34:20 +01:00
|
|
|
AlbumCoverLoader::ScaleAndPad(cover_loader_options_, original_));
|
2012-02-13 21:44:04 +01:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::KittenLoaded(quint64 id, const QImage& image) {
|
|
|
|
if (aww_ && pending_kitten_ == id) {
|
|
|
|
SetImage(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-30 23:50:57 +01:00
|
|
|
void NowPlayingWidget::AlbumArtLoaded(const Song& metadata, const QString& uri,
|
2012-02-13 21:44:04 +01:00
|
|
|
const QImage& image) {
|
|
|
|
metadata_ = metadata;
|
2013-12-30 23:50:57 +01:00
|
|
|
downloading_covers_ = false;
|
2012-02-13 21:44:04 +01:00
|
|
|
|
|
|
|
if (aww_) {
|
2014-02-07 16:34:20 +01:00
|
|
|
pending_kitten_ =
|
|
|
|
kittens_->LoadKitten(app_->current_art_loader()->options());
|
2010-06-17 00:00:39 +02:00
|
|
|
return;
|
2012-02-13 21:44:04 +01:00
|
|
|
}
|
2010-06-17 00:00:39 +02:00
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
SetImage(image);
|
2013-12-30 23:50:57 +01:00
|
|
|
|
|
|
|
// Search for cover automatically?
|
|
|
|
GetCoverAutomatically();
|
2012-02-13 21:44:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::SetImage(const QImage& image) {
|
|
|
|
if (visible_) {
|
|
|
|
// Cache the current pixmap so we can fade between them
|
|
|
|
previous_track_ = QPixmap(size());
|
2020-01-04 23:01:02 +01:00
|
|
|
previous_track_.fill(palette().window().color());
|
2012-02-13 21:44:04 +01:00
|
|
|
previous_track_opacity_ = 1.0;
|
|
|
|
QPainter p(&previous_track_);
|
|
|
|
DrawContents(&p);
|
|
|
|
p.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
original_ = image;
|
|
|
|
|
|
|
|
UpdateDetailsText();
|
|
|
|
ScaleCover();
|
|
|
|
SetVisible(true);
|
2010-06-17 00:00:39 +02:00
|
|
|
|
|
|
|
// Were we waiting for this cover to load before we started fading?
|
|
|
|
if (!previous_track_.isNull()) {
|
|
|
|
fade_animation_->start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void NowPlayingWidget::SetHeight(int height) { setMaximumHeight(height); }
|
2010-06-17 00:00:39 +02:00
|
|
|
|
|
|
|
void NowPlayingWidget::SetVisible(bool visible) {
|
2014-02-07 16:34:20 +01:00
|
|
|
if (visible == visible_) return;
|
2010-06-17 00:00:39 +02:00
|
|
|
visible_ = visible;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
show_hide_animation_->setDirection(visible ? QTimeLine::Forward
|
|
|
|
: QTimeLine::Backward);
|
2010-06-17 00:00:39 +02:00
|
|
|
show_hide_animation_->start();
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void NowPlayingWidget::paintEvent(QPaintEvent* e) {
|
2010-06-17 00:00:39 +02:00
|
|
|
QPainter p(this);
|
|
|
|
|
|
|
|
DrawContents(&p);
|
|
|
|
|
|
|
|
// Draw the previous track's image if we're fading
|
|
|
|
if (!previous_track_.isNull()) {
|
|
|
|
p.setOpacity(previous_track_opacity_);
|
|
|
|
p.drawPixmap(0, 0, previous_track_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void NowPlayingWidget::DrawContents(QPainter* p) {
|
2010-06-17 23:38:03 +02:00
|
|
|
switch (mode_) {
|
2014-02-07 16:34:20 +01:00
|
|
|
case SmallSongDetails:
|
|
|
|
if (hypnotoad_) {
|
|
|
|
p->drawPixmap(0, 0, small_ideal_height_, small_ideal_height_,
|
|
|
|
hypnotoad_->currentPixmap());
|
|
|
|
} else {
|
|
|
|
// Draw the cover
|
|
|
|
p->drawPixmap(0, 0, small_ideal_height_, small_ideal_height_, cover_);
|
|
|
|
if (downloading_covers_) {
|
|
|
|
p->drawPixmap(small_ideal_height_ - 18, 6, 16, 16,
|
|
|
|
spinner_animation_->currentPixmap());
|
|
|
|
}
|
2013-12-30 23:50:57 +01:00
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
// Draw the details
|
|
|
|
p->translate(small_ideal_height_ + kPadding, 0);
|
|
|
|
details_->drawContents(p);
|
|
|
|
p->translate(-small_ideal_height_ - kPadding, 0);
|
|
|
|
break;
|
|
|
|
|
2014-05-15 01:07:53 +02:00
|
|
|
case LargeSongDetails: {
|
2014-05-15 22:02:46 +02:00
|
|
|
const int total_size =
|
|
|
|
fit_width_ ? width() : qMin(kMaxCoverSize, width());
|
2014-02-07 16:34:20 +01:00
|
|
|
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_) {
|
2014-02-22 21:27:58 +01:00
|
|
|
p->drawPixmap(x_offset + 45, 35, 16, 16,
|
2014-02-07 16:34:20 +01:00
|
|
|
spinner_animation_->currentPixmap());
|
|
|
|
}
|
2013-12-30 23:50:57 +01:00
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
// Work out how high the text is going to be
|
|
|
|
const int text_height = details_->size().height();
|
|
|
|
const int gradient_mid = height() - qMax(text_height, kBottomOffset);
|
|
|
|
|
|
|
|
// Draw the black fade
|
|
|
|
QLinearGradient gradient(0, gradient_mid - kGradientHead, 0,
|
|
|
|
gradient_mid + kGradientTail);
|
|
|
|
gradient.setColorAt(0, QColor(0, 0, 0, 0));
|
|
|
|
gradient.setColorAt(1, QColor(0, 0, 0, 255));
|
|
|
|
|
|
|
|
p->fillRect(0, gradient_mid - kGradientHead, width(),
|
|
|
|
height() - (gradient_mid - kGradientHead), gradient);
|
|
|
|
|
|
|
|
// Draw the text on top
|
|
|
|
p->translate(x_offset, height() - text_height);
|
|
|
|
details_->drawContents(p);
|
|
|
|
p->translate(-x_offset, -height() + text_height);
|
|
|
|
break;
|
2014-05-15 01:07:53 +02:00
|
|
|
}
|
|
|
|
|
2015-01-26 19:11:19 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:53 +02:00
|
|
|
case LargeSongDetailsBelow:
|
|
|
|
// Work out how high the text is going to be
|
|
|
|
const int text_height = details_->size().height();
|
|
|
|
|
2014-05-15 22:02:46 +02:00
|
|
|
const int cover_size =
|
|
|
|
fit_width_ ? width() : qMin(kMaxCoverSize, width());
|
2014-05-15 01:07:53 +02:00
|
|
|
const int x_offset =
|
|
|
|
(width() - cover_loader_options_.desired_height_) / 2;
|
|
|
|
|
2014-05-15 22:39:32 +02:00
|
|
|
if (!fit_width_) {
|
|
|
|
// Draw the black background
|
|
|
|
p->fillRect(QRect(0, kTopBorder, width(), height() - kTopBorder),
|
|
|
|
Qt::black);
|
|
|
|
}
|
2014-05-15 01:07:53 +02:00
|
|
|
|
|
|
|
// Draw the cover
|
|
|
|
if (hypnotoad_) {
|
|
|
|
p->drawPixmap(x_offset, kTopBorder, cover_size, cover_size,
|
|
|
|
hypnotoad_->currentPixmap());
|
|
|
|
} else {
|
|
|
|
p->drawPixmap(x_offset, kTopBorder, cover_size, cover_size, cover_);
|
|
|
|
if (downloading_covers_) {
|
|
|
|
p->drawPixmap(x_offset + 45, 35, 16, 16,
|
|
|
|
spinner_animation_->currentPixmap());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the text below
|
|
|
|
p->translate(x_offset, height() - text_height);
|
|
|
|
details_->drawContents(p);
|
|
|
|
p->translate(-x_offset, -height() + text_height);
|
|
|
|
break;
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
2010-06-17 00:00:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::FadePreviousTrack(qreal value) {
|
|
|
|
previous_track_opacity_ = value;
|
2011-08-01 22:37:53 +02:00
|
|
|
if (qFuzzyCompare(previous_track_opacity_, qreal(0.0))) {
|
2010-06-17 00:00:39 +02:00
|
|
|
previous_track_ = QPixmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
void NowPlayingWidget::SetMode(int mode) {
|
|
|
|
mode_ = Mode(mode);
|
2014-05-15 22:02:46 +02:00
|
|
|
|
|
|
|
if (mode_ == SmallSongDetails) {
|
|
|
|
fit_cover_width_action_->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
fit_cover_width_action_->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
UpdateHeight();
|
2010-06-17 23:38:03 +02:00
|
|
|
UpdateDetailsText();
|
|
|
|
update();
|
2010-06-18 00:31:22 +02:00
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup);
|
|
|
|
s.setValue("mode", mode_);
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::resizeEvent(QResizeEvent* e) {
|
2014-05-15 01:07:53 +02:00
|
|
|
if (visible_ && e->oldSize() != e->size()) {
|
2015-06-10 21:23:40 +02:00
|
|
|
if (mode_ == LargeSongDetails || mode_ == LargeNoSongDetails ||
|
|
|
|
mode_ == LargeSongDetailsBelow) {
|
2014-05-15 01:07:53 +02:00
|
|
|
UpdateHeight();
|
|
|
|
UpdateDetailsText();
|
|
|
|
}
|
2010-06-17 23:38:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
|
2011-02-02 17:22:04 +01:00
|
|
|
// initial 'enabled' values depending on the kitty mode
|
|
|
|
album_cover_choice_controller_->cover_from_file_action()->setEnabled(!aww_);
|
|
|
|
album_cover_choice_controller_->cover_from_url_action()->setEnabled(!aww_);
|
2011-07-23 20:34:41 +02:00
|
|
|
album_cover_choice_controller_->search_for_cover_action()->setEnabled(
|
2014-02-07 16:34:20 +01:00
|
|
|
!aww_ && app_->cover_providers()->HasAnyProviders());
|
2011-02-02 17:22:04 +01:00
|
|
|
album_cover_choice_controller_->unset_cover_action()->setEnabled(!aww_);
|
|
|
|
album_cover_choice_controller_->show_cover_action()->setEnabled(!aww_);
|
|
|
|
|
|
|
|
// some special cases
|
2011-03-14 21:01:27 +01:00
|
|
|
if (!aww_) {
|
2014-02-07 16:34:20 +01:00
|
|
|
const bool art_is_not_set = metadata_.has_manually_unset_cover() ||
|
|
|
|
(metadata_.art_automatic().isEmpty() &&
|
|
|
|
metadata_.art_manual().isEmpty());
|
|
|
|
|
|
|
|
album_cover_choice_controller_->unset_cover_action()->setEnabled(
|
|
|
|
!art_is_not_set);
|
|
|
|
album_cover_choice_controller_->show_cover_action()->setEnabled(
|
|
|
|
!art_is_not_set);
|
2011-02-02 17:22:04 +01:00
|
|
|
}
|
2010-12-26 18:16:40 +01:00
|
|
|
|
2013-04-15 12:58:16 +02:00
|
|
|
bask_in_his_glory_action_->setVisible(static_cast<bool>(hypnotoad_));
|
2011-03-13 23:46:25 +01:00
|
|
|
|
2011-02-02 17:22:04 +01:00
|
|
|
// show the menu
|
2010-06-17 23:38:03 +02:00
|
|
|
menu_->popup(mapToGlobal(e->pos()));
|
|
|
|
}
|
2010-06-18 02:06:59 +02:00
|
|
|
|
2015-06-05 19:17:04 +02:00
|
|
|
void NowPlayingWidget::mouseReleaseEvent(QMouseEvent* e) {
|
2014-06-24 12:15:46 +02:00
|
|
|
// Same behaviour as right-click > Show Fullsize
|
2015-06-05 19:17:04 +02:00
|
|
|
if (e->button() == Qt::LeftButton && !aww_ && !hypnotoad_.get()) {
|
2014-06-24 12:15:46 +02:00
|
|
|
ShowCover();
|
|
|
|
}
|
2014-06-22 19:18:23 +02:00
|
|
|
}
|
|
|
|
|
2010-06-18 02:06:59 +02:00
|
|
|
void NowPlayingWidget::ShowAboveStatusBar(bool above) {
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup);
|
|
|
|
s.setValue("above_status_bar", above);
|
|
|
|
|
|
|
|
emit ShowAboveStatusBarChanged(above);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NowPlayingWidget::show_above_status_bar() const {
|
|
|
|
return above_statusbar_action_->isChecked();
|
|
|
|
}
|
Fixes issu...
,'``.._ ,'``.
:,--._:)\,:,._,.: All Glory to
:`--,'' :`...';\ the HYPNO TOAD!
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/
2010-07-12 21:51:23 +02:00
|
|
|
|
2014-05-15 22:02:46 +02:00
|
|
|
void NowPlayingWidget::FitCoverWidth(bool fit) {
|
|
|
|
fit_width_ = fit;
|
|
|
|
UpdateHeight();
|
|
|
|
update();
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup);
|
|
|
|
s.setValue("fit_cover_width", fit_width_);
|
|
|
|
}
|
|
|
|
|
Fixes issu...
,'``.._ ,'``.
:,--._:)\,:,._,.: All Glory to
:`--,'' :`...';\ the HYPNO TOAD!
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/
2010-07-12 21:51:23 +02:00
|
|
|
void NowPlayingWidget::AllHail(bool hypnotoad) {
|
2010-07-12 21:58:47 +02:00
|
|
|
if (hypnotoad) {
|
2011-03-13 23:46:25 +01:00
|
|
|
hypnotoad_.reset(new QMovie(kHypnotoadPath, QByteArray(), this));
|
|
|
|
connect(hypnotoad_.get(), SIGNAL(updated(const QRect&)), SLOT(update()));
|
2010-07-12 21:58:47 +02:00
|
|
|
hypnotoad_->start();
|
|
|
|
update();
|
|
|
|
} else {
|
2011-03-13 23:46:25 +01:00
|
|
|
hypnotoad_.reset();
|
2010-07-12 21:58:47 +02:00
|
|
|
update();
|
|
|
|
}
|
Fixes issu...
,'``.._ ,'``.
:,--._:)\,:,._,.: All Glory to
:`--,'' :`...';\ the HYPNO TOAD!
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/
2010-07-12 21:51:23 +02:00
|
|
|
}
|
2010-12-10 15:26:29 +01:00
|
|
|
|
|
|
|
void NowPlayingWidget::EnableKittens(bool aww) {
|
2012-02-13 21:44:04 +01:00
|
|
|
if (!kittens_ && aww) {
|
|
|
|
kittens_ = new KittenLoader(this);
|
|
|
|
app_->MoveToNewThread(kittens_);
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(kittens_, SIGNAL(ImageLoaded(quint64, QImage)),
|
|
|
|
SLOT(KittenLoaded(quint64, QImage)));
|
|
|
|
connect(kittens_, SIGNAL(ImageLoaded(quint64, QImage)),
|
|
|
|
app_->network_remote(), SLOT(SendKitten(quint64, QImage)));
|
2010-12-10 15:26:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
aww_ = aww;
|
|
|
|
}
|
2010-12-26 18:16:40 +01:00
|
|
|
|
|
|
|
void NowPlayingWidget::LoadCoverFromFile() {
|
2012-02-13 21:44:04 +01:00
|
|
|
album_cover_choice_controller_->LoadCoverFromFile(&metadata_);
|
2010-12-26 18:16:40 +01:00
|
|
|
}
|
|
|
|
|
2011-01-23 21:24:17 +01:00
|
|
|
void NowPlayingWidget::LoadCoverFromURL() {
|
2012-02-13 21:44:04 +01:00
|
|
|
album_cover_choice_controller_->LoadCoverFromURL(&metadata_);
|
2011-01-23 21:24:17 +01:00
|
|
|
}
|
|
|
|
|
2011-01-24 01:09:57 +01:00
|
|
|
void NowPlayingWidget::SearchForCover() {
|
2012-02-13 21:44:04 +01:00
|
|
|
album_cover_choice_controller_->SearchForCover(&metadata_);
|
2010-12-26 18:16:40 +01:00
|
|
|
}
|
|
|
|
|
2011-02-02 17:22:04 +01:00
|
|
|
void NowPlayingWidget::SaveCoverToFile() {
|
|
|
|
album_cover_choice_controller_->SaveCoverToFile(metadata_, original_);
|
2011-01-31 21:53:38 +01:00
|
|
|
}
|
|
|
|
|
2010-12-26 18:16:40 +01:00
|
|
|
void NowPlayingWidget::UnsetCover() {
|
2011-01-24 18:53:31 +01:00
|
|
|
album_cover_choice_controller_->UnsetCover(&metadata_);
|
2010-12-26 18:16:40 +01:00
|
|
|
}
|
|
|
|
|
2011-01-24 01:09:57 +01:00
|
|
|
void NowPlayingWidget::ShowCover() {
|
2018-06-18 15:21:44 +02:00
|
|
|
album_cover_choice_controller_->ToggleCover(metadata_);
|
2010-12-26 18:16:40 +01:00
|
|
|
}
|
|
|
|
|
2013-12-30 23:50:57 +01:00
|
|
|
void NowPlayingWidget::SearchCoverAutomatically() {
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup);
|
2014-02-07 16:34:20 +01:00
|
|
|
s.setValue(
|
|
|
|
"search_for_cover_auto",
|
|
|
|
album_cover_choice_controller_->search_cover_auto_action()->isChecked());
|
2013-12-30 23:50:57 +01:00
|
|
|
|
|
|
|
// Search for cover automatically?
|
|
|
|
GetCoverAutomatically();
|
|
|
|
}
|
|
|
|
|
2011-03-13 23:46:25 +01:00
|
|
|
void NowPlayingWidget::Bask() {
|
2020-01-04 21:18:12 +01:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
2020-01-05 02:51:08 +01:00
|
|
|
QScreen* screen = QWidget::screen();
|
2020-01-04 21:18:12 +01:00
|
|
|
#else
|
2020-01-04 21:24:31 +01:00
|
|
|
QScreen* screen =
|
|
|
|
(window() && window()->windowHandle() ? window()->windowHandle()->screen()
|
|
|
|
: QGuiApplication::primaryScreen());
|
2020-01-04 21:18:12 +01:00
|
|
|
#endif
|
2011-03-13 23:46:25 +01:00
|
|
|
big_hypnotoad_.reset(new FullscreenHypnotoad);
|
2020-01-04 21:18:12 +01:00
|
|
|
if (screen) big_hypnotoad_->setGeometry(screen->availableGeometry());
|
2011-03-13 23:46:25 +01:00
|
|
|
big_hypnotoad_->showFullScreen();
|
|
|
|
}
|
2011-03-14 21:01:27 +01:00
|
|
|
|
|
|
|
void NowPlayingWidget::dragEnterEvent(QDragEnterEvent* e) {
|
|
|
|
if (AlbumCoverChoiceController::CanAcceptDrag(e)) {
|
|
|
|
e->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::dragEnterEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::dropEvent(QDropEvent* e) {
|
|
|
|
album_cover_choice_controller_->SaveCover(&metadata_, e);
|
|
|
|
|
|
|
|
QWidget::dropEvent(e);
|
|
|
|
}
|
2013-12-30 23:50:57 +01:00
|
|
|
|
|
|
|
bool NowPlayingWidget::GetCoverAutomatically() {
|
|
|
|
// Search for cover automatically?
|
2014-02-07 16:34:20 +01:00
|
|
|
bool search =
|
|
|
|
album_cover_choice_controller_->search_cover_auto_action()->isChecked() &&
|
2013-12-30 23:50:57 +01:00
|
|
|
!metadata_.has_manually_unset_cover() &&
|
2014-05-07 21:17:33 +02:00
|
|
|
metadata_.art_automatic().isEmpty() && metadata_.art_manual().isEmpty() &&
|
2017-03-04 19:23:38 +01:00
|
|
|
!metadata_.effective_albumartist().isEmpty() &&
|
|
|
|
!metadata_.effective_album().isEmpty();
|
2013-12-30 23:50:57 +01:00
|
|
|
|
|
|
|
if (search) {
|
|
|
|
qLog(Debug) << "GetCoverAutomatically";
|
|
|
|
downloading_covers_ = true;
|
|
|
|
album_cover_choice_controller_->SearchCoverAutomatically(metadata_);
|
|
|
|
|
|
|
|
// Show a spinner animation
|
|
|
|
spinner_animation_.reset(new QMovie(":/spinner.gif", QByteArray(), this));
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(spinner_animation_.get(), SIGNAL(updated(const QRect&)),
|
|
|
|
SLOT(update()));
|
2013-12-30 23:50:57 +01:00
|
|
|
spinner_animation_->start();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return search;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::AutomaticCoverSearchDone() {
|
|
|
|
downloading_covers_ = false;
|
|
|
|
spinner_animation_.reset();
|
|
|
|
update();
|
|
|
|
}
|