TTKMusicPlayer  4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicconnectionpool.cpp
Go to the documentation of this file.
1 #include "musicconnectionpool.h"
2 #include "musicplayer.h"
3 #include "musiclrcmakerwidget.h"
5 #include "musicequalizerdialog.h"
10 #include "musiccloudtablewidget.h"
12 
13 void MusicConnectionPool::removeValue(const QObject *object)
14 {
15  for(auto it = m_parameters.constBegin(); it != m_parameters.constEnd(); ++it)
16  {
17  if(it.value() == object)
18  {
19  m_parameters.take(it.key());
20  break;
21  }
22  }
23 }
24 
25 void MusicConnectionPool::connect(const QString &from, const QString &to)
26 {
27  const QObject *first = m_parameters.value(from);
28  const QObject *second = m_parameters.value(to);
29  if(first == nullptr || second == nullptr)
30  {
31  return;
32  }
33 
34  if(from == MusicNetworkThread::className() && to == MusicDownloadStatusModule::className())
35  {
36  QObject::connect(first, SIGNAL(networkConnectionStateChanged(bool)), second, SLOT(networkConnectionStateChanged(bool)));
37  }
38  else if(from == MusicPlayer::className() && to == MusicLrcMakerWidget::className())
39  {
40  QObject::connect(first, SIGNAL(positionChanged(qint64)), second, SLOT(positionChanged(qint64)));
41  QObject::connect(first, SIGNAL(durationChanged(qint64)), second, SLOT(durationChanged(qint64)));
42  }
43  else if(from == MusicEqualizerDialog::className() && to == MusicPlayer::className())
44  {
45  QObject::connect(first, SIGNAL(setEnabledEffect(bool)), second, SLOT(setEnabledEffect(bool)));
46  QObject::connect(first, SIGNAL(setEqualizerEffect(TTKIntList)), second, SLOT(setEqualizerEffect(TTKIntList)));
47  }
48  else if(from == MusicEqualizerDialog::className() && to == MusicSoundEffectsWidget::className())
49  {
50  QObject::connect(first, SIGNAL(setEnabledEffect(bool)), second, SLOT(equalizerButtonChanged(bool)));
51  }
52  else if(from == MusicSoundEffectsWidget::className() && to == MusicPlayer::className())
53  {
54  QObject::connect(first, SIGNAL(setEqualizerConfig()), second, SLOT(setEqualizerConfig()));
55  }
56  else if(from == MusicLrcLocalLinkWidget::className() && to == MusicDownloadStatusModule::className())
57  {
58  QObject::connect(first, SIGNAL(currentLrcChanged(QString)), second, SLOT(showDownLoadInfoFinished(QString)));
59  }
60  else if(from == MusicVideoQualityPopWidget::className() && to == MusicVideoSearchTableWidget::className())
61  {
62  QObject::connect(first, SIGNAL(queryMediaProps(TTK::MusicSongPropertyList&)), second, SLOT(queryMediaProps(TTK::MusicSongPropertyList&)));
63  }
64  else if((from == MusicCloudManagerTableWidget::className() && to == MusicCloudUploadTableWidget::className()))
65  {
66  QObject::connect(first, SIGNAL(uploadFileError(MusicCloudDataItem)), second, SLOT(uploadFileError(MusicCloudDataItem)));
67  QObject::connect(second, SIGNAL(reuploadFilesToServer(QStringList)), first, SLOT(reuploadFilesToServer(QStringList)));
68  }
69 }
The class of the cloud data item.
QList< int > TTKIntList
Definition: ttkqtglobal.h:204
QMap< QString, QObject * > m_parameters
void connect(const QString &from, const QString &to)
void removeValue(const QObject *object)