TTKMusicPlayer  4.2.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("#%1{ %2 }").arg(m_mainWindow->objectName(), 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  if(!pix.isNull())
78  {
79  QPixmap cv(":/image/lb_playlist_cover");
80  pix = pix.scaled(QSize(180, 180));
81  TTK::Image::fusionPixmap(cv, pix, QPoint(0, 0));
82  m_iconLabel->setPixmap(cv);
83  }
84  }
85 }
86 
88 {
91 }
92 
94 {
99 
101  if(d)
102  {
103  item.m_server = d->queryServer();
104  }
105 
106  MusicSongSharingWidget widget(this);
107  widget.initialize(m_shareType, item);
108  widget.exec();
109 }
110 
112 {
114 }
115 
117 {
119 }
120 
122 {
124 }
125 
127 {
128  Q_UNUSED(event);
129 }
130 
132 {
133  Q_UNUSED(event);
134 }
135 
137 {
138  Q_UNUSED(event);
139 }
140 
142 {
143  QWidget *songWidget = new QWidget(this);
144  QVBoxLayout *vLayout = new QVBoxLayout(songWidget);
145  vLayout->setSpacing(0);
146  vLayout->setContentsMargins(0, 0, 0, 0);
147 
148  QWidget *middleFuncWidget = new QWidget(songWidget);
149  middleFuncWidget->setStyleSheet(TTK::UI::PushButtonStyle03);
150  QHBoxLayout *middleFuncLayout = new QHBoxLayout(middleFuncWidget);
151  middleFuncLayout->setContentsMargins(0, 5, 0, 5);
152  QLabel *marginLabel = new QLabel(middleFuncWidget);
153  marginLabel->setFixedWidth(1);
154  QCheckBox *allCheckBox = new QCheckBox(TTK_SPACE + tr("All"), middleFuncWidget);
155  QPushButton *playButton = new QPushButton(tr("Play"), middleFuncWidget);
156  playButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
157  playButton->setIconSize(QSize(14, 14));
158  playButton->setFixedSize(55, 25);
159  playButton->setCursor(QCursor(Qt::PointingHandCursor));
160  QPushButton *addButton = new QPushButton(tr("Add"), middleFuncWidget);
161  addButton->setFixedSize(55, 25);
162  addButton->setCursor(QCursor(Qt::PointingHandCursor));
163  QPushButton *downloadButton = new QPushButton(tr("Download"), middleFuncWidget);
164  downloadButton->setFixedSize(55, 25);
165  downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
166 
167 #ifdef Q_OS_UNIX
168  allCheckBox->setFocusPolicy(Qt::NoFocus);
169  playButton->setFocusPolicy(Qt::NoFocus);
170  addButton->setFocusPolicy(Qt::NoFocus);
171  downloadButton->setFocusPolicy(Qt::NoFocus);
172 #endif
173 
174  middleFuncLayout->addWidget(marginLabel);
175  middleFuncLayout->addWidget(allCheckBox);
176  middleFuncLayout->addStretch(1);
177  middleFuncLayout->addWidget(playButton);
178  middleFuncLayout->addWidget(addButton);
179  middleFuncLayout->addWidget(downloadButton);
180 
181  connect(allCheckBox, SIGNAL(clicked(bool)), m_queryTableWidget, SLOT(checkedItemsState(bool)));
182  connect(playButton, SIGNAL(clicked()), SLOT(playButtonClicked()));
183  connect(downloadButton, SIGNAL(clicked()), SLOT(downloadButtonClicked()));
184  connect(addButton, SIGNAL(clicked()), SLOT(addButtonClicked()));
185 
186  vLayout->addWidget(middleFuncWidget);
187  vLayout->addWidget(m_queryTableWidget);
188  vLayout->addStretch(1);
189  songWidget->setLayout(vLayout);
190 
191  m_queryTableWidget->show();
192  m_container->addWidget(songWidget);
193 }
194 
196 {
197  QWidget *songWidget = new QWidget(m_container);
198  QVBoxLayout *vLayout = new QVBoxLayout(songWidget);
199  vLayout->setSpacing(0);
200  vLayout->setContentsMargins(0, 0, 0, 0);
201  m_infoLabel = new QLabel(this);
202  m_infoLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
203  m_infoLabel->setWordWrap(true);
205  vLayout->addWidget(m_infoLabel);
206  songWidget->setLayout(vLayout);
207  m_container->addWidget(songWidget);
208 }
209 
211 {
213  if(!d)
214  {
215  return;
216  }
217 
218  if(m_songButton)
219  {
220  m_songButton->setText(tr("SongItems") + QString("(%1)").arg(d->items().count()));
221  }
222 }
const TTK::MusicSongInformationList & items() const noexcept
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.
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