TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiclrccontainerforwallpaper.cpp
Go to the documentation of this file.
7 
9 {
10 public:
11  AbstractDesktopControl(QWidget *parent)
12  : m_parent(parent)
13  {
14 
15  }
16  virtual ~AbstractDesktopControl() = default;
17 
18 protected:
19  QWidget *m_parent;
20 
21 };
22 
23 #if defined Q_OS_WIN
24 # define WIN32_LEAN_AND_MEAN
25 # include <qt_windows.h>
26 # if defined Q_CC_MSVC
27 # pragma comment(lib, "user32.lib")
28 # endif
29 
30 class WindowsDesktopControl : public AbstractDesktopControl
31 {
32 public:
33  WindowsDesktopControl(QWidget *parent)
34  : AbstractDesktopControl(parent)
35  {
36  sendMessageToDesktop();
37  SetParent((HWND)m_parent->winId(), findDesktopIconWnd());
38  }
39 
40  void sendMessageToDesktop()
41  {
42  PDWORD_PTR result = nullptr;
43  SendMessageTimeoutW(FindWindowW(L"Progman", nullptr), 0x52C, 0, 0, SMTO_NORMAL, 1000, result);
44  }
45 
46  HWND findDesktopIconWnd()
47  {
48  HWND hWorkerW = FindWindowExW(nullptr, nullptr, L"WorkerW", nullptr);
49  HWND hDefView = nullptr;
50 
51  while(!hDefView && hWorkerW)
52  {
53  hDefView = FindWindowExW(hWorkerW, nullptr, L"SHELLDLL_DefView", nullptr);
54  hWorkerW = FindWindowExW(nullptr, hWorkerW, L"WorkerW", nullptr);
55  }
56 
57  ShowWindow(hWorkerW, 0);
58  return FindWindowW(L"Progman", nullptr);
59  }
60 };
61 #endif
62 
63 
65  : MusicLrcContainer(parent),
66  m_animationFreshTime(0),
67  m_control(nullptr)
68 {
69  QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
70  vBoxLayout->setContentsMargins(0, 0, 0, 0);
71  vBoxLayout->setSpacing(0);
72  setLayout(vBoxLayout);
73 
75  m_background->setScaledContents(true);
76  vBoxLayout->addWidget(m_background);
77 
78  QVBoxLayout *bBoxLayout = new QVBoxLayout(m_background);
79  bBoxLayout->setContentsMargins(0, 0, 0, 0);
80  bBoxLayout->setSpacing(0);
81  m_background->setLayout(bBoxLayout);
82 
86  bBoxLayout->addWidget(m_layoutWidget);
87 
89  connect(m_thread, SIGNAL(updateBackground(QPixmap)), SLOT(updateBackground(QPixmap)));
90 
91 #ifdef Q_OS_WIN
92  m_control = new WindowsDesktopControl(this);
93 #endif
94 }
95 
97 {
99  delete m_control;
100  delete m_thread;
101 }
102 
104 {
106 }
107 
109 {
111  m_layoutWidget->stop();
112 }
113 
115 {
116  const int width = G_SETTING_PTR->value(MusicSettingManager::ScreenSize).toSize().width() - LRC_PER_WIDTH;
117  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
118  {
120  w->setLrcPerWidth(width);
121  w->setLrcFontSize(36);
122  w->setY(35 + 36);
123  w->setFixedHeight(35 + 36);
124  }
125 
126  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
127  {
128  if(i == 0 || i == 10)
129  {
130  setItemStyleSheet(i, 25, 90);
131  }
132  else if(i == 1 || i == 9)
133  {
134  setItemStyleSheet(i, 20, 80);
135  }
136  else if(i == 2 || i == 8)
137  {
138  setItemStyleSheet(i, 15, 60);
139  }
140  else if(i == 3 || i == 7)
141  {
142  setItemStyleSheet(i, 10, 40);
143  }
144  else if(i == 4 || i == 6)
145  {
146  setItemStyleSheet(i, 5, 20);
147  }
148  else
149  {
150  setItemStyleSheet(i, 0, 0);
151  }
152  }
153 }
154 
156 {
158 
160  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
161  {
164  m_lrcManagers.append(w);
165  }
167 
168  initCurrentLrc(tr("Init wallpaper module now"));
169  render(false);
170 }
171 
173 {
174  if(m_lrcAnalysis->isValid())
175  {
176  m_animationFreshTime = time;
178  }
179 
180  render(false);
181 }
182 
184 {
185  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
186  {
187  m_lrcManagers[i]->setText({});
188  }
189  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->setText(text);
190 }
191 
193 {
194  if(!m_thread)
195  {
196  return;
197  }
198 
199  m_thread->setImagePath(G_BACKGROUND_PTR->artistImageList());
200 
201  if(!m_thread->isRunning())
202  {
203  m_thread->start();
204  }
205 
206  if(immediate)
207  {
208  m_thread->timeout();
209  }
210 }
211 
213 {
214  applyParameter();
215 }
216 
218 {
219  const QSize &size = G_SETTING_PTR->value(MusicSettingManager::ScreenSize).toSize();
220  m_background->setFixedSize(size);
221  m_background->setPixmap(pix.scaled(size));
222 }
223 
225 {
226  const int length = (MUSIC_LRC_INTERIOR_MAX_LINE - m_lrcAnalysis->maximum()) / 2 + 1;
227  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
228  {
229  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i - length));
230  }
231  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->start(m_animationFreshTime);
232 }
233 
235 {
236  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
237  {
238  m_lrcManagers[i]->setText({});
239  }
240  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->setText(str);
241 }
242 
243 void MusicLrcContainerForWallpaper::setItemStyleSheet(int index, int size, int transparent)
244 {
246  w->setFontSize(size);
247 
248  const int value = TTK_RN_MAX - transparent;
249  w->setFontTransparent(value);
250  w->setTransparent(value);
251 
252  if(G_SETTING_PTR->value("LrcColor").toInt() != -1)
253  {
255  }
256  else
257  {
258  setLinearGradientColor({TTK::readColorConfig(G_SETTING_PTR->value("LrcFrontgroundColor").toString()),
259  TTK::readColorConfig(G_SETTING_PTR->value("LrcBackgroundColor").toString())});
260  }
261 }
MusicLrcContainerForWallpaper(QWidget *parent=nullptr)
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:231
The class of the lrc manager base.
MusicLrcAnalysis * m_lrcAnalysis
#define G_BACKGROUND_PTR
void setFontTransparent(int t) noexcept
virtual ~AbstractDesktopControl()=default
void setFontSize(int size) noexcept
voidpf void uLong size
Definition: ioapi.h:136
MusicDesktopWallpaperThread * m_thread
bool isValid() const noexcept
#define TTK_RN_MAX
Definition: ttkglobal.h:439
int maximum() const noexcept
void setLrcPerWidth(int width) noexcept
The class of the lrc container base.
void setTransparent(int tran) noexcept
The class of the desktop wallpaper thread.
The class of the label transition animation.
The class of the core lrc analysis.
The class of the vertical layout float animation widget.
The class of the interior lrc manager.
static constexpr int LRC_PER_WIDTH
QString text(int index) const
void setLrcFontSize(int size)
MusicVLayoutAnimationWidget * m_layoutWidget
static constexpr const char * LRC_WALLPAPER_TPYE
virtual void start() overridefinal
MusicTransitionAnimationLabel * m_background
void setY(int y) noexcept
static constexpr int MUSIC_LRC_INTERIOR_MAX_LINE
void setItemStyleSheet(int index, int size, int transparent)
virtual void applyParameter() overridefinal
void setImagePath(const QStringList &list) noexcept
void setLrcAnalysisModel(MusicLrcAnalysis *analysis)
QList< MusicLrcManager * > m_lrcManagers
void addWidget(QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
void setLinearGradientColor(MusicLrcColor::Color color)
QList< QColor > readColorConfig(const QString &value)
void setLrcAnalysisModel(MusicLrcAnalysis *analysis) noexcept
#define G_SETTING_PTR
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:82