TTKMusicPlayer  3.7.0.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 - 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 "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 = false);
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  QString m_suffixString;
104  QLabel *m_labelIcon, *m_labelText;
105 
106  bool m_isDrawTopState, m_isDrawMoveState;
107  bool m_isBlockMoveExpand, m_isActive;
108  QPoint m_pressAt;
109 
110 };
111 
112 
113 
118 {
119  Q_OBJECT
121 public:
125  explicit MusicFunctionToolBoxWidgetItem(QWidget *parent = nullptr);
126  explicit MusicFunctionToolBoxWidgetItem(int index, const QString &text, QWidget *parent = nullptr);
131 
135  QWidget *item() const;
139  void addCellItem(QWidget *item);
140 
144  void setTitle(const QString &text);
145 
149  void setExpand(bool expand);
153  bool isExpand() const;
154 
158  bool isActive() const;
159 
160 Q_SIGNALS:
164  void swapDragItemIndex(int start, int end);
165 
166 protected:
170  void initialize();
174  virtual void mousePressEvent(QMouseEvent *event) override final;
175 
176  QVBoxLayout *m_layout;
177  QWidget *m_item;
179 
180 };
181 
182 
187 {
188  Q_OBJECT
190 public:
194  explicit MusicNormalToolBoxWidgetItem(int index, const QString &text, QWidget *parent = nullptr);
195 
196 };
197 
198 
199 class QScrollArea;
200 
205 {
208 
210  : m_itemIndex(-1),
211  m_widgetItem(nullptr)
212  {
213 
214  }
215 };
217 
218 
223 {
224  Q_OBJECT
226 public:
230  explicit MusicFunctionToolBoxWidget(QWidget *parent = nullptr);
235 
239  void addCellItem(QWidget *item, const QString &text);
243  void removeItem(QWidget *item);
247  void swapItem(int start, int end);
248 
252  void setTitle(QWidget *item, const QString &text);
253 
257  void resizeScrollIndex(int index) const;
258 
262  int currentIndex() const;
266  int count() const;
267 
268 public Q_SLOTS:
272  void setCurrentIndex(int index);
276  void itemIndexChanged(int index);
280  void setTransparent(int alpha);
281 
282 protected:
286  virtual MusicFunctionToolBoxWidgetItem* initialItem(QWidget *item, const QString &text) = 0;
290  virtual void mousePressEvent(QMouseEvent *event) override final;
294  int foundMappedIndex(int index);
295 
298  QVBoxLayout *m_layout;
299  QScrollArea *m_scrollArea;
301  MusicToolBoxWidgetItemList m_itemList;
302 
303 };
304 
305 #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:152
MusicToolBoxWidgetItemList m_itemList
static constexpr int RENAME_WIDTH
MusicFunctionToolBoxWidgetItem * m_widgetItem
static unsigned char alpha[symbols+1]
Definition: rsecc.c:50
MusicFunctionToolBoxTopWidget * m_topWidget