#include "albumtile.h" #include #include AlbumTile::AlbumTile(const AlbumData& item, QWidget* parent) : QWidget(parent), item_(item) { auto* layout = new QVBoxLayout(this); layout->setAlignment(Qt::AlignCenter); layout->setSpacing(6); // Cover Image QPixmap pix(item.imagePath); QLabel* cover = new QLabel; cover->setPixmap( pix.scaled(200, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation) ); cover->setAlignment(Qt::AlignCenter); // Album Label QLabel* albumLabel = new QLabel(item.album); albumLabel->setAlignment(Qt::AlignCenter); albumLabel->setStyleSheet("font-weight: 600; font-size: 14px;"); // Artist Label QLabel* artistLabel = new QLabel(item.artist); artistLabel->setAlignment(Qt::AlignCenter); artistLabel->setStyleSheet("color: #888; font-size: 12px;"); layout->addWidget(cover); layout->addWidget(albumLabel); layout->addWidget(artistLabel); setCursor(Qt::PointingHandCursor); } // Simple click handler void AlbumTile::mousePressEvent(QMouseEvent* event) { emit activated(item_); QWidget::mousePressEvent(event); }