TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicplaylistquerycategorypopwidget.cpp
Go to the documentation of this file.
2 #include "musicwidgetutils.h"
3 #include "musicwidgetheaders.h"
4 #include "ttkclickedgroup.h"
5 #include "ttkclickedlabel.h"
6 
7 static constexpr int ITEM_MAX_COLUMN = 6;
8 static constexpr int ITEM_LABEL_WIDTH = 20;
9 
11  : QWidget(parent)
12 {
13  setStyleSheet({});
14 }
15 
17 {
18  m_category = category;
19 
20  QHBoxLayout *layout = new QHBoxLayout(this);
21  QLabel *label = new QLabel(category.m_category, this);
22  label->setStyleSheet(TTK::UI::ColorStyle03 + TTK::UI::FontStyle03);
23  label->setFixedSize(50, ITEM_LABEL_WIDTH);
24  layout->addWidget(label, 0, Qt::AlignTop);
25 
26  QWidget *item = new QWidget(this);
27  QGridLayout *itemLayout = new QGridLayout(item);
28  itemLayout->setContentsMargins(0, 0, 0, 0);
29 
30  TTKClickedGroup *clickedGroup = new TTKClickedGroup(this);
31  connect(clickedGroup, SIGNAL(clicked(int)), SLOT(buttonClicked(int)));
32 
33  for(int i = 0; i < m_category.m_items.count(); ++i)
34  {
35  TTKClickedLabel *label = new TTKClickedLabel(m_category.m_items[i].m_value, item);
36  label->setStyleSheet(QString("QLabel::hover{%1}").arg(TTK::UI::ColorStyle07));
37  label->setFixedSize(75, ITEM_LABEL_WIDTH);
38 
39  clickedGroup->mapped(label);
40  itemLayout->addWidget(label, i / ITEM_MAX_COLUMN, i % ITEM_MAX_COLUMN, Qt::AlignLeft);
41  }
42 
43  item->setLayout(itemLayout);
44  layout->addWidget(item, 0, Qt::AlignTop);
45  setLayout(layout);
46 }
47 
49 {
50  if(0 <= index && index < m_category.m_items.count())
51  {
52  Q_EMIT categoryChanged(m_category.m_items[index]);
53  }
54 }
55 
56 
58  : MusicToolMenuWidget(parent)
59 {
60  initialize();
61 }
62 
63 void MusicPlaylistFoundCategoryPopWidget::setCategory(const QString &server, QObject *obj)
64 {
65  MusicResultsCategoryList categorys;
66  MusicCategoryConfigManager manager(server);
68  manager.readBuffer(categorys);
69 
70  QVBoxLayout *layout = new QVBoxLayout(m_containWidget);
71  QWidget *containWidget = new QWidget(m_containWidget);
72  containWidget->setStyleSheet(TTK::UI::BackgroundStyle10);
73  QVBoxLayout *containLayout = new QVBoxLayout(containWidget);
74  containWidget->setLayout(containLayout);
75 
76  QScrollArea *scrollArea = new QScrollArea(this);
77  TTK::Widget::generateVScrollAreaFormat(scrollArea, containWidget);
78  layout->addWidget(scrollArea);
79 
80  for(const MusicResultsCategory &category : qAsConst(categorys))
81  {
83  connect(item, SIGNAL(categoryChanged(MusicResultsCategoryItem)), obj, SLOT(categoryChanged(MusicResultsCategoryItem)));
84  item->setCategory(category);
85  containLayout->addWidget(item);
86  }
87  m_containWidget->setLayout(layout);
88 }
89 
91 {
92  m_menu->close();
93 }
94 
96 {
97  m_menu->exec(mapToGlobal(QPoint(0, 0)));
98 }
99 
101 {
102  setFixedSize(100, 30);
104  setText(tr("All"));
105 
106  const QString &style = TTK::UI::BorderStyle03 + TTK::UI::BackgroundStyle10;
107  setObjectName(className());
108  setStyleSheet(QString("#%1{%2}").arg(className(), style));
109 
110  m_containWidget->setFixedSize(600, 370);
111  m_containWidget->setObjectName("ContainWidget");
112  m_containWidget->setStyleSheet(QString("#ContainWidget{%1}").arg(style));
113 
114  m_menu->setStyleSheet(TTK::UI::MenuStyle04);
115 }
The class of the tool menu base widget.
void categoryChanged(const MusicResultsCategoryItem &category)
static const QString MenuStyle04
static const QString FontStyle03
MusicToolMenu * m_menu
void setCategory(const MusicResultsCategory &category)
The class of the label widget that can click.
virtual bool readBuffer(MusicResultsCategoryList &items) overridefinal
void mapped(QWidget *widget)
The class of the results category core.
#define qAsConst
Definition: ttkqtglobal.h:53
static constexpr int ITEM_LABEL_WIDTH
void setCategory(const QString &server, QObject *obj)
The class of the category config manager.
static const QString BackgroundStyle10
static const QString ColorStyle07
Definition: musicuiobject.h:55
static constexpr int ITEM_MAX_COLUMN
static const QString ColorStyle03
Definition: musicuiobject.h:43
TTK_MODULE_EXPORT void generateVScrollAreaFormat(QWidget *widget, QWidget *parent, bool background=true)
The class of the results category item.
static const QString BorderStyle03
MusicResultsCategoryItemList m_items
The class of the label widget click group mapper.
The class of the playlist music query category item.