Add rounded corners to album covers

This commit is contained in:
2025-11-20 03:27:47 -07:00
parent 4a27db0412
commit dd652dac11
155 changed files with 34 additions and 3683 deletions

View File

@@ -1,7 +1,12 @@
#include "albumtile.h"
#include "albumTile.h"
#include <QPixmap>
#include <QPainter>
#include <QPainterPath>
#include <QMouseEvent>
static QPixmap rounded(const QPixmap& src, int radius); // Used to round album corners
// Box to display album cover and data
AlbumTile::AlbumTile(const AlbumData& item, QWidget* parent)
: QWidget(parent), item_(item)
{
@@ -11,21 +16,21 @@ AlbumTile::AlbumTile(const AlbumData& item, QWidget* parent)
// Cover Image
QPixmap pix(item.imagePath);
QPixmap scaled = pix.scaled(200, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QLabel* cover = new QLabel;
cover->setPixmap(
pix.scaled(200, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation)
);
cover->setPixmap(rounded(scaled, 8)); // ← rounded to 8px
cover->setAlignment(Qt::AlignCenter);
// Album Label
QLabel* albumLabel = new QLabel(item.album);
albumLabel->setAlignment(Qt::AlignCenter);
albumLabel->setStyleSheet("font-weight: 600; font-size: 14px;");
albumLabel->setStyleSheet("font-weight: 650; font-size: 18px; margin-top: 15px;");
// Artist Label
QLabel* artistLabel = new QLabel(item.artist);
artistLabel->setAlignment(Qt::AlignCenter);
artistLabel->setStyleSheet("color: #888; font-size: 12px;");
artistLabel->setStyleSheet("color: #888; font-size: 15px;");
layout->addWidget(cover);
layout->addWidget(albumLabel);
@@ -40,3 +45,20 @@ void AlbumTile::mousePressEvent(QMouseEvent* event)
emit activated(item_);
QWidget::mousePressEvent(event);
}
// Round the album corners
static QPixmap rounded(const QPixmap& src, int radius)
{
QPixmap out(src.size());
out.fill(Qt::transparent);
QPainter p(&out);
p.setRenderHint(QPainter::Antialiasing, true);
QPainterPath path;
path.addRoundedRect(src.rect(), radius, radius);
p.setClipPath(path);
p.drawPixmap(0, 0, src);
return out;
}

View File

@@ -103,7 +103,7 @@ QPixmap SpinningAlbumArt::buildRecord(const QPixmap& src, int size)
//
// 6. Spindle hole (cutout)
//
int holeDiameter = size * 0.17;
int holeDiameter = size * 0.05;
QPainterPath hole;
hole.addEllipse(
(size - holeDiameter) / 2,

View File

@@ -13,8 +13,8 @@ AlbumSelector::AlbumSelector(QWidget* parent)
setWindowTitle("Album Selector");
resize(900, 600);
// Use flow layout from Qt Library
auto* flow = new FlowLayout(this);
// Use Qt Flow Layout Library
auto* flow = new FlowLayout(this, 20, 20, 20); // margin, h, v
setLayout(flow);
// Set Media Folder

View File

@@ -8,7 +8,7 @@ NowPlaying::NowPlaying(const AlbumData& item, QWidget* parent)
: QWidget(parent), item_(item)
{
setWindowTitle("Now Playing");
resize(350, 500);
resize(350, 600);
QVBoxLayout* layout = new QVBoxLayout(this);
@@ -19,7 +19,7 @@ NowPlaying::NowPlaying(const AlbumData& item, QWidget* parent)
// Track label
trackLabel_ = new QLabel("Track");
trackLabel_->setAlignment(Qt::AlignCenter);
trackLabel_->setStyleSheet("font-size: 14px; font-weight: 500;");
trackLabel_->setStyleSheet("font-size: 20px; font-weight: 700; margin-top: 10px");
layout->addWidget(trackLabel_);
// Time played in Song Indicator
@@ -102,7 +102,7 @@ void NowPlaying::playTrack(int idx)
QString fileName = QFileInfo(filePath).fileName();
QString title = cleanTrackTitle(fileName);
trackLabel_->setText(QString("Track %1: %2").arg(idx + 1).arg(title));
trackLabel_->setText(QString(title));
player_->setSource(QUrl::fromLocalFile(filePath));
player_->play();