TTKMusicPlayer  4.1.3.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 "musictopareawidget.h"
18 #include "musicbackgroundmanager.h"
19 #include "musicwidgetheaders.h"
20 #include "ttkclickedlabel.h"
21 
22 #include <QClipboard>
23 #include <QApplication>
24 #include <QActionGroup>
25 
26 static constexpr int LRC_CHANGED_OFFSET_LIMIT = 20;
27 static constexpr int LRC_TIME_LABEL_POSITION = 20;
28 
30  : MusicLrcContainer(parent),
31  m_lrcChangeOffset(0),
32  m_lrcChangeDelta(-1),
33  m_mouseLeftPressed(false),
34  m_lrcChangeState(false),
35  m_mouseMoved(false),
36  m_lrcDisplayAll(false),
37  m_showArtistBackground(true),
38  m_animationFreshTime(0),
39  m_lrcSizeProperty(-1),
40  m_changeSpeedValue(0),
41  m_floatPlayWidget(nullptr),
42  m_commentsWidget(nullptr),
43  m_translatedWidget(nullptr)
44 {
45  QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
46  vBoxLayout->setContentsMargins(0, 0, 0, 0);
47  setLayout(vBoxLayout);
48 
53 
54  for(int i = 0; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
55  {
57  w->setText({});
59  m_lrcManagers.append(w);
60  }
61  vBoxLayout->addWidget(m_layoutWidget);
62 
65 
66  m_lrcManagers[MUSIC_LRC_INTERIOR_MAX_LINE / 2]->setText(tr("No song is playing now"));
67 }
68 
70 {
72  delete m_functionLabel;
73  delete m_lrcFloatWidget;
74  delete m_floatPlayWidget;
75  delete m_noLrcCurrentInfo;
76  delete m_commentsWidget;
77  delete m_translatedWidget;
78  delete m_layoutWidget;
79 }
80 
82 {
83  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->startDrawLrc();
84 }
85 
87 {
88  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->stopDrawLrc();
90 }
91 
93 {
95  const int size = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
96  if(m_lrcSizeProperty == -1)
97  {
99  }
100 
101  if(m_lrcChangeDelta == -1)
102  {
104  }
105 
106  setLrcSize(size);
107 }
108 
110 {
112  {
113  m_animationFreshTime = time;
115  }
116 }
117 
119 {
120  m_layoutWidget->stop();
121 
122  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
123  {
124  m_lrcManagers[i]->setText({});
125  }
126 
128  {
129  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->setText(tr("No lrc data file found"));
131  }
132  else
133  {
134  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->setText(tr("No song is playing now"));
135  m_noLrcCurrentInfo->hide();
136  }
137 }
138 
140 {
141  return m_lrcManagers[m_lrcAnalysis->lineMiddle()]->text();
142 }
143 
145 {
146  return m_lrcAnalysis->setSongTimeSpeed(time);
147 }
148 
150 {
151  int index = mapLrcSizeProperty(size);
152  if(index == -1)
153  {
154  return;
155  }
156 
157  setLrcSizeProperty(index);
158  index = (mapLrcSizeProperty(m_lrcSizeProperty) - index) / 2;
161 
162  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
163  {
164  m_lrcManagers[i]->setLrcFontSize(size);
165  m_lrcManagers[i]->setY(35 + size);
166  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i));
167  }
169 
170  resizeWindow();
172  startDrawLrc();
173 }
174 
176 {
177  return G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
178 }
179 
181 {
182  int width = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().width();
183  int height = G_SETTING_PTR->value(MusicSettingManager::WidgetSize).toSize().height();
184 
185  if(m_lrcDisplayAll)
186  {
187  width += LEFT_SIDE_WIDTH_MIN;
188  }
189 
190  if(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen())
191  {
192  width += (m_lrcDisplayAll ? 0 : LEFT_SIDE_WIDTH_MIN);
193  height += LEFT_SIDE_WIDTH_MIN / 2;
194  }
195 
197 }
198 
200 {
201  delete m_floatPlayWidget;
202  m_floatPlayWidget = nullptr;
203 
204  if(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen())
205  {
207  m_floatPlayWidget->resizeGeometry(width(), height());
208  }
209 }
210 
212 {
213  QHBoxLayout *layout = TTKObjectCast(QHBoxLayout*, m_functionLabel->layout());
215  {
216  layout->removeItem(layout->itemAt(layout->count() - 1));
217  }
218  else
219  {
220  layout->addStretch(1);
221  }
222 }
223 
225 {
226  switch(action->data().toInt())
227  {
228  case 0: setLrcSize(14); break;
229  case 1: setLrcSize(18); break;
230  case 2: setLrcSize(26); break;
231  case 3: setLrcSize(36); break;
232  case 4: setLrcSize(72); break;
233  default: break;
234  }
235 }
236 
238 {
239  int timeValue = 0;
240  switch(action->data().toInt())
241  {
242  case 0: timeValue = -0.5 * TTK_DN_S2MS; break;
243  case 1: timeValue = -1.0 * TTK_DN_S2MS; break;
244  case 2: timeValue = -2.0 * TTK_DN_S2MS; break;
245  case 3: timeValue = -5.0 * TTK_DN_S2MS; break;
246  case 4: timeValue = 0.5 * TTK_DN_S2MS; break;
247  case 5: timeValue = 1.0 * TTK_DN_S2MS; break;
248  case 6: timeValue = 2.0 * TTK_DN_S2MS; break;
249  case 7: timeValue = 5.0 * TTK_DN_S2MS; break;
250  default: break;
251  }
252 
253  m_changeSpeedValue += timeValue;
254  revertTimeSpeed(timeValue);
255 }
256 
258 {
259  if(m_changeSpeedValue == 0)
260  {
261  return;
262  }
264 }
265 
267 {
269 }
270 
272 {
274  Q_EMIT backgroundChanged();
275 }
276 
278 {
279  TTK::Url::openUrl(QFileInfo(m_lrcAnalysis->currentFilePath()).absoluteFilePath());
280 }
281 
283 {
284  QClipboard *clipBoard = QApplication::clipboard();
285  clipBoard->setText(m_lrcAnalysis->dataString());
286 }
287 
289 {
290  MusicLrcLocalLinkWidget widget(this);
292  widget.exec();
293 }
294 
296 {
297  if(m_currentSongName.isEmpty())
298  {
299  return;
300  }
301 
302  delete m_commentsWidget;
305  m_commentsWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
307  m_commentsWidget->show();
308 }
309 
311 {
312  MusicLrcPosterWidget widget(this);
314  widget.exec();
315 }
316 
318 {
319  QString text;
320 
321  if(bytes.startsWith(TTK_AUTHOR_NAME))
322  {
323  // The original and translated lrc have been merged
324  text = bytes;
325  text.remove(0, strlen(TTK_AUTHOR_NAME));
326  }
327  else
328  {
329  const QStringList &orts = m_lrcAnalysis->dataList();
330  const QStringList &trts = bytes.split(TTK_LINEFEED);
331 
332  if(orts.count() > trts.count())
333  {
334  return;
335  }
336 
337  for(int i = 0; i < orts.count(); ++i)
338  {
339  text += orts[i].trimmed() + TTK_WLINEFEED;
340  text += trts[i].trimmed() + TTK_WLINEFEED;
341  }
342  }
343 
344  delete m_translatedWidget;
347  m_translatedWidget->setGeometry(0, height() / 5.0, width(), height() * 4 / 5.0);
348  m_translatedWidget->show();
349 }
350 
352 {
353  if(m_currentSongName.isEmpty())
354  {
355  return;
356  }
357 
359  {
361  }
363 }
364 
366 {
367  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
368  {
369  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i));
370  }
371 
375 }
376 
378 {
379  const QString &path = m_lrcAnalysis->currentFilePath();
380  if(path.isEmpty())
381  {
382  return;
383  }
384 
386  connect(d, SIGNAL(downLoadDataChanged(QString)), SLOT(queryTranslatedLrcFinished(QString)));
387  d->setHeader("name", path);
388  d->setHeader("data", m_lrcAnalysis->dataString());
389  d->startToRequest();
390 }
391 
393 {
394  Q_UNUSED(event);
395  QMenu menu(this);
396  QMenu changColorMenu(tr("Color"), &menu);
397  QMenu changeLrcSize(tr("Lrc Size"), &menu);
398  QMenu changeLrcTimeFast(tr("Time After"), &menu);
399  QMenu changeLrcTimeSlow(tr("Time Before"), &menu);
400  QMenu changeLrcLinkMenu(tr("Lrc Link"), &menu);
401 
402  menu.setStyleSheet(TTK::UI::MenuStyle02);
403 
404  const bool hasLrcContainer = !m_lrcAnalysis->isEmpty();
405  menu.addAction(tr("Lrc Search"), this, SLOT(searchMusicLrcs()));
406  menu.addAction(tr("Lrc Update"), this, SIGNAL(currentLrcUpdated()));
407  menu.addAction(tr("Lrc Make"), this, SLOT(showLrcMakedWidget()));
408  menu.addAction(tr("Lrc Poster"), this, SLOT(showLrcPosterWidget()))->setEnabled(hasLrcContainer);
409  menu.addSeparator();
410  menu.addAction(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen() ? tr("Show Normal Mode") : tr("Show Fullscreen Mode"),
412  menu.addSeparator();
413  menu.addMenu(&changColorMenu);
414  menu.addMenu(&changeLrcSize);
415 
416  menu.addMenu(&changeLrcTimeFast)->setEnabled(hasLrcContainer);
417  menu.addMenu(&changeLrcTimeSlow)->setEnabled(hasLrcContainer);
418  menu.addAction(tr("Revert Mode"), this, SLOT(revertLrcTimeSpeed()))->setEnabled(hasLrcContainer);
419  menu.addAction(tr("Save Mode"), this, SLOT(saveLrcTimeChanged()))->setEnabled(hasLrcContainer);
420  menu.addSeparator();
421 
422  QActionGroup *group = new QActionGroup(this);
423  group->addAction(changeLrcSize.addAction(tr("Smaller")))->setData(0);
424  group->addAction(changeLrcSize.addAction(tr("Small")))->setData(1);
425  group->addAction(changeLrcSize.addAction(tr("Middle")))->setData(2);
426  group->addAction(changeLrcSize.addAction(tr("Big")))->setData(3);
427  group->addAction(changeLrcSize.addAction(tr("Bigger")))->setData(4);
428 
429  int index = -1, size = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
430  switch(size)
431  {
432  case 14: index = 0; break;
433  case 18: index = 1; break;
434  case 26: index = 2; break;
435  case 36: index = 3; break;
436  case 72: index = 4; break;
437  default: break;
438  }
439 
440  if(index > -1 && index < group->actions().count())
441  {
442  group->actions()[index]->setIcon(QIcon(":/contextMenu/btn_selected"));
443  }
444  connect(group, SIGNAL(triggered(QAction*)), SLOT(lrcSizeChanged(QAction*)));
445 
446  changeLrcSize.addSeparator();
447  changeLrcSize.addAction(tr("Custom"), this, SLOT(currentLrcCustom()));
448  createColorMenu(changColorMenu);
449 
450  QActionGroup *lrcTimeFastGroup = new QActionGroup(this);
451  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 0.5s")))->setData(0);
452  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 1.0s")))->setData(1);
453  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 2.0s")))->setData(2);
454  lrcTimeFastGroup->addAction(changeLrcTimeFast.addAction(tr("After 5.0s")))->setData(3);
455  connect(lrcTimeFastGroup, SIGNAL(triggered(QAction*)), SLOT(lrcTimeSpeedChanged(QAction*)));
456  TTK::Widget::adjustMenuPosition(&changeLrcTimeFast);
457  //
458  QActionGroup *lrcTimeSlowGroup = new QActionGroup(this);
459  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 0.5s")))->setData(4);
460  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 1.0s")))->setData(5);
461  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 2.0s")))->setData(6);
462  lrcTimeSlowGroup->addAction(changeLrcTimeSlow.addAction(tr("Before 5.0s")))->setData(7);
463  connect(lrcTimeSlowGroup, SIGNAL(triggered(QAction*)), SLOT(lrcTimeSpeedChanged(QAction*)));
464  TTK::Widget::adjustMenuPosition(&changeLrcTimeSlow);
465  //
466  QAction *artAction = menu.addAction(tr("Art Turn Off"), this, SLOT(artistBackgroundChanged()));
467  m_showArtistBackground ? artAction->setText(tr("Art Turn Off")) : artAction->setText(tr("Art Turn On"));
468  QAction *showLrc = menu.addAction(tr("Lrc Turn Off"), this, SLOT(linkLrcStateChanged()));
469  m_linkLocalLrc ? showLrc->setText(tr("Lrc Turn Off")) : showLrc->setText(tr("Lrc Turn On"));
470  menu.addAction(tr("Set As Background"), MusicTopAreaWidget::instance(), SLOT(setArtistBackground()))->setEnabled(!G_BACKGROUND_PTR->isEmpty());
471  menu.addSeparator();
472 
473  const QString &filePath = m_lrcAnalysis->currentFilePath();
474  const bool fileCheck = !filePath.isEmpty() && QFile::exists(filePath);
475 
476  changeLrcLinkMenu.addAction(tr("Local Lrc Link"), this, SLOT(showLocalLinkWidget()));
477  QAction *lrcLinkAc = changeLrcLinkMenu.addAction(tr("Link Off"), this, SLOT(linkLrcStateChanged()));
478  m_linkLocalLrc ? lrcLinkAc->setText(tr("Link Off")) : lrcLinkAc->setText(tr("Link On"));
479  TTK::Widget::adjustMenuPosition(&changeLrcLinkMenu);
480  menu.addMenu(&changeLrcLinkMenu);
481 
482  menu.addAction(tr("Copy To Clip"), this, SLOT(lrcCopyClipboard()))->setEnabled(fileCheck);
483  menu.addAction(tr("Open Lrc File"), this, SLOT(lrcOpenFileDir()))->setEnabled(fileCheck);
484 
485  menu.addSeparator();
486  menu.addAction(tr("Settings"), this, SLOT(currentLrcCustom()));
487 
489  menu.exec(QCursor::pos());
490 }
491 
493 {
494  if(event->button() == Qt::LeftButton)
495  {
496  if(m_functionLabel && m_functionLabel->geometry().contains(event->pos()))
497  {
498  return; //block mouse event in function label area
499  }
500 
501  m_mouseMoved = false;
502  m_mouseLeftPressed = true;
504  m_lrcChangeState = false;
505  m_lrcChangeOffset = 0;
506 
507  setCursor(Qt::CrossCursor);
508  update();
509  }
510 }
511 
513 {
515  {
516  m_layoutWidget->stop();
517 
518  m_mouseMoved = true;
519  const int offset = QtMouseGlobalY(event) - m_mousePressedAt.y();
521 
523  if(m_lrcChangeState && offset > 0)
524  {
525  m_lrcChangeState = false;
526  m_lrcChangeOffset = 0;
527  }
528  else if(!m_lrcChangeState && offset < 0)
529  {
530  m_lrcChangeState = true;
531  m_lrcChangeOffset = 0;
532  }
533 
535  {
536  int index = m_lrcAnalysis->currentIndex();
538  m_lrcChangeOffset = 0;
539 
540  if(index < 0)
541  {
542  index = 0;
543  }
544  else if(index >= m_lrcAnalysis->count())
545  {
546  index = m_lrcAnalysis->count() - m_lrcAnalysis->lineMiddle() + 2;
547  }
548 
549  int value = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
551 
553  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
554  {
555  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i - value - 1));
556  }
558  }
559 
560  update();
561  }
562 }
563 
565 {
566  if(event->button() == Qt::LeftButton)
567  {
568  setCursor(Qt::ArrowCursor);
569  m_mouseLeftPressed = false;
571  update();
572 
574  {
575  const qint64 time = m_lrcAnalysis->findTime(m_lrcAnalysis->currentIndex());
576  if(time != -1)
577  {
578  Q_EMIT updateCurrentTime(time);
579  }
580  }
581  }
582 }
583 
585 {
586  if(m_functionLabel && m_functionLabel->geometry().contains(event->pos()))
587  {
588  return; //block mouse event in function label area
589  }
591 }
592 
594 {
595  Q_UNUSED(event);
597  {
598  QLinearGradient linearGradient(0, 0, width(), 0);
599  linearGradient.setColorAt(0.0, QColor(255, 254, 161));
600  linearGradient.setColorAt(0.3, Qt::transparent);
601  linearGradient.setColorAt(0.7, Qt::transparent);
602  linearGradient.setColorAt(1.0, QColor(255, 254, 161));
603 
604  const int line = (height() - m_functionLabel->height()) / 2;
605  QPainter painter(this);
606  painter.setPen(QPen(linearGradient, 1));
607  painter.drawLine(LRC_TIME_LABEL_POSITION, line, width() - LRC_TIME_LABEL_POSITION, line);
608 
609  qint64 v = m_lrcAnalysis->currentIndex() - 1;
610  if(v < 0)
611  {
612  v = 0;
613  }
614  else if(v >= m_lrcAnalysis->count())
615  {
617  }
618 
619  v = m_lrcAnalysis->findTime(v);
621  }
622 }
623 
625 {
626  MusicLrcContainer::resizeEvent(event);
627  resizeWindow();
628 }
629 
631 {
632  QActionGroup *group = new QActionGroup(this);
633  group->addAction(menu.addAction(tr("Yellow")))->setData(0);
634  group->addAction(menu.addAction(tr("Blue")))->setData(1);
635  group->addAction(menu.addAction(tr("Gray")))->setData(2);
636  group->addAction(menu.addAction(tr("Pink")))->setData(3);
637  group->addAction(menu.addAction(tr("Green")))->setData(4);
638  group->addAction(menu.addAction(tr("Red")))->setData(5);
639  group->addAction(menu.addAction(tr("Purple")))->setData(6);
640  group->addAction(menu.addAction(tr("Orange")))->setData(7);
641  group->addAction(menu.addAction(tr("Indigo")))->setData(8);
642  connect(group, SIGNAL(triggered(QAction*)), SLOT(changeCurrentLrcColor(QAction*)));
643  menu.addSeparator();
644  menu.addAction(tr("Custom"), this, SLOT(currentLrcCustom()));
645 
646  const int index = G_SETTING_PTR->value("LrcColor").toInt();
647  if(index > -1 && index < group->actions().count())
648  {
649  group->actions()[index]->setIcon(QIcon(":/contextMenu/btn_selected"));
650  }
651 }
652 
654 {
656  const qint64 beforeTime = setSongTimeSpeed(m_currentTime);
657  updateCurrentLrc(beforeTime);
658 
659  if(m_changeSpeedValue + pos == 0)
660  {
661  m_changeSpeedValue = 0;
662  }
663 
664  QString message;
665  if(m_changeSpeedValue > 0)
666  {
667  message = tr("After %1s").arg(m_changeSpeedValue * 1.0 / TTK_DN_S2MS);
668  }
669  else if(m_changeSpeedValue < 0)
670  {
671  message = tr("Before %1s").arg(-m_changeSpeedValue * 1.0 / TTK_DN_S2MS);
672  }
673  else
674  {
675  message = tr("Restore");
676  }
677 
678  MusicToastLabel::popup(message);
679 }
680 
682 {
687  m_noLrcCurrentInfo->setText(tr("Lrc Make"));
688 
689  connect(m_noLrcCurrentInfo, SIGNAL(clicked()), SLOT(showLrcMakedWidget()));
690  m_noLrcCurrentInfo->hide();
691 }
692 
694 {
695  const int w = TTK::Widget::fontTextWidth(m_noLrcCurrentInfo->font(), m_noLrcCurrentInfo->text());
696  const int h = TTK::Widget::fontTextHeight(m_noLrcCurrentInfo->font());
697  const int offset = height() / m_lrcAnalysis->lineMax() * (m_lrcAnalysis->lineMiddle() + 1) - 20;
698 
699  m_noLrcCurrentInfo->setGeometry((width() - w) / 2, offset, w, h);
700  m_noLrcCurrentInfo->show();
701 }
702 
704 {
705  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
706  {
707  m_lrcManagers[i]->setText({});
708  }
709  m_lrcManagers[m_lrcAnalysis->lineMiddle()]->setText(str);
710 }
711 
713 {
714  m_functionLabel = new QWidget(this);
715  m_functionLabel->setFixedHeight(40);
716  m_functionLabel->lower();
717 
718  QHBoxLayout *functionLayout = new QHBoxLayout(m_functionLabel);
719  functionLayout->setContentsMargins(0, 0, 0, 0);
720 
721  QPushButton *transButton = new QPushButton(this);
722  QPushButton *movieButton = new QPushButton(this);
723  QPushButton *messageButton = new QPushButton(this);
724  QPushButton *photoButton = new QPushButton(this);
725 
726 #ifdef Q_OS_UNIX
727  transButton->setFocusPolicy(Qt::NoFocus);
728  movieButton->setFocusPolicy(Qt::NoFocus);
729  messageButton->setFocusPolicy(Qt::NoFocus);
730  photoButton->setFocusPolicy(Qt::NoFocus);
731 #endif
732 
733  transButton->setFixedSize(30, 30);
734  movieButton->setFixedSize(30, 30);
735  messageButton->setFixedSize(30, 30);
736  photoButton->setFixedSize(30, 30);
737 
738  transButton->setStyleSheet(TTK::UI::InteriorTranslation);
739  movieButton->setStyleSheet(TTK::UI::InteriorMovie);
740  messageButton->setStyleSheet(TTK::UI::InteriorMessage);
741  photoButton->setStyleSheet(TTK::UI::InteriorPhoto);
742 
743  transButton->setCursor(Qt::PointingHandCursor);
744  movieButton->setCursor(Qt::PointingHandCursor);
745  messageButton->setCursor(Qt::PointingHandCursor);
746  photoButton->setCursor(Qt::PointingHandCursor);
747 
748  transButton->setToolTip(tr("Translation"));
749  movieButton->setToolTip(tr("Movie"));
750  messageButton->setToolTip(tr("Message"));
751  photoButton->setToolTip(tr("Photo"));
752 
753  connect(transButton, SIGNAL(clicked()), SLOT(translatedLrcData()));
754  connect(movieButton, SIGNAL(clicked()), SLOT(showSongMovieClicked()));
755  connect(messageButton, SIGNAL(clicked()), SLOT(showSongCommentsWidget()));
756  connect(photoButton, SIGNAL(clicked()), m_lrcFloatWidget, SLOT(showArtistPhotoWidget()));
757 
758  functionLayout->addStretch(1);
759  functionLayout->addWidget(transButton);
760  functionLayout->addWidget(movieButton);
761  functionLayout->addWidget(messageButton);
762  functionLayout->addWidget(photoButton);
763  functionLayout->addStretch(1);
764  m_functionLabel->setLayout(functionLayout);
765 
766  layout()->addWidget(m_functionLabel);
767 }
768 
770 {
771  const int length = m_lrcAnalysis->lineMax();
772  if(length == 11)
773  {
774  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
775  {
776  if(i == 0 || i == 10)
777  {
778  setItemStyleSheet(i, 5, 90);
779  }
780  else if(i == 1 || i == 9)
781  {
782  setItemStyleSheet(i, 4, 80);
783  }
784  else if(i == 2 || i == 8)
785  {
786  setItemStyleSheet(i, 3, 60);
787  }
788  else if(i == 3 || i == 7)
789  {
790  setItemStyleSheet(i, 2, 40);
791  }
792  else if(i == 4 || i == 6)
793  {
794  setItemStyleSheet(i, 1, 20);
795  }
796  else
797  {
798  setItemStyleSheet(i, 0, 0);
799  }
800  }
801  }
802  else if(length == 9)
803  {
804  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
805  {
806  if(i == 0 || i == 8)
807  {
808  setItemStyleSheet(i, 8, 90);
809  }
810  else if(i == 1 || i == 7)
811  {
812  setItemStyleSheet(i, 6, 75);
813  }
814  else if(i == 2 || i == 6)
815  {
816  setItemStyleSheet(i, 4, 50);
817  }
818  else if(i == 3 || i == 5)
819  {
820  setItemStyleSheet(i, 2, 25);
821  }
822  else
823  {
824  setItemStyleSheet(i, 0, 0);
825  }
826  }
827  }
828  else if(length == 7)
829  {
830  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
831  {
832  if(i == 0 || i == 6)
833  {
834  setItemStyleSheet(i, 12, 90);
835  }
836  else if(i == 1 || i == 5)
837  {
838  setItemStyleSheet(i, 8, 60);
839  }
840  else if(i == 2 || i == 4)
841  {
842  setItemStyleSheet(i, 4, 30);
843  }
844  else
845  {
846  setItemStyleSheet(i, 0, 0);
847  }
848  }
849  }
850  else if(length == 5)
851  {
852  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
853  {
854  if(i == 0 || i == 4)
855  {
856  setItemStyleSheet(i, 16, 90);
857  }
858  else if(i == 1 || i == 3)
859  {
860  setItemStyleSheet(i, 8, 45);
861  }
862  else
863  {
864  setItemStyleSheet(i, 0, 0);
865  }
866  }
867  }
868  else if(length == 3)
869  {
870  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
871  {
872  if(i == 0 || i == 2)
873  {
874  setItemStyleSheet(i, 20, 90);
875  }
876  else
877  {
878  setItemStyleSheet(i, 0, 0);
879  }
880  }
881  }
882 }
883 
884 void MusicLrcContainerForInterior::setItemStyleSheet(int index, int size, int transparent)
885 {
887  w->setFontSize(size);
888 
889  int value = G_SETTING_PTR->value("LrcColorTransparent").toInt() - transparent;
890  value = (value < TTK_RN_MIN) ? TTK_RN_MIN : value;
891  value = (value > TTK_RN_MAX) ? TTK_RN_MAX : value;
892  w->setFontTransparent(value);
893  w->setTransparent(value);
894 
895  if(G_SETTING_PTR->value("LrcColor").toInt() != -1)
896  {
898  }
899  else
900  {
901  setLinearGradientColor({TTK::readColorConfig(G_SETTING_PTR->value("LrcFrontgroundColor").toString()),
902  TTK::readColorConfig(G_SETTING_PTR->value("LrcBackgroundColor").toString())});
903  }
904 }
905 
907 {
908  if(size <= 14)
909  {
910  return 0;
911  }
912  else if(14 < size && size <= 18)
913  {
914  return 2;
915  }
916  else if(18 < size && size <= 26)
917  {
918  return 4;
919  }
920  else if(26 < size && size <= 36)
921  {
922  return 6;
923  }
924  else if(36 < size && size <= 72)
925  {
926  return 8;
927  }
928  else
929  {
930  return -1;
931  }
932 }
933 
935 {
936  const int length = MUSIC_LRC_INTERIOR_MAX_LINE - property;
937  m_lrcAnalysis->setLineMax(length);
938 
939  for(MusicLrcManager *manager : qAsConst(m_lrcManagers))
940  {
941  manager->show();
942  manager->reset();
943  m_layoutWidget->removeWidget(manager);
944  }
945 
946  for(int i = 0; i < length; ++i)
947  {
949  }
950 
951  for(int i = length; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
952  {
953  m_lrcManagers[i]->hide();
954  }
955 }
956 
958 {
959  for(int i = 0; i < m_lrcAnalysis->lineMax(); ++i)
960  {
961  TTKObjectCast(MusicLrcManagerForInterior*, m_lrcManagers[i])->setLrcPerWidth(w);
962  }
963 
966  {
967  m_floatPlayWidget->resizeGeometry(width(), height());
968  }
969 
970  if(m_lrcAnalysis->isEmpty())
971  {
972  initCurrentLrc(tr("No lrc data file found"));
974  }
975  else if(m_currentTime != 0 && m_lrcAnalysis->currentIndex() == 0)
976  {
977  initCurrentLrc(tr("No song is playing now"));
978  }
979 
980  if(m_commentsWidget)
981  {
982  m_commentsWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
983  }
984 
986  {
987  m_translatedWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
988  }
989 }
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)
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:364
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:51
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:363
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:281
static constexpr int LRC_CHANGED_OFFSET_LIMIT
TTK_MODULE_EXPORT int fontTextWidth(const QFont &font, const QString &text)
void changeCurrentLrcColor(QAction *action)
#define TTK_WLINEFEED
Definition: ttkglobal.h:199
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:155
MusicLrcContainerForInterior(QWidget *parent=nullptr)
QString dataString() const
virtual void stopDrawLrc() overridefinal
virtual void mouseDoubleClickEvent(QMouseEvent *event) overridefinal
#define TTK_LINEFEED
Definition: ttkglobal.h:198
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:156
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:76
#define LEFT_SIDE_WIDTH_MIN
Definition: musicobject.h:157