TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicbackgroundmanager.cpp
Go to the documentation of this file.
2 #include "musicsong.h"
3 
5  : m_currentIndex(0)
6 {
7 
8 }
9 
11 {
14 }
15 
17 {
18  return m_currentArtistName;
19 }
20 
22 {
24 }
25 
27 {
29 }
30 
32 {
33  if(!m_photos.isEmpty())
34  {
36  }
37  else
38  {
39  return {};
40  }
41 }
42 
44 {
45  if(m_photos.isEmpty())
46  {
47  return {};
48  }
49 
50  const int index = m_currentIndex - 1;
51  return (-1 < index && index < m_photos.count()) ? m_photos[index] : QString();
52 }
53 
55 {
56  m_photos.clear();
57  m_currentIndex = 0;
58 
59  const QString &filter = BACKGROUND_DIR_FULL + m_currentArtistName + "%1" + SKN_FILE;
60  for(int i = 0; i < MAX_IMAGE_COUNT; ++i)
61  {
62  QFile file(filter.arg(i));
63  if(file.exists() && file.open(QIODevice::ReadOnly))
64  {
65  if(file.size() > 0)
66  {
67  m_photos << file.fileName();
68  }
69  file.close();
70  }
71  }
72 
73  Q_EMIT artistChanged();
74 }
75 
77 {
78  return m_photos;
79 }
80 
81 void MusicBackgroundManager::setArtistPhotoList(const QStringList &list)
82 {
83  m_photos = list;
84 }
85 
87 {
88  m_currentIndex = index;
89  Q_EMIT selectIndexChanged();
90 }
91 
93 {
94  m_observer << object;
95  connect(this, SIGNAL(backgroundChanged()), object, SLOT(backgroundChanged()));
96 }
97 
99 {
100  m_observer.removeOne(object);
101  disconnect(this, SIGNAL(backgroundChanged()), object, SLOT(backgroundChanged()));
102 }
103 
105 {
106  m_background = path;
107 }
108 
110 {
111  return m_background;
112 }
113 
115 {
116  Q_EMIT backgroundChanged();
117 }
TTK_MODULE_EXPORT QString generateSongArtist(const QString &name, const QString &key=TTK_DEFAULT_STR)
Definition: musicsong.cpp:128
void removeObserver(QObject *object)
void setBackgroundUrl(const QString &path)
const char * name
Definition: http_parser.c:458
void addObserver(QObject *object)
QString artistPhotoDefaultPath() const
#define MAX_IMAGE_COUNT
QStringList artistPhotoList() const
void setArtistPhotoList(const QStringList &list)
#define BACKGROUND_DIR_FULL
Definition: musicobject.h:129
#define SKN_FILE
Definition: musicobject.h:61
void setArtistName(const QString &name)