TTKMusicPlayer  3.7.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_queryTableWidget(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_mainWindow = new QWidget(this);
19  m_mainWindow->setObjectName("MainWindow");
20  m_mainWindow->setStyleSheet(QString("#MainWindow{%1}").arg(TTK::UI::BackgroundStyle10));
21 
22  m_statusLabel = new QLabel(tr("Loading now ... "), m_mainWindow);
24 
25  QVBoxLayout *mLayout = new QVBoxLayout(m_mainWindow);
26  mLayout->addWidget(m_statusLabel, 0, Qt::AlignCenter);
27  m_mainWindow->setLayout(mLayout);
28 
29  m_container = new QStackedWidget(this);
30  m_container->hide();
31 
32  layout->addWidget(m_mainWindow);
33  setLayout(layout);
34 }
35 
37 {
38  while(!m_resizeWidgets.isEmpty())
39  {
40  delete m_resizeWidgets.takeLast().m_label;
41  }
42  delete m_iconLabel;
43  delete m_statusLabel;
44  delete m_infoLabel;
45  delete m_songButton;
46  delete m_queryTableWidget;
47  delete m_mainWindow;
48  delete m_networkRequest;
49 }
50 
52 {
53  m_value = value;
54 }
55 
57 {
58  Q_UNUSED(id);
59 }
60 
62 {
63  if(m_iconLabel)
64  {
65  QPixmap pix;
66  if(bytes.isEmpty())
67  {
68  TTK_ERROR_STREAM("Input byte data is empty");
69  pix = QPixmap(1, 1);
70  pix.fill(Qt::transparent);
71  }
72  else
73  {
74  pix.loadFromData(bytes);
75  }
76 
77  QPixmap cv(":/image/lb_playlist_cover");
78  pix = pix.scaled(QSize(180, 180));
79  TTK::Image::fusionPixmap(cv, pix, QPoint(0, 0));
80  m_iconLabel->setPixmap(cv);
81  }
82 }
83 
85 {
88 }
89 
91 {
96 
98  if(d)
99  {
100  item.m_server = d->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  QWidget *songWidget = new QWidget(this);
141  QVBoxLayout *vLayout = new QVBoxLayout(songWidget);
142  vLayout->setSpacing(0);
143  vLayout->setContentsMargins(0, 0, 0, 0);
144 
145  QWidget *middleFuncWidget = new QWidget(songWidget);
146  middleFuncWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
147  QHBoxLayout *middleFuncLayout = new QHBoxLayout(middleFuncWidget);
148  middleFuncLayout->setContentsMargins(0, 5, 0, 5);
149  QLabel *marginLabel = new QLabel(middleFuncWidget);
150  marginLabel->setFixedWidth(1);
151  QCheckBox *allCheckBox = new QCheckBox(" " + tr("All"), middleFuncWidget);
152  QPushButton *playButton = new QPushButton(tr("Play"), middleFuncWidget);
153  playButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
154  playButton->setIconSize(QSize(14, 14));
155  playButton->setFixedSize(55, 25);
156  playButton->setCursor(QCursor(Qt::PointingHandCursor));
157  QPushButton *addButton = new QPushButton(tr("Add"), middleFuncWidget);
158  addButton->setFixedSize(55, 25);
159  addButton->setCursor(QCursor(Qt::PointingHandCursor));
160  QPushButton *downloadButton = new QPushButton(tr("Download"), middleFuncWidget);
161  downloadButton->setFixedSize(55, 25);
162  downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
163 
164 #ifdef Q_OS_UNIX
165  allCheckBox->setFocusPolicy(Qt::NoFocus);
166  playButton->setFocusPolicy(Qt::NoFocus);
167  addButton->setFocusPolicy(Qt::NoFocus);
168  downloadButton->setFocusPolicy(Qt::NoFocus);
169 #endif
170 
171  middleFuncLayout->addWidget(marginLabel);
172  middleFuncLayout->addWidget(allCheckBox);
173  middleFuncLayout->addStretch(1);
174  middleFuncLayout->addWidget(playButton);
175  middleFuncLayout->addWidget(addButton);
176  middleFuncLayout->addWidget(downloadButton);
177 
178  connect(allCheckBox, SIGNAL(clicked(bool)), m_queryTableWidget, SLOT(checkedItemsState(bool)));
179  connect(playButton, SIGNAL(clicked()), SLOT(playButtonClicked()));
180  connect(downloadButton, SIGNAL(clicked()), SLOT(downloadButtonClicked()));
181  connect(addButton, SIGNAL(clicked()), SLOT(addButtonClicked()));
182 
183  vLayout->addWidget(middleFuncWidget);
184  vLayout->addWidget(m_queryTableWidget);
185  vLayout->addStretch(1);
186  songWidget->setLayout(vLayout);
187 
188  m_queryTableWidget->show();
189  m_container->addWidget(songWidget);
190 }
191 
193 {
194  QWidget *songWidget = new QWidget(m_container);
195  QVBoxLayout *vLayout = new QVBoxLayout(songWidget);
196  vLayout->setSpacing(0);
197  vLayout->setContentsMargins(0, 0, 0, 0);
198  m_infoLabel = new QLabel(this);
199  m_infoLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
200  m_infoLabel->setWordWrap(true);
202  vLayout->addWidget(m_infoLabel);
203  songWidget->setLayout(vLayout);
204  m_container->addWidget(songWidget);
205 }
206 
208 {
210  if(!d)
211  {
212  return;
213  }
214 
215  const TTK::MusicSongInformationList songInfos(d->items());
216  if(m_songButton)
217  {
218  m_songButton->setText(tr("SongItems") + QString("(%1)").arg(songInfos.count()));
219  }
220 }
static const QString FontStyle03
The class of the song share widget.
MusicItemQueryTableWidget * m_queryTableWidget
void initialize(Module type, const MusicSongSharingWidget::Item &data)
virtual void setCurrentValue(const QString &value)
static const QString FontStyle01
Font.
MusicAbstractQueryRequest * queryInput() const
static const QString PushButtonStyle03
virtual void mouseMoveEvent(QMouseEvent *event) overridefinal
virtual void mousePressEvent(QMouseEvent *event) overridefinal
static const QString BackgroundStyle10
void downLoadFinished(const QByteArray &bytes)
static const QString FontStyle04
static const QString ColorStyle03
Definition: musicuiobject.h:43
virtual void mouseReleaseEvent(QMouseEvent *event) overridefinal
MusicAbstractQueryRequest * m_networkRequest
virtual void setCurrentID(const QString &id)
The class of the abstract query download data from net.
const TTK::MusicSongInformationList & items() const
MusicAbstractItemQueryWidget(QWidget *parent=nullptr)
MusicSongSharingWidget::Module m_shareType
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:69
TTK_MODULE_EXPORT void fusionPixmap(QImage &back, const QImage &front, const QPoint &pt)