TTKMusicPlayer  3.7.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.
5 #include "musiccoverrequest.h"
6 #include "musicratinglabel.h"
7 
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  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - WINDOW_WIDTH_MIN;
34 
35  TTKResizeWidget *data = &m_resizeWidgets[0];
36  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 200 + width));
37 
38  data = &m_resizeWidgets[1];
39  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 180 + width));
40 
41  data = &m_resizeWidgets[2];
42  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 210 + width));
43 
44  data = &m_resizeWidgets[3];
45  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, 160 + width));
46  }
47 }
48 
50 {
51  delete m_statusLabel;
52  m_statusLabel = nullptr;
53 
54  m_currentPlaylistItem = item;
55  setCurrentValue(item.m_id);
56 
57  m_infoLabel->setText(item.m_description);
59 
60  layout()->removeWidget(m_mainWindow);
61  QScrollArea *scrollArea = new QScrollArea(this);
63  layout()->addWidget(scrollArea);
64 
65  QWidget *function = new QWidget(m_mainWindow);
66  function->setStyleSheet(TTK::UI::CheckBoxStyle01);
67  QVBoxLayout *grid = new QVBoxLayout(function);
68 
69  QWidget *firstTopFuncWidget = new QWidget(function);
70  QHBoxLayout *firstTopFuncLayout = new QHBoxLayout(firstTopFuncWidget);
71 
72  QLabel *firstLabel = new QLabel(function);
73  firstLabel->setText(tr("<font color=#158FE1> Playlist > %1 </font>").arg(item.m_name));
74 
75  QPushButton *backButton = new QPushButton(tr("Back"));
76  backButton->setFixedSize(90, 30);
77  backButton->setStyleSheet(TTK::UI::PushButtonStyle03);
78  backButton->setCursor(QCursor(Qt::PointingHandCursor));
79  connect(backButton, SIGNAL(clicked()), obj, SLOT(backToPlaylistMenu()));
80 
81  firstTopFuncLayout->addWidget(firstLabel);
82  firstTopFuncLayout->addWidget(backButton);
83  grid->addWidget(firstTopFuncWidget);
84  //
85  QWidget *topFuncWidget = new QWidget(function);
86  QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);
87 
88  m_iconLabel = new QLabel(topFuncWidget);
89  m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
90  m_iconLabel->setFixedSize(210, 180);
91 
93  {
94  MusicCoverRequest *d = G_DOWNLOAD_QUERY_PTR->makeCoverRequest(this);
95  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
96  d->startToRequest(item.m_coverUrl);
97  }
98 
99  QWidget *topLineWidget = new QWidget(topFuncWidget);
100  QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
101  topLineLayout->setContentsMargins(10, 5, 5, 0);
102 
103  QLabel *playlistLabel = new QLabel(topLineWidget);
104  QFont playlistFont = playlistLabel->font();
105  playlistFont.setPixelSize(20);
106  playlistLabel->setFont(playlistFont);
107  playlistLabel->setStyleSheet(TTK::UI::FontStyle01);
108  playlistLabel->setToolTip(item.m_name);
109 
110  QLabel *creatorLabel = new QLabel(topLineWidget);
111  creatorLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
112  creatorLabel->setToolTip(tr("Creator: %1").arg(item.m_nickName));
113 
114  QLabel *tagsLabel = new QLabel(topLineWidget);
115  tagsLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
116  tagsLabel->setToolTip(tr("Tags: %1").arg(item.m_category));
117 
118  QLabel *updateLabel = new QLabel(topLineWidget);
119  updateLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
120  updateLabel->setToolTip(tr("Update: %1").arg(item.m_updateTime));
121 
122  topLineLayout->addWidget(playlistLabel);
123  topLineLayout->addWidget(creatorLabel);
124  topLineLayout->addWidget(tagsLabel);
125  topLineLayout->addWidget(updateLabel);
126  topLineWidget->setLayout(topLineLayout);
127 
128  QWidget *topButtonWidget = new QWidget(topFuncWidget);
129  topButtonWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
130  QHBoxLayout *topButtonLayout = new QHBoxLayout(topButtonWidget);
131  topButtonLayout->setContentsMargins(0, 0, 0, 0);
132 
133  QPushButton *playAllButton = new QPushButton(tr("Play All"), topButtonWidget);
134  QPushButton *shareButton = new QPushButton(tr("Share"), topButtonWidget);
135 
136  playAllButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
137  playAllButton->setIconSize(QSize(14, 14));
138  playAllButton->setCursor(QCursor(Qt::PointingHandCursor));
139  shareButton->setCursor(QCursor(Qt::PointingHandCursor));
140  playAllButton->setFixedSize(90, 30);
141  shareButton->setFixedSize(55, 30);
142 
143  topButtonLayout->addWidget(playAllButton);
144  topButtonLayout->addWidget(shareButton);
145  topButtonLayout->addStretch(1);
146  topButtonWidget->setLayout(topButtonLayout);
147  topLineLayout->addWidget(topButtonWidget);
148 
149  connect(playAllButton, SIGNAL(clicked()), SLOT(playAllButtonClicked()));
150  connect(shareButton, SIGNAL(clicked()), SLOT(shareButtonClicked()));
151  //
152  QWidget *topRightWidget = new QWidget(topFuncWidget);
153  QGridLayout *topRightLayout = new QGridLayout(topRightWidget);
154  topRightLayout->setContentsMargins(0, 0, 0, 0);
155  topRightLayout->setSpacing(0);
156 
157  QLabel *numberLabel = new QLabel(topRightWidget);
158  numberLabel->setAlignment(Qt::AlignCenter);
159  numberLabel->setStyleSheet(TTK::UI::FontStyle05 + TTK::UI::ColorStyle11);
160 
161  const int number = 7 + TTK::random(3);
162  numberLabel->setText(QString("%1.%2").arg(number).arg(TTK::random(10)));
163  topRightLayout->addWidget(numberLabel, 0, 0);
164  topRightLayout->addWidget(new MusicRatingLabel(ceil(number / 2.0), topRightWidget), 0, 1, 1, 6);
165 
166  QLabel *numberTextLabel = new QLabel(tr("Score:"), topRightWidget);
167  topRightLayout->addWidget(numberTextLabel, 1, 0);
168  topRightLayout->addWidget(new MusicRatingLabel(topRightWidget), 1, 1, 1, 6);
169 
170  QLabel *marginBottmLabel = new QLabel(topRightWidget);
171  marginBottmLabel->setFixedHeight(40);
172  topRightLayout->addWidget(marginBottmLabel, 2, 0);
173  topRightWidget->setLayout(topRightLayout);
174 
175  QRCodeQWidget *code = new QRCodeQWidget({}, QSize(90, 90), topRightWidget);
176  code->setMargin(2);
177  code->setIcon(":/image/lb_app_logo", 0.23);
178  topRightLayout->addWidget(code, 3, 2, 1, 6);
179 
180  topFuncLayout->addWidget(m_iconLabel);
181  topFuncLayout->addWidget(topLineWidget);
182  topFuncLayout->addWidget(topRightWidget);
183  topFuncWidget->setLayout(topFuncLayout);
184  grid->addWidget(topFuncWidget);
185  //
186  QWidget *functionWidget = new QWidget(this);
187  functionWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
188  QHBoxLayout *hLayout = new QHBoxLayout(functionWidget);
189 
190  m_songButton = new QPushButton(functionWidget);
191  m_songButton->setText(tr("SongItems"));
192  m_songButton->setFixedSize(100, 25);
193  m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
194  hLayout->addWidget(m_songButton);
195 
196  QPushButton *infoButton = new QPushButton(functionWidget);
197  infoButton->setText(tr("Info"));
198  infoButton->setFixedSize(100, 25);
199  infoButton->setCursor(QCursor(Qt::PointingHandCursor));
200  hLayout->addWidget(infoButton);
201  functionWidget->setLayout(hLayout);
202 
203  QPushButton *commentsButton = new QPushButton(functionWidget);
204  commentsButton->setText(tr("Comments"));
205  commentsButton->setFixedSize(100, 25);
206  commentsButton->setCursor(QCursor(Qt::PointingHandCursor));
207  hLayout->addWidget(commentsButton);
208  hLayout->addStretch(1);
209  functionWidget->setLayout(hLayout);
210 
211  QButtonGroup *buttonGroup = new QButtonGroup(this);
212  buttonGroup->addButton(m_songButton, 0);
213  buttonGroup->addButton(infoButton, 1);
214  buttonGroup->addButton(commentsButton, 2);
215  QtButtonGroupConnect(buttonGroup, this, setCurrentIndex, TTK_SLOT);
216 
217 #ifdef Q_OS_UNIX
218  backButton->setFocusPolicy(Qt::NoFocus);
219  playAllButton->setFocusPolicy(Qt::NoFocus);
220  shareButton->setFocusPolicy(Qt::NoFocus);
221  m_songButton->setFocusPolicy(Qt::NoFocus);
222  infoButton->setFocusPolicy(Qt::NoFocus);
223  commentsButton->setFocusPolicy(Qt::NoFocus);
224 #endif
225  grid->addWidget(functionWidget);
226  grid->addWidget(m_container);
227  grid->addStretch(1);
228 
229  function->setLayout(grid);
230  m_mainWindow->layout()->addWidget(function);
231 
232  m_resizeWidgets.push_back({playlistLabel, playlistLabel->font()});
233  m_resizeWidgets.push_back({creatorLabel, creatorLabel->font()});
234  m_resizeWidgets.push_back({tagsLabel, tagsLabel->font()});
235  m_resizeWidgets.push_back({updateLabel, updateLabel->font()});
236 
237  resizeWidget();
238 }
239 
241 {
244 }
245 
247 {
249  {
250  m_queryTableWidget->hide();
251  }
252 
253  if(m_infoLabel)
254  {
255  m_infoLabel->hide();
256  }
257 
258  delete m_commentsWidget;
259  m_commentsWidget = nullptr;
260 
261  if(index == 0 && m_queryTableWidget)
262  {
263  m_queryTableWidget->show();
264  }
265  else if(index == 1 && m_infoLabel)
266  {
267  m_infoLabel->show();
268  }
269  else if(index == 2)
270  {
273  m_container->addWidget(m_commentsWidget);
275  }
276 
277  m_container->setCurrentIndex(index);
278 }
279 
281 {
283 }
virtual void setQueryInput(MusicAbstractQueryRequest *query)
The class of the search result data item.
static const QString FontStyle03
MusicItemQueryTableWidget * m_queryTableWidget
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
TTK_MODULE_EXPORT int random(int value=RAND_MAX)
Definition: ttktime.cpp:14
static const QString FontStyle05
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:165
#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
TTK_MODULE_EXPORT void generateVScrollAreaFormat(QWidget *widget, QWidget *parent, bool background=true)
void setResultDataItem(const MusicResultDataItem &item, QObject *obj)
virtual void startToSearchByText(const QString &text) overridefinal
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:153
static const QString ColorStyle11
Definition: musicuiobject.h:67
#define G_DOWNLOAD_QUERY_PTR
The class of the cover data download request.
The class of the abstract query download data from net.
void setQueryInput(MusicAbstractQueryRequest *query)
MusicSongSharingWidget::Module m_shareType
virtual void resizeWidget() overridefinal
MusicPlaylistQueryInfoWidget(QWidget *parent=nullptr)
The class of the playlist music query table widget.
#define G_SETTING_PTR
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:60