TTKMusicPlayer
4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
TTKModule
TTKCore
musicToolsSetsKits
musicdesktopwallpaperthread.cpp
Go to the documentation of this file.
1
#include "
musicdesktopwallpaperthread.h
"
2
#include "
musicbackgroundconfigmanager.h
"
3
#include "
musicbackgroundmanager.h
"
4
#include "
musicextractmanager.h
"
5
6
#include <QTimer>
7
#include <QPixmap>
8
9
MusicDesktopWallpaperThread::MusicDesktopWallpaperThread
(QObject *parent)
10
: QObject(parent),
11
m_run(false),
12
m_random(false),
13
m_currentImageIndex(0)
14
{
15
TTK::initRandom
();
16
17
m_timer
=
new
QTimer(
this
);
18
setInterval
(20 *
TTK_DN_S2MS
);
19
connect(
m_timer
, SIGNAL(
timeout
()), SLOT(
timeout
()));
20
}
21
22
MusicDesktopWallpaperThread::~MusicDesktopWallpaperThread
()
23
{
24
stop
();
25
delete
m_timer
;
26
}
27
28
void
MusicDesktopWallpaperThread::setInterval
(
int
msec)
29
{
30
m_timer
->setInterval(msec);
31
}
32
33
bool
MusicDesktopWallpaperThread::isRunning
()
const
noexcept
34
{
35
return
m_run
;
36
}
37
38
void
MusicDesktopWallpaperThread::setRandom
(
bool
random
) noexcept
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
71
void
MusicDesktopWallpaperThread::start
()
72
{
73
m_run
=
true
;
74
timeout
();
75
m_timer
->start();
76
}
77
78
void
MusicDesktopWallpaperThread::stop
()
79
{
80
m_run
=
false
;
81
m_timer
->stop();
82
}
83
84
void
MusicDesktopWallpaperThread::timeout
()
85
{
86
if
(!
m_run
)
87
{
88
return
;
89
}
90
91
if
(!
m_path
.isEmpty())
92
{
93
if
(
m_random
)
94
{
95
m_currentImageIndex
=
TTK::random
(
m_path
.count());
96
}
97
else
if
(++
m_currentImageIndex
>=
m_path
.count())
98
{
99
m_currentImageIndex
= 0;
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
}
MusicDesktopWallpaperThread::m_currentImageIndex
int m_currentImageIndex
Definition:
musicdesktopwallpaperthread.h:102
musicbackgroundconfigmanager.h
G_BACKGROUND_PTR
#define G_BACKGROUND_PTR
Definition:
musicbackgroundmanager.h:140
MusicDesktopWallpaperThread::m_run
bool m_run
Definition:
musicdesktopwallpaperthread.h:101
MusicDesktopWallpaperThread::isRunning
bool isRunning() const noexcept
Definition:
musicdesktopwallpaperthread.cpp:33
TTK::initRandom
TTK_MODULE_EXPORT void initRandom()
Definition:
ttktime.cpp:7
MusicDesktopWallpaperThread::stop
void stop()
Definition:
musicdesktopwallpaperthread.cpp:78
MusicDesktopWallpaperThread::~MusicDesktopWallpaperThread
~MusicDesktopWallpaperThread()
Definition:
musicdesktopwallpaperthread.cpp:22
musicdesktopwallpaperthread.h
MusicDesktopWallpaperThread::m_timer
QTimer * m_timer
Definition:
musicdesktopwallpaperthread.h:103
TTK::random
TTK_MODULE_EXPORT int random(int value=RAND_MAX)
Definition:
ttktime.cpp:14
MusicBackgroundImage::m_pix
QPixmap m_pix
Definition:
musicbackgroundconfigmanager.h:53
MusicBackgroundImage
The class of the skin backgroud image.
Definition:
musicbackgroundconfigmanager.h:51
MusicDesktopWallpaperThread::timeout
void timeout()
Definition:
musicdesktopwallpaperthread.cpp:84
MusicDesktopWallpaperThread::m_random
bool m_random
Definition:
musicdesktopwallpaperthread.h:101
musicbackgroundmanager.h
MusicExtractManager::outputSkin
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
Definition:
musicextractmanager.cpp:149
musicextractmanager.h
TTK_DN_S2MS
#define TTK_DN_S2MS
Definition:
ttkglobal.h:355
MusicDesktopWallpaperThread::setRandom
void setRandom(bool random) noexcept
Definition:
musicdesktopwallpaperthread.cpp:38
MusicDesktopWallpaperThread::setImagePath
void setImagePath(const QStringList &list) noexcept
Definition:
musicdesktopwallpaperthread.cpp:43
MusicDesktopWallpaperThread::m_path
QStringList m_path
Definition:
musicdesktopwallpaperthread.h:104
const
#define const
Definition:
zconf.h:233
MusicDesktopWallpaperThread::setInterval
void setInterval(int msec)
Definition:
musicdesktopwallpaperthread.cpp:28
MusicDesktopWallpaperThread::updateBackground
void updateBackground(const QPixmap &pix)
MusicDesktopWallpaperThread::MusicDesktopWallpaperThread
MusicDesktopWallpaperThread(QObject *parent=nullptr)
Definition:
musicdesktopwallpaperthread.cpp:9
MusicDesktopWallpaperThread::start
void start()
Definition:
musicdesktopwallpaperthread.cpp:71
Generated on Sat Jul 19 2025 16:53:02 for TTKMusicPlayer by
1.8.8