add: Audio Info in NowPlayingPanel.cpp ; Includes: Samplerate, bits/sample, and codec
change: opengl dll for windows now is not included, cause it is too large refactor: Spectrogram colors for bars are now in a Header (GradientPresetHeader.h), with accompaning methods
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "GradientDialog.h"
|
||||
#include "GradientPresetHeader.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
@@ -8,47 +9,6 @@
|
||||
#include <QPixmap>
|
||||
#include <QComboBox>
|
||||
|
||||
static QVector<QColor> makePreset4(const QColor &c0, const QColor &c1,
|
||||
const QColor &c2, const QColor &c3,
|
||||
const QColor &c4)
|
||||
{
|
||||
return { c0, c2, c3, c4 };
|
||||
}
|
||||
|
||||
struct Preset {
|
||||
QString name;
|
||||
QVector<QColor> colors;
|
||||
};
|
||||
|
||||
// Presets are defined in a Vector for simplicity of adding new ones
|
||||
static const QVector<Preset> PRESETS = {
|
||||
{ "Default",
|
||||
{ QColor("#078D70"), QColor("#26CEAA"), QColor("#98E8C1"), QColor("#FFFFFF") } },
|
||||
|
||||
{ "Pastels",
|
||||
makePreset4(QColor("#92ccdd"), QColor("#c7eff0"),
|
||||
QColor("#f5d5fd"), QColor("#fdc4ec"), QColor("#ffc2cb")) },
|
||||
|
||||
{ "Raddish",
|
||||
makePreset4(QColor("#ff0000"), QColor("#b40000"),
|
||||
QColor("#890000"), QColor("#540000"), QColor("#240000")) },
|
||||
|
||||
{ "Blau",
|
||||
makePreset4(QColor("#72c8dd"), QColor("#43b5d2"),
|
||||
QColor("#14a3c7"), QColor("#1293b3"), QColor("#10829f")) },
|
||||
|
||||
{ "Turquoise",
|
||||
makePreset4(QColor("#d8f2f6"), QColor("#8bd9ef"),
|
||||
QColor("#3ec1d5"), QColor("#319aaa"), QColor("#25737f")) },
|
||||
|
||||
{ "Aqua",
|
||||
makePreset4(QColor("#2278FB"), QColor("#3A9AF0"),
|
||||
QColor("#53BDE6"), QColor("#6BDFDB"), QColor("#1A5BB8")) },
|
||||
|
||||
{ "Peaches",
|
||||
makePreset4(QColor("#FFCAA6"), QColor("#FDA8A0"),
|
||||
QColor("#FA879A"), QColor("#F86594"), QColor("#FFE0CC")) }
|
||||
};
|
||||
|
||||
static int findPresetIndex(const QVector<QColor> &stops)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
|
||||
/** preset function */
|
||||
inline QVector<QColor> makePreset4(const QColor &c0, const QColor &c1,
|
||||
const QColor &c2, const QColor &c3,
|
||||
const QColor &c4)
|
||||
{
|
||||
// if you dont define c1 as #FFFF worry, cause it does NOT get used!
|
||||
return { c0, c2, c3, c4 };
|
||||
}
|
||||
|
||||
/** Preset Struct */
|
||||
struct Preset {
|
||||
QString name;
|
||||
QVector<QColor> colors;
|
||||
};
|
||||
|
||||
/** Defined Presets */
|
||||
inline const QVector<Preset> PRESETS = {
|
||||
{ "Default",
|
||||
{ QColor("#078D70"), QColor("#26CEAA"), QColor("#98E8C1"), QColor("#FFFFFF") } },
|
||||
|
||||
{ "Pastels",
|
||||
makePreset4(QColor("#92ccdd"), QColor("#c7eff0"),
|
||||
QColor("#f5d5fd"), QColor("#fdc4ec"), QColor("#ffc2cb")) },
|
||||
|
||||
{ "Raddish",
|
||||
makePreset4(QColor("#ff0000"), QColor("#b40000"),
|
||||
QColor("#890000"), QColor("#540000"), QColor("#240000")) },
|
||||
|
||||
{ "Blau",
|
||||
makePreset4(QColor("#72c8dd"), QColor("#43b5d2"),
|
||||
QColor("#14a3c7"), QColor("#1293b3"), QColor("#10829f")) },
|
||||
|
||||
{ "Turquoise",
|
||||
makePreset4(QColor("#d8f2f6"), QColor("#8bd9ef"),
|
||||
QColor("#3ec1d5"), QColor("#319aaa"), QColor("#25737f")) },
|
||||
|
||||
{ "Aqua",
|
||||
makePreset4(QColor("#2278FB"), QColor("#3A9AF0"),
|
||||
QColor("#53BDE6"), QColor("#6BDFDB"), QColor("#1A5BB8")) },
|
||||
|
||||
{ "Peaches",
|
||||
makePreset4(QColor("#FFCAA6"), QColor("#FDA8A0"),
|
||||
QColor("#FA879A"), QColor("#F86594"), QColor("#FFE0CC")) },
|
||||
|
||||
{ "Windows Green",
|
||||
makePreset4(QColor("#BFFFE3"), QColor("#7FFFC2"),
|
||||
QColor("#43FFAC"), QColor("#27FF97"), QColor("#0EDB7D")) },
|
||||
};
|
||||
@@ -48,6 +48,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
e->positionFrames(),
|
||||
e->totalFrames(),
|
||||
float(e->sampleRate()));
|
||||
m_nowPlaying->updateAudioInfo(
|
||||
e->sampleRate(),
|
||||
e->bitsPerSample(),
|
||||
e->codecName());
|
||||
|
||||
if (e->state() == AudioEngine::State::Stopped)
|
||||
m_nowPlaying->setPlaybackActive(false);
|
||||
|
||||
@@ -60,11 +60,22 @@ void NowPlayingPanel::buildLayout()
|
||||
transport->addWidget(new QLabel("Volume:"));
|
||||
transport->addWidget(m_volSlider);
|
||||
|
||||
auto *metaRow = new QHBoxLayout;
|
||||
metaRow->setSpacing(8);
|
||||
metaRow->addWidget(new QLabel("Sample rate:"));
|
||||
metaRow->addWidget(m_lblSampleRate);
|
||||
metaRow->addWidget(new QLabel("Bits/Sample:"));
|
||||
metaRow->addWidget(m_lblBitsPerSample);
|
||||
metaRow->addWidget(new QLabel("Codec:"));
|
||||
metaRow->addWidget(m_lblCodec);
|
||||
metaRow->addStretch();
|
||||
|
||||
auto *right = new QVBoxLayout;
|
||||
right->setSpacing(4);
|
||||
right->addWidget(m_lblTitle);
|
||||
right->addWidget(m_lblArtist);
|
||||
right->addWidget(m_lblAlbum);
|
||||
right->addLayout(metaRow);
|
||||
right->addLayout(seekRow);
|
||||
right->addLayout(transport);
|
||||
|
||||
@@ -73,14 +84,25 @@ void NowPlayingPanel::buildLayout()
|
||||
hlay->addLayout(right, 1);
|
||||
}
|
||||
|
||||
void NowPlayingPanel::clearAudioInfo()
|
||||
{
|
||||
m_lblSampleRate->setText("-");
|
||||
m_lblBitsPerSample->setText("-");
|
||||
m_lblCodec->setText("-");
|
||||
}
|
||||
|
||||
void NowPlayingPanel::updateTrack(const engine::Track *t)
|
||||
{
|
||||
if (!t) return;
|
||||
if (!t) {
|
||||
clearAudioInfo();
|
||||
return;
|
||||
}
|
||||
m_cover->setTrack(t);
|
||||
m_lblTitle->setText(t->displayTitle());
|
||||
m_lblArtist->setText(t->artist);
|
||||
m_lblAlbum->setText(t->album +
|
||||
(t->year > 0 ? " (" + QString::number(t->year) + ")" : ""));
|
||||
clearAudioInfo();
|
||||
m_seekBar->setValue(0);
|
||||
m_btnPlay->setText("Pause");
|
||||
}
|
||||
@@ -101,6 +123,13 @@ void NowPlayingPanel::updatePosition(qint64 posFrames, qint64 totalFrames, float
|
||||
m_seekBar->setValue(int(posFrames * 1000 / totalFrames));
|
||||
}
|
||||
|
||||
void NowPlayingPanel::updateAudioInfo(int sampleRate, int bitsPerSample, const QString &codec)
|
||||
{
|
||||
m_lblSampleRate->setText(sampleRate > 0 ? QString("%1 Hz").arg(sampleRate) : "-");
|
||||
m_lblBitsPerSample->setText(bitsPerSample > 0 ? QString("%1").arg(bitsPerSample) : "-");
|
||||
m_lblCodec->setText(!codec.isEmpty() ? codec : "-");
|
||||
}
|
||||
|
||||
void NowPlayingPanel::setPlaybackActive(bool playing)
|
||||
{
|
||||
m_btnPlay->setText(playing ? "Pause" : "Play");
|
||||
|
||||
@@ -20,7 +20,8 @@ public:
|
||||
public slots:
|
||||
void updateTrack(const engine::Track *track);
|
||||
void updatePosition(qint64 posFrames, qint64 totalFrames, float sampleRate);
|
||||
void setPlaybackActive(bool playing);
|
||||
void updateAudioInfo(int sampleRate, int bitsPerSample, const QString &codec);
|
||||
void setPlaybackActive(bool playing);
|
||||
|
||||
signals:
|
||||
void playPauseClicked();
|
||||
@@ -31,12 +32,16 @@ signals:
|
||||
|
||||
private:
|
||||
void buildLayout();
|
||||
void clearAudioInfo();
|
||||
|
||||
CoverArtWidget *m_cover;
|
||||
QLabel *m_lblTitle = new QLabel("No track selected");
|
||||
QLabel *m_lblArtist = new QLabel(" ");
|
||||
QLabel *m_lblAlbum = new QLabel(" ");
|
||||
QLabel *m_lblTime = new QLabel("0:00 / 0:00");
|
||||
QLabel *m_lblSampleRate = new QLabel("—");
|
||||
QLabel *m_lblBitsPerSample = new QLabel("-");
|
||||
QLabel *m_lblCodec = new QLabel("—");
|
||||
QSlider *m_seekBar = new QSlider(Qt::Horizontal);
|
||||
QPushButton *m_btnPrev = new QPushButton("|<");
|
||||
QPushButton *m_btnPlay = new QPushButton("Play");
|
||||
|
||||
Reference in New Issue
Block a user