TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicabstractitemquerywidget.cpp
Go to the documentation of this file.
2 #include "musicimageutils.h"
3 
5  : QWidget(parent),
6  m_songButton(nullptr),
7  m_iconLabel(nullptr),
8  m_statusLabel(nullptr),
9  m_infoLabel(nullptr),
10  m_tableWidget(nullptr),
11  m_networkRequest(nullptr),
12  m_shareType(MusicSongSharingWidget::Module::Null)
13 {
14  QHBoxLayout *layout = new QHBoxLayout(this);
15  layout->setSpacing(0);
16  layout->setContentsMargins(0, 0, 0, 0);
17 
18  m_mainWidget= new QWidget(this);
19  m_mainWidget->setObjectName("MainWidget");
20  m_mainWidget->setStyleSheet(QString("#%1{ %2 }").arg(m_mainWidget->objectName(), TTK::UI::BackgroundStyle10));
21 
22  m_statusLabel = new QLabel(tr("Loading now ... "), m_mainWidget);
24 
25  QVBoxLayout *mLayout = new QVBoxLayout(m_mainWidget);
26  mLayout->addWidget(m_statusLabel, 0, Qt::AlignCenter);
27  m_mainWidget->setLayout(mLayout);
28 
29  m_container = new QStackedWidget(this);
30  m_container->hide();
31 
32  layout->addWidget(m_mainWidget);
33  setLayout(layout);
34 }
35 
37 {
38  removeItems(nullptr);
39  delete m_iconLabel;
40  delete m_statusLabel;
41  delete m_infoLabel;
42  delete m_songButton;
43  delete m_tableWidget;
44  delete m_mainWidget;
45  delete m_networkRequest;
46 }
47 
49 {
50  m_value = value;
51 }
52 
54 {
55  Q_UNUSED(id);
56 }
57 
59 {
60  if(m_iconLabel)
61  {
62  QPixmap pix;
63  if(bytes.isEmpty())
64  {
65  TTK_ERROR_STREAM("Input byte data is empty");
66  pix = QPixmap(1, 1);
67  pix.fill(Qt::transparent);
68  }
69  else
70  {
71  pix.loadFromData(bytes);
72  }
73 
74  if(!pix.isNull())
75  {
76  QPixmap cv(":/image/lb_playlist_cover");
77  pix = pix.scaled(QSize(180, 180));
78  TTK::Image::fusionPixmap(cv, pix, QPoint(0, 0));
79  m_iconLabel->setPixmap(cv);
80  }
81  }
82 }
83 
85 {
88 }
89 
91 {
96 
98  if(req)
99  {
100  item.m_server = req->queryServer();
101  }
102 
103  MusicSongSharingWidget widget(this);
104  widget.initialize(m_shareType, item);
105  widget.exec();
106 }
107 
109 {
111 }
112 
114 {
116 }
117 
119 {
121 }
122 
124 {
125  Q_UNUSED(event);
126 }
127 
129 {
130  Q_UNUSED(event);
131 }
132 
134 {
135  Q_UNUSED(event);
136 }
137 
139 {
140  while(!m_resizeWidgets.isEmpty())
141  {
142  QWidget *w = m_resizeWidgets.takeLast().m_label;
143  if(layout)
144  {
145  layout->removeWidget(w);
146  }
147  delete w;
148  }
149 }
150 
152 {
153  QWidget *songWidget = new QWidget(this);
154  QVBoxLayout *vLayout = new QVBoxLayout(songWidget);
155  vLayout->setSpacing(0);
156  vLayout->setContentsMargins(0, 0, 0, 0);
157 
158  QWidget *middleFuncWidget = new QWidget(songWidget);
159  middleFuncWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
160  QHBoxLayout *middleFuncLayout = new QHBoxLayout(middleFuncWidget);
161  middleFuncLayout->setContentsMargins(0, 5, 0, 5);
162  QLabel *marginLabel = new QLabel(middleFuncWidget);
163  marginLabel->setFixedWidth(1);
164  QCheckBox *allCheckBox = new QCheckBox(TTK_SPACE + tr("All"), middleFuncWidget);
165  QPushButton *playButton = new QPushButton(tr("Play"), middleFuncWidget);
166  playButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
167  playButton->setIconSize(QSize(14, 14));
168  playButton->setFixedSize(55, 25);
169  playButton->setCursor(QCursor(Qt::PointingHandCursor));
170  QPushButton *addButton = new QPushButton(tr("Add"), middleFuncWidget);
171  addButton->setFixedSize(55, 25);
172  addButton->setCursor(QCursor(Qt::PointingHandCursor));
173  QPushButton *downloadButton = new QPushButton(tr("Download"), middleFuncWidget);
174  downloadButton->setFixedSize(55, 25);
175  downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
176 
177 #ifdef Q_OS_UNIX
178  allCheckBox->setFocusPolicy(Qt::NoFocus);
179  playButton->setFocusPolicy(Qt::NoFocus);
180  addButton->setFocusPolicy(Qt::NoFocus);
181  downloadButton->setFocusPolicy(Qt::NoFocus);
182 #endif
183 
184  middleFuncLayout->addWidget(marginLabel);
185  middleFuncLayout->addWidget(allCheckBox);
186  middleFuncLayout->addStretch(1);
187  middleFuncLayout->addWidget(playButton);
188  middleFuncLayout->addWidget(addButton);
189  middleFuncLayout->addWidget(downloadButton);
190 
191  connect(allCheckBox, SIGNAL(clicked(bool)), m_tableWidget, SLOT(checkedItemsState(bool)));
192  connect(playButton, SIGNAL(clicked()), SLOT(playButtonClicked()));
193  connect(downloadButton, SIGNAL(clicked()), SLOT(downloadButtonClicked()));
194  connect(addButton, SIGNAL(clicked()), SLOT(addButtonClicked()));
195 
196  vLayout->addWidget(middleFuncWidget);
197  vLayout->addWidget(m_tableWidget);
198  vLayout->addStretch(1);
199  songWidget->setLayout(vLayout);
200 
201  m_tableWidget->show();
202  m_container->addWidget(songWidget);
203 }
204 
206 {
207  QWidget *songWidget = new QWidget(m_container);
208  QVBoxLayout *vLayout = new QVBoxLayout(songWidget);
209  vLayout->setSpacing(0);
210  vLayout->setContentsMargins(0, 0, 0, 0);
211 
212  m_infoLabel = new QLabel(this);
213  m_infoLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
214  m_infoLabel->setWordWrap(true);
216  vLayout->addWidget(m_infoLabel);
217 
218  songWidget->setLayout(vLayout);
219  m_container->addWidget(songWidget);
220 }
221 
223 {
225  if(!req)
226  {
227  return;
228  }
229 
230  if(m_songButton)
231  {
232  m_songButton->setText(tr("SongItems") + QString("(%1)").arg(req->items().count()));
233  }
234 }
const TTK::MusicSongInformationList & items() const noexcept
static const QString FontStyle03
The class of the song share widget.
virtual void setCurrentValue(const QString &value)
static const QString FontStyle01
Font.
void downloadFinished(const QByteArray &bytes)
virtual void setCurrentKey(const QString &id)
MusicAbstractQueryRequest * queryInput() const
static const QString FontStyle05
static const QString PushButtonStyle03
virtual void mouseMoveEvent(QMouseEvent *event) overridefinal
virtual void mousePressEvent(QMouseEvent *event) overridefinal
static const QString BackgroundStyle10
static const QString ColorStyle03
Definition: musicuiobject.h:43
void initialize(Module type, const MusicSongSharingWidget::Data &data)
virtual void mouseReleaseEvent(QMouseEvent *event) overridefinal
MusicAbstractQueryRequest * m_networkRequest
MusicItemQueryTableWidget * m_tableWidget
The class of the abstract query data from net.
MusicAbstractItemQueryWidget(QWidget *parent=nullptr)
MusicSongSharingWidget::Module m_shareType
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:76
#define TTK_SPACE
Definition: ttkglobal.h:268
TTK_MODULE_EXPORT void fusionPixmap(QImage &back, const QImage &front, const QPoint &pt)
QString queryServer() const noexcept