TTKMusicPlayer  4.3.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"
6 #include "musictoastlabel.h"
7 #include "musiclrcanalysis.h"
8 #include "musicurlutils.h"
9 #include "musicvoicepopwidget.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_timePositionOffset(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->middle()]->start();
83 }
84 
86 {
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  // update state
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->maximum(); ++i)
124  {
125  m_lrcManagers[i]->setText({});
126  }
127 
129  {
130  m_lrcManagers[m_lrcAnalysis->middle()]->setText(tr("No lrc data file found"));
132  }
133  else
134  {
135  m_lrcManagers[m_lrcAnalysis->middle()]->setText(tr("No song is playing now"));
136  m_noLrcCurrentInfo->hide();
137  }
138 }
139 
141 {
142  return m_lrcManagers[m_lrcAnalysis->middle()]->text();
143 }
144 
146 {
147  return m_lrcAnalysis->findTimePosition(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->maximum(); ++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  resizeGeometry();
173  start();
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_timePositionOffset += timeValue;
255  setTimePosition(timeValue);
256 }
257 
259 {
260  if(m_timePositionOffset == 0)
261  {
262  return;
263  }
264 
266 }
267 
269 {
270  m_lrcAnalysis->save();
271 }
272 
274 {
276  Q_EMIT backgroundChanged();
277 }
278 
280 {
282 }
283 
285 {
286  QClipboard *clipBoard = QApplication::clipboard();
287  clipBoard->setText(m_lrcAnalysis->dataString());
288 }
289 
291 {
292  MusicLrcLocalLinkWidget widget(this);
294  widget.exec();
295 }
296 
298 {
299  if(m_currentSongName.isEmpty())
300  {
301  return;
302  }
303 
304  delete m_commentsWidget;
307  m_commentsWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
308  m_commentsWidget->show();
309 
310  MusicToastLabel::popup(tr("Loading now ... "));
312 }
313 
315 {
316  MusicLrcPosterWidget widget(this);
318  widget.exec();
319 }
320 
322 {
323  if(m_currentSongName.isEmpty())
324  {
325  return;
326  }
327 
329  {
331  }
333 }
334 
336 {
337  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
338  {
339  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i));
340  }
341 
345 }
346 
348 {
349  const QString &path = m_lrcAnalysis->filePath();
350  if(path.isEmpty())
351  {
352  return;
353  }
354 
355  delete m_translatedWidget;
358  m_translatedWidget->setGeometry(0, height() / 5.0, width(), height() * 4 / 5.0);
359  m_translatedWidget->show();
360 
361  MusicToastLabel::popup(tr("Loading now ... "));
363 }
364 
366 {
367  Q_UNUSED(event);
368  QMenu menu(this);
369  menu.setStyleSheet(TTK::UI::MenuStyle02);
370 
371  const bool hasLrcContainer = !m_lrcAnalysis->isEmpty();
372  menu.addAction(tr("Lrc Search"), this, SLOT(searchMusicLrcs()));
373  menu.addAction(tr("Lrc Update"), this, SIGNAL(currentLrcUpdated()));
374  menu.addAction(tr("Lrc Make"), this, SLOT(showLrcMakedWidget()));
375  menu.addAction(tr("Lrc Poster"), this, SLOT(showLrcPosterWidget()))->setEnabled(hasLrcContainer);
376  menu.addSeparator();
377  menu.addAction(MusicBottomAreaWidget::instance()->isLrcWidgetShowFullScreen() ? tr("Show Normal Mode") : tr("Show Fullscreen Mode"),
379  menu.addSeparator();
380 
381  QMenu *colorMenu = menu.addMenu(tr("Color"));
382  QMenu *lrcSizeMenu = menu.addMenu(tr("Lrc Size"));
383  QMenu *lrcTimeFastMenu = menu.addMenu(tr("Time After"));
384  QMenu *lrcTimeSlowMenu = menu.addMenu(tr("Time Before"));
385  lrcTimeFastMenu->setEnabled(hasLrcContainer);
386  lrcTimeSlowMenu->setEnabled(hasLrcContainer);
387 
388  menu.addAction(tr("Revert Mode"), this, SLOT(revertTimePosition()))->setEnabled(hasLrcContainer);
389  menu.addAction(tr("Save Mode"), this, SLOT(saveLrcTimeChanged()))->setEnabled(hasLrcContainer);
390  menu.addSeparator();
391 
392  QActionGroup *actions = new QActionGroup(this);
393  actions->addAction(lrcSizeMenu->addAction(tr("Smaller")))->setData(0);
394  actions->addAction(lrcSizeMenu->addAction(tr("Small")))->setData(1);
395  actions->addAction(lrcSizeMenu->addAction(tr("Middle")))->setData(2);
396  actions->addAction(lrcSizeMenu->addAction(tr("Big")))->setData(3);
397  actions->addAction(lrcSizeMenu->addAction(tr("Bigger")))->setData(4);
398 
399  int index = -1, size = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
400  switch(size)
401  {
402  case 14: index = 0; break;
403  case 18: index = 1; break;
404  case 26: index = 2; break;
405  case 36: index = 3; break;
406  case 72: index = 4; break;
407  default: break;
408  }
409 
410  if(index > -1 && index < actions->actions().count())
411  {
412  actions->actions()[index]->setIcon(QIcon(":/contextMenu/btn_selected"));
413  }
414  connect(actions, SIGNAL(triggered(QAction*)), SLOT(lrcSizeChanged(QAction*)));
415 
416  lrcSizeMenu->addSeparator();
417  lrcSizeMenu->addAction(tr("Custom"), this, SLOT(currentLrcCustom()));
418  createColorMenu(colorMenu);
419 
420  QActionGroup *lrcTimeFastActions = new QActionGroup(this);
421  lrcTimeFastActions->addAction(lrcTimeFastMenu->addAction(tr("After 0.5s")))->setData(0);
422  lrcTimeFastActions->addAction(lrcTimeFastMenu->addAction(tr("After 1.0s")))->setData(1);
423  lrcTimeFastActions->addAction(lrcTimeFastMenu->addAction(tr("After 2.0s")))->setData(2);
424  lrcTimeFastActions->addAction(lrcTimeFastMenu->addAction(tr("After 5.0s")))->setData(3);
425  connect(lrcTimeFastActions, SIGNAL(triggered(QAction*)), SLOT(lrcTimePositionChanged(QAction*)));
426  TTK::Widget::adjustMenuPosition(lrcTimeFastMenu);
427  //
428  QActionGroup *lrcTimeSlowActions = new QActionGroup(this);
429  lrcTimeSlowActions->addAction(lrcTimeSlowMenu->addAction(tr("Before 0.5s")))->setData(4);
430  lrcTimeSlowActions->addAction(lrcTimeSlowMenu->addAction(tr("Before 1.0s")))->setData(5);
431  lrcTimeSlowActions->addAction(lrcTimeSlowMenu->addAction(tr("Before 2.0s")))->setData(6);
432  lrcTimeSlowActions->addAction(lrcTimeSlowMenu->addAction(tr("Before 5.0s")))->setData(7);
433  connect(lrcTimeSlowActions, SIGNAL(triggered(QAction*)), SLOT(lrcTimePositionChanged(QAction*)));
434  TTK::Widget::adjustMenuPosition(lrcTimeSlowMenu);
435  //
436  QAction *artAction = menu.addAction(tr("Art Turn Off"), this, SLOT(artistBackgroundChanged()));
437  m_showArtistBackground ? artAction->setText(tr("Art Turn Off")) : artAction->setText(tr("Art Turn On"));
438  QAction *showLrc = menu.addAction(tr("Lrc Turn Off"), this, SLOT(linkLrcStateChanged()));
439  m_linkLocalLrc ? showLrc->setText(tr("Lrc Turn Off")) : showLrc->setText(tr("Lrc Turn On"));
440  menu.addAction(tr("Set As Background"), MusicTopAreaWidget::instance(), SLOT(setArtistBackground()))->setEnabled(!G_BACKGROUND_PTR->isEmpty());
441  menu.addSeparator();
442 
443  const QString &filePath = m_lrcAnalysis->filePath();
444  const bool fileCheck = !filePath.isEmpty() && QFile::exists(filePath);
445 
446  QMenu *lrcLinkMenu = menu.addMenu(tr("Lrc Link"));
447  lrcLinkMenu->addAction(tr("Local Lrc Link"), this, SLOT(showLocalLinkWidget()));
448  QAction *lrcLinkAc = lrcLinkMenu->addAction(tr("Link Off"), this, SLOT(linkLrcStateChanged()));
449  m_linkLocalLrc ? lrcLinkAc->setText(tr("Link Off")) : lrcLinkAc->setText(tr("Link On"));
450  TTK::Widget::adjustMenuPosition(lrcLinkMenu);
451 
452  menu.addAction(tr("Copy To Clip"), this, SLOT(lrcCopyClipboard()))->setEnabled(fileCheck);
453  menu.addAction(tr("Open Lrc File"), this, SLOT(lrcOpenFileDir()))->setEnabled(fileCheck);
454 
455  menu.addSeparator();
456  menu.addAction(tr("Settings"), this, SLOT(currentLrcCustom()));
457 
459  menu.exec(QCursor::pos());
460 }
461 
463 {
464  if(event->button() == Qt::LeftButton)
465  {
466  if(m_functionLabel && m_functionLabel->geometry().contains(event->pos()))
467  {
468  return; //block mouse event in function label area
469  }
470 
471  m_mouseMoved = false;
472  m_mouseLeftPressed = true;
474  m_lrcChangeState = false;
475  m_lrcChangeOffset = 0;
476 
477  setCursor(Qt::CrossCursor);
478  update();
479  }
480 }
481 
483 {
485  {
486  m_layoutWidget->stop();
487 
488  m_mouseMoved = true;
489  const int offset = QtGlobalPositionY(event) - m_pressedPos.y();
491 
493  if(m_lrcChangeState && offset > 0)
494  {
495  m_lrcChangeState = false;
496  m_lrcChangeOffset = 0;
497  }
498  else if(!m_lrcChangeState && offset < 0)
499  {
500  m_lrcChangeState = true;
501  m_lrcChangeOffset = 0;
502  }
503 
505  {
506  int index = m_lrcAnalysis->currentIndex();
508  m_lrcChangeOffset = 0;
509 
510  if(index < 0)
511  {
512  index = 0;
513  }
514  else if(index >= m_lrcAnalysis->count())
515  {
516  index = m_lrcAnalysis->count() - m_lrcAnalysis->middle() + 2;
517  }
518 
519  int value = G_SETTING_PTR->value(MusicSettingManager::LrcSize).toInt();
521 
523  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
524  {
525  m_lrcManagers[i]->setText(m_lrcAnalysis->text(i - value - 1));
526  }
528  }
529 
530  update();
531  }
532 }
533 
535 {
536  if(event->button() == Qt::LeftButton)
537  {
538  setCursor(Qt::ArrowCursor);
539  m_mouseLeftPressed = false;
541  update();
542 
544  {
545  const qint64 time = m_lrcAnalysis->findTime(m_lrcAnalysis->currentIndex());
546  if(time != -1)
547  {
548  Q_EMIT updateCurrentTime(time);
549  }
550  }
551  }
552 }
553 
555 {
556  if(m_functionLabel && m_functionLabel->geometry().contains(event->pos()))
557  {
558  return; //block mouse event in function label area
559  }
561 }
562 
564 {
565  Q_UNUSED(event);
566  if(!m_mouseLeftPressed)
567  {
568  return;
569  }
570 
571  QLinearGradient linearGradient(0, 0, width(), 0);
572  linearGradient.setColorAt(0.0, QColor(255, 254, 161));
573  linearGradient.setColorAt(0.3, Qt::transparent);
574  linearGradient.setColorAt(0.7, Qt::transparent);
575  linearGradient.setColorAt(1.0, QColor(255, 254, 161));
576 
577  const int line = (height() - m_functionLabel->height()) / 2;
578  QPainter painter(this);
579  painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
580  painter.setPen(QPen(linearGradient, 1));
581  painter.drawLine(LRC_TIME_LABEL_POSITION, line, width() - LRC_TIME_LABEL_POSITION, line);
582 
583  qint64 v = m_lrcAnalysis->currentIndex() - 1;
584  if(v < 0)
585  {
586  v = 0;
587  }
588  else if(v >= m_lrcAnalysis->count())
589  {
590  v = m_lrcAnalysis->count() - m_lrcAnalysis->middle() + 2;
591  }
592 
593  v = m_lrcAnalysis->findTime(v);
595 }
596 
598 {
599  m_functionLabel = new QWidget(this);
600  m_functionLabel->setFixedHeight(40);
601  m_functionLabel->lower();
602 
603  QHBoxLayout *functionLayout = new QHBoxLayout(m_functionLabel);
604  functionLayout->setContentsMargins(0, 0, 0, 0);
605 
606  QPushButton *transButton = new QPushButton(m_functionLabel);
607  QPushButton *movieButton = new QPushButton(m_functionLabel);
608  QPushButton *messageButton = new QPushButton(m_functionLabel);
609  QPushButton *photoButton = new QPushButton(m_functionLabel);
611 
612 #ifdef Q_OS_UNIX
613  transButton->setFocusPolicy(Qt::NoFocus);
614  movieButton->setFocusPolicy(Qt::NoFocus);
615  messageButton->setFocusPolicy(Qt::NoFocus);
616  photoButton->setFocusPolicy(Qt::NoFocus);
617  m_mufflerButton->setFocusPolicy(Qt::NoFocus);
618 #endif
619 
620  transButton->setFixedSize(30, 30);
621  movieButton->setFixedSize(30, 30);
622  messageButton->setFixedSize(30, 30);
623  photoButton->setFixedSize(30, 30);
624 
625  transButton->setStyleSheet(TTK::UI::InteriorTranslation);
626  movieButton->setStyleSheet(TTK::UI::InteriorMovie);
627  messageButton->setStyleSheet(TTK::UI::InteriorMessage);
628  photoButton->setStyleSheet(TTK::UI::InteriorPhoto);
629 
630  transButton->setCursor(Qt::PointingHandCursor);
631  movieButton->setCursor(Qt::PointingHandCursor);
632  messageButton->setCursor(Qt::PointingHandCursor);
633  photoButton->setCursor(Qt::PointingHandCursor);
634 
635  transButton->setToolTip(tr("Translation"));
636  movieButton->setToolTip(tr("Movie"));
637  messageButton->setToolTip(tr("Message"));
638  photoButton->setToolTip(tr("Photo"));
639 
640  connect(transButton, SIGNAL(clicked()), SLOT(translatedLrcData()));
641  connect(movieButton, SIGNAL(clicked()), SLOT(showSongMovieWidget()));
642  connect(messageButton, SIGNAL(clicked()), SLOT(showSongCommentsWidget()));
643  connect(photoButton, SIGNAL(clicked()), m_lrcFloatWidget, SLOT(showArtistPhotoWidget()));
644 
645  functionLayout->addStretch(1);
646  functionLayout->addWidget(transButton);
647  functionLayout->addWidget(m_mufflerButton);
648  functionLayout->addWidget(movieButton);
649  functionLayout->addWidget(messageButton);
650  functionLayout->addWidget(photoButton);
651  functionLayout->addStretch(1);
652  m_functionLabel->setLayout(functionLayout);
653 
654  layout()->addWidget(m_functionLabel);
655 }
656 
658 {
659  QActionGroup *actions = new QActionGroup(this);
660  actions->addAction(menu->addAction(tr("Yellow")))->setData(0);
661  actions->addAction(menu->addAction(tr("Blue")))->setData(1);
662  actions->addAction(menu->addAction(tr("Gray")))->setData(2);
663  actions->addAction(menu->addAction(tr("Pink")))->setData(3);
664  actions->addAction(menu->addAction(tr("Green")))->setData(4);
665  actions->addAction(menu->addAction(tr("Red")))->setData(5);
666  actions->addAction(menu->addAction(tr("Purple")))->setData(6);
667  actions->addAction(menu->addAction(tr("Orange")))->setData(7);
668  actions->addAction(menu->addAction(tr("Indigo")))->setData(8);
669  connect(actions, SIGNAL(triggered(QAction*)), SLOT(changeCurrentLrcColor(QAction*)));
670  menu->addSeparator();
671  menu->addAction(tr("Custom"), this, SLOT(currentLrcCustom()));
672 
673  const int index = G_SETTING_PTR->value("LrcColor").toInt();
674  if(index > -1 && index < actions->actions().count())
675  {
676  actions->actions()[index]->setIcon(QIcon(":/contextMenu/btn_selected"));
677  }
678 }
679 
681 {
683  const qint64 beforeTime = findTimePosition(m_currentTime);
684  updateCurrentLrc(beforeTime);
685 
686  if(m_timePositionOffset + pos == 0)
687  {
689  }
690 
691  QString message;
692  if(m_timePositionOffset > 0)
693  {
694  message = tr("After %1s").arg(m_timePositionOffset * 1.0 / TTK_DN_S2MS);
695  }
696  else if(m_timePositionOffset < 0)
697  {
698  message = tr("Before %1s").arg(-m_timePositionOffset * 1.0 / TTK_DN_S2MS);
699  }
700  else
701  {
702  message = tr("Restore");
703  }
704 
705  MusicToastLabel::popup(message);
706 }
707 
709 {
714  m_noLrcCurrentInfo->setText(tr("Lrc Make"));
715 
716  connect(m_noLrcCurrentInfo, SIGNAL(clicked()), SLOT(showLrcMakedWidget()));
717  m_noLrcCurrentInfo->hide();
718 }
719 
721 {
722  const int w = TTK::Widget::fontTextWidth(m_noLrcCurrentInfo->font(), m_noLrcCurrentInfo->text());
723  const int h = TTK::Widget::fontTextHeight(m_noLrcCurrentInfo->font());
724  const int offset = height() / m_lrcAnalysis->maximum() * (m_lrcAnalysis->middle() + 1) - 20;
725 
726  m_noLrcCurrentInfo->setGeometry((width() - w) / 2, offset, w, h);
727  m_noLrcCurrentInfo->show();
728 }
729 
731 {
732  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
733  {
734  m_lrcManagers[i]->setText({});
735  }
736  m_lrcManagers[m_lrcAnalysis->middle()]->setText(str);
737 }
738 
740 {
741  const int length = m_lrcAnalysis->maximum();
742  if(length == 11)
743  {
744  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
745  {
746  if(i == 0 || i == 10)
747  {
748  setItemStyleSheet(i, 5, 90);
749  }
750  else if(i == 1 || i == 9)
751  {
752  setItemStyleSheet(i, 4, 80);
753  }
754  else if(i == 2 || i == 8)
755  {
756  setItemStyleSheet(i, 3, 60);
757  }
758  else if(i == 3 || i == 7)
759  {
760  setItemStyleSheet(i, 2, 40);
761  }
762  else if(i == 4 || i == 6)
763  {
764  setItemStyleSheet(i, 1, 20);
765  }
766  else
767  {
768  setItemStyleSheet(i, 0, 0);
769  }
770  }
771  }
772  else if(length == 9)
773  {
774  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
775  {
776  if(i == 0 || i == 8)
777  {
778  setItemStyleSheet(i, 8, 90);
779  }
780  else if(i == 1 || i == 7)
781  {
782  setItemStyleSheet(i, 6, 75);
783  }
784  else if(i == 2 || i == 6)
785  {
786  setItemStyleSheet(i, 4, 50);
787  }
788  else if(i == 3 || i == 5)
789  {
790  setItemStyleSheet(i, 2, 25);
791  }
792  else
793  {
794  setItemStyleSheet(i, 0, 0);
795  }
796  }
797  }
798  else if(length == 7)
799  {
800  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
801  {
802  if(i == 0 || i == 6)
803  {
804  setItemStyleSheet(i, 12, 90);
805  }
806  else if(i == 1 || i == 5)
807  {
808  setItemStyleSheet(i, 8, 60);
809  }
810  else if(i == 2 || i == 4)
811  {
812  setItemStyleSheet(i, 4, 30);
813  }
814  else
815  {
816  setItemStyleSheet(i, 0, 0);
817  }
818  }
819  }
820  else if(length == 5)
821  {
822  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
823  {
824  if(i == 0 || i == 4)
825  {
826  setItemStyleSheet(i, 16, 90);
827  }
828  else if(i == 1 || i == 3)
829  {
830  setItemStyleSheet(i, 8, 45);
831  }
832  else
833  {
834  setItemStyleSheet(i, 0, 0);
835  }
836  }
837  }
838  else if(length == 3)
839  {
840  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
841  {
842  if(i == 0 || i == 2)
843  {
844  setItemStyleSheet(i, 20, 90);
845  }
846  else
847  {
848  setItemStyleSheet(i, 0, 0);
849  }
850  }
851  }
852 }
853 
854 void MusicLrcContainerForInterior::setItemStyleSheet(int index, int size, int transparent)
855 {
857  w->setFontSize(size);
858 
859  int value = G_SETTING_PTR->value("LrcColorTransparent").toInt() - transparent;
860  value = (value < TTK_RN_MIN) ? TTK_RN_MIN : value;
861  value = (value > TTK_RN_MAX) ? TTK_RN_MAX : value;
862  w->setFontTransparent(value);
863  w->setTransparent(value);
864 
865  if(G_SETTING_PTR->value("LrcColor").toInt() != -1)
866  {
868  }
869  else
870  {
871  setLinearGradientColor({TTK::readColorConfig(G_SETTING_PTR->value("LrcFrontgroundColor").toString()),
872  TTK::readColorConfig(G_SETTING_PTR->value("LrcBackgroundColor").toString())});
873  }
874 }
875 
877 {
878  if(size <= 14)
879  {
880  return 0;
881  }
882  else if(14 < size && size <= 18)
883  {
884  return 2;
885  }
886  else if(18 < size && size <= 26)
887  {
888  return 4;
889  }
890  else if(26 < size && size <= 36)
891  {
892  return 6;
893  }
894  else if(36 < size && size <= 72)
895  {
896  return 8;
897  }
898  else
899  {
900  return -1;
901  }
902 }
903 
905 {
906  const int length = MUSIC_LRC_INTERIOR_MAX_LINE - property;
907  m_lrcAnalysis->setMaximum(length);
908 
909  for(MusicLrcManager *manager : qAsConst(m_lrcManagers))
910  {
911  manager->show();
912  manager->reset();
913  m_layoutWidget->removeWidget(manager);
914  }
915 
916  for(int i = 0; i < length; ++i)
917  {
919  }
920 
921  for(int i = length; i < MUSIC_LRC_INTERIOR_MAX_LINE; ++i)
922  {
923  m_lrcManagers[i]->hide();
924  }
925 }
926 
928 {
929  for(int i = 0; i < m_lrcAnalysis->maximum(); ++i)
930  {
931  TTKObjectCast(MusicLrcManagerForInterior*, m_lrcManagers[i])->setLrcPerWidth(w);
932  }
933 
936  {
937  m_floatPlayWidget->resizeGeometry(width(), height());
938  }
939 
940  if(m_lrcAnalysis->isEmpty())
941  {
942  initCurrentLrc(tr("No lrc data file found"));
944  }
945  else if(m_currentTime != 0 && m_lrcAnalysis->currentIndex() == 0)
946  {
947  initCurrentLrc(tr("No song is playing now"));
948  }
949 
950  if(m_commentsWidget)
951  {
952  m_commentsWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
953  }
954 
956  {
957  m_translatedWidget->setGeometry(0, height() / 5, width(), height() * 4 / 5);
958  }
959 }
static MusicRightAreaWidget * instance()
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:231
MusicLrcFloatPlayWidget * m_floatPlayWidget
#define QtGlobalPositionY(p)
Definition: ttkqtcompat.h:164
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
static QString message(const TTK::Attribute attr)
void currentLrcUpdated()
#define G_BACKGROUND_PTR
void setFontTransparent(int t) noexcept
MusicVLayoutAnimationWidget * m_layoutWidget
#define QtGlobalPosition(p)
Definition: ttkqtcompat.h:161
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 updateVoiceRemove(bool v=true)
void updateCurrentTime(qint64 time)
bool isValid() const noexcept
void setCurrentSongName(const QString &name)
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:439
static const QString ColorStyle12
Definition: musicuiobject.h:70
int maximum() const noexcept
The class of the lrc art poster maker widget.
void setTimePosition(qint64 pos)
void setCurrentIndex(int index) noexcept
static void popup(const QString &text)
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
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
The class of the volume popup widget.
virtual void applyParameter()
virtual void paintEvent(QPaintEvent *event) overridefinal
void setCurrentSongName(const QString &name)
void setMaximum(int max) noexcept
#define TTK_RN_MIN
Definition: ttkglobal.h:438
void resizeGeometry(int width, int height)
qint64 findTimePosition(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 setLrcAnalysisModel(MusicLrcAnalysis *analysis) noexcept
#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)
QString filePath() const noexcept
#define WINDOW_WIDTH_MIN
Definition: musicobject.h:172
MusicLrcContainerForInterior(QWidget *parent=nullptr)
QString dataString() const
virtual void mouseDoubleClickEvent(QMouseEvent *event) overridefinal
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
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:173
void showMovieSearchedFound(const QString &name, const QString &id)
#define G_SETTING_PTR
static qint64 formatDuration(const QString &time) noexcept
Definition: ttktime.cpp:123
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:82
int middle() const noexcept
#define LEFT_SIDE_WIDTH_MIN
Definition: musicobject.h:174