TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiclrccontainerforinterior.cpp
Go to the documentation of this file.
3 #include "musiclrcfloatwidget.h"
7 #include "musictoastlabel.h"
8 #include "musiclrcanalysis.h"
9 #include "musicurlutils.h"
11 #include "musicrightareawidget.h"
12 #include "musiclrccommentswidget.h"
14 #include "musiclrcposterwidget.h"
16 #include "musicbottomareawidget.h"
17 #include "musicleftareawidget.h"
18 #include "musictopareawidget.h"
19 #include "musicbackgroundmanager.h"
20 #include "musicwidgetheaders.h"
21 #include "ttkclickedlabel.h"
22 
23 #include <QClipboard>
24 #include <QApplication>
25 #include <QActionGroup>
26 
27 static constexpr int LRC_CHANGED_OFFSET_LIMIT = 20;
28 static constexpr int LRC_TIME_LABEL_POSITION = 20;
29 
31  : MusicLrcContainer(parent),
32  m_lrcChangeOffset(0),
33  m_lrcChangeDelta(-1),
34  m_mouseLeftPressed(false),
35  m_lrcChangeState(false),
36  m_mouseMoved(false),
37  m_lrcDisplayAll(false),
38  m_showArtistBackground(true),
39  m_animationFreshTime(0),
40  m_lrcSizeProperty(-1),
41  m_changeSpeedValue(0),
42  m_floatPlayWidget(nullptr),
43  m_commentsWidget(nullptr),
44  m_translatedWidget(nullptr)
45 {
46  QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
47  vBoxLayout->setContentsMargins(0, 0, 0, 0);
48  setLayout(vBoxLayout);
49 
54 
55  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
56  {
58  w->setText({});
60  m_lrcManagers.append(w);
61  }
62  vBoxLayout->addWidget(m_layoutWidget);
63 
66 
67  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->setText(tr("No song is playing now"));
68 }
69 
71 {
73  delete m_functionLabel;
74  delete m_lrcFloatWidget;
75  delete m_floatPlayWidget;
76  delete m_noLrcCurrentInfo;
77  delete m_commentsWidget;
78  delete m_translatedWidget;
79  delete m_layoutWidget;
80 }
81 
83 {
84  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->startDrawLrc();
85 }
86 
88 {
89  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->stopDrawLrc();
91 }
92 
94 {
96  const int size = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
97  if(m_lrcSizeProperty == -1)
98  {
100  }
101 
102  if(m_lrcChangeDelta == -1)
103  {
105  }
106 
107  setLrcSize(size);
108 }
109 
111 {
113  {
114  m_animationFreshTime = time;
116  }
117 }
118 
120 {
121  m_layoutWidget->stop();
122 
123  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
124  {
125  m_lrcManagers[i]->setText({});
126  }
127 
129  {
130  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->setText(tr("No lrc data file found"));
132  }
133  else
134  {
135  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->setText(tr("No song is playing now"));
136  m_noLrcCurrentInfo->hide();
137  }
138 }
139 
141 {
142  return m_lrcManagers[m_lrcAnalysis->lineMiddle()]->text();
143 }
144 
146 {
147  return m_lrcAnalysis->setSongTimeSpeed(time);
148 }
149 
151 {
152  int index = mapLrcSizeProperty(size);
153  if(index == -1)
154  {
155  return;
156  }
157 
158  setLrcSizeProperty(index);
159  index = (mapLrcSizeProperty(m_lrcSizeProperty) - index) / 2;
162 
163  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
164  {
165  m_lrcManagers[i]->setLrcFontSize(size);
166  m_lrcManagers[i]->setY(35 + size);
167  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i));
168  }
170 
171  resizeWindow();
173  startDrawLrc();
174 }
175 
177 {
178  return G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
179 }
180 
182 {
183  int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width();
184  int height = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().height();
185 
186  if(m_lrcDisplayAll)
187  {
188  width += LEFT_SIDE_WIDTH_MIN;
189  }
190 
191  if(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen())
192  {
193  width += (m_lrcDisplayAll ? 0 : LEFT_SIDE_WIDTH_MIN);
194  height += LEFT_SIDE_WIDTH_MIN / 2;
195  }
196 
198 }
199 
201 {
202  delete m_floatPlayWidget;
203  m_floatPlayWidget = nullptr;
204 
205  if(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen())
206  {
208  m_floatPlayWidget->resizeGeometry(width(), height());
209  }
210 }
211 
213 {
214  QHBoxLayout *layout = TTKObjectCast(QHBoxLayout*, m_functionLabel->layout());
216  {
217  layout->removeItem(layout->itemAt(layout->count() - 1));
218  }
219  else
220  {
221  layout->addStretch(1);
222  }
223 }
224 
226 {
227  switch(action->data().toInt())
228  {
229  case 0: setLrcSize(14); break;
230  case 1: setLrcSize(18); break;
231  case 2: setLrcSize(26); break;
232  case 3: setLrcSize(36); break;
233  case 4: setLrcSize(72); break;
234  default: break;
235  }
236 }
237 
239 {
240  int timeValue = 0;
241  switch(action->data().toInt())
242  {
243  case 0: timeValue = -0.5 * TTK_DN_S2MS; break;
244  case 1: timeValue = -1.0 * TTK_DN_S2MS; break;
245  case 2: timeValue = -2.0 * TTK_DN_S2MS; break;
246  case 3: timeValue = -5.0 * TTK_DN_S2MS; break;
247  case 4: timeValue = 0.5 * TTK_DN_S2MS; break;
248  case 5: timeValue = 1.0 * TTK_DN_S2MS; break;
249  case 6: timeValue = 2.0 * TTK_DN_S2MS; break;
250  case 7: timeValue = 5.0 * TTK_DN_S2MS; break;
251  default: break;
252  }
253 
254  m_changeSpeedValue += timeValue;
255  revertTimeSpeed(timeValue);
256 }
257 
259 {
260  if(m_changeSpeedValue == 0)
261  {
262  return;
263  }
265 }
266 
268 {
270 }
271 
273 {
275  Q_EMIT backgroundChanged();
276 }
277 
279 {
280  TTK::Url::openUrl(QFileInfo(m_lrcAnalysis->currentFilePath()).absoluteFilePath());
281 }
282 
284 {
285  QClipboard *clipBoard = QApplication::clipboard();
286  clipBoard->setText(m_lrcAnalysis->dataString());
287 }
288 
290 {
291  MusicLrcLocalLinkWidget widget(this);
293  widget.exec();
294 }
295 
297 {
298  if(m_currentSongName.isEmpty())
299  {
300  return;
301  }
302 
303  delete m_commentsWidget;
306  m_commentsWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
308  m_commentsWidget->show();
309 }
310 
312 {
313  MusicLrcPosterWidget widget(this);
315  widget.exec();
316 }
317 
319 {
320  QString text;
321 
322  if(bytes.startsWith(TTK_AUTHOR_NAME))
323  {
324  // The original and translated lrc have been merged
325  text = bytes;
326  text.remove(0, strlen(TTK_AUTHOR_NAME));
327  }
328  else
329  {
330  const QStringList &orts = m_lrcAnalysis->dataList();
331  const QStringList &trts = bytes.split("\n");
332 
333  if(orts.count() > trts.count())
334  {
335  return;
336  }
337 
338  for(int i = 0; i < orts.count(); ++i)
339  {
340  text += orts[i].trimmed() + "\r\n";
341  text += trts[i].trimmed() + "\r\n";
342  }
343  }
344 
345  delete m_translatedWidget;
348  m_translatedWidget->setGeometry(0, height() / 5.0, width(), height() * 4 / 5.0);
349  m_translatedWidget->show();
350 }
351 
353 {
354  if(m_currentSongName.isEmpty())
355  {
356  return;
357  }
358 
360  {
362  }
364 }
365 
367 {
368  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
369  {
370  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i));
371  }
372 
376 }
377 
379 {
380  const QString &path = m_lrcAnalysis->currentFilePath();
381  if(path.isEmpty())
382  {
383  return;
384  }
385 
387  connect(d, SIGNAL(downLoadDataChanged(QString)), SLOT(queryTranslatedLrcFinished(QString)));
388  d->setHeader("name", path);
389  d->setHeader("data", m_lrcAnalysis->dataString());
390  d->startToRequest();
391 }
392 
394 {
395  Q_UNUSED(event);
396  QMenu menu(this);
397  QMenu changColorMenu(tr("Color"), &menu);
398  QMenu changeLrcSize(tr("Lrc Size"), &menu);
399  QMenu changeLrcTimeFast(tr("Time After"), &menu);
400  QMenu changeLrcTimeSlow(tr("Time Before"), &menu);
401  QMenu changeLrcLinkMenu(tr("Lrc Link"), &menu);
402 
403  menu.setStyleSheet(TTK::UI::MenuStyle02);
404 
405  const bool hasLrcContainer = !m_lrcAnalysis->isEmpty();
406  menu.addAction(tr("Lrc Search"), this, SLOT(searchMusicLrcs()));
407  menu.addAction(tr("Lrc Update"), this, SIGNAL(currentLrcUpdated()));
408  menu.addAction(tr("Lrc Make"), this, SLOT(showLrcMakedWidget()));
409  menu.addAction(tr("Lrc Poster"), this, SLOT(showLrcPosterWidget()))->setEnabled(hasLrcContainer);
410  menu.addSeparator();
411  menu.addAction(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen() ? tr("Show Normal Mode") : tr("Show Fullscreen Mode"),
413  menu.addSeparator();
414  menu.addMenu(&changColorMenu);
415  menu.addMenu(&changeLrcSize);
416 
417  menu.addMenu(&changeLrcTimeFast)->setEnabled(hasLrcContainer);
418  menu.addMenu(&changeLrcTimeSlow)->setEnabled(hasLrcContainer);
419  menu.addAction(tr("Revert Mode"), this, SLOT(revertLrcTimeSpeed()))->setEnabled(hasLrcContainer);
420  menu.addAction(tr("Save Mode"), this, SLOT(saveLrcTimeChanged()))->setEnabled(hasLrcContainer);
421  menu.addSeparator();
422 
423  QActionGroup *group = new QActionGroup(this);
424  group->addAction(changeLrcSize.addAction(tr("Smaller")))->setData(0);
425  group->addAction(changeLrcSize.addAction(tr("Small")))->setData(1);
426  group->addAction(changeLrcSize.addAction(tr("Middle")))->setData(2);
427  group->addAction(changeLrcSize.addAction(tr("Big")))->setData(3);
428  group->addAction(changeLrcSize.addAction(tr("Bigger")))->setData(4);
429 
430  int index = -1, size = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
431  switch(size)
432  {
433  case 14: index = 0; break;
434  case 18: index = 1; break;
435  case 26: index = 2; break;
436  case 36: index = 3; break;
437  case 72: index = 4; break;
438  default: break;
439  }
440 
441  if(index > -1 && index < group->actions().count())
442  {
443  group->actions()[index]->setIcon(QIcon(":/contextMenu/btn_selected"));
444  }
445  connect(group, SIGNAL(triggered(QAction*)), SLOT(lrcSizeChanged(QAction*)));
446 
447  changeLrcSize.addSeparator();
448  changeLrcSize.addAction(tr("Custom"), this, SLOT(currentLrcCustom()));
449  createColorMenu(changColorMenu);
450 
451  QActionGroup *lrcTimeFastGroup = new QActionGroup(this);
452  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 0.5s")))->setData(0);
453  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 1.0s")))->setData(1);
454  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 2.0s")))->setData(2);
455  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 5.0s")))->setData(3);
456  connect(lrcTimeFastGroup, SIGNAL(triggered(QAction*)), SLOT(lrcTimeSpeedChanged(QAction*)));
457  TTK::Widget::adjustMenuPosition(&changeLrcTimeFast);
458  //
459  QActionGroup *lrcTimeSlowGroup = new QActionGroup(this);
460  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 0.5s")))->setData(4);
461  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 1.0s")))->setData(5);
462  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 2.0s")))->setData(6);
463  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 5.0s")))->setData(7);
464  connect(lrcTimeSlowGroup, SIGNAL(triggered(QAction*)), SLOT(lrcTimeSpeedChanged(QAction*)));
465  TTK::Widget::adjustMenuPosition(&changeLrcTimeSlow);
466  //
467  QAction *artAction = menu.addAction(tr("Art Turn Off"), this, SLOT(artistBackgroundChanged()));
468  m_showArtistBackground ? artAction->setText(tr("Art Turn Off")) : artAction->setText(tr("Art Turn On"));
469  QAction *showLrc = menu.addAction(tr("Lrc Turn Off"), this, SLOT(linkLrcStateChanged()));
470  m_linkLocalLrc ? showLrc->setText(tr("Lrc Turn Off")) : showLrc->setText(tr("Lrc Turn On"));
471  menu.addAction(tr("Set As Background"), MusicTopAreaWidget::instance(), SLOT(setAsArtistBackground()))->setEnabled(!G_BACKGROUND_PTR->isEmpty());
472  menu.addSeparator();
473 
474  const QString &filePath = m_lrcAnalysis->currentFilePath();
475  const bool fileCheck = !filePath.isEmpty() && QFile::exists(filePath);
476 
477  changeLrcLinkMenu.addAction(tr("Local Lrc Link"), this, SLOT(showLocalLinkWidget()));
478  QAction *lrcLinkAc = changeLrcLinkMenu.addAction(tr("Link Off"), this, SLOT(linkLrcStateChanged()));
479  m_linkLocalLrc ? lrcLinkAc->setText(tr("Link Off")) : lrcLinkAc->setText(tr("Link On"));
480  TTK::Widget::adjustMenuPosition(&changeLrcLinkMenu);
481  menu.addMenu(&changeLrcLinkMenu);
482 
483  menu.addAction(tr("Copy To Clip"), this, SLOT(lrcCopyClipboard()))->setEnabled(fileCheck);
484  menu.addAction(tr("Open Lrc File"), this, SLOT(lrcOpenFileDir()))->setEnabled(fileCheck);
485 
486  menu.addSeparator();
487  menu.addAction(tr("Settings"), this, SLOT(currentLrcCustom()));
488 
490  menu.exec(QCursor::pos());
491 }
492 
494 {
495  if(event->button() == Qt::LeftButton)
496  {
497  if(m_functionLabel && m_functionLabel->geometry().contains(event->pos()))
498  {
499  return; //block mouse event in function label area
500  }
501 
502  m_mouseMoved = false;
503  m_mouseLeftPressed = true;
505  m_lrcChangeState = false;
506  m_lrcChangeOffset = 0;
507 
508  setCursor(Qt::CrossCursor);
509  update();
510  }
511 }
512 
514 {
516  {
517  m_layoutWidget->stop();
518 
519  m_mouseMoved = true;
520  const int offset = QtMouseGlobalY(event) - m_mousePressedAt.y();
522 
524  if(m_lrcChangeState && offset > 0)
525  {
526  m_lrcChangeState = false;
527  m_lrcChangeOffset = 0;
528  }
529  else if(!m_lrcChangeState && offset < 0)
530  {
531  m_lrcChangeState = true;
532  m_lrcChangeOffset = 0;
533  }
534 
536  {
537  int index = m_lrcAnalysis->currentIndex();
539  m_lrcChangeOffset = 0;
540 
541  if(index < 0)
542  {
543  index = 0;
544  }
545  else if(index >= m_lrcAnalysis->count())
546  {
547  index = m_lrcAnalysis->count() - m_lrcAnalysis->lineMiddle() + 2;
548  }
549 
550  int value = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
552 
554  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
555  {
556  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i - value - 1));
557  }
559  }
560 
561  update();
562  }
563 }
564 
566 {
567  if(event->button() == Qt::LeftButton)
568  {
569  setCursor(Qt::ArrowCursor);
570  m_mouseLeftPressed = false;
572  update();
573 
575  {
576  const qint64 time = m_lrcAnalysis->findTime(m_lrcAnalysis->currentIndex());
577  if(time != -1)
578  {
579  Q_EMIT updateCurrentTime(time);
580  }
581  }
582  }
583 }
584 
586 {
587  if(m_functionLabel && m_functionLabel->geometry().contains(event->pos()))
588  {
589  return; //block mouse event in function label area
590  }
592 }
593 
595 {
596  Q_UNUSED(event);
598  {
599  QLinearGradient linearGradient(0, 0, width(), 0);
600  linearGradient.setColorAt(0.0, QColor(255, 254, 161));
601  linearGradient.setColorAt(0.3, Qt::transparent);
602  linearGradient.setColorAt(0.7, Qt::transparent);
603  linearGradient.setColorAt(1.0, QColor(255, 254, 161));
604 
605  const int line = (height() - m_functionLabel->height()) / 2;
606  QPainter painter(this);
607  painter.setPen(QPen(linearGradient, 1));
608  painter.drawLine(LRC_TIME_LABEL_POSITION, line, width() - LRC_TIME_LABEL_POSITION, line);
609 
610  qint64 v = m_lrcAnalysis->currentIndex() - 1;
611  if(v < 0)
612  {
613  v = 0;
614  }
615  else if(v >= m_lrcAnalysis->count())
616  {
618  }
619 
620  v = m_lrcAnalysis->findTime(v);
622  }
623 }
624 
626 {
627  MusicLrcContainer::resizeEvent(event);
628  resizeWindow();
629 }
630 
632 {
633  QActionGroup *group = new QActionGroup(this);
634  group->addAction(menu.addAction(tr("Yellow")))->setData(0);
635  group->addAction(menu.addAction(tr("Blue")))->setData(1);
636  group->addAction(menu.addAction(tr("Gray")))->setData(2);
637  group->addAction(menu.addAction(tr("Pink")))->setData(3);
638  group->addAction(menu.addAction(tr("Green")))->setData(4);
639  group->addAction(menu.addAction(tr("Red")))->setData(5);
640  group->addAction(menu.addAction(tr("Purple")))->setData(6);
641  group->addAction(menu.addAction(tr("Orange")))->setData(7);
642  group->addAction(menu.addAction(tr("Indigo")))->setData(8);
643  connect(group, SIGNAL(triggered(QAction*)), SLOT(changeCurrentLrcColor(QAction*)));
644  menu.addSeparator();
645  menu.addAction(tr("Custom"), this, SLOT(currentLrcCustom()));
646 
647  const int index = G_SETTING_PTR->value("LrcColor").toInt();
648  if(index > -1 && index < group->actions().count())
649  {
650  group->actions()[index]->setIcon(QIcon(":/contextMenu/btn_selected"));
651  }
652 }
653 
655 {
657  const qint64 beforeTime = setSongTimeSpeed(m_currentTime);
658  updateCurrentLrc(beforeTime);
659 
660  if(m_changeSpeedValue + pos == 0)
661  {
662  m_changeSpeedValue = 0;
663  }
664 
665  QString message;
666  if(m_changeSpeedValue > 0)
667  {
668  message = tr("After %1s").arg(m_changeSpeedValue * 1.0 / TTK_DN_S2MS);
669  }
670  else if(m_changeSpeedValue < 0)
671  {
672  message = tr("Before %1s").arg(-m_changeSpeedValue * 1.0 / TTK_DN_S2MS);
673  }
674  else
675  {
676  message = tr("Restore");
677  }
678 
679  MusicToastLabel::popup(message);
680 }
681 
683 {
688  m_noLrcCurrentInfo->setText(tr("Lrc Make"));
689 
690  connect(m_noLrcCurrentInfo, SIGNAL(clicked()), SLOT(showLrcMakedWidget()));
691  m_noLrcCurrentInfo->hide();
692 }
693 
695 {
696  const int w = TTK::Widget::fontTextWidth(m_noLrcCurrentInfo->font(), m_noLrcCurrentInfo->text());
697  const int h = TTK::Widget::fontTextHeight(m_noLrcCurrentInfo->font());
698  const int offset = height() / m_lrcAnalysis->lineMax() * (m_lrcAnalysis->lineMiddle() + 1) - 20;
699 
700  m_noLrcCurrentInfo->setGeometry((width() - w) / 2, offset, w, h);
701  m_noLrcCurrentInfo->show();
702 }
703 
705 {
706  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
707  {
708  m_lrcManagers[i]->setText({});
709  }
710  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->setText(str);
711 }
712 
714 {
715  m_functionLabel = new QWidget(this);
716  m_functionLabel->setFixedHeight(40);
717  m_functionLabel->lower();
718 
719  QHBoxLayout *functionLayout = new QHBoxLayout(m_functionLabel);
720  functionLayout->setContentsMargins(0, 0, 0, 0);
721 
722  QPushButton *translation = new QPushButton(this);
723  QPushButton *movie = new QPushButton(this);
724  QPushButton *message = new QPushButton(this);
725  QPushButton *photo = new QPushButton(this);
726 
727 #ifdef Q_OS_UNIX
728  translation->setFocusPolicy(Qt::NoFocus);
729  movie->setFocusPolicy(Qt::NoFocus);
730  message->setFocusPolicy(Qt::NoFocus);
731  photo->setFocusPolicy(Qt::NoFocus);
732 #endif
733 
734  translation->setFixedSize(30, 30);
735  movie->setFixedSize(30, 30);
736  message->setFixedSize(30, 30);
737  photo->setFixedSize(30, 30);
738 
739  translation->setStyleSheet(TTK::UI::InteriorTranslation);
740  movie->setStyleSheet(TTK::UI::InteriorMovie);
741  message->setStyleSheet(TTK::UI::InteriorMessage);
742  photo->setStyleSheet(TTK::UI::InteriorPhoto);
743 
744  translation->setCursor(Qt::PointingHandCursor);
745  movie->setCursor(Qt::PointingHandCursor);
746  message->setCursor(Qt::PointingHandCursor);
747  photo->setCursor(Qt::PointingHandCursor);
748 
749  translation->setToolTip(tr("Translation"));
750  movie->setToolTip(tr("Movie"));
751  message->setToolTip(tr("Message"));
752  photo->setToolTip(tr("Photo"));
753 
754  connect(translation, SIGNAL(clicked()), SLOT(translatedLrcData()));
755  connect(movie, SIGNAL(clicked()), SLOT(showSongMovieClicked()));
756  connect(message, SIGNAL(clicked()), SLOT(showSongCommentsWidget()));
757  connect(photo, SIGNAL(clicked()), m_lrcFloatWidget, SLOT(showArtistPhotoWidget()));
758 
759  functionLayout->addStretch(1);
760  functionLayout->addWidget(translation);
761  functionLayout->addWidget(movie);
762  functionLayout->addWidget(message);
763  functionLayout->addWidget(photo);
764  functionLayout->addStretch(1);
765  m_functionLabel->setLayout(functionLayout);
766 
767  layout()->addWidget(m_functionLabel);
768 }
769 
771 {
772  const int length = m_lrcAnalysis->lineMax();
773  if(length == 11)
774  {
775  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
776  {
777  if(i == 0 || i == 10)
778  {
779  setItemStyleSheet(i, 5, 90);
780  }
781  else if(i == 1 || i == 9)
782  {
783  setItemStyleSheet(i, 4, 80);
784  }
785  else if(i == 2 || i == 8)
786  {
787  setItemStyleSheet(i, 3, 60);
788  }
789  else if(i == 3 || i == 7)
790  {
791  setItemStyleSheet(i, 2, 40);
792  }
793  else if(i == 4 || i == 6)
794  {
795  setItemStyleSheet(i, 1, 20);
796  }
797  else
798  {
799  setItemStyleSheet(i, 0, 0);
800  }
801  }
802  }
803  else if(length == 9)
804  {
805  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
806  {
807  if(i == 0 || i == 8)
808  {
809  setItemStyleSheet(i, 8, 90);
810  }
811  else if(i == 1 || i == 7)
812  {
813  setItemStyleSheet(i, 6, 75);
814  }
815  else if(i == 2 || i == 6)
816  {
817  setItemStyleSheet(i, 4, 50);
818  }
819  else if(i == 3 || i == 5)
820  {
821  setItemStyleSheet(i, 2, 25);
822  }
823  else
824  {
825  setItemStyleSheet(i, 0, 0);
826  }
827  }
828  }
829  else if(length == 7)
830  {
831  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
832  {
833  if(i == 0 || i == 6)
834  {
835  setItemStyleSheet(i, 12, 90);
836  }
837  else if(i == 1 || i == 5)
838  {
839  setItemStyleSheet(i, 8, 60);
840  }
841  else if(i == 2 || i == 4)
842  {
843  setItemStyleSheet(i, 4, 30);
844  }
845  else
846  {
847  setItemStyleSheet(i, 0, 0);
848  }
849  }
850  }
851  else if(length == 5)
852  {
853  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
854  {
855  if(i == 0 || i == 4)
856  {
857  setItemStyleSheet(i, 16, 90);
858  }
859  else if(i == 1 || i == 3)
860  {
861  setItemStyleSheet(i, 8, 45);
862  }
863  else
864  {
865  setItemStyleSheet(i, 0, 0);
866  }
867  }
868  }
869  else if(length == 3)
870  {
871  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
872  {
873  if(i == 0 || i == 2)
874  {
875  setItemStyleSheet(i, 20, 90);
876  }
877  else
878  {
879  setItemStyleSheet(i, 0, 0);
880  }
881  }
882  }
883 }
884 
885 void MusicLrcContainerForInterior::setItemStyleSheet(int index, int size, int transparent)
886 {
888  w->setFontSize(size);
889 
890  int value = G_SETTING_PTR->value("LrcColorTransparent").toInt() - transparent;
891  value = (value < TTK_RN_MIN) ? TTK_RN_MIN : value;
892  value = (value > TTK_RN_MAX) ? TTK_RN_MAX : value;
893  w->setFontTransparent(value);
894  w->setTransparent(value);
895 
896  if(G_SETTING_PTR->value("LrcColor").toInt() != -1)
897  {
898  const MusicLrcColor::Color index = TTKStaticCast(MusicLrcColor::Color, G_SETTING_PTR->value("LrcColor").toInt());
899  setLinearGradientColor(index);
900  }
901  else
902  {
903  const MusicLrcColor cl(TTK::readColorConfig(G_SETTING_PTR->value("LrcFrontgroundColor").toString()),
904  TTK::readColorConfig(G_SETTING_PTR->value("LrcBackgroundColor").toString()));
906  }
907 }
908 
910 {
911  if(size <= 14)
912  {
913  return 0;
914  }
915  else if(14 < size && size <= 18)
916  {
917  return 2;
918  }
919  else if(18 < size && size <= 26)
920  {
921  return 4;
922  }
923  else if(26 < size && size <= 36)
924  {
925  return 6;
926  }
927  else if(36 < size && size <= 72)
928  {
929  return 8;
930  }
931  else
932  {
933  return -1;
934  }
935 }
936 
938 {
939  const int length = MUSIC_LRC_INTERIOR_MAX_LINE - property;
940  m_lrcAnalysis->setLineMax(length);
941 
942  for(MusicLrcManager *manager : qAsConst(m_lrcManagers))
943  {
944  manager->show();
945  manager->reset();
946  m_layoutWidget->removeWidget(manager);
947  }
948 
949  for(int i = 0; i < length; ++i)
950  {
952  }
953 
954  for(int i = length; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
955  {
956  m_lrcManagers[i]->hide();
957  }
958 }
959 
961 {
962  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
963  {
964  TTKObjectCast(MusicLrcManagerForInterior*, m_lrcManagers[i])->setLrcPerWidth(w);
965  }
966 
969  {
970  m_floatPlayWidget->resizeGeometry(width(), height());
971  }
972 
973  if(m_lrcAnalysis->isEmpty())
974  {
975  initCurrentLrc(tr("No lrc data file found"));
977  }
978  else if(m_currentTime != 0 && m_lrcAnalysis->currentIndex() == 0)
979  {
980  initCurrentLrc(tr("No song is playing now"));
981  }
982 
983  if(m_commentsWidget)
984  {
985  m_commentsWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
986  }
987 
989  {
990  m_translatedWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
991  }
992 }
static MusicRightAreaWidget * instance()
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:159
MusicLrcFloatPlayWidget * m_floatPlayWidget
The class of the lrc manager base.
The class of the lrc song comment widget.
static constexpr int LRC_TIME_LABEL_POSITION
MusicLrcAnalysis * m_lrcAnalysis
bool isValid() const
void revertTime(qint64 pos)
The class of the lrc color.
void setLineMax(int max)
void currentLrcUpdated()
#define TTK_AUTHOR_NAME
void setCurrentIndex(int index)
int lineMax() const
#define QtMouseGlobalY(p)
Definition: ttkqtcompat.h:147
void queryTranslatedLrcFinished(const QString &bytes)
#define G_BACKGROUND_PTR
MusicVLayoutAnimationWidget * m_layoutWidget
static MusicBottomAreaWidget * instance()
static constexpr const char * InteriorTranslation
virtual void applyParameter() overridefinal
QStringList dataList() const
voidpf void uLong size
Definition: ioapi.h:136
void updateCurrentTime(qint64 time)
static constexpr const char * InteriorMessage
The class of the label widget that can click.
TTK_MODULE_EXPORT void setFontStyle(QWidget *widget, TTK::FontStyleMode type)
#define TTK_RN_MAX
Definition: ttkglobal.h:359
static const QString ColorStyle12
Definition: musicuiobject.h:70
The class of the lrc art poster maker widget.
static void popup(const QString &text)
#define QtMouseGlobalPos(p)
Definition: ttkqtcompat.h:148
TTK_MODULE_EXPORT void setFontSize(QWidget *widget, int size)
The class of the lrc container base.
static constexpr const char * InteriorPhoto
voidpf uLong offset
Definition: ioapi.h:142
virtual void mousePressEvent(QMouseEvent *event) overridefinal
virtual void mouseReleaseEvent(QMouseEvent *event) overridefinal
The class of the lrc float widget.
int lineMiddle() const
#define qAsConst
Definition: ttkqtglobal.h:53
The class of the lrc play float widget.
static constexpr const char * InteriorMovie
The class of the translation words manager request.
virtual void mouseMoveEvent(QMouseEvent *event) overridefinal
bool isEmpty() const
The class of the vertical layout float animation widget.
The class of the interior lrc manager.
int currentIndex() const
QString text(int index) const
virtual void applyParameter()
virtual void paintEvent(QPaintEvent *event) overridefinal
void setCurrentSongName(const QString &name)
QString currentFilePath() const
void setPlainText(const QString &name, const QString &text)
virtual void startDrawLrc() overridefinal
#define TTK_RN_MIN
Definition: ttkglobal.h:358
void resizeGeometry(int width, int height)
qint64 setSongTimeSpeed(qint64 time)
virtual void start() overridefinal
qint64 findTime(int index) const
TTK_MODULE_EXPORT bool openUrl(const QString &path, bool local=true)
static constexpr int MUSIC_LRC_INTERIOR_MAX_LINE
void setText(const QString &str)
The class of the lrc translate widget.
static const QString MenuStyle02
void setHeader(const QString &key, const QVariant &value)
#define TTK_DN_S2MS
Definition: ttkglobal.h:276
static constexpr int LRC_CHANGED_OFFSET_LIMIT
TTK_MODULE_EXPORT int fontTextWidth(const QFont &font, const QString &text)
void changeCurrentLrcColor(QAction *action)
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:153
MusicLrcContainerForInterior(QWidget *parent=nullptr)
QString dataString() const
virtual void stopDrawLrc() overridefinal
virtual void mouseDoubleClickEvent(QMouseEvent *event) overridefinal
TTK_MODULE_EXPORT int fontTextHeight(const QFont &font)
QList< MusicLrcManager * > m_lrcManagers
void addWidget(QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
virtual void initialize(bool isPain) overridefinal
void setCurrentLrcs(const QStringList &lrcs, const QString &name)
void setLinearGradientColor(MusicLrcColor::Color color)
QList< QColor > readColorConfig(const QString &value)
virtual void contextMenuEvent(QContextMenuEvent *event) overridefinal
TTK_MODULE_EXPORT void adjustMenuPosition(QMenu *menu)
static constexpr const char * LRC_INTERIOR_TPYE
void showVideoSearchedFound(const QString &name, const QString &id)
virtual void resizeEvent(QResizeEvent *event) overridefinal
MusicLrcTranslatedWidget * m_translatedWidget
static MusicTopAreaWidget * instance()
state
Definition: http_parser.c:279
void resizeGeometry(int width, int height)
#define WINDOW_HEIGHT_MIN
Definition: musicobject.h:154
void setFontTransparent(int t)
#define G_SETTING_PTR
static qint64 formatDuration(const QString &time) noexcept
Definition: ttktime.cpp:123
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:60
#define LEFT_SIDE_WIDTH_MIN
Definition: musicobject.h:155