-
Notifications
You must be signed in to change notification settings - Fork 0
/
myinfowidget.cpp
95 lines (79 loc) · 2.78 KB
/
myinfowidget.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "myinfowidget.h"
#include "mymetadata.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QPixmap>
#include <QFont>
#include <QString>
#include <QSpacerItem>
#include <QSizePolicy>
#include <QVariant>
#include <QDebug>
MyInfoWidget::MyInfoWidget(QWidget *parent)
: QWidget(parent)
{
/*********abandon********
WidgetTitle = new QLabel(this);
WidgetTitle->setFont(QFont("Microsoft Yahei", 14));
WidgetTitle->setText(QObject::tr("Info"));
***********************/
//default cover icon
defaultCoverIcon = new QPixmap(":/icon/coverIcon.png");
coverArtImageLabel = new QLabel(this);
coverArtImageLabel->setScaledContents(true);
coverArtImageLabel->setPixmap(*defaultCoverIcon);
coverArtImageLabel->setMaximumSize(200, 200);
titleLabel = new QLabel(this);
titleLabel->setFont(QFont("Microsoft Yahei", 14, -1, "italic"));
titleLabel->setText(QObject::tr(("title")));
authorLabel = new QLabel(this);
authorLabel->setFont(QFont("Microsoft Yahei", 14));
authorLabel->setText(QObject::tr(("author")));
albumTitleLabel = new QLabel(this);
albumTitleLabel->setFont(QFont("Microsoft Yahei", 14));
albumTitleLabel->setText(QObject::tr(("album")));
yearLabel = new QLabel(this);
yearLabel->setFont(QFont("Microsoft Yahei", 14));
yearLabel->setText(QObject::tr(("year")));
mainLayout = new QVBoxLayout(this);
spacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding);
//mainLayout->addWidget(WidgetTitle);
mainLayout->addWidget(coverArtImageLabel);
mainLayout->addSpacerItem(spacer);
mainLayout->addWidget(titleLabel);
mainLayout->addWidget(authorLabel);
mainLayout->addWidget(albumTitleLabel);
mainLayout->addWidget(yearLabel);
this->setLayout(mainLayout);
}
void MyInfoWidget::flashWidgetInfo(const MyMetaData &data)
{
qDebug() << "flashed info widget";
//cover
if (data.coverArtImage.isNull())
this->coverArtImageLabel->setPixmap(QPixmap(":/icon/coverIcon.png"));
else {
QPixmap pixmap = QPixmap::fromImage(data.coverArtImage);
this->coverArtImageLabel->setPixmap(pixmap);
}
//title
if (data.title.isEmpty())
this->titleLabel->setText(QObject::tr("title: null"));
else
this->titleLabel->setText(data.title);
//author
if (data.author.isEmpty())
this->authorLabel->setText(QObject::tr("author: null"));
else
this->authorLabel->setText(data.author);
//album
if (data.albumTitle.isEmpty())
this->albumTitleLabel->setText(QObject::tr("album: null"));
else
this->albumTitleLabel->setText(data.albumTitle);
//year
if (data.year.isEmpty())
this->yearLabel->setText(QObject::tr("year: null"));
else
this->yearLabel->setText(data.year);
}