TTKMusicPlayer  4.2.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 - 2025 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) noexcept { m_name = name; }
46  inline QString fileName() const noexcept { return m_name; }
50  inline void setFilePath(const QString &path) noexcept { m_path = path; }
54  inline QString filePath() const noexcept { 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 noexcept { return m_isSelected; }
77 
81  void setSelectEnabled(bool v);
85  inline bool isSelectEnabled() const noexcept { return m_selectedEnabled; }
86 
90  void setCloseEnabled(bool v);
94  inline bool isCloseEnabled() const noexcept { return m_closeEnabled; }
95 
99  void setShowNameEnabled(bool v);
103  inline bool isShowNameEnabled() const noexcept { 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) noexcept { m_type = type; }
169  inline Module type() const noexcept { 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 updateLastItem();
220 
224  inline int count() const noexcept { 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
bool isShowNameEnabled() const noexcept
bool isSelected() const noexcept
The class of the background list item.
void setType(Module type) noexcept
The class of the background list widget.
QString fileName() const noexcept
The class of the skin backgroud image.
const char * name
Definition: http_parser.c:458
The class of the skin item.
QString filePath() const noexcept
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:164
bool isSelectEnabled() const noexcept
void setFileName(const QString &name) noexcept
void setFilePath(const QString &path) noexcept
#define const
Definition: zconf.h:233
bool isCloseEnabled() const noexcept
state
Definition: http_parser.c:279