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/>.
|
|
|
|
*/
|
|
|
|
|
2011-03-13 23:46:25 +01:00
|
|
|
#include "fullscreenhypnotoad.h"
|
2010-06-17 00:00:39 +02:00
|
|
|
#include "nowplayingwidget.h"
|
2012-02-12 14:41:50 +01:00
|
|
|
#include "core/application.h"
|
2011-04-02 15:34:06 +02:00
|
|
|
#include "covers/albumcoverloader.h"
|
2011-04-27 21:10:37 +02:00
|
|
|
#include "covers/coverproviders.h"
|
2012-02-13 21:44:04 +01:00
|
|
|
#include "covers/currentartloader.h"
|
2011-04-02 15:34:06 +02:00
|
|
|
#include "covers/kittenloader.h"
|
2010-12-26 18:16:40 +01:00
|
|
|
#include "library/librarybackend.h"
|
2011-01-24 01:09:57 +01:00
|
|
|
#include "ui/albumcoverchoicecontroller.h"
|
2010-12-26 18:16:40 +01:00
|
|
|
#include "ui/iconloader.h"
|
2010-06-17 00:00:39 +02:00
|
|
|
|
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 <QPainter>
|
|
|
|
#include <QPaintEvent>
|
2010-06-18 00:31:22 +02:00
|
|
|
#include <QSettings>
|
2010-06-17 23:38:03 +02:00
|
|
|
#include <QSignalMapper>
|
2010-06-17 00:00:39 +02:00
|
|
|
#include <QTextDocument>
|
|
|
|
#include <QTimeLine>
|
|
|
|
#include <QtDebug>
|
|
|
|
|
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;
|
|
|
|
|
2010-06-18 00:31:22 +02:00
|
|
|
|
2011-07-23 20:34:41 +02:00
|
|
|
NowPlayingWidget::NowPlayingWidget(QWidget* parent)
|
2010-06-17 00:00:39 +02:00
|
|
|
: QWidget(parent),
|
2012-02-12 14:41:50 +01:00
|
|
|
app_(NULL),
|
2011-01-26 00:33:27 +01:00
|
|
|
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
|
2010-06-17 23:38:03 +02:00
|
|
|
mode_(SmallSongDetails),
|
|
|
|
menu_(new QMenu(this)),
|
2010-06-18 02:06:59 +02:00
|
|
|
above_statusbar_action_(NULL),
|
2010-06-17 00:00:39 +02:00
|
|
|
visible_(false),
|
2010-06-17 23:38:03 +02:00
|
|
|
small_ideal_height_(0),
|
2010-06-17 00:00:39 +02:00
|
|
|
show_hide_animation_(new QTimeLine(500, this)),
|
|
|
|
fade_animation_(new QTimeLine(1000, this)),
|
|
|
|
details_(new QTextDocument(this)),
|
Fixes issu...
,'``.._ ,'``.
:,--._:)\,:,._,.: All Glory to
:`--,'' :`...';\ the HYPNO TOAD!
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/
2010-07-12 21:51:23 +02:00
|
|
|
previous_track_opacity_(0.0),
|
2011-03-13 23:46:25 +01:00
|
|
|
bask_in_his_glory_action_(NULL),
|
2012-02-13 21:44:04 +01:00
|
|
|
aww_(false),
|
|
|
|
kittens_(NULL),
|
|
|
|
pending_kitten_(0)
|
2010-06-17 00:00:39 +02:00
|
|
|
{
|
2010-06-18 00:31:22 +02:00
|
|
|
// Load settings
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(kSettingsGroup);
|
|
|
|
mode_ = Mode(s.value("mode", SmallSongDetails).toInt());
|
|
|
|
|
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);
|
|
|
|
QSignalMapper* mode_mapper = new QSignalMapper(this);
|
2010-06-18 02:06:59 +02:00
|
|
|
connect(mode_mapper, SIGNAL(mapped(int)), SLOT(SetMode(int)));
|
2010-06-17 23:38:03 +02:00
|
|
|
CreateModeAction(SmallSongDetails, tr("Small album cover"), mode_group, mode_mapper);
|
|
|
|
CreateModeAction(LargeSongDetails, tr("Large album cover"), mode_group, mode_mapper);
|
2010-06-18 02:06:59 +02:00
|
|
|
|
2010-06-17 23:38:03 +02:00
|
|
|
menu_->addActions(mode_group->actions());
|
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
|
|
|
|
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()));
|
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);
|
|
|
|
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
|
|
|
|
2011-03-13 23:46:25 +01:00
|
|
|
bask_in_his_glory_action_ = menu_->addAction(tr("ALL GLORY TO THE HYPNOTOAD"));
|
|
|
|
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
|
2010-06-17 00:00:39 +02:00
|
|
|
connect(show_hide_animation_, SIGNAL(frameChanged(int)), SLOT(SetHeight(int)));
|
|
|
|
setMaximumHeight(0);
|
|
|
|
|
|
|
|
connect(fade_animation_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousTrack(qreal)));
|
|
|
|
fade_animation_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
UpdateHeight();
|
2011-01-23 21:24:17 +01:00
|
|
|
}
|
|
|
|
|
2011-03-13 23:46:25 +01:00
|
|
|
NowPlayingWidget::~NowPlayingWidget() {
|
|
|
|
}
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
void NowPlayingWidget::SetApplication(Application* app) {
|
|
|
|
app_ = app;
|
|
|
|
|
|
|
|
album_cover_choice_controller_->SetApplication(app_);
|
2012-02-13 21:44:04 +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
|
|
|
}
|
|
|
|
|
2010-06-17 23:38:03 +02:00
|
|
|
void NowPlayingWidget::CreateModeAction(Mode mode, const QString &text, QActionGroup *group, QSignalMapper* mapper) {
|
|
|
|
QAction* action = new QAction(text, group);
|
|
|
|
action->setCheckable(true);
|
|
|
|
mapper->setMapping(action, mode);
|
|
|
|
connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
|
|
|
|
|
|
|
|
if (mode == mode_)
|
|
|
|
action->setChecked(true);
|
|
|
|
}
|
|
|
|
|
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_) {
|
|
|
|
case SmallSongDetails:
|
2012-02-13 21:44:04 +01:00
|
|
|
cover_loader_options_.desired_height_ = small_ideal_height_;
|
2010-06-17 23:38:03 +02:00
|
|
|
total_height_ = small_ideal_height_;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LargeSongDetails:
|
2012-02-13 21:44:04 +01:00
|
|
|
cover_loader_options_.desired_height_ = qMin(kMaxCoverSize, width());
|
|
|
|
total_height_ = kTopBorder + cover_loader_options_.desired_height_ + kBottomOffset;
|
2010-06-17 23:38:03 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
2010-06-17 00:00:39 +02:00
|
|
|
void NowPlayingWidget::Stopped() {
|
|
|
|
SetVisible(false);
|
|
|
|
}
|
|
|
|
|
2010-06-17 23:38:03 +02:00
|
|
|
void NowPlayingWidget::UpdateDetailsText() {
|
|
|
|
QString html;
|
|
|
|
|
|
|
|
switch (mode_) {
|
|
|
|
case SmallSongDetails:
|
|
|
|
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_);
|
2010-06-17 23:38:03 +02:00
|
|
|
details_->setDefaultStyleSheet("p {"
|
|
|
|
" font-size: small;"
|
|
|
|
" color: white;"
|
|
|
|
"}");
|
|
|
|
html += "<p align=center>";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Make this configurable
|
|
|
|
html += QString("<i>%1</i><br/>%2<br/>%3").arg(
|
2010-08-06 16:15:14 +02:00
|
|
|
Qt::escape(metadata_.PrettyTitle()), Qt::escape(metadata_.artist()),
|
2010-06-17 23:38:03 +02:00
|
|
|
Qt::escape(metadata_.album()));
|
|
|
|
|
|
|
|
html += "</p>";
|
|
|
|
details_->setHtml(html);
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
void NowPlayingWidget::ScaleCover() {
|
|
|
|
cover_ = QPixmap::fromImage(
|
|
|
|
AlbumCoverLoader::ScaleAndPad(cover_loader_options_, original_));
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::KittenLoaded(quint64 id, const QImage& image) {
|
|
|
|
if (aww_ && pending_kitten_ == id) {
|
|
|
|
SetImage(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::AlbumArtLoaded(const Song& metadata, const QString&,
|
|
|
|
const QImage& image) {
|
|
|
|
metadata_ = metadata;
|
|
|
|
|
|
|
|
if (aww_) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::SetImage(const QImage& image) {
|
|
|
|
if (visible_) {
|
|
|
|
// Cache the current pixmap so we can fade between them
|
|
|
|
previous_track_ = QPixmap(size());
|
|
|
|
previous_track_.fill(palette().background().color());
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::SetHeight(int height) {
|
|
|
|
setMaximumHeight(height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::SetVisible(bool visible) {
|
|
|
|
if (visible == visible_)
|
|
|
|
return;
|
|
|
|
visible_ = visible;
|
|
|
|
|
|
|
|
show_hide_animation_->setDirection(visible ? QTimeLine::Forward : QTimeLine::Backward);
|
|
|
|
show_hide_animation_->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::paintEvent(QPaintEvent *e) {
|
|
|
|
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_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NowPlayingWidget::DrawContents(QPainter *p) {
|
2010-06-17 23:38:03 +02:00
|
|
|
switch (mode_) {
|
|
|
|
case SmallSongDetails:
|
2010-07-14 13:16:56 +02:00
|
|
|
if (hypnotoad_) {
|
|
|
|
p->drawPixmap(0, 0, small_ideal_height_, small_ideal_height_, hypnotoad_->currentPixmap());
|
2010-07-14 15:44:45 +02:00
|
|
|
} else {
|
|
|
|
// Draw the cover
|
|
|
|
p->drawPixmap(0, 0, small_ideal_height_, small_ideal_height_, cover_);
|
2010-07-14 13:16:56 +02:00
|
|
|
}
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
// Draw the details
|
|
|
|
p->translate(small_ideal_height_ + kPadding, 0);
|
|
|
|
details_->drawContents(p);
|
|
|
|
p->translate(-small_ideal_height_ - kPadding, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LargeSongDetails:
|
2010-07-14 13:16:56 +02:00
|
|
|
const int total_size = qMin(kMaxCoverSize, width());
|
2012-02-13 21:44:04 +01:00
|
|
|
const int x_offset = (width() - cover_loader_options_.desired_height_) / 2;
|
2010-06-18 00:31:22 +02:00
|
|
|
|
|
|
|
// Draw the black background
|
2010-06-18 02:24:09 +02:00
|
|
|
p->fillRect(QRect(0, kTopBorder, width(), height() - kTopBorder), Qt::black);
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
// Draw the cover
|
2010-07-14 15:44:45 +02:00
|
|
|
if (hypnotoad_) {
|
|
|
|
p->drawPixmap(x_offset, kTopBorder, total_size, total_size, hypnotoad_->currentPixmap());
|
|
|
|
} else {
|
|
|
|
p->drawPixmap(x_offset, kTopBorder, total_size, total_size, cover_);
|
|
|
|
}
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
// Work out how high the text is going to be
|
2010-06-18 00:31:22 +02:00
|
|
|
const int text_height = details_->size().height();
|
|
|
|
const int gradient_mid = height() - qMax(text_height, kBottomOffset);
|
2010-06-17 23:38:03 +02:00
|
|
|
|
|
|
|
// 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);
|
2010-06-17 00:00:39 +02:00
|
|
|
|
2010-06-17 23:38:03 +02:00
|
|
|
// Draw the text on top
|
2010-06-18 00:31:22 +02:00
|
|
|
p->translate(x_offset, height() - text_height);
|
2010-06-17 23:38:03 +02:00
|
|
|
details_->drawContents(p);
|
2010-06-18 00:31:22 +02:00
|
|
|
p->translate(-x_offset, -height() + text_height);
|
2010-06-17 23:38:03 +02:00
|
|
|
break;
|
|
|
|
}
|
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);
|
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) {
|
2012-03-19 20:42:19 +01:00
|
|
|
if (visible_ && mode_ == LargeSongDetails && e->oldSize() != e->size()) {
|
2012-02-13 21:44:04 +01:00
|
|
|
UpdateHeight();
|
2010-06-17 23:38:03 +02:00
|
|
|
UpdateDetailsText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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(
|
2012-02-12 14:41:50 +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_) {
|
2011-02-02 22:01:08 +01:00
|
|
|
const bool art_is_not_set = metadata_.has_manually_unset_cover()
|
2011-02-02 17:22:04 +01:00
|
|
|
|| (metadata_.art_automatic().isEmpty() && metadata_.art_manual().isEmpty());
|
2010-12-26 18:16:40 +01:00
|
|
|
|
2011-02-02 17:22:04 +01:00
|
|
|
album_cover_choice_controller_->unset_cover_action()->setEnabled(!art_is_not_set);
|
|
|
|
album_cover_choice_controller_->show_cover_action()->setEnabled(!art_is_not_set);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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_);
|
|
|
|
connect(kittens_, SIGNAL(ImageLoaded(quint64,QImage)), SLOT(KittenLoaded(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() {
|
|
|
|
album_cover_choice_controller_->ShowCover(metadata_);
|
2010-12-26 18:16:40 +01:00
|
|
|
}
|
|
|
|
|
2011-03-13 23:46:25 +01:00
|
|
|
void NowPlayingWidget::Bask() {
|
|
|
|
big_hypnotoad_.reset(new FullscreenHypnotoad);
|
|
|
|
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);
|
|
|
|
}
|