TTKMusicPlayer  4.3.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 - 2026 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
32 public:
36  explicit MusicBackgroundListItem(QWidget *parent = nullptr);
37 
41  inline void setFileName(const QString &name) noexcept { m_name = name; }
45  inline QString fileName() const noexcept { return m_name; }
49  inline void setFilePath(const QString &path) noexcept { m_path = path; }
53  inline QString filePath() const noexcept { return m_path; }
54 
58  void updatePixmap();
62  void updatePixmap(const MusicBackgroundImage &image);
66  bool contains(const MusicSkinItem &item) const;
67 
71  void setSelected(bool v);
75  inline bool isSelected() const noexcept { return m_isSelected; }
76 
80  void setSelectEnabled(bool v);
84  inline bool isSelectEnabled() const noexcept { return m_selectedEnabled; }
85 
89  void setCloseEnabled(bool v);
93  inline bool isCloseEnabled() const noexcept { return m_closeEnabled; }
94 
98  void setShowNameEnabled(bool v);
102  inline bool isShowNameEnabled() const noexcept { return m_showNameEnabled; }
103 
104 Q_SIGNALS:
108  void closeClicked(MusicBackgroundListItem *item);
112  void itemClicked(MusicBackgroundListItem *item);
113 
114 private:
118  virtual void mousePressEvent(QMouseEvent *event) override final;
119  virtual void leaveEvent(QEvent *event) override final;
120  virtual void enterEvent(QtEnterEvent *event) override final;
121  virtual void paintEvent(QPaintEvent *event) override final;
122 
123  bool m_isSelected, m_printMask;
124  bool m_selectedEnabled, m_closeEnabled, m_showNameEnabled;
125  QString m_name, m_path;
127 
128 };
129 
130 
135 {
136  Q_OBJECT
137 public:
138  enum Module
139  {
143  OnlineModule
144  };
145 
149  explicit MusicBackgroundListWidget(QWidget *parent = nullptr);
154 
158  void setCurrentItemName(const QString &name);
159 
163  inline void setType(Module type) noexcept { m_type = type; }
167  inline Module type() const noexcept { return m_type; }
168 
172  void clearState();
176  void clearItems();
177 
181  void addCellItem(const QString &icon, bool state);
185  void addCellItem(const QString &name, const QString &path, bool state);
186 
190  void updateItem(const MusicBackgroundImage &image, const QString &path);
191 
195  bool contains(const QString &name) const;
199  bool contains(const MusicBackgroundImage &image) const;
200 
204  int find(MusicBackgroundListItem *item) const;
208  MusicBackgroundListItem* find(const QString &name) const;
212  MusicBackgroundListItem* find(const MusicBackgroundImage &image) const;
213 
217  void updateLastItem();
218 
222  inline int count() const noexcept { return m_items.count(); }
223 
224 Q_SIGNALS:
228  void itemClicked(int type, const QString &name);
229 
230 private Q_SLOTS:
234  void itemCloseClicked(MusicBackgroundListItem *item);
238  void currentItemClicked(MusicBackgroundListItem *item);
239 
240 private:
242  QGridLayout *m_gridLayout;
244  QList<MusicBackgroundListItem*> m_items;
245 
246 };
247 
248 #endif // MUSICBACKGROUNDLISTWIDGET_H
#define QtEnterEvent
Event enter.
Definition: ttkqtcompat.h:178
#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
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