TTKMusicPlayer  4.2.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 
48 #if defined Q_OS_WIN
49 HWND MusicDesktopWallpaperThread::findDesktopIconWnd()
50 {
51  HWND hWorkerW = FindWindowExW(nullptr, nullptr, L"WorkerW", nullptr);
52  HWND hDefView = nullptr;
53 
54  while(!hDefView && hWorkerW)
55  {
56  hDefView = FindWindowExW(hWorkerW, nullptr, L"SHELLDLL_DefView", nullptr);
57  hWorkerW = FindWindowExW(nullptr, hWorkerW, L"WorkerW", nullptr);
58  }
59 
60  ShowWindow(hWorkerW, 0);
61  return FindWindowW(L"Progman", nullptr);
62 }
63 
64 void MusicDesktopWallpaperThread::sendMessageToDesktop()
65 {
66  PDWORD_PTR result = nullptr;
67  SendMessageTimeoutW(FindWindowW(L"Progman", nullptr), 0x52C, 0, 0, SMTO_NORMAL, 1000, result);
68 }
69 #endif
70 
72 {
73  m_run = true;
74  timeout();
75  m_timer->start();
76 }
77 
79 {
80  m_run = false;
81  m_timer->stop();
82 }
83 
85 {
86  if(!m_run)
87  {
88  return;
89  }
90 
91  if(!m_path.isEmpty())
92  {
93  if(m_random)
94  {
96  }
97  else if(++m_currentImageIndex >= m_path.count())
98  {
100  }
101 
102  Q_EMIT updateBackground(QPixmap(m_path[m_currentImageIndex]));
103  }
104  else
105  {
106  MusicBackgroundImage image;
107  MusicExtractManager::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl());
108  Q_EMIT updateBackground(image.m_pix);
109  }
110 }
#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)