TTKMusicPlayer  4.3.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.setRenderHint(QPainter::Antialiasing);
31  painter.setPen(QPen(QColor(0x66, 0x66, 0x66)));
32  painter.drawLine(0, 0, width() - 1, 0);
33  painter.drawLine(0, 0, 0, height() - 1);
34  painter.drawLine(0, height() - 1, width() - 1, height() - 1);
35  painter.drawLine(width() - 1, 0, width() - 1, height() - 1);
36 }
37 
38 
40  : QWidget(parent)
41 {
42  setStyleSheet(TTK::UI::BackgroundStyle01);
43 
44  QHBoxLayout *layout = new QHBoxLayout(this);
45  layout->setContentsMargins(5, 2, 0, 0);
46 
47  QPushButton *button = new QPushButton(this);
48  button->setIcon(QIcon(":/tiny/btn_search_main_hover"));
49  button->setCursor(QCursor(Qt::PointingHandCursor));
50  button->setIconSize(QSize(25, 25));
51 #ifdef Q_OS_UNIX
52  button->setFocusPolicy(Qt::NoFocus);
53 #endif
54  m_searchEdit = new MusicSearchEdit(this);
55  layout->addWidget(m_searchEdit);
56  layout->addWidget(button);
57  setLayout(layout);
58 
59  connect(button, SIGNAL(clicked()), SLOT(enterFinished()));
60  connect(m_searchEdit, SIGNAL(enterFinished(QString)), SLOT(enterFinished()));
61 }
62 
64 {
65  delete m_searchEdit;
66 }
67 
69 {
70  Q_EMIT trigger(m_searchEdit->text());
71 }
72 
73 void MusicItemQueryEdit::paintEvent(QPaintEvent *event)
74 {
75  QWidget::paintEvent(event);
76 
77  QPainter painter(this);
78  painter.setRenderHint(QPainter::Antialiasing);
79  painter.fillRect(rect(), QColor(255, 255, 255, 180));
80 
81  painter.setPen(QPen(QColor(0x66, 0x66, 0x66)));
82  painter.drawLine(0, 0, width() - 1, 0);
83  painter.drawLine(0, 0, 0, height() - 1);
84  painter.drawLine(0, height() - 1, width() - 1, height() - 1);
85  painter.drawLine(width() - 1, 0, width() - 1, height() - 1);
86 }
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)