TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musictopareawidget.cpp
Go to the documentation of this file.
1 #include "musictopareawidget.h"
2 #include "ui_musicapplication.h"
3 #include "musicapplication.h"
12 #include "musictinyuiobject.h"
13 #include "musicfunctionuiobject.h"
14 #include "musictoolsetswidget.h"
15 #include "musicimageutils.h"
16 
18 
20  : QWidget(parent),
21  m_backgroundWidget(nullptr),
22  m_remoteWidget(nullptr),
23  m_lastRemoteBeforeWallpaper(-1),
24  m_backgroundListTransparent(60)
25 {
26  m_instance = this;
27 
28  m_pictureCarouselTimer.setInterval(10 * TTK_DN_S2MS);
29  connect(&m_pictureCarouselTimer, SIGNAL(timeout()), SLOT(backgroundChanged()));
30  connect(G_BACKGROUND_PTR, SIGNAL(selectIndexChanged()), SLOT(backgroundChanged()));
31 }
32 
34 {
35  delete m_backgroundWidget;
36  delete m_remoteWidget;
37 }
38 
40 {
41  return m_instance;
42 }
43 
44 void MusicTopAreaWidget::setupUi(Ui::MusicApplication *ui)
45 {
46  m_ui = ui;
47  //
49 
50  ui->userIcon->setPixmap(TTK::Image::roundedPixmap(QPixmap(":/image/lb_app_logo"), QPixmap(":/image/lb_mask_30"), QSize(30, 30)));
51 
52  ui->songSearchEdit->initialize(MusicApplication::instance());
53  ui->songSearchEdit->setStyleSheet(TTK::UI::LineEditStyle02);
54 
55  ui->songSearchButton->setCursor(QCursor(Qt::PointingHandCursor));
56  ui->songSearchButton->setStyleSheet(TTK::UI::TinyBtnMainSearch);
57 
58  ui->windowIdentify->setToolTip(tr("Identify Songs"));
59  ui->windowIdentify->setCursor(QCursor(Qt::PointingHandCursor));
60  ui->windowIdentify->setStyleSheet(TTK::UI::BtnIdentify);
61 
62  ui->windowTools->setToolTip(tr("Tools"));
63  ui->windowTools->setCursor(QCursor(Qt::PointingHandCursor));
64  ui->windowTools->setStyleSheet(TTK::UI::BtnTools);
65  connect(ui->windowTools, SIGNAL(clicked()), SLOT(showToolSetsWidget()));
66 
67  ui->windowChangeSkin->setToolTip(tr("Skin"));
68  ui->windowChangeSkin->setCursor(QCursor(Qt::PointingHandCursor));
69  ui->windowChangeSkin->setStyleSheet(TTK::UI::BtnSkin);
70  connect(ui->windowChangeSkin, SIGNAL(clicked()), SLOT(showSkinManagerWidget()));
71 
72  ui->windowSetting->setToolTip(tr("Settings"));
73  ui->windowSetting->setCursor(QCursor(Qt::PointingHandCursor));
74  ui->windowSetting->setStyleSheet(TTK::UI::BtnSetting);
75  connect(ui->windowSetting, SIGNAL(clicked()), MusicApplication::instance(), SLOT(createRightMenu()));
76 
77  ui->windowConcise->setToolTip(tr("Concise Mode"));
78  ui->windowConcise->setCursor(QCursor(Qt::PointingHandCursor));
79  ui->windowConcise->setStyleSheet(TTK::UI::BtnConciseIn);
80  connect(ui->windowConcise, SIGNAL(clicked()), MusicApplication::instance(), SLOT(windowConciseChanged()));
81 
82  ui->windowRemote->setToolTip(tr("Open Remote"));
83  ui->windowRemote->setCursor(QCursor(Qt::PointingHandCursor));
84  ui->windowRemote->setStyleSheet(TTK::UI::BtnRemote);
85  connect(ui->windowRemote, SIGNAL(clicked()), SLOT(showSquareRemote()));
86 
87  ui->minimization->setStyleSheet(TTK::UI::BtnMinimum);
88  ui->minimization->setCursor(QCursor(Qt::PointingHandCursor));
89  ui->minimization->setToolTip(tr("Minimization"));
90  connect(ui->minimization, SIGNAL(clicked()), MusicApplication::instance(), SLOT(showMinimized()));
91 
92  ui->windowClose->setToolTip(tr("Close"));
93  ui->windowClose->setCursor(QCursor(Qt::PointingHandCursor));
94  ui->windowClose->setStyleSheet(TTK::UI::BtnTClose);
95  connect(ui->windowClose, SIGNAL(clicked()), MusicApplication::instance(), SLOT(close()));
96 }
97 
99 {
103 }
104 
106 {
108  {
110  }
112 }
113 
115 {
117  {
119  }
120  return false;
121 }
122 
123 const QImage& MusicTopAreaWidget::originImage() const
124 {
125  return m_backgroundImage;
126 }
127 
128 const QPixmap& MusicTopAreaWidget::renderPixmap() const
129 {
130  return m_ui->background->renderPixmap();
131 }
132 
134 {
135  state ? m_pictureCarouselTimer.start() : m_pictureCarouselTimer.stop();
136 }
137 
139 {
140  if(m_remoteWidget)
141  {
143  }
144 }
145 
146 void MusicTopAreaWidget::setLabelText(const QString &name) const
147 {
148  if(m_remoteWidget)
149  {
151  }
152 }
153 
155 {
156  if(m_remoteWidget)
157  {
159  }
160 }
161 
163 {
164  if(m_backgroundWidget == nullptr)
165  {
167  }
168 
171 }
172 
174 {
175  if(isArtistBackground())
176  {
177  return;
178  }
179 
181  {
183  }
184 
185  m_backgroundTransparent = value;
187 }
188 
190 {
191  if(isArtistBackground())
192  {
193  return;
194  }
195 
196  drawWindowBackgroundByPath(fileName);
197 }
198 
200 {
201  QString path = G_BACKGROUND_PTR->artistImageDefaultPath();
202  if(!path.isEmpty())
203  {
205  if(path.isEmpty())
206  {
207  return;
208  }
209 
211  {
213  }
214 
215  backgroundSkinChanged(path);
216  }
217 }
218 
220 {
222 }
223 
224 void MusicTopAreaWidget::backgroundSkinChanged(const QString &fileName)
225 {
226  m_backgroundImagePath = fileName;
227  if(!isArtistBackground())
228  {
230  }
231 }
232 
234 {
235  const QString &path = G_BACKGROUND_PTR->artistImagePath();
236  if(!path.isEmpty())
237  {
238  G_BACKGROUND_PTR->imageNext();
240  }
241  else
242  {
244  }
245 }
246 
248 {
249  m_ui->background->setAnimation(!state);
250 }
251 
253 {
254  if(isArtistBackground() && m_ui->lrcForInterior->isShowArtistBackground())
255  {
258  }
259  else
260  {
262  }
263 }
264 
266 {
268  setBackgroundAnimation(false);
271 
272  if(isArtistBackground())
273  {
275  }
276 }
277 
279 {
281  {
283  }
284 
287 }
288 
290 {
291  delete m_remoteWidget;
294 }
295 
297 {
298  delete m_remoteWidget;
300  m_remoteWidget->setLabelText(m_ui->songTitleLabel->text());
302 }
303 
305 {
306  delete m_remoteWidget;
308  m_remoteWidget->setLabelText(m_ui->songTitleLabel->text());
310 }
311 
313 {
314  delete m_remoteWidget;
316  m_remoteWidget->setLabelText(m_ui->songTitleLabel->text());
318 }
319 
321 {
322  delete m_remoteWidget;
324  m_remoteWidget->setLabelText(m_ui->songTitleLabel->text());
326 }
327 
329 {
330  if(create)
331  {
332  if(m_remoteWidget)
333  {
335  delete m_remoteWidget;
336  }
337 
339  m_remoteWidget->setLabelText(m_ui->songTitleLabel->text());
341  }
342  else
343  {
344  delete m_remoteWidget;
345  m_remoteWidget = nullptr;
348  }
349 }
350 
352 {
353  delete m_remoteWidget;
354  m_remoteWidget = nullptr;
355 }
356 
358 {
359  if(!m_remoteWidget)
360  {
361  return;
362  }
363 
365  m_remoteWidget = nullptr;
366 
367  remoteTypeChanged(type->data().toInt());
368 
369  if(m_remoteWidget)
370  {
371  remote->deleteLater();
372  }
373 }
374 
376 {
377  switch(type)
378  {
384  default: break;
385  }
386 }
387 
389 {
391 }
392 
394 {
396  m_ui->centerLeftWidget->backgroundTransparent(value);
397 }
398 
400 {
401  return m_ui->functionsContainer->currentIndex() == MUSIC_LRC_PAGE;
402 }
403 
405 {
406  if(!m_remoteWidget)
407  {
408  return;
409  }
410 
412  m_remoteWidget->setVolumeValue(m_ui->soundButton->value());
413 
414  connect(m_remoteWidget, SIGNAL(showMainWindow()), MusicApplication::instance(), SLOT(showNormal()));
415  connect(m_remoteWidget, SIGNAL(playPreviousChanged()), MusicApplication::instance(), SLOT(playPrevious()));
416  connect(m_remoteWidget, SIGNAL(playNextChanged()), MusicApplication::instance(), SLOT(playNext()));
417  connect(m_remoteWidget, SIGNAL(playStateChanged()), MusicApplication::instance(), SLOT(switchToPlayState()));
418  connect(m_remoteWidget, SIGNAL(settingChanged()), MusicApplication::instance(), SLOT(showSettingWidget()));
419  connect(m_remoteWidget, SIGNAL(volumeChanged(int)), MusicApplication::instance(), SLOT(volumeChanged(int)));
420  connect(m_remoteWidget, SIGNAL(remoteTypeChanged(QAction*)), SLOT(remoteTypeChanged(QAction*)));
421  m_remoteWidget->show();
422 }
423 
425 {
426  setBackgroundAnimation(false);
428 }
429 
431 {
432  if(image.isNull())
433  {
434  return;
435  }
436 
437  QImage origin(image);
438  if(!origin.colorTable().isEmpty())
439  {
440  origin = origin.convertToFormat(QImage::Format_ARGB32);
441  }
442 
443  TTK::Image::reRenderImage(35, &origin, &origin);
444 
447 }
448 
450 {
451  if(m_backgroundImage.isNull())
452  {
453  return;
454  }
455 
456  const float v = TTK::Image::boundValue<float>(1.0f, 0.35f, TTK_RN_MAX - m_backgroundTransparent);
457  MusicApplication::instance()->setWindowOpacity(v);
458 
459  const QSize size(G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize());
460 
461  QPixmap pix(size);
462  pix.fill(Qt::transparent);
463  QPainter painter(&pix);
464  painter.setRenderHint(QPainter::SmoothPixmapTransform);
465  painter.drawImage(0, 0, m_backgroundImage.scaled(size, Qt::KeepAspectRatioByExpanding));
466 
469 
470  m_ui->background->setPixmap(pix);
471 }
472 
474 {
475  drawWindowBackground(QImage(path));
476 }
void setupUi(Ui::MusicApplication *ui)
int backgroundTransparent() const noexcept
The class of the desktop complex remote widget.
MusicTopAreaWidget(QWidget *parent=nullptr)
static constexpr const char * TinyBtnMainSearch
The class of the app top area widget.
static QString cpoyArtistFileToLocal(const QString &path)
static MusicApplication * instance()
The class of the tool sets widget.
static constexpr const char * BtnSetting
#define G_BACKGROUND_PTR
static QPixmap setBackgroundUrl(QString &name)
voidpf uLong int origin
Definition: ioapi.h:142
The class of the local background widget.
voidpf void uLong size
Definition: ioapi.h:136
void drawWindowBackgroundByPath(const QString &path)
#define MUSIC_LRC_PAGE
bool isArtistBackground() const
static constexpr const char * BtnMinimum
#define TTK_RN_MAX
Definition: ttkglobal.h:439
The class of the desktop square remote widget.
TTK_MODULE_EXPORT QPixmap roundedPixmap(const QPixmap &input, int ratioX, int ratioY)
MusicRemoteWidget * m_remoteWidget
Ui::MusicApplication * m_ui
The class of the desktop simple remote widget.
const char * name
Definition: http_parser.c:458
The class of the desktop ripple remote widget.
#define TTK_GENERATE_SINGLE_WIDGET(...)
const QPixmap & renderPixmap() const
void setLabelText(const QString &name) const
void setCurrentPlayState(bool state) const
The class of the desktop strip remote widget.
The class of the desktop rectangle remote widget.
void originImageChanged(const QImage &image)
The class of the desktop remote widget base.
const QImage & originImage() const
static constexpr const char * BtnIdentify
void setCurrentPlayState(bool state) const
static const QString LineEditStyle02
bool backgroundTransparentEnabled() const
#define TTK_DN_S2MS
Definition: ttkglobal.h:355
void backgroundSkinChanged(const QString &fileName)
void setVolumeValue(int value) const
void updateArtistFileTheme(const QString &theme)
void showWallpaperRemote(bool create)
static constexpr const char * BtnTools
static MusicTopAreaWidget * m_instance
void playlistTransparentChanged(int index)
TTK_MODULE_EXPORT void reRenderImage(int delta, const QImage *input, QImage *output)
MusicBackgroundSkinDialog * m_backgroundWidget
static constexpr const char * BtnSkin
void setBackgroundAnimation(bool state)
void setCurrentBackgroundTheme(const QString &theme, int background, int list)
void setVolumeValue(int index)
static constexpr const char * BtnConciseIn
void remoteTypeChanged(QAction *type)
static constexpr const char * BtnTClose
void backgroundAnimationChanged(bool state)
virtual void setLabelText(const QString &text)
static MusicTopAreaWidget * instance()
state
Definition: http_parser.c:279
#define G_SETTING_PTR
static constexpr const char * BtnRemote