TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicbackgroundlistwidget.h
Go to the documentation of this file.
1 #ifndef MUSICBACKGROUNDLISTWIDGET_H
2 #define MUSICBACKGROUNDLISTWIDGET_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QLabel>
23 #include <QGridLayout>
25 
30 {
31  Q_OBJECT
33 public:
37  explicit MusicBackgroundListItem(QWidget *parent = nullptr);
38 
42  inline void setFileName(const QString &name) { m_name = name; }
46  inline QString fileName() const { return m_name; }
50  inline void setFilePath(const QString &path) { m_path = path; }
54  inline QString filePath() const { return m_path; }
55 
59  void updatePixmap();
63  void updatePixmap(const MusicBackgroundImage &image);
67  bool contains(const MusicSkinItem &item) const;
68 
72  void setSelected(bool v);
76  inline bool isSelected() const { return m_isSelected; }
77 
81  void setSelectEnabled(bool v);
85  inline bool isSelectEnabled() const { return m_selectedEnabled; }
86 
90  void setCloseEnabled(bool v);
94  inline bool isCloseEnabled() const { return m_closeEnabled; }
95 
99  void setShowNameEnabled(bool v);
103  inline bool isShowNameEnabled() const { return m_showNameEnabled; }
104 
105 Q_SIGNALS:
109  void closeClicked(MusicBackgroundListItem *item);
113  void itemClicked(MusicBackgroundListItem *item);
114 
115 private:
119  virtual void mousePressEvent(QMouseEvent *event) override final;
120  virtual void leaveEvent(QEvent *event) override final;
121  virtual void enterEvent(QtEnterEvent *event) override final;
122  virtual void paintEvent(QPaintEvent *event) override final;
123 
124  bool m_isSelected, m_printMask;
125  bool m_selectedEnabled, m_closeEnabled, m_showNameEnabled;
126  QString m_name, m_path;
128 
129 };
130 
131 
136 {
137  Q_OBJECT
139 public:
140  enum Module
141  {
145  OnlineModule
146  };
147 
151  explicit MusicBackgroundListWidget(QWidget *parent = nullptr);
156 
160  void setCurrentItemName(const QString &name);
161 
165  inline void setType(Module type) { m_type = type; }
169  inline Module type() const { return m_type; }
170 
174  void clearState();
178  void clearItems();
179 
183  void addCellItem(const QString &icon, bool state);
187  void addCellItem(const QString &name, const QString &path, bool state);
188 
192  void updateItem(const MusicBackgroundImage &image, const QString &path);
193 
197  bool contains(const QString &name) const;
201  bool contains(const MusicBackgroundImage &image) const;
202 
206  int find(MusicBackgroundListItem *item) const;
210  MusicBackgroundListItem* find(const QString &name) const;
214  MusicBackgroundListItem* find(const MusicBackgroundImage &image) const;
215 
219  void updateLastedItem();
220 
224  inline int count() const { return m_items.count(); }
225 
226 Q_SIGNALS:
230  void itemClicked(int type, const QString &name);
231 
232 private Q_SLOTS:
236  void itemCloseClicked(MusicBackgroundListItem *item);
240  void currentItemClicked(MusicBackgroundListItem *item);
241 
242 private:
244  QGridLayout *m_gridLayout;
246  QList<MusicBackgroundListItem*> m_items;
247 
248 };
249 
250 #endif // MUSICBACKGROUNDLISTWIDGET_H
#define QtEnterEvent
Event enter.
Definition: ttkqtcompat.h:160
#define TTK_MODULE_EXPORT
MusicBackgroundListItem * m_currentItem
QList< MusicBackgroundListItem * > m_items
The class of the background list item.
The class of the background list widget.
void setFilePath(const QString &path)
The class of the skin backgroud image.
const char * name
Definition: http_parser.c:458
The class of the skin item.
void setFileName(const QString &name)
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
state
Definition: http_parser.c:279