Merge branch 'master' into streamserve
This commit is contained in:
commit
3452da4525
|
@ -209,3 +209,8 @@ void QtLocalPeer::receiveConnection()
|
||||||
emit messageReceived(uMsg); //### (might take a long time to return)
|
emit messageReceived(uMsg); //### (might take a long time to return)
|
||||||
emit messageReceived(QString::fromUtf8(uMsg));
|
emit messageReceived(QString::fromUtf8(uMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtLocalPeer::~QtLocalPeer ()
|
||||||
|
{
|
||||||
|
lockFile.remove();
|
||||||
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ class QtLocalPeer : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
|
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
|
||||||
|
~QtLocalPeer ();
|
||||||
bool isClient();
|
bool isClient();
|
||||||
bool sendMessage(const QString &message, int timeout);
|
bool sendMessage(const QString &message, int timeout);
|
||||||
bool sendMessage(const QByteArray &message, int timeout);
|
bool sendMessage(const QByteArray &message, int timeout);
|
||||||
|
|
|
@ -50,6 +50,8 @@ class Base : public QWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void framerateChanged() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Base(QWidget*, uint scopeSize = 7);
|
Base(QWidget*, uint scopeSize = 7);
|
||||||
|
|
||||||
|
@ -84,6 +86,4 @@ void initSin(Scope&, const uint = 6000);
|
||||||
|
|
||||||
} // END namespace Analyzer
|
} // END namespace Analyzer
|
||||||
|
|
||||||
using Analyzer::Scope;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -165,6 +165,9 @@ void AnalyzerContainer::ChangeFramerate(int new_framerate) {
|
||||||
// Even if it is not supposed to happen, I don't want to get a dbz error
|
// Even if it is not supposed to happen, I don't want to get a dbz error
|
||||||
new_framerate = new_framerate == 0 ? kMediumFramerate : new_framerate;
|
new_framerate = new_framerate == 0 ? kMediumFramerate : new_framerate;
|
||||||
current_analyzer_->changeTimeout(1000 / new_framerate);
|
current_analyzer_->changeTimeout(1000 / new_framerate);
|
||||||
|
|
||||||
|
// notify the current analyzer that the framerate has changed
|
||||||
|
current_analyzer_->framerateChanged();
|
||||||
}
|
}
|
||||||
SaveFramerate(new_framerate);
|
SaveFramerate(new_framerate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
using Analyzer::Scope;
|
||||||
|
|
||||||
const char* BarAnalyzer::kName =
|
const char* BarAnalyzer::kName =
|
||||||
QT_TRANSLATE_NOOP("AnalyzerContainer", "Bar analyzer");
|
QT_TRANSLATE_NOOP("AnalyzerContainer", "Bar analyzer");
|
||||||
|
|
||||||
BarAnalyzer::BarAnalyzer(QWidget* parent)
|
BarAnalyzer::BarAnalyzer(QWidget* parent) : Analyzer::Base(parent, 8) {
|
||||||
: Analyzer::Base(parent, 8) {
|
|
||||||
// roof pixmaps don't depend on size() so we do in the ctor
|
// roof pixmaps don't depend on size() so we do in the ctor
|
||||||
m_bg = parent->palette().color(QPalette::Background);
|
m_bg = parent->palette().color(QPalette::Background);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class BarAnalyzer : public Analyzer::Base {
|
||||||
Q_INVOKABLE BarAnalyzer(QWidget*);
|
Q_INVOKABLE BarAnalyzer(QWidget*);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
virtual void analyze(QPainter& p, const Scope&, bool new_frame);
|
virtual void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
||||||
// virtual void transform( Scope& );
|
// virtual void transform( Scope& );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ class BarAnalyzer : public Analyzer::Base {
|
||||||
QPixmap m_pixBarGradient;
|
QPixmap m_pixBarGradient;
|
||||||
QPixmap m_pixCompose;
|
QPixmap m_pixCompose;
|
||||||
QPixmap canvas_;
|
QPixmap canvas_;
|
||||||
Scope m_scope; // so we don't create a vector every frame
|
Analyzer::Scope m_scope; // so we don't create a vector every frame
|
||||||
QColor m_bg;
|
QColor m_bg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -100,10 +100,16 @@ void BlockAnalyzer::determineStep() {
|
||||||
// boxes/blocks of pixels)
|
// boxes/blocks of pixels)
|
||||||
// I calculated the value 30 based on some trial and error
|
// I calculated the value 30 based on some trial and error
|
||||||
|
|
||||||
const double fallTime = 30 * m_rows;
|
// the fall time of 30 is too slow on framerates above 50fps
|
||||||
|
const double fallTime = timeout() < 20 ? 20 * m_rows : 30 * m_rows;
|
||||||
|
|
||||||
m_step = double(m_rows * timeout()) / fallTime;
|
m_step = double(m_rows * timeout()) / fallTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlockAnalyzer::framerateChanged() { // virtual
|
||||||
|
determineStep();
|
||||||
|
}
|
||||||
|
|
||||||
void BlockAnalyzer::transform(Analyzer::Scope& s) // pure virtual
|
void BlockAnalyzer::transform(Analyzer::Scope& s) // pure virtual
|
||||||
{
|
{
|
||||||
for (uint x = 0; x < s.size(); ++x) s[x] *= 2;
|
for (uint x = 0; x < s.size(); ++x) s[x] *= 2;
|
||||||
|
|
|
@ -32,10 +32,11 @@ class BlockAnalyzer : public Analyzer::Base {
|
||||||
static const char* kName;
|
static const char* kName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void transform(Scope&);
|
virtual void transform(Analyzer::Scope&);
|
||||||
virtual void analyze(QPainter& p, const Scope&, bool new_frame);
|
virtual void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
||||||
virtual void resizeEvent(QResizeEvent*);
|
virtual void resizeEvent(QResizeEvent*);
|
||||||
virtual void paletteChange(const QPalette&);
|
virtual void paletteChange(const QPalette&);
|
||||||
|
virtual void framerateChanged();
|
||||||
|
|
||||||
void drawBackground();
|
void drawBackground();
|
||||||
void determineStep();
|
void determineStep();
|
||||||
|
@ -49,7 +50,7 @@ class BlockAnalyzer : public Analyzer::Base {
|
||||||
QPixmap m_topBarPixmap;
|
QPixmap m_topBarPixmap;
|
||||||
QPixmap m_background;
|
QPixmap m_background;
|
||||||
QPixmap canvas_;
|
QPixmap canvas_;
|
||||||
Scope m_scope; // so we don't create a vector every frame
|
Analyzer::Scope m_scope; // so we don't create a vector every frame
|
||||||
std::vector<float> m_store; // current bar heights
|
std::vector<float> m_store; // current bar heights
|
||||||
std::vector<float> m_yscale;
|
std::vector<float> m_yscale;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
using Analyzer::Scope;
|
||||||
|
|
||||||
const char* BoomAnalyzer::kName =
|
const char* BoomAnalyzer::kName =
|
||||||
QT_TRANSLATE_NOOP("AnalyzerContainer", "Boom analyzer");
|
QT_TRANSLATE_NOOP("AnalyzerContainer", "Boom analyzer");
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ class BoomAnalyzer : public Analyzer::Base {
|
||||||
static const char* kName;
|
static const char* kName;
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual void transform(Scope& s);
|
virtual void transform(Analyzer::Scope& s);
|
||||||
virtual void analyze(QPainter& p, const Scope&, bool new_frame);
|
virtual void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changeK_barHeight(int);
|
void changeK_barHeight(int);
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "core/arraysize.h"
|
#include "core/arraysize.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
|
using Analyzer::Scope;
|
||||||
|
|
||||||
const char* NyanCatAnalyzer::kName = "Nyanalyzer cat";
|
const char* NyanCatAnalyzer::kName = "Nyanalyzer cat";
|
||||||
const float NyanCatAnalyzer::kPixelScale = 0.02f;
|
const float NyanCatAnalyzer::kPixelScale = 0.02f;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class NyanCatAnalyzer : public Analyzer::Base {
|
||||||
static const char* kName;
|
static const char* kName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void transform(Scope&);
|
void transform(Analyzer::Scope&);
|
||||||
void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
||||||
|
|
||||||
void timerEvent(QTimerEvent* e);
|
void timerEvent(QTimerEvent* e);
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
using Analyzer::Scope;
|
||||||
|
|
||||||
const char* Sonogram::kName =
|
const char* Sonogram::kName =
|
||||||
QT_TRANSLATE_NOOP("AnalyzerContainer", "Sonogram");
|
QT_TRANSLATE_NOOP("AnalyzerContainer", "Sonogram");
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ class Sonogram : public Analyzer::Base {
|
||||||
static const char* kName;
|
static const char* kName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void analyze(QPainter& p, const Scope&, bool new_frame);
|
void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
||||||
void transform(Scope&);
|
void transform(Analyzer::Scope&);
|
||||||
void demo(QPainter& p);
|
void demo(QPainter& p);
|
||||||
void resizeEvent(QResizeEvent*);
|
void resizeEvent(QResizeEvent*);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include "turbine.h"
|
#include "turbine.h"
|
||||||
|
|
||||||
|
using Analyzer::Scope;
|
||||||
|
|
||||||
const char* TurbineAnalyzer::kName =
|
const char* TurbineAnalyzer::kName =
|
||||||
QT_TRANSLATE_NOOP("AnalyzerContainer", "Turbine");
|
QT_TRANSLATE_NOOP("AnalyzerContainer", "Turbine");
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TurbineAnalyzer : public BoomAnalyzer {
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE TurbineAnalyzer(QWidget* parent) : BoomAnalyzer(parent) {}
|
Q_INVOKABLE TurbineAnalyzer(QWidget* parent) : BoomAnalyzer(parent) {}
|
||||||
|
|
||||||
void analyze(QPainter& p, const Scope&, bool new_frame);
|
void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
||||||
|
|
||||||
static const char* kName;
|
static const char* kName;
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,7 @@ void CurrentArtLoader::TempArtLoaded(quint64 id, const QImage& image) {
|
||||||
|
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
temp_art_.reset(new QTemporaryFile(temp_file_pattern_));
|
temp_art_.reset(new QTemporaryFile(temp_file_pattern_));
|
||||||
|
temp_art_->setAutoRemove(true);
|
||||||
temp_art_->open();
|
temp_art_->open();
|
||||||
image.save(temp_art_->fileName(), "JPEG");
|
image.save(temp_art_->fileName(), "JPEG");
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ void CurrentArtLoader::TempArtLoaded(quint64 id, const QImage& image) {
|
||||||
// since it's the GUI thread, but the alternative is hard.
|
// since it's the GUI thread, but the alternative is hard.
|
||||||
temp_art_thumbnail_.reset(new QTemporaryFile(temp_file_pattern_));
|
temp_art_thumbnail_.reset(new QTemporaryFile(temp_file_pattern_));
|
||||||
temp_art_thumbnail_->open();
|
temp_art_thumbnail_->open();
|
||||||
|
temp_art_thumbnail_->setAutoRemove(true);
|
||||||
thumbnail = image.scaledToHeight(120, Qt::SmoothTransformation);
|
thumbnail = image.scaledToHeight(120, Qt::SmoothTransformation);
|
||||||
thumbnail.save(temp_art_thumbnail_->fileName(), "JPEG");
|
thumbnail.save(temp_art_thumbnail_->fileName(), "JPEG");
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMutexLocker>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
|
@ -72,7 +73,8 @@ RipCD::RipCD(QWidget* parent)
|
||||||
queued_(0),
|
queued_(0),
|
||||||
finished_success_(0),
|
finished_success_(0),
|
||||||
finished_failed_(0),
|
finished_failed_(0),
|
||||||
ui_(new Ui_RipCD) {
|
ui_(new Ui_RipCD),
|
||||||
|
cancel_requested_(false) {
|
||||||
cdio_ = cdio_open(NULL, DRIVER_UNKNOWN);
|
cdio_ = cdio_open(NULL, DRIVER_UNKNOWN);
|
||||||
// Init
|
// Init
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
@ -144,9 +146,7 @@ RipCD::RipCD(QWidget* parent)
|
||||||
ui_->progress_bar->setMaximum(100);
|
ui_->progress_bar->setMaximum(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
RipCD::~RipCD() {
|
RipCD::~RipCD() { cdio_destroy(cdio_); }
|
||||||
cdio_destroy(cdio_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WAV Header documentation
|
* WAV Header documentation
|
||||||
|
@ -232,6 +232,13 @@ void RipCD::ThreadClickedRipButton() {
|
||||||
|
|
||||||
QByteArray buffered_input_bytes(CDIO_CD_FRAMESIZE_RAW, '\0');
|
QByteArray buffered_input_bytes(CDIO_CD_FRAMESIZE_RAW, '\0');
|
||||||
for (lsn_t i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor++) {
|
for (lsn_t i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor++) {
|
||||||
|
{
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
if (cancel_requested_) {
|
||||||
|
qLog(Debug) << "CD ripping canceled.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (cdio_read_audio_sector(cdio_, buffered_input_bytes.data(),
|
if (cdio_read_audio_sector(cdio_, buffered_input_bytes.data(),
|
||||||
i_cursor) == DRIVER_OP_SUCCESS) {
|
i_cursor) == DRIVER_OP_SUCCESS) {
|
||||||
destination_file->write(buffered_input_bytes.data(),
|
destination_file->write(buffered_input_bytes.data(),
|
||||||
|
@ -317,6 +324,10 @@ void RipCD::ClickedRipButton() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetWorking(true);
|
SetWorking(true);
|
||||||
|
{
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
cancel_requested_ = false;
|
||||||
|
}
|
||||||
QtConcurrent::run(this, &RipCD::ThreadClickedRipButton);
|
QtConcurrent::run(this, &RipCD::ThreadClickedRipButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,6 +412,10 @@ void RipCD::AddDestinationDirectory(QString dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RipCD::Cancel() {
|
void RipCD::Cancel() {
|
||||||
|
{
|
||||||
|
QMutexLocker l(&mutex_);
|
||||||
|
cancel_requested_ = true;
|
||||||
|
}
|
||||||
ui_->progress_bar->setValue(0);
|
ui_->progress_bar->setValue(0);
|
||||||
transcoder_->Cancel();
|
transcoder_->Cancel();
|
||||||
RemoveTemporaryDirectory();
|
RemoveTemporaryDirectory();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QMutex>
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include "ui_ripcd.h"
|
#include "ui_ripcd.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -62,6 +63,8 @@ class RipCD : public QDialog {
|
||||||
QPushButton* close_button_;
|
QPushButton* close_button_;
|
||||||
QPushButton* rip_button_;
|
QPushButton* rip_button_;
|
||||||
QString temporary_directory_;
|
QString temporary_directory_;
|
||||||
|
bool cancel_requested_;
|
||||||
|
QMutex mutex_;
|
||||||
|
|
||||||
void WriteWAVHeader(QFile* stream, int32_t i_bytecount);
|
void WriteWAVHeader(QFile* stream, int32_t i_bytecount);
|
||||||
int NumTracksToRip();
|
int NumTracksToRip();
|
||||||
|
|
|
@ -93,6 +93,9 @@ NowPlayingWidget::NowPlayingWidget(QWidget* parent)
|
||||||
mode_mapper);
|
mode_mapper);
|
||||||
CreateModeAction(LargeSongDetails, tr("Large album cover"), mode_group,
|
CreateModeAction(LargeSongDetails, tr("Large album cover"), mode_group,
|
||||||
mode_mapper);
|
mode_mapper);
|
||||||
|
CreateModeAction(LargeSongDetailsBelow,
|
||||||
|
tr("Large album cover (details below)"), mode_group,
|
||||||
|
mode_mapper);
|
||||||
|
|
||||||
menu_->addActions(mode_group->actions());
|
menu_->addActions(mode_group->actions());
|
||||||
menu_->addSeparator();
|
menu_->addSeparator();
|
||||||
|
@ -141,6 +144,16 @@ NowPlayingWidget::NowPlayingWidget(QWidget* parent)
|
||||||
SLOT(FadePreviousTrack(qreal)));
|
SLOT(FadePreviousTrack(qreal)));
|
||||||
fade_animation_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
|
fade_animation_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
|
||||||
|
|
||||||
|
// add placeholder text to get the correct height
|
||||||
|
if (mode_ == LargeSongDetailsBelow) {
|
||||||
|
details_->setDefaultStyleSheet(
|
||||||
|
"p {"
|
||||||
|
" font-size: small;"
|
||||||
|
" color: white;"
|
||||||
|
"}");
|
||||||
|
details_->setHtml(QString("<p align=center><i></i><br/><br/></p>"));
|
||||||
|
}
|
||||||
|
|
||||||
UpdateHeight();
|
UpdateHeight();
|
||||||
|
|
||||||
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()),
|
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()),
|
||||||
|
@ -189,6 +202,12 @@ void NowPlayingWidget::UpdateHeight() {
|
||||||
total_height_ =
|
total_height_ =
|
||||||
kTopBorder + cover_loader_options_.desired_height_ + kBottomOffset;
|
kTopBorder + cover_loader_options_.desired_height_ + kBottomOffset;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LargeSongDetailsBelow:
|
||||||
|
cover_loader_options_.desired_height_ = qMin(kMaxCoverSize, width());
|
||||||
|
total_height_ = kTopBorder + cover_loader_options_.desired_height_ +
|
||||||
|
kBottomOffset + details_->size().height();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the animation settings and resize the widget now if we're visible
|
// Update the animation settings and resize the widget now if we're visible
|
||||||
|
@ -226,6 +245,16 @@ void NowPlayingWidget::UpdateDetailsText() {
|
||||||
"}");
|
"}");
|
||||||
html += "<p align=center>";
|
html += "<p align=center>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LargeSongDetailsBelow:
|
||||||
|
details_->setTextWidth(cover_loader_options_.desired_height_);
|
||||||
|
details_->setDefaultStyleSheet(
|
||||||
|
"p {"
|
||||||
|
" font-size: small;"
|
||||||
|
" color: white;"
|
||||||
|
"}");
|
||||||
|
html += "<p align=center>";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make this configurable
|
// TODO: Make this configurable
|
||||||
|
@ -235,6 +264,11 @@ void NowPlayingWidget::UpdateDetailsText() {
|
||||||
|
|
||||||
html += "</p>";
|
html += "</p>";
|
||||||
details_->setHtml(html);
|
details_->setHtml(html);
|
||||||
|
|
||||||
|
// if something spans multiple lines the height needs to change
|
||||||
|
if (mode_ == LargeSongDetailsBelow) {
|
||||||
|
UpdateHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NowPlayingWidget::ScaleCover() {
|
void NowPlayingWidget::ScaleCover() {
|
||||||
|
@ -333,7 +367,7 @@ void NowPlayingWidget::DrawContents(QPainter* p) {
|
||||||
p->translate(-small_ideal_height_ - kPadding, 0);
|
p->translate(-small_ideal_height_ - kPadding, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LargeSongDetails:
|
case LargeSongDetails: {
|
||||||
const int total_size = qMin(kMaxCoverSize, width());
|
const int total_size = qMin(kMaxCoverSize, width());
|
||||||
const int x_offset =
|
const int x_offset =
|
||||||
(width() - cover_loader_options_.desired_height_) / 2;
|
(width() - cover_loader_options_.desired_height_) / 2;
|
||||||
|
@ -373,6 +407,37 @@ void NowPlayingWidget::DrawContents(QPainter* p) {
|
||||||
p->translate(-x_offset, -height() + text_height);
|
p->translate(-x_offset, -height() + text_height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LargeSongDetailsBelow:
|
||||||
|
// Work out how high the text is going to be
|
||||||
|
const int text_height = details_->size().height();
|
||||||
|
|
||||||
|
const int cover_size = 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, 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NowPlayingWidget::FadePreviousTrack(qreal value) {
|
void NowPlayingWidget::FadePreviousTrack(qreal value) {
|
||||||
|
@ -396,11 +461,13 @@ void NowPlayingWidget::SetMode(int mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NowPlayingWidget::resizeEvent(QResizeEvent* e) {
|
void NowPlayingWidget::resizeEvent(QResizeEvent* e) {
|
||||||
if (visible_ && mode_ == LargeSongDetails && e->oldSize() != e->size()) {
|
if (visible_ && e->oldSize() != e->size()) {
|
||||||
|
if (mode_ == LargeSongDetails || mode_ == LargeSongDetailsBelow) {
|
||||||
UpdateHeight();
|
UpdateHeight();
|
||||||
UpdateDetailsText();
|
UpdateDetailsText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NowPlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
|
void NowPlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
|
||||||
// initial 'enabled' values depending on the kitty mode
|
// initial 'enabled' values depending on the kitty mode
|
||||||
|
|
|
@ -54,7 +54,11 @@ class NowPlayingWidget : public QWidget {
|
||||||
static const int kTopBorder;
|
static const int kTopBorder;
|
||||||
|
|
||||||
// Values are saved in QSettings
|
// Values are saved in QSettings
|
||||||
enum Mode { SmallSongDetails = 0, LargeSongDetails = 1, };
|
enum Mode {
|
||||||
|
SmallSongDetails = 0,
|
||||||
|
LargeSongDetails = 1,
|
||||||
|
LargeSongDetailsBelow = 2,
|
||||||
|
};
|
||||||
|
|
||||||
void SetApplication(Application* app);
|
void SetApplication(Application* app);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue