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