-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalbummodel.cpp
More file actions
68 lines (48 loc) · 2.16 KB
/
albummodel.cpp
File metadata and controls
68 lines (48 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "albummodel.h"
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
AlbumModel::AlbumModel(QWidget *parent) : QFrame(parent) {
createLayout();
}
void AlbumModel::createLayout() {
//QWidget *albumWidget = new QWidget();
QHBoxLayout *baseAlbumLayout = new QHBoxLayout();
QLabel *albumCover = new QLabel();
QPixmap *image = new QPixmap(":/res/empty_album.png");
QPixmap newImage = image->scaled(QSize(150, 150), Qt::IgnoreAspectRatio);
albumCover->setPixmap(newImage);
QWidget *albumInfo = new QWidget();
QVBoxLayout *albumInfoLayout = new QVBoxLayout();
albumInfoLayout->setContentsMargins(0,0,0,0);
albumInfoLayout->setSpacing(0);
albumInfoLayout->setAlignment(Qt::AlignTop);
QLabel *albumLabel = new QLabel("Album name");
albumLabel->setStyleSheet("font-size: 25px;");
QLabel *artistLabel = new QLabel("Artist Name");
artistLabel->setStyleSheet("font-size: 20px;");
QLabel *yearLabel = new QLabel("2009");
yearLabel->setStyleSheet("font-size: 15px;");
QLabel *genreLabel = new QLabel("Rock");
genreLabel->setStyleSheet("font-size: 15px;");
QSpacerItem *spacer = new QSpacerItem(0, 38, QSizePolicy::Minimum, QSizePolicy::Maximum);
QPushButton *playButton = new QPushButton("Play");
//playButton->setStyleSheet("qproperty-alignment: 'AlignBottom';");
playButton->setMaximumWidth(100);
playButton->setIcon(QPixmap(":/res/play.svg"));
albumInfoLayout->addWidget(albumLabel);
albumInfoLayout->addWidget(artistLabel);
albumInfoLayout->addWidget(yearLabel);
albumInfoLayout->addWidget(genreLabel);
albumInfoLayout->addItem(spacer);
albumInfoLayout->addWidget(playButton);
albumInfo->setLayout(albumInfoLayout);
baseAlbumLayout->addWidget(albumCover);
baseAlbumLayout->addWidget(albumInfo);
this->setLayout(baseAlbumLayout);
this->setMaximumSize(350,200);
this->setObjectName("albumWidget"); //css Id name for albumWidget
this->setStyleSheet("#albumWidget { border: 1px solid black }"); //only affects albumWidget not children
//this->setSizePolicy(QSizePolicy::Expanding , QSizePolicy::Expanding);
}