TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicdesktopwallpaperthread.cpp
Go to the documentation of this file.
4 #include "musicextractmanager.h"
5 
6 #include <QTimer>
7 #include <QPixmap>
8 
10  : QObject(parent),
11  m_run(false),
12  m_random(false),
13  m_currentImageIndex(0)
14 {
16 
17  m_timer = new QTimer(this);
19  connect(m_timer, SIGNAL(timeout()), SLOT(timeout()));
20 }
21 
23 {
24  stop();
25  delete m_timer;
26 }
27 
29 {
30  m_timer->setInterval(msec);
31 }
32 
34 {
35  return m_run;
36 }
37 
39 {
40  m_random = random;
41 }
42 
43 void MusicDesktopWallpaperThread::setImagePath(const QStringList &list) noexcept
44 {
45  m_path = list;
46 }
47 
49 {
50  m_run = true;
51  timeout();
52  m_timer->start();
53 }
54 
56 {
57  m_run = false;
58  m_timer->stop();
59 }
60 
62 {
63  if(!m_run)
64  {
65  return;
66  }
67 
68  if(!m_path.isEmpty())
69  {
70  if(m_random)
71  {
73  }
74  else if(++m_currentImageIndex >= m_path.count())
75  {
77  }
78 
80  }
81  else
82  {
84  MusicExtractManager::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl());
85  Q_EMIT updateBackground(image.m_pix);
86  }
87 }
#define G_BACKGROUND_PTR
TTK_MODULE_EXPORT void initRandom()
Definition: ttktime.cpp:7
TTK_MODULE_EXPORT int random(int value=RAND_MAX)
Definition: ttktime.cpp:14
The class of the skin backgroud image.
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
#define TTK_DN_S2MS
Definition: ttkglobal.h:355
void setRandom(bool random) noexcept
void setImagePath(const QStringList &list) noexcept
#define const
Definition: zconf.h:233
void updateBackground(const QPixmap &pix)
MusicDesktopWallpaperThread(QObject *parent=nullptr)