TTKMusicPlayer  4.3.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 - 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 "musicglobaldefine.h"
23 #include "musicwidgetheaders.h"
24 
25 static constexpr int RENAME_WIDTH = 240;
26 
31 {
32  Q_OBJECT
33 public:
37  explicit MusicFunctionToolBoxTopWidget(int index, const QString &text, QWidget *parent = nullptr);
42 
46  inline void setIndex(int index) noexcept { m_index = index; }
50  inline int index() const noexcept { return m_index; }
51 
55  bool isActive();
56 
60  void setExpand(bool expand);
64  bool isExpand() const;
65 
69  void setTitle(const QString &text);
73  QString title(bool suffix);
74 
75 Q_SIGNALS:
79  void itemIndexChanged(int index);
83  void swapDragItemIndex(int start, int end);
84 
85 protected:
89  virtual bool isItemEnabled() const;
93  virtual void dragEnterEvent(QDragEnterEvent *event) override final;
94  virtual void dragMoveEvent(QDragMoveEvent *event) override final;
95  virtual void dragLeaveEvent(QDragLeaveEvent *event) override final;
96  virtual void dropEvent(QDropEvent *event) override final;
97  virtual void mousePressEvent(QMouseEvent *event) override final;
98  virtual void mouseMoveEvent(QMouseEvent *event) override final;
99  virtual void paintEvent(QPaintEvent *event) override;
100 
101  int m_index;
102  QLabel *m_labelIcon, *m_labelText;
103 
104  bool m_isDrawTopState, m_isDrawMoveState;
105  bool m_isBlockMoveExpand, m_isActive;
106  QPoint m_pressedPos;
107 
108 };
109 
110 
111 
116 {
117  Q_OBJECT
118 public:
122  explicit MusicFunctionToolBoxWidgetItem(QWidget *parent = nullptr);
123  explicit MusicFunctionToolBoxWidgetItem(int index, const QString &text, QWidget *parent = nullptr);
128 
132  QWidget *item() const noexcept;
136  void addCellItem(QWidget *item);
137 
141  void setTitle(const QString &text);
142 
146  void setExpand(bool expand);
150  bool isExpand() const;
151 
155  bool isActive() const;
156 
157 Q_SIGNALS:
161  void swapDragItemIndex(int start, int end);
162 
163 protected:
167  void initialize();
171  virtual void mousePressEvent(QMouseEvent *event) override final;
172 
173  QVBoxLayout *m_layout;
174  QWidget *m_item;
176 
177 };
178 
179 
184 {
185  Q_OBJECT
186 public:
190  explicit MusicNormalToolBoxWidgetItem(int index, const QString &text, QWidget *parent = nullptr);
191 
192 };
193 
194 
195 class QScrollArea;
196 
197 
202 {
203  Q_OBJECT
204 public:
208  explicit MusicFunctionToolBoxWidget(QWidget *parent = nullptr);
213 
217  void addCellItem(QWidget *item, const QString &text);
221  void removeItem(QWidget *item);
225  void swapItem(int start, int end);
226 
230  void setTitle(QWidget *item, const QString &text);
231 
235  void resizeScrollIndex(int index) const;
236 
240  int currentIndex() const noexcept;
244  int count() const noexcept;
245 
246 public Q_SLOTS:
250  void setCurrentIndex(int index);
254  void itemIndexChanged(int index);
258  void setTransparent(int alpha);
259 
260 protected:
264  virtual MusicFunctionToolBoxWidgetItem* initialItem(QWidget *item, const QString &text) = 0;
268  virtual void mousePressEvent(QMouseEvent *event) override final;
272  int foundMappedIndex(int index);
273 
276  QVBoxLayout *m_layout;
277  QScrollArea *m_scrollArea;
279 
280 protected:
281  struct Data
282  {
285  };
286  QList<Data> m_items;
287 
288 };
289 
290 #endif // MUSICFUNCTIONTOOLBOXWIDGET_H
#define TTK_MODULE_EXPORT
The class of the function tool box widget.
The class of the function tool box top widget.
MusicFunctionToolBoxWidgetItem * m_itemWidget
The class of the normal 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)
TTK_MODULE_EXPORT void initialize(TTK::Attribute attr)
static constexpr int RENAME_WIDTH
static unsigned char alpha[symbols+1]
Definition: rsecc.c:50
#define const
Definition: zconf.h:233
MusicFunctionToolBoxTopWidget * m_topWidget