TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musictoplistquerywidget.cpp
Go to the documentation of this file.
3 #include "musiccoverrequest.h"
5 
8  m_categoryButton(nullptr)
9 {
11  m_tableWidget->hide();
12 
13  MusicAbstractQueryRequest *req = G_DOWNLOAD_QUERY_PTR->makeToplistRequest(this);
15 
16  connect(req, SIGNAL(downloadDataChanged(QString)), SLOT(queryAllFinished()));
18 }
19 
21 {
22  delete m_categoryButton;
23 }
24 
25 void MusicToplistQueryWidget::setCurrentValue(const QString &value)
26 {
29  createLabels();
30 }
31 
33 {
35 
36  if(m_resizeWidgets.isEmpty())
37  {
38  return;
39  }
40 
41  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - WINDOW_WIDTH_MIN + 410;
42 
43  Data *data = &m_resizeWidgets[0];
44  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width - 20));
45 
46  data = &m_resizeWidgets[1];
47  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
48 
49  data = &m_resizeWidgets[2];
50  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
51 
52  data = &m_resizeWidgets[3];
53  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width + 410 * 10));
54 }
55 
57 {
59 }
60 
62 {
63  delete m_statusLabel;
64  m_statusLabel = nullptr;
65 
67  m_container->show();
68 
69  layout()->removeWidget(m_mainWidget);
70  QScrollArea *scrollArea = new QScrollArea(this);
72  layout()->addWidget(scrollArea);
73 
74  QWidget *function = new QWidget(m_mainWidget);
75  function->setStyleSheet(TTK::UI::CheckBoxStyle01 + TTK::UI::PushButtonStyle03);
76  QVBoxLayout *grid = new QVBoxLayout(function);
77 
78  QLabel *firstLabel = new QLabel(function);
79  firstLabel->setText(tr("<font color=#158FE1> Rank </font>"));
80  grid->addWidget(firstLabel);
81  //
82  QWidget *categoryWidget = new QWidget(function);
83  QHBoxLayout *categoryWidgetLayout = new QHBoxLayout(categoryWidget);
84 
87 
88  categoryWidgetLayout->addWidget(m_categoryButton);
89  categoryWidgetLayout->addStretch(1);
90  categoryWidget->setLayout(categoryWidgetLayout);
91  grid->addWidget(categoryWidget);
92  //
93  QWidget *topFuncWidget = new QWidget(function);
94  QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);
95 
96  m_iconLabel = new QLabel(topFuncWidget);
97  m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
98  m_iconLabel->setFixedSize(210, 180);
99  //
100  QWidget *topLineWidget = new QWidget(topFuncWidget);
101  QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
102  topLineLayout->setContentsMargins(10, 5, 5, 0);
103 
104  QLabel *nameLabel = new QLabel(topLineWidget);
105  QFont toplistFont = nameLabel->font();
106  toplistFont.setPixelSize(20);
107  nameLabel->setFont(toplistFont);
108  nameLabel->setStyleSheet(TTK::UI::FontStyle01);
109 
110  QLabel *playCountLabel = new QLabel(topLineWidget);
111  playCountLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
112  QLabel *updateTimeLabel = new QLabel(topLineWidget);
113  updateTimeLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
114  QLabel *descriptionLabel = new QLabel(topLineWidget);
115  descriptionLabel->setStyleSheet(TTK::UI::ColorStyle04 + TTK::UI::FontStyle03);
116  descriptionLabel->setWordWrap(true);
117 
118  topLineLayout->addWidget(nameLabel);
119  topLineLayout->addWidget(playCountLabel);
120  topLineLayout->addWidget(updateTimeLabel);
121  topLineLayout->addWidget(descriptionLabel);
122  topLineWidget->setLayout(topLineLayout);
123 
124  topFuncLayout->addWidget(m_iconLabel);
125  topFuncLayout->addWidget(topLineWidget);
126  topFuncWidget->setLayout(topFuncLayout);
127  grid->addWidget(topFuncWidget);
128 
129  QWidget *functionWidget = new QWidget(this);
130  functionWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
131  QHBoxLayout *hLayout = new QHBoxLayout(functionWidget);
132 
133  m_songButton = new QPushButton(functionWidget);
134  m_songButton->setText(tr("SongItems"));
135  m_songButton->setFixedSize(100, 25);
136  m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
137 #ifdef Q_OS_UNIX
138  m_songButton->setFocusPolicy(Qt::NoFocus);
139 #endif
140 
141  hLayout->addWidget(m_songButton);
142  hLayout->addStretch(1);
143  functionWidget->setLayout(hLayout);
144 
145  QButtonGroup *buttonGroup = new QButtonGroup(this);
146  buttonGroup->addButton(m_songButton, 0);
147  QtButtonGroupConnect(buttonGroup, m_container, setCurrentIndex, TTK_SLOT);
148 
149  grid->addWidget(functionWidget);
150  grid->addWidget(m_container);
151  grid->addStretch(1);
152 
153  function->setLayout(grid);
154  m_mainWidget->layout()->addWidget(function);
155 
156  m_resizeWidgets.append({nameLabel, nameLabel->font()});
157  m_resizeWidgets.append({playCountLabel, playCountLabel->font()});
158  m_resizeWidgets.append({updateTimeLabel, updateTimeLabel->font()});
159  m_resizeWidgets.append({descriptionLabel, descriptionLabel->font()});
160 }
161 
163 {
164  if(TTK::isCoverValid(item.m_coverUrl))
165  {
166  MusicCoverRequest *req = G_DOWNLOAD_QUERY_PTR->makeCoverRequest(this);
167  connect(req, SIGNAL(downloadRawDataChanged(QByteArray)), SLOT(downloadFinished(QByteArray)));
168  req->startToRequest(item.m_coverUrl);
169  }
170 
171  if(m_resizeWidgets.isEmpty())
172  {
173  return;
174  }
175 
176  const int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width() - WINDOW_WIDTH_MIN + 410;
177 
178  Data *data = &m_resizeWidgets[0];
179  data->m_label->setToolTip(item.m_name);
180  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width - 20));
181 
182  data = &m_resizeWidgets[1];
183  data->m_label->setToolTip(tr("PlayCount: %1").arg(item.m_count));
184  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
185 
186  data = &m_resizeWidgets[2];
187  data->m_label->setToolTip(tr("UpdateTime: %1").arg(item.m_time));
188  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width));
189 
190  data = &m_resizeWidgets[3];
191  data->m_label->setToolTip(tr("Description: %1").arg(item.m_description));
192  data->m_label->setText(TTK::Widget::elidedText(data->m_font, data->m_label->toolTip(), Qt::ElideRight, width + 410 * 10));
193 }
194 
196 {
197  if(m_categoryButton)
198  {
199  m_categoryButton->setToolTip(category.m_value);
200  m_categoryButton->setText(TTK::Widget::elidedText(m_categoryButton->font(), category.m_value, Qt::ElideRight, m_categoryButton->width() - 20));
202 
203  m_songButton->setText(tr("SongItems"));
205  }
206 }
void setQueryInput(MusicAbstractQueryRequest *query)
void categoryChanged(const MusicResultsCategoryItem &category)
The class of the search result data item.
MusicToplistQueryCategoryPopWidget * m_categoryButton
static const QString FontStyle03
static bool isCoverValid(const QString &url) noexcept
The class of the toplist music query category pop widget.
virtual void startToRequest(const QString &url)=0
static const QString CheckBoxStyle01
CheckBox.
static const QString ColorStyle04
Definition: musicuiobject.h:46
virtual void setCurrentValue(const QString &value)
static const QString FontStyle01
Font.
The class of the query item table widget.
void downloadFinished(const QByteArray &bytes)
MusicToplistQueryWidget(QWidget *parent=nullptr)
MusicAbstractQueryRequest * queryInput() const
static const QString PushButtonStyle03
virtual void resizeGeometry() overridefinal
TTK_MODULE_EXPORT QString elidedText(const QFont &font, const QString &text, Qt::TextElideMode mode, int width)
#define TTK_SLOT
Definition: ttkqtglobal.h:177
TTK_MODULE_EXPORT void generateVScrollAreaStyle(QWidget *widget, QWidget *parent, bool background=true)
#define QtButtonGroupConnect(p, q, f, s)
Button group connect.
Definition: ttkqtcompat.h:115
The class of the item query widget base.
void setCategory(const QString &server, QObject *obj)
The class of the results category item.
void createToplistItem(const MusicResultDataItem &item)
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:172
virtual void setCurrentValue(const QString &value) overridefinal
#define G_DOWNLOAD_QUERY_PTR
MusicItemQueryTableWidget * m_tableWidget
The class of the cover data download request.
virtual void startToSearch(const QString &value)=0
The class of the abstract query data from net.
virtual void resizeGeometry() overridefinal
#define G_SETTING_PTR
QString queryServer() const noexcept