void RefImage::downloadImage() { m_imageReply = downloadManager()->get(QNetworkRequest(uri())); connect(imageReply(),SIGNAL(finished()),this,SLOT(imageFromReply())); thumbItem()->startDownload(); connect(imageReply(),SIGNAL(downloadProgress(qint64,qint64)),thumbItem(),SLOT(updateDownloadProgress(qint64,qint64))); }
void Pulsars::startDownload(QString urlString) { QUrl url(urlString); if (!url.isValid() || url.isRelative() || !url.scheme().startsWith("http", Qt::CaseInsensitive)) { qWarning() << "[Pulsars] Invalid URL:" << urlString; return; } if (progressBar == Q_NULLPTR) progressBar = StelApp::getInstance().addProgressBar(); progressBar->setValue(0); progressBar->setRange(0, 0); connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadComplete(QNetworkReply*))); QNetworkRequest request; request.setUrl(QUrl(updateUrl)); request.setRawHeader("User-Agent", StelUtils::getUserAgentString().toUtf8()); #if QT_VERSION >= 0x050600 request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); #endif downloadReply = networkManager->get(request); connect(downloadReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDownloadProgress(qint64,qint64))); updateState = Pulsars::Updating; emit(updateStateChanged(updateState)); }
void Pulsars::deleteDownloadProgressBar() { disconnect(this, SLOT(updateDownloadProgress(qint64,qint64))); if (progressBar) { StelApp::getInstance().removeProgressBar(progressBar); progressBar = Q_NULLPTR; } }
void ConfigGui::startRequest(QUrl url) { // emits the readyRead() signal whenever new data arrives. reply = manager->get(QNetworkRequest(url)); // Whenever more data is received from the network, this readyRead() signal is emitted QObject::connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead())); // Also, downloadProgress() signal is emitted when data is received connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDownloadProgress(qint64,qint64))); // This signal is emitted when the reply has finished processing. QObject::connect(reply, SIGNAL(finished()), this, SLOT(httpDownloadFinished())); }
// This will be called when download button is clicked void Downloader::startRequest(QUrl url) { downloadProgress = 0; downloadFinished = false; // Create a timer to handle hung download requests downloadTimer = new QTimer(this); connect(downloadTimer, SIGNAL(timeout()), this, SLOT(timerCheckDownloadProgress())); downloadTimer->start(30000); // get() method posts a request // to obtain the contents of the target request // and returns a new QNetworkReply object // opened for reading which emits // the readyRead() signal whenever new data arrives. reply = manager->get(QNetworkRequest(url)); // Whenever more data is received from the network, // this readyRead() signal is emitted connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead())); // Also, downloadProgress() signal is emitted when data is received connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDownloadProgress(qint64,qint64))); // This signal is emitted when the reply has finished processing. // After this signal is emitted, // there will be no more updates to the reply's data or metadata. connect(reply, SIGNAL(finished()), this, SLOT(downloaderFinished())); if (!autoDownload) { ui->statusLabel->setText(tr("Downloading...")); progressDialog->show(); } }
void dbmanager::doDownload(const QVariant& v) { if (v.type() == QVariant::StringList) { QNetworkAccessManager *manager= new QNetworkAccessManager(this); QUrl url = v.toStringList().at(current); filename = url.toString().remove("http://restbase.wikitolearn.org/en.wikitolearn.org/v1/media/math/render/svg/"); m_network_reply = manager->get(QNetworkRequest(QUrl(url))); connect(m_network_reply, SIGNAL(downloadProgress (qint64, qint64)),this, SLOT(updateDownloadProgress(qint64, qint64))); // checks download progress connect(m_network_reply,SIGNAL(finished()),this,SLOT(downloadFinished())); // signal that download is finished } }