TTKMusicPlayer  3.7.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  : MusicLrcContainer(parent),
10  m_animationFreshTime(0)
11 {
12  QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
13  vBoxLayout->setContentsMargins(0, 0, 0, 0);
14  vBoxLayout->setSpacing(0);
15  setLayout(vBoxLayout);
16 
18  m_background->setScaledContents(true);
19  vBoxLayout->addWidget(m_background);
20 
21  QVBoxLayout *bBoxLayout = new QVBoxLayout(m_background);
22  bBoxLayout->setContentsMargins(0, 0, 0, 0);
23  bBoxLayout->setSpacing(0);
24  m_background->setLayout(bBoxLayout);
25 
29  bBoxLayout->addWidget(m_layoutWidget);
30 
32  connect(m_wallThread, SIGNAL(updateBackground(QPixmap)), SLOT(updateBackground(QPixmap)));
33 
34 #ifdef Q_OS_WIN
35  m_wallThread->sendMessageToDesktop();
36  SetParent((HWND)winId(), m_wallThread->findDesktopIconWnd());
37 #endif
38 }
39 
41 {
43  delete m_wallThread;
44 }
45 
47 {
48  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->startDrawLrc();
49 }
50 
52 {
53  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->stopDrawLrc();
55 }
56 
58 {
59  const int width = G_SETTING_PTR->value(MusicSettingManager::ScreenSize).toSize().width() - LRC_PER_WIDTH;
60  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
61  {
63  w->setLrcPerWidth(width);
64  w->setLrcFontSize(36);
65  w->setY(35 + 36);
66  w->setFixedHeight(35 + 36);
67  }
68 
69  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
70  {
71  if(i == 0 || i == 10)
72  {
73  setItemStyleSheet(i, 25, 90);
74  }
75  else if(i == 1 || i == 9)
76  {
77  setItemStyleSheet(i, 20, 80);
78  }
79  else if(i == 2 || i == 8)
80  {
81  setItemStyleSheet(i, 15, 60);
82  }
83  else if(i == 3 || i == 7)
84  {
85  setItemStyleSheet(i, 10, 40);
86  }
87  else if(i == 4 || i == 6)
88  {
89  setItemStyleSheet(i, 5, 20);
90  }
91  else
92  {
93  setItemStyleSheet(i, 0, 0);
94  }
95  }
96 }
97 
99 {
102  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
103  {
106  m_lrcManagers.append(w);
107  }
109 
110  initCurrentLrc(tr("Init wallpaper module now"));
111 
112  start(false);
113 }
114 
116 {
117  if(m_lrcAnalysis->isValid())
118  {
119  m_animationFreshTime = time;
121  }
122 
123  start(false);
124 }
125 
127 {
128  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
129  {
130  m_lrcManagers[i]->setText({});
131  }
132  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->setText(text);
133 }
134 
136 {
137  if(m_wallThread)
138  {
139  m_wallThread->setImagePath(G_BACKGROUND_PTR->artistPhotoList());
140 
141  if(!m_wallThread->isRunning())
142  {
143  m_wallThread->start();
144  }
145 
146  if(immediate)
147  {
149  }
150  }
151 }
152 
154 {
155  applyParameter();
156 }
157 
159 {
160  const QSize &windowSize = G_SETTING_PTR->value(MusicSettingManager::ScreenSize).toSize();
161  m_background->setFixedSize(windowSize);
162  m_background->setPixmap(pix.scaled(windowSize));
163 }
164 
166 {
167  const int length = (MUSIC_LRC_INTERIOR_MAX_LINE - m_lrcAnalysis->lineMax()) / 2 + 1;
168  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
169  {
170  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i - length));
171  }
172  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->startDrawLrcMask(m_animationFreshTime);
173 }
174 
176 {
177  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
178  {
179  m_lrcManagers[i]->setText({});
180  }
181  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->setText(str);
182 }
183 
184 void MusicLrcContainerForWallpaper::setItemStyleSheet(int index, int size, int transparent)
185 {
187  w->setFontSize(size);
188 
189  const int value = TTK_RN_MAX - transparent;
190  w->setFontTransparent(value);
191  w->setTransparent(value);
192 
193  if(G_SETTING_PTR->value("LrcColor").toInt() != -1)
194  {
195  const MusicLrcColor::Color index = TTKStaticCast(MusicLrcColor::Color, G_SETTING_PTR->value("LrcColor").toInt());
196  setLinearGradientColor(index);
197  }
198  else
199  {
200  const MusicLrcColor cl(TTK::readColorConfig(G_SETTING_PTR->value("LrcFrontgroundColor").toString()),
201  TTK::readColorConfig(G_SETTING_PTR->value("LrcBackgroundColor").toString()));
203  }
204 }
MusicLrcContainerForWallpaper(QWidget *parent=nullptr)
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:159
The class of the lrc manager base.
MusicLrcAnalysis * m_lrcAnalysis
bool isValid() const
The class of the lrc color.
int lineMax() const
#define G_BACKGROUND_PTR
voidpf void uLong size
Definition: ioapi.h:136
void setLrcAnalysisModel(MusicLrcAnalysis *analysis)
#define TTK_RN_MAX
Definition: ttkglobal.h:359
The class of the lrc container base.
The class of the desktop wallpaper thread.
MusicDesktopWallpaperThread * m_wallThread
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
static constexpr int MUSIC_LRC_INTERIOR_MAX_LINE
void setImagePath(const QStringList &list)
void setItemStyleSheet(int index, int size, int transparent)
virtual void startDrawLrc() overridefinal
virtual void applyParameter() overridefinal
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)
virtual void stopDrawLrc() overridefinal
void setFontTransparent(int t)
#define G_SETTING_PTR
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:60