TTKMusicPlayer  3.7.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 "musicextractwrapper.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 void MusicDesktopWallpaperThread::setImagePath(const QStringList &list)
43 {
44  m_path = list;
45 }
46 
47 #if defined Q_OS_WIN
48 HWND MusicDesktopWallpaperThread::findDesktopIconWnd()
49 {
50  HWND hWorkerW = FindWindowExW(nullptr, nullptr, L"WorkerW", nullptr);
51  HWND hDefView = nullptr;
52 
53  while(!hDefView && hWorkerW)
54  {
55  hDefView = FindWindowExW(hWorkerW, nullptr, L"SHELLDLL_DefView", nullptr);
56  hWorkerW = FindWindowExW(nullptr, hWorkerW, L"WorkerW", nullptr);
57  }
58 
59  ShowWindow(hWorkerW, 0);
60  return FindWindowW(L"Progman", nullptr);
61 }
62 
63 void MusicDesktopWallpaperThread::sendMessageToDesktop()
64 {
65  PDWORD_PTR result = nullptr;
66  SendMessageTimeoutW(FindWindowW(L"Progman", nullptr), 0x52C, 0, 0, SMTO_NORMAL, 1000, result);
67 }
68 #endif
69 
71 {
72  m_run = true;
73  timeout();
74  m_timer->start();
75 }
76 
78 {
79  m_run = false;
80  m_timer->stop();
81 }
82 
84 {
85  if(!m_run)
86  {
87  return;
88  }
89 
90  if(!m_path.isEmpty())
91  {
92  if(m_random)
93  {
95  }
96  else if(++m_currentImageIndex >= m_path.count())
97  {
99  }
100 
101  Q_EMIT updateBackground(QPixmap(m_path[m_currentImageIndex]));
102  }
103  else
104  {
105  MusicBackgroundImage image;
106  MusicExtractWrapper::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl());
107  Q_EMIT updateBackground(image.m_pix);
108  }
109 }
#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.
void setImagePath(const QStringList &list)
#define TTK_DN_S2MS
Definition: ttkglobal.h:276
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
void updateBackground(const QPixmap &pix)
MusicDesktopWallpaperThread(QObject *parent=nullptr)