TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicprogresswidget.cpp
Go to the documentation of this file.
1 #include "musicprogresswidget.h"
4 #include "musicextractmanager.h"
5 #include "musicwidgetheaders.h"
6 #include "musicwidgetutils.h"
7 #include "ttkglobalinterface.h"
8 
10  : QProgressDialog(parent)
11 {
12  setModal(true);
13  setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
14  setWindowModality(Qt::ApplicationModal);
15  setAttribute(Qt::WA_TranslucentBackground);
16 
17  setCancelButton(nullptr);
18  setLabel(nullptr);
19  setFixedSize(368, 123);
20  setMinimumDuration(2);
21 
22  initialize();
23 }
24 
26 {
27  delete m_background;
28  delete m_textLabel;
29  delete m_progressBar;
30 }
31 
33 {
34  m_background = new QLabel(this);
35  m_background->setGeometry(4, 4, 360, 115);
36 
37  QWidget *backgroundMask = new QWidget(this);
38  backgroundMask->setGeometry(4, 29, 360, 90);
39  backgroundMask->setStyleSheet(TTK::UI::BackgroundStyle11);
40 
41  QLabel *topTitleName = new QLabel(this);
42  topTitleName->setText(tr("Progress Bar"));
43  topTitleName->setGeometry(14, 4, 221, 25);
44  topTitleName->setStyleSheet(TTK::UI::ColorStyle06 + TTK::UI::FontStyle01);
45 
46  QToolButton *topTitleCloseButton = new QToolButton(this);
47  topTitleCloseButton->setGeometry(344, 6, 20, 20);
48  topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
49  topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
50  topTitleCloseButton->setEnabled(false);
51 
52  m_progressBar = new QProgressBar(this);
53  setBar(m_progressBar);
54  m_progressBar->setStyleSheet(TTK::UI::ProgressBar01);
55 
56  m_textLabel = new QLabel(this);
57  m_textLabel->setAlignment(Qt::AlignCenter);
58  m_textLabel->setGeometry(24, 34, 320, 25);
59 }
60 
61 void MusicProgressWidget::setTitle(const QString &name)
62 {
63  m_textLabel->setText(name);
64 }
65 
66 void MusicProgressWidget::resizeEvent(QResizeEvent *event)
67 {
68  QDialog::resizeEvent(event);
69  m_progressBar->setGeometry(24, 69, 320, 25);
70 }
71 
72 void MusicProgressWidget::paintEvent(QPaintEvent *event)
73 {
74  QDialog::paintEvent(event);
75  QPainter painter(this);
76  TTK::setBorderShadow(this, &painter);
77 }
78 
80 {
82  if(MusicExtractManager::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl()))
83  {
84  m_background->setPixmap(image.m_pix.scaled(size()));
85  }
86  else
87  {
88  QPixmap pix(G_BACKGROUND_PTR->backgroundUrl());
89  if(pix.isNull())
90  {
91  TTK_ERROR_STREAM("Load current pixmap data error, path is" << G_BACKGROUND_PTR->backgroundUrl());
92  return;
93  }
94 
95  m_background->setPixmap(pix.scaled(size()));
96  }
97 
98  QProgressDialog::show();
99 }
static const QString ColorStyle06
Definition: musicuiobject.h:52
virtual void paintEvent(QPaintEvent *event) overridefinal
#define G_BACKGROUND_PTR
voidpf void uLong size
Definition: ioapi.h:136
TTK_MODULE_EXPORT void setBorderShadow(QWidget *widget, QPainter *painter)
static const QString ProgressBar01
ProgressBar.
QProgressBar * m_progressBar
static const QString FontStyle01
Font.
void setTitle(const QString &name)
The class of the skin backgroud image.
const char * name
Definition: http_parser.c:458
MusicProgressWidget(QWidget *parent=nullptr)
static const QString BackgroundStyle11
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
virtual void resizeEvent(QResizeEvent *event) overridefinal
static const QString ToolButtonStyle04
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:76