TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicmainrecommendwidget.cpp
Go to the documentation of this file.
3 #include "musicrightareawidget.h"
4 #include "musicqueryitemwidget.h"
5 #include "musictoastlabel.h"
6 #include "musicpagequerywidget.h"
7 #include "musicdownloadwidget.h"
9 #include "ttkclickedgroup.h"
10 
11 #define QUERY_WIDGET_WIDTH (G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - LEFT_SIDE_WIDTH_MIN)
12 
14  : MusicQueryTableWidget(parent)
15 {
16  setStyleSheet(styleSheet() + TTK::UI::LabelStyle03);
17  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
18  setColumnCount(5);
19 
20  delete m_labelDelegate;
21  m_labelDelegate = nullptr;
22  setItemDelegateForColumn(0, nullptr);
23 
24  QHeaderView *headerView = horizontalHeader();
25  headerView->resizeSection(0, 230);
26  headerView->resizeSection(1, 20);
27  headerView->resizeSection(2, 20);
28  headerView->resizeSection(3, 40);
29  headerView->resizeSection(4, 5);
30 }
31 
33 {
34  removeItems();
35 }
36 
38 {
39  if(!G_NETWORK_PTR->isOnline())
40  {
41  removeItems();
42  return;
43  }
44 
46 }
47 
49 {
50  if(!isValid(row))
51  {
52  return;
53  }
54 
55  MusicDownloadWidget *widget = new MusicDownloadWidget(this);
56  widget->initialize(m_networkRequest, row);
57  widget->show();
58 }
59 
61 {
62  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width();
63  QHeaderView *headerView = horizontalHeader();
64  headerView->resizeSection(0, 230 + (width - WINDOW_WIDTH_MIN) / 2.0);
65 
66  for(int i = 0; i < rowCount(); ++i)
67  {
68  QTableWidgetItem *it = item(i, 0);
69  it->setText(TTK::Widget::elidedText(font(), it->toolTip(), Qt::ElideRight, headerView->sectionSize(0)));
70  }
71 }
72 
74 {
75  if(column < 0 || row < 0 || row >= rowCount() - 1)
76  {
77  return;
78  }
79 
80  addSearchMusicToPlaylist(row, true);
81 }
82 
84 {
85  QTableWidgetItem *it = item(m_previousColorRow, 1);
86  if(it)
87  {
88  it->setIcon(QIcon());
89  }
90 
91  it = item(m_previousColorRow, 2);
92  if(it)
93  {
94  it->setIcon(QIcon());
95  }
96 
97  it = item(m_previousColorRow, 3);
98  if(it)
99  {
100  it->setIcon(QIcon());
101  it->setText(m_networkRequest->items()[m_previousColorRow].m_duration);
102  }
103 
104  if(it = item(row, 1))
105  {
106  it->setIcon(QIcon(":/contextMenu/btn_play"));
107  }
108 
109  if(it = item(row, 2))
110  {
111  it->setIcon(QIcon(":/contextMenu/btn_add"));
112  }
113 
114  if(it = item(row, 3))
115  {
116  it->setText({});
117  it->setIcon(QIcon(":/contextMenu/btn_download"));
118  }
119 
121 
122  if(column == 1 || column == 2 || column == 3)
123  {
124  setCursor(QCursor(Qt::PointingHandCursor));
125  }
126  else
127  {
128  unsetCursor();
129  }
130 }
131 
133 {
135 
136  switch(column)
137  {
138  case 1: addSearchMusicToPlaylist(row, true); break;
139  case 2: addSearchMusicToPlaylist(row, false); break;
140  case 3: downloadQueryResult(row); break;
141  default: break;
142  }
143 }
144 
146 {
148  setColumnCount(5);
149 }
150 
152 {
153  const int count = rowCount();
154  setRowCount(count + 1);
155 
156  QHeaderView *headerView = horizontalHeader();
157  QTableWidgetItem *item = new QTableWidgetItem;
158  item->setToolTip(TTK::generateSongName(result.m_songName, result.m_artistName));
159  item->setText(TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(0)));
160  item->setForeground(QColor(TTK::UI::Color02));
161  QtItemSetTextAlignment(item, Qt::AlignLeft | Qt::AlignVCenter);
162  setItem(count, 0, item);
163 
164  item = new QTableWidgetItem;
165  setItem(count, 1, item);
166 
167  item = new QTableWidgetItem;
168  setItem(count, 2, item);
169 
170  item = new QTableWidgetItem(result.m_duration);
171  item->setForeground(QColor(TTK::UI::Color02));
172  QtItemSetTextAlignment(item, Qt::AlignLeft | Qt::AlignVCenter);
173  setItem(count, 3, item);
174 
175  item = new QTableWidgetItem;
176  setItem(count, 4, item);
177 }
178 
180 {
181  if(!isValid(row))
182  {
183  return;
184  }
185 
186  TTK::MusicSongInformationList songInfos(m_networkRequest->items());
187  if(row >= songInfos.count())
188  {
189  return;
190  }
191 
192  downloadDataFrom(&songInfos[row], play);
193 }
194 
196 {
197  if(!G_NETWORK_PTR->isOnline())
198  {
199  MusicToastLabel::popup(tr("No resource found"));
200  return false;
201  }
202 
204 
205  if(info->m_songProps.isEmpty())
206  {
207  MusicToastLabel::popup(tr("No resource found"));
208  return false;
209  }
210 
211  const TTK::MusicSongProperty &prop = info->m_songProps.first();
212 
213  MusicResultDataItem item;
215  item.m_time = info->m_duration;
216  item.m_id = info->m_songId;
217  item.m_nickName = prop.m_url;
218  item.m_description = prop.m_format;
219  item.m_count = prop.m_size;
220  item.m_title = play ? MUSIC_PLAY_NOW : MUSIC_PLAY_LATER;
221 
222  if(m_networkRequest)
223  {
224  item.m_id = m_networkRequest->queryServer() + item.m_id;
225  }
226 
228  return true;
229 }
230 
231 
233  : QWidget(parent),
234  m_module(module),
235  m_networkRequest(nullptr)
236 {
237  m_gridLayout = new QGridLayout(this);
238  m_gridLayout->setContentsMargins(0, 0, 0, 0);
239  m_gridLayout->setVerticalSpacing(5);
240  setLayout(m_gridLayout);
241 }
242 
244 {
245  delete m_gridLayout;
246  delete m_networkRequest;
247 }
248 
250 {
251  m_networkRequest = query;
252  switch(m_module)
253  {
254  case RecommendModule::Album: connect(m_networkRequest, SIGNAL(createAlbumItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem))); break;
255  case RecommendModule::Artist: connect(m_networkRequest, SIGNAL(createArtistListItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem))); break;
257  case RecommendModule::PlaylistHQ: connect(m_networkRequest, SIGNAL(createPlaylistItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem))); break;
258  default: break;
259  }
260 }
261 
263 {
266  label->hide();
267  label->setShowTime(false);
268  label->setShowCount(false);
270  label->setResultDataItem(item, new MusicCoverSourceRequest(this));
271 
273  const int lineNumber = (QUERY_WIDGET_WIDTH - lineSize / 2) / lineSize;
274  int row = 0, col = 0;
275 
277  {
278  row = 0;
279  col = m_resizeWidgets.count();
280  }
281  else
282  {
283  int rowNumber = lineNumber;
284  if(rowNumber > m_networkRequest->pageSize())
285  {
286  rowNumber = m_networkRequest->pageSize();
287  }
288 
289  row = m_resizeWidgets.count() / (rowNumber / 2);
290  col = m_resizeWidgets.count() % (rowNumber / 2);
291  }
292 
293  if(m_resizeWidgets.count() < lineNumber)
294  {
295  label->show();
296  m_gridLayout->addWidget(label, row, col, Qt::AlignLeft | Qt::AlignTop);
297  }
298  m_resizeWidgets.append(label);
299 }
300 
302 {
303  switch(m_module)
304  {
309  default: break;
310  }
311 }
312 
314 {
315  if(m_resizeWidgets.isEmpty() || !m_gridLayout)
316  {
317  return;
318  }
319 
320  for(QWidget *widget : qAsConst(m_resizeWidgets))
321  {
322  widget->hide();
323  m_gridLayout->removeWidget(widget);
324  }
325 
327  const int lineNumber = (QUERY_WIDGET_WIDTH - lineSize / 2) / lineSize;
328  int row = 0, col = 0, rowNumber = 0;
329 
331  {
332  row = TTK_RN_MAX;
333  col = lineNumber;
334  rowNumber = lineNumber;
335  }
336  else
337  {
338  rowNumber = lineNumber / 2;
339  if(rowNumber > m_networkRequest->pageSize() / 2)
340  {
341  rowNumber = m_networkRequest->pageSize() / 2;
342  }
343 
344  row = rowNumber;
345  col = rowNumber;
346  rowNumber = 2 * rowNumber;
347  }
348 
349  for(int i = 0; i < m_resizeWidgets.count(); ++i)
350  {
351  if(i < rowNumber)
352  {
353  m_gridLayout->addWidget(m_resizeWidgets[i], i / row, i % col, Qt::AlignLeft | Qt::AlignTop);
354  m_resizeWidgets[i]->show();
355  }
356  }
357 }
358 
359 
361  : QWidget(parent),
362  m_categoryChanged(false),
363  m_module(module),
364  m_pageQueryWidget(nullptr),
365  m_networkRequest(nullptr)
366 {
367  setStyleSheet(TTK::UI::BackgroundStyle01);
368 
369  QHBoxLayout *layout = new QHBoxLayout(this);
370  layout->setSpacing(0);
371  layout->setContentsMargins(12, 0, 12, 0);
372  setLayout(layout);
373 
374  m_mainWidget = new QWidget(this);
375 
376  QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_mainWidget);
377  mainWidgetLayout->setSpacing(0);
378  mainWidgetLayout->setContentsMargins(0, 0, 0, 0);
379  m_mainWidget->setLayout(mainWidgetLayout);
380 
381  QScrollArea *scrollArea = new QScrollArea(this);
383  layout->addWidget(scrollArea);
384 
385  initialize();
386 }
387 
389 {
390  delete m_areasGroup;
391  delete m_gridLayout;
392  delete m_pageQueryWidget;
393  delete m_mainWidget;
394  delete m_networkRequest;
395 }
396 
398 {
399  if(m_resizeWidgets.isEmpty() || !m_gridLayout)
400  {
401  return;
402  }
403 
404  for(QWidget *widget : qAsConst(m_resizeWidgets))
405  {
406  m_gridLayout->removeWidget(widget);
407  }
408 
410  const int lineNumber = (QUERY_WIDGET_WIDTH - lineSize / 2) / lineSize;
411  for(int i = 0; i < m_resizeWidgets.count(); ++i)
412  {
413  m_gridLayout->addWidget(m_resizeWidgets[i], i / lineNumber, i % lineNumber, Qt::AlignLeft);
414  }
415 }
416 
418 {
422 }
423 
425 {
426  switch(m_module)
427  {
429  {
430  QString key;
431  switch(index)
432  {
433  case 0: key = "ALL"; break;
434  case 1: key = "ZH"; break;
435  case 2: key = "EA"; break;
436  case 3: key = "KR"; break;
437  case 4: key = "JP"; break;
438  default: break;
439  }
440 
441  if(!key.isEmpty())
442  {
444  m_categoryChanged = true;
446  }
447  break;
448  }
449  case RecommendModule::Artist: break;
450  case RecommendModule::Playlist: break;
452  {
454  m_categoryChanged = true;
455  m_networkRequest->startToSearch(QString::number(index));
456  break;
457  }
458  default: break;
459  }
460 }
461 
463 {
464  if(!m_pageQueryWidget)
465  {
467  connect(m_pageQueryWidget, SIGNAL(clicked(int)), SLOT(buttonClicked(int)));
468 
469  QVBoxLayout *mainLayout = TTKObjectCast(QVBoxLayout*, m_mainWidget->layout());
470  mainLayout->addWidget(m_pageQueryWidget->createPageWidget(this, m_networkRequest->pageTotalSize()));
471  mainLayout->addStretch(1);
472  }
473 
475  {
476  m_categoryChanged = false;
478  }
479 
482  label->setShowTime(false);
483  label->setShowCount(false);
485  label->setResultDataItem(item, new MusicCoverSourceRequest(this));
486 
488  const int lineNumber = (QUERY_WIDGET_WIDTH - lineSize / 2) / lineSize;
489  m_gridLayout->addWidget(label, m_resizeWidgets.count() / lineNumber, m_resizeWidgets.count() % lineNumber, Qt::AlignLeft);
490  m_resizeWidgets.append(label);
491 }
492 
494 {
495  switch(m_module)
496  {
501  default: break;
502  }
503 }
504 
506 {
507  QWidget *topWidget = new QWidget(m_mainWidget);
508  topWidget->setFixedHeight(65);
509  m_mainWidget->layout()->addWidget(topWidget);
510 
511  QHBoxLayout *topWidgetLayout = new QHBoxLayout(topWidget);
512  topWidgetLayout->setContentsMargins(0, 20, 12, 10);
513  topWidget->setLayout(topWidgetLayout);
514 
515  QWidget *frame = new QWidget(topWidget);
516  frame->setFixedSize(3, 36);
517  frame->setStyleSheet(TTK::UI::BackgroundStyle13);
518  topWidgetLayout->addWidget(frame);
519 
520  QLabel *label = new QLabel(topWidget);
521  label->setStyleSheet(TTK::UI::FontStyle06);
522  topWidgetLayout->addWidget(label);
523  topWidgetLayout->addStretch(1);
524 
525  TTKClickedLabel *backButton = new TTKClickedLabel("<<", topWidget);
526  backButton->setAlignment(Qt::AlignBottom);
527  backButton->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle01 + TTK::UI::FontStyle03);
528  topWidgetLayout->addWidget(backButton, 0, Qt::AlignBottom);
529  connect(backButton, SIGNAL(clicked()), parent(), SLOT(moreItemChangedToArea()));
530 
531  QWidget *container = new QWidget(m_mainWidget);
532  m_mainWidget->layout()->addWidget(container);
533 
534  m_gridLayout = new QGridLayout(container);
535  m_gridLayout->setContentsMargins(0, 0, 0, 0);
536  m_gridLayout->setVerticalSpacing(5);
537  container->setLayout(m_gridLayout);
538 
539  m_areasGroup = new TTKClickedGroup(this);
540  connect(m_areasGroup, SIGNAL(clicked(int)), SLOT(categoryChanged(int)));
541 
542  switch(m_module)
543  {
545  {
546  label->setText(tr("New Albums"));
547 
548  QWidget *spacing = new QWidget(topWidget);
549  spacing->setFixedWidth(10);
550  topWidgetLayout->insertWidget(2, spacing);
551 
552  TTKClickedLabel *allButton = new TTKClickedLabel(tr("All"), topWidget);
553  allButton->setAlignment(Qt::AlignBottom);
554  m_areasGroup->addWidget(allButton, 0);
555  topWidgetLayout->insertWidget(3, allButton);
556 
557  QWidget *frame1 = new QWidget(topWidget);
558  frame1->setFixedSize(2, topWidget->height() / 4);
559  frame1->setStyleSheet(TTK::UI::BackgroundStyle03);
560  topWidgetLayout->insertWidget(4, frame1, 0, Qt::AlignBottom);
561 
562  TTKClickedLabel *zhButton = new TTKClickedLabel(tr("ZH"), topWidget);
563  zhButton->setAlignment(Qt::AlignBottom);
564  m_areasGroup->addWidget(zhButton, 1);
565  topWidgetLayout->insertWidget(5, zhButton);
566 
567  QWidget *frame2 = new QWidget(topWidget);
568  frame2->setFixedSize(2, topWidget->height() / 4);
569  frame2->setStyleSheet(TTK::UI::BackgroundStyle03);
570  topWidgetLayout->insertWidget(6, frame2, 0, Qt::AlignBottom);
571 
572  TTKClickedLabel *eaButton = new TTKClickedLabel(tr("EA"), topWidget);
573  eaButton->setAlignment(Qt::AlignBottom);
574  m_areasGroup->addWidget(eaButton, 2);
575  topWidgetLayout->insertWidget(7, eaButton);
576 
577  QWidget *frame3 = new QWidget(topWidget);
578  frame3->setFixedSize(2, topWidget->height() / 4);
579  frame3->setStyleSheet(TTK::UI::BackgroundStyle03);
580  topWidgetLayout->insertWidget(8, frame3, 0, Qt::AlignBottom);
581 
582  TTKClickedLabel *krButton = new TTKClickedLabel(tr("KR"), topWidget);
583  krButton->setAlignment(Qt::AlignBottom);
584  m_areasGroup->addWidget(krButton, 3);
585  topWidgetLayout->insertWidget(9, krButton);
586 
587  QWidget *frame4 = new QWidget(topWidget);
588  frame4->setFixedSize(2, topWidget->height() / 4);
589  frame4->setStyleSheet(TTK::UI::BackgroundStyle03);
590  topWidgetLayout->insertWidget(10, frame4, 0, Qt::AlignBottom);
591 
592  TTKClickedLabel *jpButton = new TTKClickedLabel(tr("JP"), topWidget);
593  jpButton->setAlignment(Qt::AlignBottom);
594  m_areasGroup->addWidget(jpButton, 4);
595  topWidgetLayout->insertWidget(11, jpButton);
596 
597  m_networkRequest = G_DOWNLOAD_QUERY_PTR->makeNewAlbumRequest(this);
598  connect(m_networkRequest, SIGNAL(createAlbumItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem)));
600  break;
601  }
603  {
604  label->setText(tr("Popular Artists"));
605 
606  m_networkRequest = G_DOWNLOAD_QUERY_PTR->makeHotArtistListRequest(this);
607  connect(m_networkRequest, SIGNAL(createArtistListItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem)));
609  break;
610  }
612  {
613  label->setText(tr("Recommended Playlist"));
614 
615  m_networkRequest = G_DOWNLOAD_QUERY_PTR->makePlaylistRecommendRequest(this);
616  connect(m_networkRequest, SIGNAL(createPlaylistItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem)));
618  break;
619  }
621  {
622  label->setText(tr("Premium Playlist"));
623 
624  QWidget *spacing = new QWidget(topWidget);
625  spacing->setFixedWidth(10);
626  topWidgetLayout->insertWidget(2, spacing);
627 
628  TTKClickedLabel *allButton = new TTKClickedLabel(tr("All"), topWidget);
629  allButton->setAlignment(Qt::AlignBottom);
630  m_areasGroup->addWidget(allButton, 0);
631  topWidgetLayout->insertWidget(3, allButton);
632 
633  QWidget *frame1 = new QWidget(topWidget);
634  frame1->setFixedSize(2, topWidget->height() / 4);
635  frame1->setStyleSheet(TTK::UI::BackgroundStyle03);
636  topWidgetLayout->insertWidget(4, frame1, 0, Qt::AlignBottom);
637 
638  TTKClickedLabel *zhButton = new TTKClickedLabel(tr("ZH"), topWidget);
639  zhButton->setAlignment(Qt::AlignBottom);
640  m_areasGroup->addWidget(zhButton, 1);
641  topWidgetLayout->insertWidget(5, zhButton);
642 
643  QWidget *frame2 = new QWidget(topWidget);
644  frame2->setFixedSize(2, topWidget->height() / 4);
645  frame2->setStyleSheet(TTK::UI::BackgroundStyle03);
646  topWidgetLayout->insertWidget(6, frame2, 0, Qt::AlignBottom);
647 
648  TTKClickedLabel *eaButton = new TTKClickedLabel(tr("EA"), topWidget);
649  eaButton->setAlignment(Qt::AlignBottom);
650  m_areasGroup->addWidget(eaButton, 2);
651  topWidgetLayout->insertWidget(7, eaButton);
652 
653  QWidget *frame3 = new QWidget(topWidget);
654  frame3->setFixedSize(2, topWidget->height() / 4);
655  frame3->setStyleSheet(TTK::UI::BackgroundStyle03);
656  topWidgetLayout->insertWidget(8, frame3, 0, Qt::AlignBottom);
657 
658  TTKClickedLabel *krButton = new TTKClickedLabel(tr("KR"), topWidget);
659  krButton->setAlignment(Qt::AlignBottom);
660  m_areasGroup->addWidget(krButton, 3);
661  topWidgetLayout->insertWidget(9, krButton);
662 
663  QWidget *frame4 = new QWidget(topWidget);
664  frame4->setFixedSize(2, topWidget->height() / 4);
665  frame4->setStyleSheet(TTK::UI::BackgroundStyle03);
666  topWidgetLayout->insertWidget(10, frame4, 0, Qt::AlignBottom);
667 
668  TTKClickedLabel *jpButton = new TTKClickedLabel(tr("JP"), topWidget);
669  jpButton->setAlignment(Qt::AlignBottom);
670  m_areasGroup->addWidget(jpButton, 4);
671  topWidgetLayout->insertWidget(11, jpButton);
672 
673  m_networkRequest = G_DOWNLOAD_QUERY_PTR->makePlaylistHighRequest(this);
674  connect(m_networkRequest, SIGNAL(createPlaylistItem(MusicResultDataItem)), SLOT(createResultItem(MusicResultDataItem)));
676  break;
677  }
678  default: break;
679  }
680 }
681 
683 {
684  while(!m_resizeWidgets.isEmpty())
685  {
686  QWidget *w = m_resizeWidgets.takeLast();
687  if(layout)
688  {
689  layout->removeWidget(w);
690  }
691  delete w;
692  }
693 }
694 
695 
697  : QWidget(parent),
698  m_itemMoreWidget(nullptr)
699 {
700  QVBoxLayout *layout = new QVBoxLayout(this);
701  layout->setSpacing(0);
702  layout->setContentsMargins(0, 0, 0, 0);
703  setLayout(layout);
704 
705  m_mainWidget = new QStackedWidget(this);
706  m_mainWidget->setObjectName("MainWidget");
707  m_mainWidget->setStyleSheet(QString("#%1{ %2 }").arg(m_mainWidget->objectName(), TTK::UI::BackgroundStyle10));
708  layout->addWidget(m_mainWidget);
709 
711 }
712 
714 {
715  delete m_newSongsWidget;
716  delete m_newAlbumsWidget;
717  delete m_artistsWidget;
718  delete m_hqPlaylistWidget;
719  delete m_playlistWidget;
720  delete m_areasGroup;
721  delete m_homeContainer;
722  delete m_homeWidget;
723  delete m_itemMoreWidget;
724  delete m_mainWidget;
725 }
726 
728 {
734 
735  if(m_itemMoreWidget)
736  {
738  }
739 }
740 
742 {
743  delete m_itemMoreWidget;
745  m_mainWidget->addWidget(m_itemMoreWidget);
746 
747  m_homeWidget->hide();
748  m_mainWidget->setCurrentWidget(m_itemMoreWidget);
749 }
750 
752 {
753  m_homeWidget->show();
754  m_itemMoreWidget->hide();
755  m_mainWidget->setCurrentWidget(m_homeWidget);
756 }
757 
759 {
760  m_homeWidget = new QWidget(m_mainWidget);
762  m_mainWidget->addWidget(m_homeWidget);
763 
764  QVBoxLayout *layout = new QVBoxLayout(m_homeWidget);
765  layout->setContentsMargins(12, 0, 12, 0);
766  layout->setSpacing(6);
767  m_homeWidget->setLayout(layout);
768 
770  connect(m_areasGroup, SIGNAL(clicked(int)), SLOT(areaItemChangedToMore(int)));
771 
772  createTopWidget();
774 }
775 
777 {
778  QWidget *widget = new QWidget(m_homeWidget);
779  widget->setFixedHeight(40);
781  m_homeWidget->layout()->addWidget(widget);
782 
783  QHBoxLayout *topLayout = new QHBoxLayout(widget);
784  topLayout->setContentsMargins(0, 0, 0, 0);
785  topLayout->setSpacing(25);
786  topLayout->addStretch(1);
787 
788  TTKClickedGroup *clickedGroup = new TTKClickedGroup(this);
789  TTKClickedLabel *discovery = new TTKClickedLabel(tr("Discovery"), widget);
790  discovery->setStyleSheet(TTK::UI::FontStyle03);
791  clickedGroup->addWidget(discovery, MusicRightAreaWidget::MainRecommendWidget);
792  topLayout->addWidget(discovery);
793 
794  TTKClickedLabel *recommend = new TTKClickedLabel(tr("Recommend"), widget);
795  recommend->setStyleSheet(TTK::UI::FontStyle03);
796  clickedGroup->addWidget(recommend, MusicRightAreaWidget::SongRecommendWidget);
797  topLayout->addWidget(recommend);
798 
799  TTKClickedLabel *toplist = new TTKClickedLabel(tr("Toplist"), widget);
800  toplist->setStyleSheet(TTK::UI::FontStyle03);
801  clickedGroup->addWidget(toplist, MusicRightAreaWidget::ToplistWidget);
802  topLayout->addWidget(toplist);
803 
804  TTKClickedLabel *artists = new TTKClickedLabel(tr("Artists"), widget);
805  artists->setStyleSheet(TTK::UI::FontStyle03);
807  topLayout->addWidget(artists);
808 
809  TTKClickedLabel *category = new TTKClickedLabel(tr("Category"), widget);
810  category->setStyleSheet(TTK::UI::FontStyle03);
812  topLayout->addWidget(category);
813 
814  topLayout->addStretch(1);
815  connect(clickedGroup, SIGNAL(clicked(int)), MusicRightAreaWidget::instance(), SLOT(functionClicked(int)));
816 }
817 
819 {
820  m_homeContainer = new QWidget(m_homeWidget);
821 
822  QVBoxLayout *layout = new QVBoxLayout(m_homeContainer);
823  layout->setContentsMargins(0, 0, 0, 0);
824  layout->setSpacing(0);
825  m_homeContainer->setLayout(layout);
826 
827  QScrollArea *scrollArea = new QScrollArea(m_homeWidget);
829  m_homeWidget->layout()->addWidget(scrollArea);
830 
835 
836  layout->addStretch(1);
837 }
838 
840 {
841  QWidget *widget = new QWidget(m_homeWidget);
842  widget->setFixedHeight(430);
843  m_homeContainer->layout()->addWidget(widget);
844 
845  QHBoxLayout *layout = new QHBoxLayout(widget);
846  layout->setContentsMargins(0, 0, 0, 0);
847  layout->setSpacing(10);
848  widget->setLayout(layout);
849 
850  QWidget *leftWidget = new QWidget(widget);
851  layout->addWidget(leftWidget, 1);
852 
853  QVBoxLayout *leftLayout = new QVBoxLayout(leftWidget);
854  leftLayout->setContentsMargins(0, 0, 0, 0);
855  leftWidget->setLayout(leftLayout);
856 
857  QWidget *leftTopWidget = new QWidget(leftWidget);
858  leftTopWidget->setFixedHeight(30);
859  leftLayout->addWidget(leftTopWidget);
860 
861  QHBoxLayout *leftTopLayout = new QHBoxLayout(leftTopWidget);
862  leftTopLayout->setContentsMargins(0, 0, 0, 0);
863  leftTopWidget->setLayout(leftTopLayout);
864 
865  QWidget *leftTopFrame = new QWidget(leftTopWidget);
866  leftTopFrame->setFixedWidth(3);
867  leftTopFrame->setStyleSheet(TTK::UI::BackgroundStyle13);
868  leftTopLayout->addWidget(leftTopFrame);
869 
870  QLabel *leftTopLabel = new QLabel(tr("New Songs"), leftTopWidget);
871  leftTopLabel->setStyleSheet(TTK::UI::FontStyle04);
872  leftTopLayout->addWidget(leftTopLabel);
873  leftTopLayout->addStretch(1);
874 
875  QWidget *leftMiddle = new QWidget(leftWidget);
876  leftMiddle->setFixedHeight(1);
877  leftMiddle->setStyleSheet(TTK::UI::BackgroundStyle03);
878  leftLayout->addWidget(leftMiddle);
879 
881  leftLayout->addWidget(m_newSongsWidget);
884 
885  QWidget *rightWidget = new QWidget(widget);
886  layout->addWidget(rightWidget, 1);
887 
888  QVBoxLayout *rightLayout = new QVBoxLayout(rightWidget);
889  rightLayout->setContentsMargins(0, 0, 0, 0);
890  rightWidget->setLayout(rightLayout);
891 
892  QWidget *rightTopWidget = new QWidget(rightWidget);
893  rightTopWidget->setFixedHeight(30);
894  rightLayout->addWidget(rightTopWidget);
895 
896  QHBoxLayout *rightTopLayout = new QHBoxLayout(rightTopWidget);
897  rightTopLayout->setContentsMargins(0, 0, 0, 0);
898  rightTopWidget->setLayout(rightTopLayout);
899 
900  QWidget *rightTopFrame = new QWidget(rightTopWidget);
901  rightTopFrame->setFixedWidth(3);
902  rightTopFrame->setStyleSheet(TTK::UI::BackgroundStyle13);
903  rightTopLayout->addWidget(rightTopFrame);
904 
905  TTKClickedLabel *rightTopLabel = new TTKClickedLabel(tr("New Albums"), rightTopWidget);
906  rightTopLabel->setStyleSheet(TTK::UI::FontStyle04);
907  rightTopLayout->addWidget(rightTopLabel);
908  rightTopLayout->addStretch(1);
910 
912  rightLayout->addWidget(m_newAlbumsWidget);
913 
916  req->setPageSize(8);
917  req->startToSearch("ALL");
918 }
919 
921 {
922  QWidget *widget = new QWidget(m_homeWidget);
923  widget->setFixedHeight(260);
924  m_homeContainer->layout()->addWidget(widget);
925 
926  QVBoxLayout *layout = new QVBoxLayout(widget);
927  layout->setContentsMargins(0, 0, 0, 0);
928  widget->setLayout(layout);
929 
930  QWidget *topWidget = new QWidget(widget);
931  topWidget->setFixedHeight(30);
932  layout->addWidget(topWidget);
933 
934  QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
935  topLayout->setContentsMargins(0, 0, 0, 0);
936  topWidget->setLayout(topLayout);
937 
938  QWidget *topFrame = new QWidget(topWidget);
939  topFrame->setFixedSize(3, 30);
940  topFrame->setStyleSheet(TTK::UI::BackgroundStyle13);
941  topLayout->addWidget(topFrame, 0, Qt::AlignVCenter);
942 
943  TTKClickedLabel *topLabel = new TTKClickedLabel(tr("Popular Artists"), topWidget);
944  topLabel->setStyleSheet(TTK::UI::FontStyle04);
945  topLayout->addWidget(topLabel);
946  topLayout->addStretch(1);
948 
950  layout->addWidget(m_artistsWidget);
951 
952  MusicAbstractQueryRequest *req = G_DOWNLOAD_QUERY_PTR->makeHotArtistListRequest(m_artistsWidget);
954  req->setPageSize(8);
955  req->startToSearch({});
956 }
957 
959 {
960  QWidget *widget = new QWidget(m_homeWidget);
961  widget->setFixedHeight(260);
962  m_homeContainer->layout()->addWidget(widget);
963 
964  QVBoxLayout *layout = new QVBoxLayout(widget);
965  layout->setContentsMargins(0, 0, 0, 0);
966  widget->setLayout(layout);
967 
968  QWidget *topWidget = new QWidget(widget);
969  topWidget->setFixedHeight(30);
970  layout->addWidget(topWidget);
971 
972  QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
973  topLayout->setContentsMargins(0, 0, 0, 0);
974  topWidget->setLayout(topLayout);
975 
976  QWidget *topFrame = new QWidget(topWidget);
977  topFrame->setFixedSize(3, 30);
978  topFrame->setStyleSheet(TTK::UI::BackgroundStyle13);
979  topLayout->addWidget(topFrame, 0, Qt::AlignVCenter);
980 
981  TTKClickedLabel *topLabel = new TTKClickedLabel(tr("Premium Playlist"), topWidget);
982  topLabel->setStyleSheet(TTK::UI::FontStyle04);
983  topLayout->addWidget(topLabel);
984  topLayout->addStretch(1);
986 
988  layout->addWidget(m_hqPlaylistWidget);
989 
990  MusicAbstractQueryRequest *req = G_DOWNLOAD_QUERY_PTR->makePlaylistHighRequest(m_hqPlaylistWidget);
992  req->setPageSize(8);
993  req->startToSearch("0");
994 }
995 
997 {
998  QWidget *widget = new QWidget(m_homeWidget);
999  widget->setFixedHeight(260);
1000  m_homeContainer->layout()->addWidget(widget);
1001 
1002  QVBoxLayout *layout = new QVBoxLayout(widget);
1003  layout->setContentsMargins(0, 0, 0, 0);
1004  widget->setLayout(layout);
1005 
1006  QWidget *topWidget = new QWidget(widget);
1007  topWidget->setFixedHeight(30);
1008  layout->addWidget(topWidget);
1009 
1010  QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
1011  topLayout->setContentsMargins(0, 0, 0, 0);
1012  topWidget->setLayout(topLayout);
1013 
1014  QWidget *topFrame = new QWidget(topWidget);
1015  topFrame->setFixedSize(3, 30);
1016  topFrame->setStyleSheet(TTK::UI::BackgroundStyle13);
1017  topLayout->addWidget(topFrame, 0, Qt::AlignVCenter);
1018 
1019  TTKClickedLabel *topLabel = new TTKClickedLabel(tr("Recommended Playlist"), topWidget);
1020  topLabel->setStyleSheet(TTK::UI::FontStyle04);
1021  topLayout->addWidget(topLabel);
1022  topLayout->addStretch(1);
1024 
1026  layout->addWidget(m_playlistWidget);
1027 
1028  MusicAbstractQueryRequest *req = G_DOWNLOAD_QUERY_PTR->makePlaylistRecommendRequest(m_playlistWidget);
1030  req->setPageSize(8);
1031  req->startToSearch({});
1032 }
static MusicRightAreaWidget * instance()
const TTK::MusicSongInformationList & items() const noexcept
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:231
void setQueryInput(MusicAbstractQueryRequest *query)
MusicNewSongRecommendQueryTableWidget * m_newSongsWidget
The class of the search result data item.
The class of the download widget.
void setValueLabel(bool v) noexcept
MusicItemMoreRecommendQueryWidget * m_itemMoreWidget
static const QString FontStyle03
The class of the music song property.
Definition: musicobject.h:242
int pageTotalSize() const noexcept
static const QString PushButtonStyle01
PushButton.
virtual void itemCellEntered(int row, int column) overridefinal
static const QString ColorStyle04
Definition: musicuiobject.h:46
virtual void downloadQueryResult(int row) overridefinal
MusicSongPropertyList m_songProps
Definition: musicobject.h:314
static constexpr int LINE_SPACING_SIZE
#define QtItemSetTextAlignment(p, a)
Item text alignment.
Definition: ttkqtcompat.h:45
static constexpr unsigned int Color02
Definition: musicuiobject.h:34
void createResultItem(const MusicResultDataItem &item)
The class of the label widget that can click.
MusicNewSongRecommendQueryTableWidget(QWidget *parent=nullptr)
static const QString FontStyle01
Font.
The class of the new song recommend query item table widget.
#define TTK_RN_MAX
Definition: ttkglobal.h:439
MusicAbstractQueryRequest * m_networkRequest
MusicItemRecommendQueryWidget * m_hqPlaylistWidget
static void popup(const QString &text)
virtual void resizeGeometry() overridefinal
void addWidget(QWidget *widget, int id=-1)
void initialize(const QString &name)
virtual void startToQueryResult(TTK::MusicSongInformation *info, int bitrate)
MusicItemRecommendQueryWidget * m_artistsWidget
The class of the item recommend query widget.
void setQueryInput(MusicAbstractQueryRequest *query)
#define MUSIC_PLAY_NOW
#define qAsConst
Definition: ttkqtglobal.h:57
static const QString FontStyle06
void setShowTime(bool v) noexcept
TTKLabelItemDelegate * m_labelDelegate
void setPageSize(int page) noexcept
bool isValid() const noexcept
The class of the cover source data download request.
MusicMainRecommendWidget(QWidget *parent=nullptr)
void showArtistFound(const QString &text, const QString &id)
void currentItemClicked(const MusicResultDataItem &item)
static constexpr wchar_t key[]
static const QString BackgroundStyle01
Background.
Definition: musicuiobject.h:77
virtual void itemDoubleClicked(int row, int column) override
MusicItemMoreRecommendQueryWidget(RecommendModule module, QWidget *parent=nullptr)
The class of the page query widget.
static MusicSongsContainerWidget * instance()
virtual void startToPage(int offset)
virtual void createResultItem(const MusicResultInfoItem &result) override
TTK_MODULE_EXPORT QString elidedText(const QFont &font, const QString &text, Qt::TextElideMode mode, int width)
virtual void itemCellEntered(int row, int column)
void page(int index, int total)
void showAlbumFound(const QString &text, const QString &id)
void addSongBufferToPlaylist(const MusicResultDataItem &item)
TTK_MODULE_EXPORT void generateVScrollAreaStyle(QWidget *widget, QWidget *parent, bool background=true)
static const QString BackgroundStyle13
static const QString PushButtonStyle13
virtual void itemCellClicked(int row, int column) override
static const QString BackgroundStyle10
void showPlaylistFound(const QString &id)
void setResultDataItem(const MusicResultDataItem &item, MusicCoverRequest *cover)
void setShowCount(bool v) noexcept
MusicItemRecommendQueryWidget * m_newAlbumsWidget
static const QString FontStyle04
MusicAbstractQueryRequest * m_networkRequest
virtual void removeItems() override
The class of the search result info item.
#define QUERY_WIDGET_WIDTH
MusicItemRecommendQueryWidget(RecommendModule module, QWidget *parent=nullptr)
QWidget * createPageWidget(QWidget *parent, int total)
#define MUSIC_PLAY_LATER
#define G_NETWORK_PTR
static const QString LabelStyle03
void currentItemClicked(const MusicResultDataItem &item)
int pageSize() const noexcept
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:172
The class of the query table widget.
virtual void startToSearchByValue(const QString &value) overridefinal
void createResultItem(const MusicResultDataItem &item)
#define G_DOWNLOAD_QUERY_PTR
static const QString BackgroundStyle03
Definition: musicuiobject.h:88
virtual void itemCellClicked(int row, int column) override
virtual void startToSearch(const QString &value)=0
The class of the abstract query data from net.
bool downloadDataFrom(TTK::MusicSongInformation *info, bool play)
MusicItemRecommendQueryWidget * m_playlistWidget
The class of the item more recommend query widget.
TTK_MODULE_EXPORT QString generateSongName(const QString &title, const QString &artist) noexcept
MusicAbstractQueryRequest * m_networkRequest
The class of the music song information.
Definition: musicobject.h:300
The class of the label widget click group mapper.
#define TTK_BN_128
Definition: ttkglobal.h:428
#define G_SETTING_PTR
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:82
QString queryServer() const noexcept
The class of the square query item widget.