TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsongslistplayedwidget.cpp
Go to the documentation of this file.
2 #include "musictinyuiobject.h"
3 #include "musicwidgetutils.h"
4 #include "musicgiflabelwidget.h"
5 #include "musicleftareawidget.h"
6 #include "musicwidgetheaders.h"
7 
8 #include <QTimer>
9 
11  : QWidget(parent),
12  m_currentPlayIndex(index),
13  m_parent(parent)
14 {
15  QPalette plt(palette());
16  plt.setBrush(QPalette::Base, QBrush(QColor(0, 0, 0, 20)));
17  setPalette(plt);
18  setAutoFillBackground(true);
19 
20  m_textLabel = new QLabel(this);
21  m_textLabel->setStyleSheet(TTK::UI::ColorStyle08);
22  m_textLabel->setGeometry(23, 0, 170, 30);
23 
26  m_gifLabel->setGeometry(193, 8, 14, 14);
27 
28  m_downloadButton = new QPushButton(this);
29  m_downloadButton->setGeometry(220, 7, 16, 16);
30  m_downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
31  m_downloadButton->setToolTip(tr("Download"));
33 
34  m_deleteButton = new QPushButton(this);
35  m_deleteButton->setGeometry(245, 7, 16, 16);
36  m_deleteButton->setStyleSheet(TTK::UI::TinyBtnDelete);
37  m_deleteButton->setCursor(QCursor(Qt::PointingHandCursor));
38  m_deleteButton->setToolTip(tr("Delete"));
39 
40  m_moreButton = new QPushButton(this);
41  m_moreButton->setGeometry(270, 7, 16, 16);
43  m_moreButton->setCursor(QCursor(Qt::PointingHandCursor));
44  m_moreButton->setToolTip(tr("More"));
45 
46 #ifdef Q_OS_UNIX
47  m_downloadButton->setFocusPolicy(Qt::NoFocus);
48  m_deleteButton->setFocusPolicy(Qt::NoFocus);
49  m_moreButton->setFocusPolicy(Qt::NoFocus);
50 #endif
51 
52  QMenu *menu = new QMenu(this);
53  createMoreMenu(menu);
54  m_moreButton->setMenu(menu);
55 
56  connect(m_downloadButton, SIGNAL(clicked()), MusicLeftAreaWidget::instance(), SLOT(downloadSongToLocal()));
57  connect(m_deleteButton, SIGNAL(clicked()), SLOT(removeItemAt()));
58  connect(this, SIGNAL(enterChanged(int,int)), m_parent, SLOT(itemCellEntered(int,int)));
59 }
60 
62 {
63  delete m_textLabel;
64  delete m_gifLabel;
65  delete m_downloadButton;
66  delete m_deleteButton;
67  delete m_moreButton;
68 }
69 
71 {
72  m_textLabel->setText(TTK::Widget::elidedText(font(), name, Qt::ElideRight, 168));
73  m_textLabel->setToolTip(name);
74  m_gifLabel->start();
75 }
76 
78 {
80 }
81 
83 {
84  QWidget::enterEvent(event);
85  Q_EMIT enterChanged(m_currentPlayIndex, -1);
86 }
87 
89 {
90  menu->setStyleSheet(TTK::UI::MenuStyle02);
91  menu->addAction(QIcon(":/contextMenu/btn_similar"), tr("Similar"), m_parent, SLOT(showPlayedSimilarQueryWidget()));
92  menu->addAction(QIcon(":/contextMenu/btn_share"), tr("Share"), m_parent, SLOT(showPlayedSongSharedWidget()));
93 }
#define QtEnterEvent
Event enter.
Definition: ttkqtcompat.h:160
static constexpr const char * TinyBtnUnDownload
MusicSongsListPlayedWidget(int index, QWidget *parent=nullptr)
static constexpr const char * TinyBtnDelete
const char * name
Definition: http_parser.c:458
#define TTK_SIGNLE_SHOT(...)
Definition: ttkqtglobal.h:177
TTK_MODULE_EXPORT QString elidedText(const QFont &font, const QString &text, Qt::TextElideMode mode, int width)
static constexpr const char * TinyBtnMore
#define TTK_SLOT
Definition: ttkqtglobal.h:165
static const QString ColorStyle08
Definition: musicuiobject.h:58
static MusicLeftAreaWidget * instance()
static const QString MenuStyle02
void initialize(const QString &name)
void enterChanged(int row, int column)
The class of the float gif label widget.
void setInterval(int value)
virtual void enterEvent(QtEnterEvent *event) overridefinal
static const QString PushButtonStyle10
#define TTK_DN_MS
Definition: ttkglobal.h:270