TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicnetworkconnectiontestwidget.cpp
Go to the documentation of this file.
2 #include "ui_musicnetworkconnectiontestwidget.h"
4 #include "musicalgorithmutils.h"
5 
6 static constexpr const char *CHECK_WWW_VISIT = "dm81Smp4VzI3eHFVNzV4aHgyU2RYN2paNDhJPQ==";
7 static constexpr const char *CHECK_NORMAL_VISIT = "aGEvbU52TkJVMzQ0Z0hoSllOd2wwZz09";
8 static constexpr const char *CHECK_VIP_VISIT = "ZjlBQUFxY25KM1BKd2h3VzZVZ1F5dVJHMThEYlFkTWU=";
9 static constexpr const char *CHECK_DOWNLOAD_VISIT = "bkIwTS9NZE9wSUZyLythbm5YQVJVeDBtQStBPQ==";
10 static constexpr const char *CHECK_SERVER_VISIT = "T2tjRlYvUVUvVUVORDg4dHI1NlorOUR0SHVvZ3RUQ1g=";
11 
13  : QWidget(parent)
14 {
15  QHBoxLayout *layout = new QHBoxLayout(this);
16  layout->setSpacing(0);
17  layout->setContentsMargins(0, 0, 0, 0);
18 
19  m_iconLabel = new QLabel(this);
20  m_nameText = new QLabel(this);
21  m_stateText = new QLabel(this);
22 
23  m_iconLabel->setFixedWidth(32);
24  m_nameText->setFixedWidth(325);
25  m_stateText->setAlignment(Qt::AlignCenter);
26 
27  layout->addWidget(m_iconLabel);
28  layout->addWidget(m_nameText);
29  layout->addWidget(m_stateText);
30 
31  m_thread = new MusicNetworkTestThread(this);
32  connect(m_thread, SIGNAL(networkConnectionTestChanged(bool)), SLOT(testFinshed(bool)));
33  stop();
34 
35  setLayout(layout);
36 }
37 
39 {
40  m_thread->stop();
41  delete m_thread;
42  delete m_iconLabel;
43  delete m_nameText;
44  delete m_stateText;
45 }
46 
47 void MusicNetworkConnectionItem::setText(const QString &text)
48 {
49  m_nameText->setText(text);
50 }
51 
52 void MusicNetworkConnectionItem::setUrl(const QString &url)
53 {
54  m_thread->setUrl(url);
55 }
56 
58 {
59  m_stateText->setText(tr("Detecting"));
60  m_stateText->setStyleSheet(TTK::UI::ColorStyle07);
61  m_thread->start();
62 }
63 
65 {
66  m_iconLabel->setPixmap(QPixmap(":/tiny/lb_question"));
67 
68  m_stateText->setText(tr("Undetected"));
69  m_stateText->setStyleSheet(TTK::UI::ColorStyle03);
70  if(m_thread->isRunning())
71  {
72  m_thread->stop();
73  }
74 }
75 
77 {
78  m_stateText->setText(state ? tr("Detected") : tr("Failed"));
79  m_iconLabel->setPixmap(QPixmap(state ? ":/tiny/lb_right" : ":/tiny/lb_error"));
81 
83 }
84 
85 
87  : MusicAbstractMoveWidget(parent),
89  m_index(0)
90 {
91  m_ui->setupUi(this);
92  setFixedSize(size());
93  setAttribute(Qt::WA_DeleteOnClose);
94  setBackgroundLabel(m_ui->background);
95 
96  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
97  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
98  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
99  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
100  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
101 
102  m_ui->iconLabel->setType(MusicGifLabelWidget::Module::CheckBlue);
103  m_ui->textLabel->setStyleSheet(TTK::UI::BackgroundStyle01);
104  m_ui->startButton->setStyleSheet(TTK::UI::PushButtonStyle04);
105 #ifdef Q_OS_UNIX
106  m_ui->startButton->setFocusPolicy(Qt::NoFocus);
107 #endif
108 
109  m_ui->verticalLayout->setSpacing(3);
110  m_ui->verticalLayout->setContentsMargins(0, 0, 0, 0);
111 
113  m_connectionItems << item;
114  item->setText(tr("Check www visit"));
115  item->setUrl(TTK::Algorithm::mdII(CHECK_WWW_VISIT, false));
116  connect(item, SIGNAL(networkConnectionTestChanged()), SLOT(testFinshed()));
117  m_ui->verticalLayout->addWidget(item);
118 
119  item = new MusicNetworkConnectionItem(this);
120  m_connectionItems << item;
121  item->setText(tr("Check normal visit"));
122  item->setUrl(TTK::Algorithm::mdII(CHECK_NORMAL_VISIT, false));
123  connect(item, SIGNAL(networkConnectionTestChanged()), SLOT(testFinshed()));
124  m_ui->verticalLayout->addWidget(item);
125 
126  item = new MusicNetworkConnectionItem(this);
127  m_connectionItems << item;
128  item->setText(tr("Check vip visit"));
129  item->setUrl(TTK::Algorithm::mdII(CHECK_VIP_VISIT, false));
130  connect(item, SIGNAL(networkConnectionTestChanged()), SLOT(testFinshed()));
131  m_ui->verticalLayout->addWidget(item);
132 
133  item = new MusicNetworkConnectionItem(this);
134  m_connectionItems << item;
135  item->setText(tr("Check download visit"));
136  item->setUrl(TTK::Algorithm::mdII(CHECK_DOWNLOAD_VISIT, false));
137  connect(item, SIGNAL(networkConnectionTestChanged()), SLOT(testFinshed()));
138  m_ui->verticalLayout->addWidget(item);
139 
140  item = new MusicNetworkConnectionItem(this);
141  m_connectionItems << item;
142  item->setText(tr("Check server visit"));
143  item->setUrl(TTK::Algorithm::mdII(CHECK_SERVER_VISIT, false));
144  connect(item, SIGNAL(networkConnectionTestChanged()), SLOT(testFinshed()));
145  m_ui->verticalLayout->addWidget(item);
146 
147  connect(m_ui->startButton, SIGNAL(clicked()), SLOT(buttonStateChanged()));
148 }
149 
151 {
152  TTKRemoveSingleWidget(className());
153  qDeleteAll(m_connectionItems);
154  delete m_ui;
155 }
156 
158 {
159  m_ui->iconLabel->updateRender();
161 }
162 
164 {
165  m_index = 0;
166  if(!m_ui->iconLabel->isRunning())
167  {
168  m_ui->iconLabel->start();
169  m_ui->startButton->setText(tr("Stop"));
170 
172  {
173  item->start();
174  }
175  }
176  else
177  {
178  m_ui->iconLabel->stop();
179  m_ui->startButton->setText(tr("Start"));
180 
182  {
183  item->stop();
184  }
185  }
186 }
187 
189 {
190  if(++m_index == 5)
191  {
192  m_ui->iconLabel->stop();
193  m_ui->startButton->setText(tr("Start"));
194  }
195 }
void setBackgroundLabel(QLabel *label)
static constexpr const char * CHECK_SERVER_VISIT
MusicNetworkConnectionItem(QWidget *parent=nullptr)
voidpf void uLong size
Definition: ioapi.h:136
static constexpr const char * CHECK_VIP_VISIT
static constexpr const char * CHECK_WWW_VISIT
The class of the thread to test input url network.
#define qAsConst
Definition: ttkqtglobal.h:53
#define TTKRemoveSingleWidget(name)
The class of the network connection item Widget.
static const QString BackgroundStyle01
Background.
Definition: musicuiobject.h:77
The class of the network connection test widget.
static const QString PushButtonStyle04
static const QString ColorStyle09
Definition: musicuiobject.h:61
Ui::MusicNetworkConnectionTestWidget * m_ui
static constexpr const char * CHECK_DOWNLOAD_VISIT
static const QString ColorStyle07
Definition: musicuiobject.h:55
static constexpr const char * CHECK_NORMAL_VISIT
static const QString ColorStyle03
Definition: musicuiobject.h:43
QList< MusicNetworkConnectionItem * > m_connectionItems
static const QString ToolButtonStyle04
static const QString ColorStyle11
Definition: musicuiobject.h:67
void setUrl(const QString &url)
TTK_MODULE_EXPORT QString mdII(const QString &data, bool encode)
state
Definition: http_parser.c:279
The class of the moving widget base.