TTKMusicPlayer  3.7.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 "musicextractwrapper.h"
5 #include "musicwidgetheaders.h"
6 #include "musicwidgetutils.h"
7 #include "ttkglobalhelper.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  QWidget *backgroundMask = new QWidget(this);
37  backgroundMask->setGeometry(4, 29, 360, 90);
38  backgroundMask->setStyleSheet(TTK::UI::BackgroundStyle11);
39 
40  QLabel *topTitleName = new QLabel(this);
41  topTitleName->setText(tr("Progress Bar"));
42  topTitleName->setGeometry(14, 4, 221, 25);
43  topTitleName->setStyleSheet(TTK::UI::ColorStyle06 + TTK::UI::FontStyle01);
44 
45  QToolButton *topTitleCloseButton = new QToolButton(this);
46  topTitleCloseButton->setGeometry(344, 6, 20, 20);
47  topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
48  topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
49  topTitleCloseButton->setEnabled(false);
50 
51  m_progressBar = new QProgressBar(this);
52  setBar(m_progressBar);
53  m_progressBar->setStyleSheet(TTK::UI::ProgressBar01);
54 
55  m_textLabel = new QLabel(this);
56  m_textLabel->setAlignment(Qt::AlignCenter);
57  m_textLabel->setGeometry(24, 34, 320, 25);
58 }
59 
60 void MusicProgressWidget::setTitle(const QString &name)
61 {
62  m_textLabel->setText(name);
63 }
64 
65 void MusicProgressWidget::resizeEvent(QResizeEvent *event)
66 {
67  QDialog::resizeEvent(event);
68  m_progressBar->setGeometry(24, 69, 320, 25);
69 }
70 
71 void MusicProgressWidget::paintEvent(QPaintEvent *event)
72 {
73  QDialog::paintEvent(event);
74  QPainter painter(this);
75  TTK::setBorderShadow(this, &painter);
76 }
77 
79 {
81  if(MusicExtractWrapper::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl()))
82  {
83  m_background->setPixmap(image.m_pix.scaled(size()));
84  }
85  else
86  {
87  m_background->setPixmap(QPixmap(G_BACKGROUND_PTR->backgroundUrl()).scaled(size()));
88  }
89  QProgressDialog::show();
90 }
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
virtual void resizeEvent(QResizeEvent *event) overridefinal
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
static const QString ToolButtonStyle04