TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsourceupdatewidget.cpp
Go to the documentation of this file.
2 #include "ui_musicsourceupdatewidget.h"
4 #include "musicsettingmanager.h"
5 #include "musicalgorithmutils.h"
6 #include "musiccoreutils.h"
7 #include "musicurlutils.h"
8 
9 #include <QBoxLayout>
10 
13 {
14  hide();
15 
16  setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
17  setAttribute(Qt::WA_DeleteOnClose);
18  setStyleSheet(TTK::UI::BackgroundStyle10);
19  setMouseTracking(true);
20  blockMoveOption(true);
21 
22  const QSize &windowSize = G_SETTING_PTR->value(MusicSettingManager::ScreenSize).toSize();
23  setGeometry(windowSize.width() - 240, windowSize.height() - 150, 220, 100);
24 
25  QVBoxLayout *vLayout = new QVBoxLayout(m_container);
26  vLayout->setContentsMargins(5, 5, 5, 5);
27 
28  m_textLabel = new QLabel(this);
29  m_textLabel->setStyleSheet(TTK::UI::ColorStyle03);
30  m_textLabel->setAlignment(Qt::AlignCenter);
31 
32  QWidget *contain = new QWidget(this);
33  QHBoxLayout *hLayout = new QHBoxLayout(contain);
34  hLayout->setContentsMargins(0, 0, 0, 0);
35  QPushButton *updateButton = new QPushButton(tr("Update"), contain);
36  QPushButton *nextTimeButton = new QPushButton(tr("Close"), contain);
37  updateButton->setStyleSheet(TTK::UI::PushButtonStyle04);
38  nextTimeButton->setStyleSheet(TTK::UI::PushButtonStyle04);
39  updateButton->setFixedSize(85, 27);
40  nextTimeButton->setFixedSize(85, 27);
41  hLayout->addWidget(updateButton);
42  hLayout->addWidget(nextTimeButton);
43  contain->setLayout(hLayout);
44 
45 #ifdef Q_OS_UNIX
46  updateButton->setFocusPolicy(Qt::NoFocus);
47  nextTimeButton->setFocusPolicy(Qt::NoFocus);
48 #endif
49 
50  vLayout->addWidget(m_textLabel);
51  vLayout->addWidget(contain);
52  m_container->setLayout(vLayout);
53 
54  connect(updateButton, SIGNAL(clicked()), SLOT(updateSourceClicked()));
55  connect(nextTimeButton, SIGNAL(clicked()), SLOT(close()));
56 
58  connect(d, SIGNAL(downLoadDataChanged(QString)), SLOT(downLoadFinished()));
59  d->startToRequest();
60 }
61 
63 {
64  delete m_textLabel;
65 }
66 
68 {
69  close();
71 }
72 
74 {
76  if(!d)
77  {
78  close();
79  return;
80  }
81 
82  const QString &version = d->version();
84  {
85  show();
86  m_textLabel->setText(tr("New version found") + "\r\n" + version);
87  }
88  else
89  {
90  close();
91  }
92 }
93 
94 
95 
97  : TTKAbstractMoveDialog(parent),
98  m_ui(new Ui::MusicSourceUpdateWidget)
99 {
100  m_ui->setupUi(this);
101  setFixedSize(size());
102 
103  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
104  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
105  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
106  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
107  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
108 
109  m_ui->upgradeButton->setStyleSheet(TTK::UI::PushButtonStyle03);
110  m_ui->upgradeButton->setEnabled(false);
111 #ifdef Q_OS_UNIX
112  m_ui->upgradeButton->setFocusPolicy(Qt::NoFocus);
113 #endif
114 
115  connect(m_ui->upgradeButton, SIGNAL(clicked()), SLOT(upgradeButtonClicked()));
116  connect(m_ui->cancelButton, SIGNAL(clicked()), SLOT(close()));
117 }
118 
120 {
121  delete m_ui;
122 }
123 
125 {
127  connect(d, SIGNAL(downLoadDataChanged(QString)), SLOT(downLoadFinished()));
128  d->startToRequest();
129 }
130 
132 {
134 }
135 
137 {
139  if(!d)
140  {
141  return;
142  }
143 
144  const QString &version = d->version();
145  const QString &description = d->description();
146 
147  QString text;
149  {
150  text.append("v" + version);
151  text.append("\r\n");
152  text.append(description);
153 
154  m_ui->upgradeButton->setEnabled(true);
155  m_ui->titleLable->move(50, 2);
156  m_ui->titleLable->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
157  }
158  else
159  {
160  text.append(tr("Current version is updated"));
161  m_ui->titleLable->move(0, 0);
162  m_ui->titleLable->setAlignment(Qt::AlignCenter);
163  }
164 
165  m_ui->titleLable->setText(text);
166 }
167 
169 {
170  start();
171  return TTKAbstractMoveDialog::exec();
172 }
The class of the moving widget with plain.
voidpf void uLong size
Definition: ioapi.h:136
MusicSourceUpdateWidget(QWidget *parent=nullptr)
The class of the source data query update request.
static const QString PushButtonStyle03
MusicSourceUpdateNotifyWidget(QWidget *parent=nullptr)
static const QString PushButtonStyle04
#define TTK_VERSION_STR
Definition: ttkversion.h:171
TTK_MODULE_EXPORT bool openUrl(const QString &path, bool local=true)
static const QString BackgroundStyle10
static const QString ColorStyle03
Definition: musicuiobject.h:43
void blockMoveOption(bool block)
Ui::MusicSourceUpdateWidget * m_ui
TTK_MODULE_EXPORT bool appVersionCheck(const QString &o, const QString &d)
static const QString ToolButtonStyle04
The class of the ttk moving dialog base.
static constexpr const char * RELEASE_DATA_URL
TTK_MODULE_EXPORT QString mdII(const QString &data, bool encode)
The class of the application upgrade widget.
#define G_SETTING_PTR
const char * description
Definition: http_parser.c:459
#define TTKObjectCast(x, y)
Definition: ttkqtglobal.h:60