TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicitemsearchedit.cpp
Go to the documentation of this file.
1 #include "musicitemsearchedit.h"
2 #include "musicwidgetheaders.h"
3 
5  : QWidget(parent)
6 {
7  QHBoxLayout *layout = new QHBoxLayout(this);
8  layout->setContentsMargins(5, 2, 5, 0);
9 
10  QLabel *icon = new QLabel(this);
11  icon->setFixedSize(16, 16);
12  icon->setStyleSheet(TTK::UI::BackgroundStyle01 + "border-image: url(:/tiny/btn_search_main_hover);");
13 
14  m_searchEdit = new MusicSearchEdit(this);
15  layout->addWidget(icon);
16  layout->addWidget(m_searchEdit);
17  setLayout(layout);
18 }
19 
21 {
22  delete m_searchEdit;
23 }
24 
25 void MusicItemSearchEdit::paintEvent(QPaintEvent *event)
26 {
27  QWidget::paintEvent(event);
28 
29  QPainter painter(this);
30  painter.setPen(QPen(QColor(0x66, 0x66, 0x66)));
31  painter.drawLine(0, 0, width() - 1, 0);
32  painter.drawLine(0, 0, 0, height() - 1);
33  painter.drawLine(0, height() - 1, width() - 1, height() - 1);
34  painter.drawLine(width() - 1, 0, width() - 1, height() - 1);
35 }
36 
37 
39  : QWidget(parent)
40 {
41  setStyleSheet(TTK::UI::BackgroundStyle01);
42 
43  QHBoxLayout *layout = new QHBoxLayout(this);
44  layout->setContentsMargins(5, 2, 0, 0);
45 
46  QPushButton *button = new QPushButton(this);
47  button->setIcon(QIcon(":/tiny/btn_search_main_hover"));
48  button->setCursor(QCursor(Qt::PointingHandCursor));
49  button->setIconSize(QSize(25, 25));
50 #ifdef Q_OS_UNIX
51  button->setFocusPolicy(Qt::NoFocus);
52 #endif
53  m_searchEdit = new MusicSearchEdit(this);
54  layout->addWidget(m_searchEdit);
55  layout->addWidget(button);
56  setLayout(layout);
57 
58  connect(button, SIGNAL(clicked()), SLOT(enterFinished()));
59  connect(m_searchEdit, SIGNAL(enterFinished(QString)), SLOT(enterFinished()));
60 }
61 
63 {
64  delete m_searchEdit;
65 }
66 
68 {
69  Q_EMIT trigger(m_searchEdit->text());
70 }
71 
72 void MusicItemQueryEdit::paintEvent(QPaintEvent *event)
73 {
74  QWidget::paintEvent(event);
75 
76  QPainter painter(this);
77  painter.fillRect(rect(), QColor(255, 255, 255, 180));
78 
79  painter.setPen(QPen(QColor(0x66, 0x66, 0x66)));
80  painter.drawLine(0, 0, width() - 1, 0);
81  painter.drawLine(0, 0, 0, height() - 1);
82  painter.drawLine(0, height() - 1, width() - 1, height() - 1);
83  painter.drawLine(width() - 1, 0, width() - 1, height() - 1);
84 }
The class of the search line edit widget.
virtual void paintEvent(QPaintEvent *event) overridefinal
void trigger(const QString &text)
MusicSearchEdit * m_searchEdit
MusicSearchEdit * m_searchEdit
MusicItemQueryEdit(QWidget *parent=nullptr)
static const QString BackgroundStyle01
Background.
Definition: musicuiobject.h:77
virtual void paintEvent(QPaintEvent *event) overridefinal
MusicItemSearchEdit(QWidget *parent=nullptr)