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