TTKMusicPlayer  4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicfunctiontoolboxwidget.h
Go to the documentation of this file.
1 #ifndef MUSICFUNCTIONTOOLBOXWIDGET_H
2 #define MUSICFUNCTIONTOOLBOXWIDGET_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 "musicglobaldefine.h"
23 #include "musicwidgetheaders.h"
24 
25 static constexpr int RENAME_WIDTH = 240;
26 
31 {
32  Q_OBJECT
34 public:
38  explicit MusicFunctionToolBoxTopWidget(int index, const QString &text, QWidget *parent = nullptr);
43 
47  inline void setIndex(int index) { m_index = index; }
51  inline int index() const { return m_index; }
52 
56  bool isActive();
57 
61  void setExpand(bool expand);
65  bool isExpand() const;
66 
70  void setTitle(const QString &text);
74  QString title(bool suffix);
75 
76 Q_SIGNALS:
80  void itemIndexChanged(int index);
84  void swapDragItemIndex(int start, int end);
85 
86 protected:
90  virtual bool isItemEnabled() const;
94  virtual void dragEnterEvent(QDragEnterEvent *event) override final;
95  virtual void dragMoveEvent(QDragMoveEvent *event) override final;
96  virtual void dragLeaveEvent(QDragLeaveEvent *event) override final;
97  virtual void dropEvent(QDropEvent *event) override final;
98  virtual void mousePressEvent(QMouseEvent *event) override final;
99  virtual void mouseMoveEvent(QMouseEvent *event) override final;
100  virtual void paintEvent(QPaintEvent *event) override;
101 
102  int m_index;
103  QLabel *m_labelIcon, *m_labelText;
104 
105  bool m_isDrawTopState, m_isDrawMoveState;
106  bool m_isBlockMoveExpand, m_isActive;
108 
109 };
110 
111 
112 
117 {
118  Q_OBJECT
120 public:
124  explicit MusicFunctionToolBoxWidgetItem(QWidget *parent = nullptr);
125  explicit MusicFunctionToolBoxWidgetItem(int index, const QString &text, QWidget *parent = nullptr);
130 
134  QWidget *item() const;
138  void addCellItem(QWidget *item);
139 
143  void setTitle(const QString &text);
144 
148  void setExpand(bool expand);
152  bool isExpand() const;
153 
157  bool isActive() const;
158 
159 Q_SIGNALS:
163  void swapDragItemIndex(int start, int end);
164 
165 protected:
169  void initialize();
173  virtual void mousePressEvent(QMouseEvent *event) override final;
174 
175  QVBoxLayout *m_layout;
176  QWidget *m_item;
178 
179 };
180 
181 
186 {
187  Q_OBJECT
189 public:
193  explicit MusicNormalToolBoxWidgetItem(int index, const QString &text, QWidget *parent = nullptr);
194 
195 };
196 
197 
198 class QScrollArea;
199 
204 {
207 
209  : m_itemIndex(-1),
210  m_widgetItem(nullptr)
211  {
212 
213  }
214 };
216 
217 
222 {
223  Q_OBJECT
225 public:
229  explicit MusicFunctionToolBoxWidget(QWidget *parent = nullptr);
234 
238  void addCellItem(QWidget *item, const QString &text);
242  void removeItem(QWidget *item);
246  void swapItem(int start, int end);
247 
251  void setTitle(QWidget *item, const QString &text);
252 
256  void resizeScrollIndex(int index) const;
257 
261  int currentIndex() const;
265  int count() const;
266 
267 public Q_SLOTS:
271  void setCurrentIndex(int index);
275  void itemIndexChanged(int index);
279  void setTransparent(int alpha);
280 
281 protected:
285  virtual MusicFunctionToolBoxWidgetItem* initialItem(QWidget *item, const QString &text) = 0;
289  virtual void mousePressEvent(QMouseEvent *event) override final;
293  int foundMappedIndex(int index);
294 
297  QVBoxLayout *m_layout;
298  QScrollArea *m_scrollArea;
300  MusicToolBoxWidgetItemList m_itemList;
301 
302 };
303 
304 #endif // MUSICFUNCTIONTOOLBOXWIDGET_H
#define TTK_MODULE_EXPORT
The class of the function tool box widget.
The class of the function tool box top widget.
TTK_DECLARE_LIST(MusicToolBoxWidgetItem)
The class of the normal tool box widget item.
The class of the tool box widget item.
TTK_MODULE_EXPORT QString suffix(const QString &name)
The class of the function tool box widget item.
TTK_MODULE_EXPORT void setTransparent(QWidget *widget, int alpha)
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:168
MusicToolBoxWidgetItemList m_itemList
static constexpr int RENAME_WIDTH
MusicFunctionToolBoxWidgetItem * m_widgetItem
static unsigned char alpha[symbols+1]
Definition: rsecc.c:50
MusicFunctionToolBoxTopWidget * m_topWidget