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