TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicplaylistqueryinfowidget.cpp
Go to the documentation of this file.
4 #include "musiccoverrequest.h"
5 #include "musicratinglabel.h"
6 
7 #include <cmath>
9 
12  m_commentsWidget(nullptr)
13 {
16  m_container->show();
17 
20 }
21 
23 {
24  delete m_commentsWidget;
25 }
26 
28 {
30 
31  if(m_resizeWidgets.isEmpty())
32  {
33  return;
34  }
35 
36  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - WINDOW_WIDTH_MIN;
37 
38  Data *data = &m_resizeWidgets[0];
39  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 200 + width));
40 
41  data = &m_resizeWidgets[1];
42  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 180 + width));
43 
44  data = &m_resizeWidgets[2];
45  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 210 + width));
46 
47  data = &m_resizeWidgets[3];
48  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 160 + width));
49 }
50 
52 {
53  delete m_statusLabel;
54  m_statusLabel = nullptr;
55 
56  m_currentPlaylistItem = item;
57  setCurrentValue(item.m_id);
58 
59  m_infoLabel->setText(item.m_description);
61 
62  layout()->removeWidget(m_mainWidget);
63  QScrollArea *scrollArea = new QScrollArea(this);
65  layout()->addWidget(scrollArea);
66 
67  QWidget *function = new QWidget(m_mainWidget);
68  function->setStyleSheet(TTK::UI::CheckBoxStyle01);
69  QVBoxLayout *grid = new QVBoxLayout(function);
70 
71  QWidget *firstTopFuncWidget = new QWidget(function);
72  QHBoxLayout *firstTopFuncLayout = new QHBoxLayout(firstTopFuncWidget);
73  grid->addWidget(firstTopFuncWidget);
74 
75  QLabel *firstLabel = new QLabel(function);
76  firstLabel->setText(tr("<font color=#158FE1> Playlist > %1 </font>").arg(item.m_name));
77  firstTopFuncLayout->addWidget(firstLabel);
78 
79  if(obj)
80  {
81  QPushButton *backButton = new QPushButton(tr("Back"));
82 #ifdef Q_OS_UNIX
83  backButton->setFocusPolicy(Qt::NoFocus);
84 #endif
85  backButton->setFixedSize(90, 30);
86  backButton->setStyleSheet(TTK::UI::PushButtonStyle03);
87  backButton->setCursor(QCursor(Qt::PointingHandCursor));
88  connect(backButton, SIGNAL(clicked()), obj, SLOT(backToPlaylistMenu()));
89  firstTopFuncLayout->addWidget(backButton);
90  }
91  //
92  QWidget *topFuncWidget = new QWidget(function);
93  QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);
94 
95  m_iconLabel = new QLabel(topFuncWidget);
96  m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
97  m_iconLabel->setFixedSize(210, 180);
98 
100  {
101  MusicCoverRequest *req = G_DOWNLOAD_QUERY_PTR->makeCoverRequest(this);
102  connect(req, SIGNAL(downloadRawDataChanged(QByteArray)), SLOT(downloadFinished(QByteArray)));
103  req->startToRequest(item.m_coverUrl);
104  }
105 
106  QWidget *topLineWidget = new QWidget(topFuncWidget);
107  QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
108  topLineLayout->setContentsMargins(10, 5, 5, 0);
109 
110  QLabel *nameLabel = new QLabel(topLineWidget);
111  QFont nameFont = nameLabel->font();
112  nameFont.setPixelSize(20);
113  nameLabel->setFont(nameFont);
114  nameLabel->setStyleSheet(TTK::UI::FontStyle01);
115  nameLabel->setToolTip(item.m_name);
116 
117  QLabel *creatorLabel = new QLabel(topLineWidget);
118  creatorLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
119  creatorLabel->setToolTip(tr("Creator: %1").arg(item.m_nickName));
120 
121  QLabel *tagsLabel = new QLabel(topLineWidget);
122  tagsLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
123  tagsLabel->setToolTip(tr("Tags: %1").arg(item.m_category));
124 
125  QLabel *updateLabel = new QLabel(topLineWidget);
126  updateLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
127  updateLabel->setToolTip(tr("UpdateTime: %1").arg(item.m_time));
128 
129  topLineLayout->addWidget(nameLabel);
130  topLineLayout->addWidget(creatorLabel);
131  topLineLayout->addWidget(tagsLabel);
132  topLineLayout->addWidget(updateLabel);
133  topLineWidget->setLayout(topLineLayout);
134 
135  QWidget *topButtonWidget = new QWidget(topFuncWidget);
136  topButtonWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
137  QHBoxLayout *topButtonLayout = new QHBoxLayout(topButtonWidget);
138  topButtonLayout->setContentsMargins(0, 0, 0, 0);
139 
140  QPushButton *playAllButton = new QPushButton(tr("Play All"), topButtonWidget);
141  QPushButton *shareButton = new QPushButton(tr("Share"), topButtonWidget);
142 
143  playAllButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
144  playAllButton->setIconSize(QSize(14, 14));
145  playAllButton->setCursor(QCursor(Qt::PointingHandCursor));
146  shareButton->setCursor(QCursor(Qt::PointingHandCursor));
147  playAllButton->setFixedSize(90, 30);
148  shareButton->setFixedSize(55, 30);
149 
150  topButtonLayout->addWidget(playAllButton);
151  topButtonLayout->addWidget(shareButton);
152  topButtonLayout->addStretch(1);
153  topButtonWidget->setLayout(topButtonLayout);
154  topLineLayout->addWidget(topButtonWidget);
155 
156  connect(playAllButton, SIGNAL(clicked()), SLOT(playAllButtonClicked()));
157  connect(shareButton, SIGNAL(clicked()), SLOT(shareButtonClicked()));
158  //
159  QWidget *topRightWidget = new QWidget(topFuncWidget);
160  QGridLayout *topRightLayout = new QGridLayout(topRightWidget);
161  topRightLayout->setContentsMargins(0, 0, 0, 0);
162  topRightLayout->setSpacing(0);
163 
164  QLabel *numberLabel = new QLabel(topRightWidget);
165  numberLabel->setAlignment(Qt::AlignCenter);
166  numberLabel->setStyleSheet(TTK::UI::FontStyle06 + TTK::UI::ColorStyle11);
167 
168  const int number = 7 + TTK::random(3);
169  numberLabel->setText(QString("%1.%2").arg(number).arg(TTK::random(10)));
170  topRightLayout->addWidget(numberLabel, 0, 0);
171  topRightLayout->addWidget(new MusicRatingLabel(std::ceil(number / 2.0), topRightWidget), 0, 1, 1, 6);
172 
173  QLabel *numberTextLabel = new QLabel(tr("Score:"), topRightWidget);
174  topRightLayout->addWidget(numberTextLabel, 1, 0);
175  topRightLayout->addWidget(new MusicRatingLabel(topRightWidget), 1, 1, 1, 6);
176 
177  QLabel *marginBottmLabel = new QLabel(topRightWidget);
178  marginBottmLabel->setFixedHeight(40);
179  topRightLayout->addWidget(marginBottmLabel, 2, 0);
180  topRightWidget->setLayout(topRightLayout);
181 
182  QRCodeQWidget *code = new QRCodeQWidget({}, QSize(90, 90), topRightWidget);
183  code->setMargin(2);
184  code->setIcon(":/image/lb_app_logo", 0.23);
185  topRightLayout->addWidget(code, 3, 2, 1, 6);
186 
187  topFuncLayout->addWidget(m_iconLabel);
188  topFuncLayout->addWidget(topLineWidget);
189  topFuncLayout->addWidget(topRightWidget);
190  topFuncWidget->setLayout(topFuncLayout);
191  grid->addWidget(topFuncWidget);
192  //
193  QWidget *functionWidget = new QWidget(this);
194  functionWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
195  QHBoxLayout *hLayout = new QHBoxLayout(functionWidget);
196 
197  m_songButton = new QPushButton(functionWidget);
198  m_songButton->setText(tr("SongItems"));
199  m_songButton->setFixedSize(100, 25);
200  m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
201  hLayout->addWidget(m_songButton);
202 
203  QPushButton *infoButton = new QPushButton(functionWidget);
204  infoButton->setText(tr("Info"));
205  infoButton->setFixedSize(100, 25);
206  infoButton->setCursor(QCursor(Qt::PointingHandCursor));
207  hLayout->addWidget(infoButton);
208  functionWidget->setLayout(hLayout);
209 
210  QPushButton *commentsButton = new QPushButton(functionWidget);
211  commentsButton->setText(tr("Comments"));
212  commentsButton->setFixedSize(100, 25);
213  commentsButton->setCursor(QCursor(Qt::PointingHandCursor));
214  hLayout->addWidget(commentsButton);
215  hLayout->addStretch(1);
216  functionWidget->setLayout(hLayout);
217 
218  QButtonGroup *buttonGroup = new QButtonGroup(this);
219  buttonGroup->addButton(m_songButton, 0);
220  buttonGroup->addButton(infoButton, 1);
221  buttonGroup->addButton(commentsButton, 2);
222  QtButtonGroupConnect(buttonGroup, this, setCurrentIndex, TTK_SLOT);
223 
224 #ifdef Q_OS_UNIX
225  playAllButton->setFocusPolicy(Qt::NoFocus);
226  shareButton->setFocusPolicy(Qt::NoFocus);
227  m_songButton->setFocusPolicy(Qt::NoFocus);
228  infoButton->setFocusPolicy(Qt::NoFocus);
229  commentsButton->setFocusPolicy(Qt::NoFocus);
230 #endif
231  grid->addWidget(functionWidget);
232  grid->addWidget(m_container);
233  grid->addStretch(1);
234 
235  function->setLayout(grid);
236  m_mainWidget->layout()->addWidget(function);
237 
238  m_resizeWidgets.append({nameLabel, nameLabel->font()});
239  m_resizeWidgets.append({creatorLabel, creatorLabel->font()});
240  m_resizeWidgets.append({tagsLabel, tagsLabel->font()});
241  m_resizeWidgets.append({updateLabel, updateLabel->font()});
242 
243  resizeGeometry();
244 }
245 
247 {
249  connect(query, SIGNAL(downloadDataChanged(QString)), SLOT(queryAllFinished()));
250 }
251 
253 {
254  if(m_tableWidget)
255  {
256  m_tableWidget->hide();
257  }
258 
259  if(m_infoLabel)
260  {
261  m_infoLabel->hide();
262  }
263 
264  delete m_commentsWidget;
265  m_commentsWidget = nullptr;
266 
267  if(index == 0 && m_tableWidget)
268  {
269  m_tableWidget->show();
270  }
271  else if(index == 1 && m_infoLabel)
272  {
273  m_infoLabel->show();
274  }
275  else if(index == 2)
276  {
279  m_container->addWidget(m_commentsWidget);
281  }
282 
283  m_container->setCurrentIndex(index);
284 }
285 
287 {
289 }
void setQueryInput(MusicAbstractQueryRequest *query)
The class of the search result data item.
static const QString FontStyle03
static bool isCoverValid(const QString &url) noexcept
virtual void startToRequest(const QString &url)=0
MusicPlaylistQueryCommentsWidget * m_commentsWidget
static const QString CheckBoxStyle01
CheckBox.
static const QString ColorStyle04
Definition: musicuiobject.h:46
void setIcon(const QString &path, float percent)
virtual void setCurrentValue(const QString &value)
static const QString FontStyle01
Font.
void setMargin(const int margin)
virtual void initialize(bool isPain) overridefinal
The class of the query item table widget.
void downloadFinished(const QByteArray &bytes)
TTK_MODULE_EXPORT int random(int value=RAND_MAX)
Definition: ttktime.cpp:14
static const QString FontStyle06
static const QString PushButtonStyle03
The class of the qr code widget.
Definition: qrcodewidget.h:31
The class of the playlist comment widget.
void setCurrentSongName(const QString &name)
TTK_MODULE_EXPORT QString elidedText(const QFont &font, const QString &text, Qt::TextElideMode mode, int width)
#define TTK_SLOT
Definition: ttkqtglobal.h:177
TTK_MODULE_EXPORT void generateVScrollAreaStyle(QWidget *widget, QWidget *parent, bool background=true)
#define QtButtonGroupConnect(p, q, f, s)
Button group connect.
Definition: ttkqtcompat.h:115
The class of the rating label.
The class of the item query widget base.
Definition: inftrees.h:24
virtual void resizeGeometry() overridefinal
void setResultDataItem(const MusicResultDataItem &item, QObject *obj)
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:172
virtual void startToSearchByValue(const QString &value) overridefinal
static const QString ColorStyle11
Definition: musicuiobject.h:67
#define G_DOWNLOAD_QUERY_PTR
MusicItemQueryTableWidget * m_tableWidget
The class of the cover data download request.
The class of the abstract query data from net.
virtual void resizeGeometry() overridefinal
void setQueryInput(MusicAbstractQueryRequest *query)
MusicSongSharingWidget::Module m_shareType
MusicPlaylistQueryInfoWidget(QWidget *parent=nullptr)
#define G_SETTING_PTR