LoginWidget::LoginWidget(QWidget *parent) : QWidget(parent) { m_loginEdit = new QLineEdit(this); m_passwordEdit = new QLineEdit(this); m_passwordEdit->setEchoMode(QLineEdit::Password); m_rememberCheck = new QCheckBox("Remember me", this); m_signInButton = new QPushButton("Sign in", this); m_createAccountButton = new QPushButton("Create account", this); initGUI(); m_loginQuery = new LoginQuery(DEFAULT_USER_NAME, DEFAULT_USER_PASSWORD, this); m_addEventsChannelQuery = new AddChannelQuery(this); connect(m_signInButton, SIGNAL(clicked()), this, SLOT(onSignInClicked())); connect(m_createAccountButton, SIGNAL(clicked()), this, SLOT(onCreateAccountClicked())); connect(m_loginQuery, SIGNAL(connected()), this, SLOT(onLoginConnected())); connect(m_loginQuery, SIGNAL(errorOccured(QString)), this, SLOT(onError(QString))); connect(m_loginQuery, SIGNAL(networkErrorOccured(QString)), this, SLOT(onError(QString)), Qt::QueuedConnection); }
void SubscribeThread::subscribeDanmaku(QString &url) { QNetworkRequest request; request.setUrl(QUrl(url)); // qDebug()<<"uuid:"<<this->_uuid<<"key:"<<this->_password; request.setRawHeader("User-Agent", "DiveineduDanmaku"); request.setRawHeader("X-GDANMAKU-SUBSCRIBER-ID", this->_uuid.toLocal8Bit()); request.setRawHeader("X-GDANMAKU-AUTH-KEY", this->_password.toLocal8Bit()); QNetworkReply *reply = networkAccessManager->get(request); this->currentReply = reply; connect(reply, SIGNAL(finished()), this, SLOT(processSubscribeDanmakuResponse())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkErrorOccured(QNetworkReply::NetworkError))); connect(reply, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(restartSubscribeTimer()), Qt::QueuedConnection); connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(restartSubscribeTimer()), Qt::QueuedConnection); if(this->subscribeTimer){ this->subscribeTimer->stop(); delete this->subscribeTimer; this->subscribeTimer = NULL; } this->subscribeTimer = new QTimer(); this->subscribeTimer->setInterval(1000*12); connect(this->subscribeTimer, SIGNAL(timeout()), this, SLOT(cancelSubscribe())); this->subscribeTimer->start(); }
void DefaultQuery::handleError() { qDebug() << "Network error occured while sending request"; Q_EMIT networkErrorOccured("network error"); }