TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicalbumquerywidget.cpp
Go to the documentation of this file.
3 #include "musiccoverrequest.h"
4 #include "musicratinglabel.h"
5 
7 
10 {
11 
12 }
13 
15 {
16  removeItems();
17 }
18 
20 {
22  if(parent()->metaObject()->indexOfSlot("queryAlbumFinished()") != -1)
23  {
24  connect(m_networkRequest, SIGNAL(downLoadDataChanged(QString)), parent(), SLOT(queryAlbumFinished()));
25  }
26 }
27 
28 
29 
32 {
35  m_queryTableWidget->hide();
36 
37  m_networkRequest = G_DOWNLOAD_QUERY_PTR->makeQueryRequest(this);
38  connect(m_networkRequest, SIGNAL(downLoadDataChanged(QString)), SLOT(queryAllFinished()));
39 }
40 
41 void MusicAlbumQueryWidget::setCurrentValue(const QString &value)
42 {
47 }
48 
49 void MusicAlbumQueryWidget::setCurrentID(const QString &id)
50 {
51  MusicAbstractQueryRequest *d = G_DOWNLOAD_QUERY_PTR->makeAlbumRequest(this);
55 }
56 
58 {
60 
61  if(!m_resizeWidgets.isEmpty())
62  {
63  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - WINDOW_WIDTH_MIN + 180;
64 
65  TTKResizeWidget *data = &m_resizeWidgets[1];
66  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width + 30));
67 
68  data = &m_resizeWidgets[2];
69  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
70 
71  data = &m_resizeWidgets[3];
72  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
73 
74  data = &m_resizeWidgets[4];
75  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
76 
77  data = &m_resizeWidgets[5];
78  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
79  }
80 }
81 
83 {
84  const TTK::MusicSongInformationList songInfos(m_networkRequest->items());
85  if(songInfos.isEmpty())
86  {
87  m_statusLabel->setPixmap(QPixmap(":/image/lb_no_album_found"));
88  }
89  else
90  {
91  bool hasItem = false;
92  for(const TTK::MusicSongInformation &info : qAsConst(songInfos))
93  {
94  if(m_value.contains(info.m_songName))
95  {
96  hasItem = true;
97  setCurrentID(info.m_albumId);
98  break;
99  }
100  }
101 
102  if(!hasItem)
103  {
104  m_statusLabel->setPixmap(QPixmap(":/image/lb_no_album_found"));
105  }
106  }
107 }
108 
110 {
112  if(!d)
113  {
114  return;
115  }
116 
117  const TTK::MusicSongInformationList songInfos(d->items());
118  if(songInfos.isEmpty())
119  {
120  m_statusLabel->setPixmap(QPixmap(":/image/lb_no_album_found"));
121  }
122  else
123  {
125  }
126 }
127 
129 {
130  m_currentPlaylistItem = item;
131 
132  createLabels();
133 
134  if(!m_resizeWidgets.isEmpty())
135  {
136  if(TTK::isCoverValid(item.m_coverUrl))
137  {
138  MusicCoverRequest *d = G_DOWNLOAD_QUERY_PTR->makeCoverRequest(this);
139  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
140  d->startToRequest(item.m_coverUrl);
141  }
142 
143  QStringList list{item.m_count, item.m_category, item.m_description, item.m_updateTime};
144  for(int i = 0; i < list.count(); ++i)
145  {
146  if(list[i].isEmpty())
147  {
148  list[i] = TTK_DEFAULT_STR;
149  }
150  }
151 
152  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - WINDOW_WIDTH_MIN + 180;
153 
154  TTKResizeWidget *data = &m_resizeWidgets[0];
155  data->m_label->setText(tr("<font color=#158FE1> Alubm > %1 </font>").arg(list[0]));
156 
157  data = &m_resizeWidgets[1];
158  data->m_label->setToolTip(list[0]);
159  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width + 30));
160 
161  data = &m_resizeWidgets[2];
162  data->m_label->setToolTip(tr("Singer: %1").arg(item.m_name));
163  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
164 
165  data = &m_resizeWidgets[3];
166  data->m_label->setToolTip(tr("Language: %1").arg(list[1]));
167  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
168 
169  data = &m_resizeWidgets[4];
170  data->m_label->setToolTip(tr("Company: %1").arg(list[2]));
171  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
172 
173  data = &m_resizeWidgets[5];
174  data->m_label->setToolTip(tr("Year: %1").arg(list[3]));
175  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
176  }
177 }
178 
180 {
181  delete m_statusLabel;
182  m_statusLabel = nullptr;
183 
184  initFirstWidget();
185  m_container->show();
186 
187  layout()->removeWidget(m_mainWindow);
188  QScrollArea *scrollArea = new QScrollArea(this);
190  layout()->addWidget(scrollArea);
191 
192  QWidget *function = new QWidget(m_mainWindow);
193  function->setStyleSheet(TTK::UI::CheckBoxStyle01 + TTK::UI::PushButtonStyle03);
194  QVBoxLayout *grid = new QVBoxLayout(function);
195 
196  QLabel *firstLabel = new QLabel(function);
197  grid->addWidget(firstLabel);
198  //
199  QWidget *topFuncWidget = new QWidget(function);
200  QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);
201 
202  m_iconLabel = new QLabel(topFuncWidget);
203  m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
204  m_iconLabel->setFixedSize(210, 180);
205  //
206  QWidget *topLineWidget = new QWidget(topFuncWidget);
207  QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
208  topLineLayout->setContentsMargins(10, 5, 5, 0);
209 
210  QLabel *albumLabel = new QLabel(topLineWidget);
211  QFont albumFont = albumLabel->font();
212  albumFont.setPixelSize(20);
213  albumLabel->setFont(albumFont);
214  albumLabel->setStyleSheet(TTK::UI::FontStyle01);
215  albumLabel->setText(TTK_DEFAULT_STR);
216 
217  QLabel *singerLabel = new QLabel(topLineWidget);
218  singerLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
219  singerLabel->setText(TTK_DEFAULT_STR);
220 
221  QLabel *languageLabel = new QLabel(topLineWidget);
222  languageLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
223  languageLabel->setText(TTK_DEFAULT_STR);
224 
225  QLabel *companyLabel = new QLabel(topLineWidget);
226  companyLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
227  companyLabel->setText(TTK_DEFAULT_STR);
228 
229  QLabel *yearLabel = new QLabel(topLineWidget);
230  yearLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
231  yearLabel->setText(TTK_DEFAULT_STR);
232 
233  topLineLayout->addWidget(albumLabel);
234  topLineLayout->addWidget(singerLabel);
235  topLineLayout->addWidget(languageLabel);
236  topLineLayout->addWidget(companyLabel);
237  topLineLayout->addWidget(yearLabel);
238  topLineWidget->setLayout(topLineLayout);
239 
240  QWidget *topButtonWidget = new QWidget(topFuncWidget);
241  QHBoxLayout *topButtonLayout = new QHBoxLayout(topButtonWidget);
242  topButtonLayout->setContentsMargins(0, 0, 0, 0);
243 
244  QPushButton *playAllButton = new QPushButton(tr("Play All"), topButtonWidget);
245  QPushButton *shareButton = new QPushButton(tr("Share"), topButtonWidget);
246 
247  playAllButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
248  playAllButton->setIconSize(QSize(14, 14));
249  playAllButton->setCursor(QCursor(Qt::PointingHandCursor));
250  shareButton->setCursor(QCursor(Qt::PointingHandCursor));
251  playAllButton->setFixedSize(90, 30);
252  shareButton->setFixedSize(55, 30);
253 
254  topButtonLayout->addWidget(playAllButton);
255  topButtonLayout->addWidget(shareButton);
256  topButtonLayout->addStretch(1);
257  topButtonWidget->setLayout(topButtonLayout);
258  topLineLayout->addWidget(topButtonWidget);
259 
260  connect(playAllButton, SIGNAL(clicked()), SLOT(playAllButtonClicked()));
261  connect(shareButton, SIGNAL(clicked()), SLOT(shareButtonClicked()));
262  //
263  QWidget *topRightWidget = new QWidget(topFuncWidget);
264  QGridLayout *topRightLayout = new QGridLayout(topRightWidget);
265  topRightLayout->setContentsMargins(0, 0, 0, 0);
266  topRightLayout->setSpacing(0);
267 
268  QLabel *numberLabel = new QLabel(topRightWidget);
269  numberLabel->setAlignment(Qt::AlignCenter);
270  numberLabel->setStyleSheet(TTK::UI::FontStyle05 + TTK::UI::ColorStyle11);
271 
272  const int number = 7 + TTK::random(3);
273  numberLabel->setText(QString("%1.%2").arg(number).arg(TTK::random(10)));
274  topRightLayout->addWidget(numberLabel, 0, 0);
275  topRightLayout->addWidget(new MusicRatingLabel(ceil(number / 2.0), topRightWidget), 0, 1, 1, 6);
276 
277  QLabel *numberTextLabel = new QLabel(tr("Score:"), topRightWidget);
278  topRightLayout->addWidget(numberTextLabel, 1, 0);
279  topRightLayout->addWidget(new MusicRatingLabel(topRightWidget), 1, 1, 1, 6);
280 
281  QLabel *marginBottmLabel = new QLabel(topRightWidget);
282  marginBottmLabel->setFixedHeight(40);
283  topRightLayout->addWidget(marginBottmLabel, 2, 0);
284  topRightWidget->setLayout(topRightLayout);
285 
286  QRCodeQWidget *code = new QRCodeQWidget({}, QSize(90, 90), topRightWidget);
287  code->setMargin(2);
288  code->setIcon(":/image/lb_app_logo", 0.23);
289  topRightLayout->addWidget(code, 3, 2, 1, 6);
290 
291  topFuncLayout->addWidget(m_iconLabel);
292  topFuncLayout->addWidget(topLineWidget);
293  topFuncLayout->addWidget(topRightWidget);
294  topFuncWidget->setLayout(topFuncLayout);
295  grid->addWidget(topFuncWidget);
296  //
297  QWidget *functionWidget = new QWidget(this);
298  functionWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
299  QHBoxLayout *hLayout = new QHBoxLayout(functionWidget);
300 
301  m_songButton = new QPushButton(functionWidget);
302  m_songButton->setText(tr("SongItems"));
303  m_songButton->setFixedSize(100, 25);
304  m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
305  hLayout->addWidget(m_songButton);
306  hLayout->addStretch(1);
307  functionWidget->setLayout(hLayout);
308 
309  QButtonGroup *buttonGroup = new QButtonGroup(this);
310  buttonGroup->addButton(m_songButton, 0);
311  QtButtonGroupConnect(buttonGroup, m_container, setCurrentIndex, TTK_SLOT);
312 
313 #ifdef Q_OS_UNIX
314  playAllButton->setFocusPolicy(Qt::NoFocus);
315  shareButton->setFocusPolicy(Qt::NoFocus);
316  m_songButton->setFocusPolicy(Qt::NoFocus);
317 #endif
318  grid->addWidget(functionWidget);
319  grid->addWidget(m_container);
320  grid->addStretch(1);
321 
322  function->setLayout(grid);
323  m_mainWindow->layout()->addWidget(function);
324 
325  m_resizeWidgets.push_back({firstLabel, firstLabel->font()});
326  m_resizeWidgets.push_back({albumLabel, albumLabel->font()});
327  m_resizeWidgets.push_back({singerLabel, singerLabel->font()});
328  m_resizeWidgets.push_back({languageLabel, languageLabel->font()});
329  m_resizeWidgets.push_back({companyLabel, companyLabel->font()});
330  m_resizeWidgets.push_back({yearLabel, yearLabel->font()});
331 }
virtual void setQueryInput(MusicAbstractQueryRequest *query)
The class of the search result data item.
#define TTK_DEFAULT_STR
Definition: ttkglobal.h:200
static const QString FontStyle03
MusicItemQueryTableWidget * m_queryTableWidget
virtual void startToRequest(const QString &url)=0
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)
virtual void setCurrentID(const QString &id) overridefinal
static const QString FontStyle01
Font.
void setMargin(const int margin)
The class of the query item table widget.
TTK_MODULE_EXPORT int random(int value=RAND_MAX)
Definition: ttktime.cpp:14
virtual void setCurrentValue(const QString &value) overridefinal
MusicAbstractQueryRequest * queryInput() const
#define qAsConst
Definition: ttkqtglobal.h:53
static const QString FontStyle05
static const QString PushButtonStyle03
The class of the qr code widget.
Definition: qrcodewidget.h:31
virtual void removeItems() overridefinal
TTK_MODULE_EXPORT QString elidedText(const QFont &font, const QString &text, Qt::TextElideMode mode, int width)
#define TTK_SLOT
Definition: ttkqtglobal.h:165
MusicAlbumQueryWidget(QWidget *parent=nullptr)
#define QtButtonGroupConnect(p, q, f, s)
Button group connect.
Definition: ttkqtcompat.h:101
static bool isCoverValid(const QString &url)
void downLoadFinished(const QByteArray &bytes)
virtual void setQueryInput(MusicAbstractQueryRequest *query) overridefinal
The class of the rating label.
The class of the item query widget base.
Definition: inftrees.h:24
TTK_MODULE_EXPORT void generateVScrollAreaFormat(QWidget *widget, QWidget *parent, bool background=true)
virtual void startToSearchByText(const QString &text) overridefinal
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:153
MusicAbstractQueryRequest * m_networkRequest
void createAlbumItem(const MusicResultDataItem &item)
static const QString ColorStyle11
Definition: musicuiobject.h:67
#define G_DOWNLOAD_QUERY_PTR
MusicAlbumQueryTableWidget(QWidget *parent=nullptr)
The class of the cover data download request.
virtual void startToSearch(const QString &value)=0
The class of the abstract query download data from net.
const TTK::MusicSongInformationList & items() const
MusicSongSharingWidget::Module m_shareType
virtual void resizeWidget() overridefinal
MusicAbstractQueryRequest * m_networkRequest
The class of the music song information.
Definition: musicobject.h:281
The class of the album music query table widget.
#define G_SETTING_PTR