ImageProcessing::ImageProcessing(QWidget *parent) : QMainWindow(parent) { iImageIndex = 0; m_NetTimeout = 0; m_ImageTimeout = 0; lbImage = new QLabel(this); bTurnOff = false; m_notRunning = true; setWindowState(Qt::WindowFullScreen); player = new QMediaPlayer(this); playlist = new QMediaPlaylist(); player->setPlaylist(playlist); m_contentList = new FileDownload(this); m_imageFile = new FileDownload(this); pNextImage = new QTimer(); connect(pNextImage, SIGNAL(timeout()), this, SLOT(timeout())); connect(m_contentList, SIGNAL(downloaded()), this, SLOT(contentListDownloadComplete())); connect(m_contentList, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError))); connect(m_imageFile, SIGNAL(downloaded()), this, SLOT(fileDownloadComplete())); connect(m_imageFile, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError))); connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64))); connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged())); connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage())); connect(this, SIGNAL(fileDownloadsComplete()), this, SLOT(unlockShowEvent())); videoWidget = new QVideoWidget(this); player->setVideoOutput(videoWidget); videoWidget->hide(); }
void CWizObjectDataDownloadWorker::startDownload() { // FIXME CWizKMAccountsServer asServer(WizKMGetAccountsServerURL(true)); QString strUserId = m_dbMgr.db().GetUserId(); QString strPassword = m_dbMgr.db().GetPassword(); // FIXME: hard-coded "normal" if (!asServer.Login(strUserId, strPassword, "normal")) { Q_EMIT downloaded(false); return; } WIZUSERINFOBASE info = asServer.GetUserInfo(); info.strKbGUID = m_data.strKbGUID; bool bOk = false; // reset info kb_guid and server url for downloading if (m_data.strKbGUID != m_dbMgr.db().kbGUID()) { CWizGroupDataArray arrayGroup; if (!asServer.GetGroupList(arrayGroup) || arrayGroup.empty()) { Q_EMIT downloaded(false); } CWizGroupDataArray::const_iterator it = arrayGroup.begin(); for (; it != arrayGroup.end(); it++) { const WIZGROUPDATA& group = *it; if (group.strGroupGUID == m_data.strKbGUID) { info.strDatabaseServer = group.strDatabaseServer; bOk = true; break; } } } else { bOk = true; } if (!bOk) { Q_EMIT downloaded(false); return; } CWizKMDatabaseServer ksServer(info); // FIXME: should we query object before download data? if (!ksServer.data_download(m_data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(m_data.eObjectType), m_data.arrayData, m_data.strDisplayName)) { Q_EMIT downloaded(false); return; } m_dbMgr.db(m_data.strKbGUID).UpdateObjectData(m_data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(m_data.eObjectType), m_data.arrayData); Q_EMIT downloaded(true); }
void QGitHubReleaseAPIPrivate::init() const { QObject::connect(m_apiDownloader, SIGNAL(error(QString)), this, SLOT(fdError(QString))); QObject::connect(m_apiDownloader, SIGNAL(downloaded(FileDownloader)), this, SLOT(downloaded(FileDownloader))); QObject::connect(m_apiDownloader, SIGNAL(progress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); m_apiDownloader->start(m_type); }
TileDownloader::TileDownloader(QWidget *parent) : QMainWindow(parent), ui(new Ui::TileDownloader) { ui->setupUi(this); ////////////////////////////////////////////////// //DOWNLOADING STUFF //keep 32 images in ram and store once full or done buffer_size = 1024; connect(ui->pushButtonCancel,SIGNAL(clicked()),this,SLOT(cancelDownload())); connect(ui->pushButtonBrowse,SIGNAL(clicked()),this,SLOT(setOutputPath())); connect(ui->pushButtonDownload,SIGNAL(clicked()),this,SLOT(downloadTiles())); connect(ui->pushButtonStich,SIGNAL(clicked()),this,SLOT(stichDownloadedTiles())); fdl_1 = new FileDownloader(this); connect(fdl_1, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_1())); fdl_2 = new FileDownloader(this); connect(fdl_2, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_2())); fdl_3 = new FileDownloader(this); connect(fdl_3, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_3())); fdl_4 = new FileDownloader(this); connect(fdl_4, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_4())); ////////////////////////////////////////////////// //STICHING STUFF m_stichthread = new Stichthread(); // Worker thread connect( m_stichthread, SIGNAL( progress(const QString&) ), this, SLOT( threadStatus(const QString&) ) ); /* connect( m_stichthread, SIGNAL( ready(bool) ), goButton, SLOT( setEnabled(bool) ) ); */ connect( m_stichthread, SIGNAL( results( const QString& ) ), this, SLOT( threadDone( const QString& ) ) ); // Launch worker thread m_stichthread->start(); }
void OsmTileDownloader::fileDownloaded(QNetworkReply* reply) { QUrl url = reply->url(); if (!requests.contains(url)){ qWarning() << "Response from non-requested url: " << url; }else{ TileCacheKey key = requests.value(url); requests.remove(url); if (reply->error() != QNetworkReply::NoError){ // TODO: it seems that this code is affected by https://bugreports.qt.io/browse/QTBUG-46323 // on Jolla phone (Qt 5.2.2), exists some workaround? Can we copy-paste fixed QNetworkAccessManager to project? qWarning() << "Downloading " << url << "failed with " << reply->errorString(); serverNumber = qrand(); // try another server for future requests emit failed(key.zoomLevel, key.xtile, key.ytile, false); }else{ QByteArray downloadedData = reply->readAll(); QImage image; if (image.loadFromData(downloadedData, Q_NULLPTR)){ qDebug() << "Downloaded tile " << url << " (current thread: " << QThread::currentThread() << ")"; emit downloaded(key.zoomLevel, key.xtile, key.ytile, image, downloadedData); }else{ qWarning() << "Failed to load image data from " << url; emit failed(key.zoomLevel, key.xtile, key.ytile, false); } } } reply->deleteLater(); }
dialogOauthSetup::dialogOauthSetup(QWidget *parent) : QDialog(parent), ui(new Ui::dialogOauthSetup) { ui->setupUi(this); profileimageUrl = ""; if (genericHelper::getOAuthAccessToken().length() > 3) { tw = new TwitchApi(this, genericHelper::getOAuthAccessToken()); } else { tw = new TwitchApi(this, ""); } // init the image loader imgl = new imageLoader(this); QObject::connect(tw, SIGNAL(twitchReady(const QJsonDocument)), this, SLOT(on_AuthSuccess(const QJsonDocument))); QObject::connect(tw, SIGNAL(networkError(QString)), this, SLOT(errorPopup(QString))); QObject::connect(imgl, SIGNAL(downloaded()), this, SLOT(loadProfileImage())); }
HtmlParser::HtmlParser(const QUrl &url, const QString &text, QObject *parent) : QObject(parent), _info(new UrlInfo, [](UrlInfo* p){delete p;}), _downloaded(false), _text(text), _downloader(nullptr) { _info->_url = url.toString(); _info->_found = false; _info->_status = UrlInfo::DOWNLOADING; _info->_percentage = 0; emit processing(_info.data()); QThread * thread = new QThread(); _downloader = new HtmlDownloader(url); _downloader->moveToThread(thread); connect( thread, SIGNAL(started()), _downloader, SLOT(doWork())); connect( _downloader, SIGNAL(finished(QString)), thread, SLOT(quit())); connect( _downloader, SIGNAL(finished(QString)), this, SLOT(downloaded(QString)), Qt::ConnectionType::DirectConnection); connect(_downloader, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); connect( thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); }
void FileDownloader::fileDownloaded(QNetworkReply* pReply) { m_DownloadedData = pReply->readAll(); //emit a signal pReply->deleteLater(); emit downloaded(); }
void TileDownloader::cancelDownload(){ disconnect(fdl_1, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_1())); disconnect(fdl_2, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_2())); disconnect(fdl_3, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_3())); disconnect(fdl_4, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_4())); ui->progressBar->setValue(0); QMessageBox msgBox; msgBox.setWindowTitle("Tile Downloader"); msgBox.setText("Canceled."); msgBox.setIcon(QMessageBox::Information); msgBox.setInformativeText("Canceled all jobs!"); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.exec(); }
bool ExportCommon::download(ExportContext *ctx, QString url, QString to) { QString filePath = QDir::cleanPath(ctx->outputDir.absoluteFilePath(to)); QFileInfo fi = QFileInfo(filePath); ctx->outputDir.mkpath(fi.dir().absolutePath()); QFile file(filePath); if (file.exists()) return true; if (file.open(QIODevice::WriteOnly)) { exportInfo("Downloading %s\n", url.toStdString().c_str()); QUrl imageUrl(url); FileDownloader *m_pImgCtrl = new FileDownloader(imageUrl); QEventLoop loop; loop.connect(m_pImgCtrl, SIGNAL(downloaded()), &loop, SLOT(quit())); loop.exec(); QByteArray data = m_pImgCtrl->downloadedData(); delete m_pImgCtrl; if (data.length() > 0) { file.write(data); return true; } else exportError("Failed to download %s\n", url.toStdString().c_str()); } else exportError("Can't open file %s\n", to.toStdString().c_str()); return false; }
void Report::setData(const QString& data) { if (data == data_) { return; } clear(); data_ = data; processCommands(); // Count the number of rows/cols if (rows_ == 0 || cols_ == 0) { const QSize size = Text::pageSize(data_); rows_ = size.height(); cols_ = size.width(); } // Load pictures if (!pictures_.isEmpty()) { DownloadPictures* download = new DownloadPictures(this); connect(download, SIGNAL(downloaded(QUrl,QPixmap)), this, SLOT(pictureDownloaded(QUrl,QPixmap))); connect(download, SIGNAL(finished()), this, SIGNAL(loaded())); connect(download, SIGNAL(finished()), download, SLOT(deleteLater())); foreach (const QUrl& url, pictures_.uniqueKeys()) { download->download(url); } }
void HSCardDownloader::saveWebImage(QNetworkReply * reply) { reply->deleteLater(); QString code = gettingWebCards[reply]; if(reply->error() != QNetworkReply::NoError) { emit pDebug("Failed to download card image: " + code, Error); emit pLog(tr("Web: Failed to download card image.")); return; } QImage webImage; webImage.loadFromData(reply->readAll()); if(!webImage.save(Utility::appPath() + "/HSCards/" + code + ".png", "png")) { emit pDebug("Failed to save card image to disk: " + code, Error); emit pLog(tr("File: ERROR:Saving card image to disk. Make sure HSCards dir is in the same place as the exe.")); return; } emit downloaded(code); gettingWebCards.remove(reply); emit pDebug("Web Cards remaining(-1): " + QString::number(gettingWebCards.count())); emit pLog(tr("Web: New card image downloaded.")); }
Song PodcastEpisode::ToSong(const Podcast& podcast) const { Song ret; ret.set_valid(true); ret.set_title(title().simplified()); ret.set_artist(author().simplified()); ret.set_length_nanosec(kNsecPerSec * duration_secs()); ret.set_year(publication_date().date().year()); ret.set_comment(description()); if (downloaded() && QFile::exists(local_url().toLocalFile())) { ret.set_url(local_url()); } else { ret.set_url(url()); } ret.set_basefilename(QFileInfo(ret.url().path()).fileName()); // Use information from the podcast if it's set if (podcast.is_valid()) { ret.set_album(podcast.title().simplified()); ret.set_art_automatic(podcast.ImageUrlLarge().toString()); if (author().isEmpty()) ret.set_artist(podcast.title().simplified()); } return ret; }
void RISE::downloadRequested(const QNetworkRequest &request) { // First prompted with a file dialog to make sure // they want the file and to select a download // location and name. QString defaultFileName = QFileInfo(request.url().toString()).fileName(); QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), defaultFileName); if (fileName.isEmpty()) return; // Construct a new request that stores the // file name that should be used when the // download is complete QNetworkRequest newRequest = request; newRequest.setAttribute(QNetworkRequest::User, fileName); // Ask the network manager to download // the file and connect to the progress // and finished signals. QNetworkAccessManager *networkManager = page()->networkAccessManager(); QNetworkReply *reply = networkManager->get(newRequest); connect(reply, SIGNAL(finished()), this, SLOT(downloaded())); }
void DownloadManager::dataFileRequest(QNetworkReply *finished, QString language) { if (checkError(finished)) return; QByteArray data = finished->readAll(); QString dataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString path = dataDir + "/" + fileName + language + fileType; QFile file(path); file.open(QIODevice::WriteOnly); qint64 bytes = file.write(data); if(bytes == -1) { qDebug() << "write error"; } file.close(); emit downloaded(language); QStringList argList; argList.append("-xzf"); argList.append(path); argList.append("-C"); argList.append(dataDir); QObject::connect(process_, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(extracted(int, QProcess::ExitStatus))); process_->start("tar", argList, QIODevice::ReadOnly); finished->deleteLater(); }
FileHandler::FileHandler(QString newFileName, QObject * parent): QObject(parent), fileName(newFileName), fileObject(fileName), fileStatus(unknown) { if (fileObject.exists()) { setFileStatus(exists); fileInfos = new QFileInfo(fileName); fileDateCreated = fileInfos->created(); delete fileInfos; if (isOutdated()) { setFileStatus(outdated); } else { setFileStatus(good); } } else { setFileStatus(missing); } QUrl fileUrl("http://www.netmark.pl/templates/portal/images/whmcslogo.png"); m_Downloader = new Downloader(fileUrl, this); connect(m_Downloader, SIGNAL(downloaded()), this, SLOT(loadFile())); connect(m_Downloader, SIGNAL(logmsg(QString)),this,SLOT(mainlog(QString))); }
void WebBridgeRS::downloadURL(QString url){ QUrl imageUrl(url); FileDownloader* fileDownloader = new FileDownloader(imageUrl, this); connect(fileDownloader, SIGNAL(downloaded()), SLOT(onUrlDownloaded())); }
void FileDownloader::fileDownloaded(QNetworkReply* pReply) { m_DownloadedData = pReply->readAll(); //emit a signal pReply->deleteLater(); finished = true; emit downloaded(m_fileName,m_DownloadedData); }
void DownloadFile::cancel() { reply->disconnect(this, SLOT(downloaded(qint64,qint64))); reply->disconnect(this, SLOT(gotMetaData())); reply->abort(); if(file->isOpen()) file->close(); file->remove(); }
void TileDownloader::startImgDownloader_4(){ setProgress(current_tile_index,tiles_to_load.size()); if(image_buffer.size() >= buffer_size){ writeImagesToDisk(); } disconnect(fdl_4, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_4())); if(current_tile_index < tiles_to_load.size()){ current_tile_index_4 = current_tile_index; current_tile_index += 1; connect(fdl_4, SIGNAL (downloaded()), this, SLOT (loadAndSaveImage_4())); fdl_4->download(getnextUrl(current_tile_index_4)); } else{ downloadDone(); } }
void DkImageContainerT::downloadFile(const QUrl& url) { if (!mFileDownloader) { mFileDownloader = QSharedPointer<FileDownloader>(new FileDownloader(url, this)); connect(mFileDownloader.data(), SIGNAL(downloaded()), this, SLOT(fileDownloaded()), Qt::UniqueConnection); qDebug() << "trying to download: " << url; } else mFileDownloader->downloadFile(url); }
void AvatarDownloader::downloadAvatar( const QString& username, const KUrl& url ) { if( !url.isValid() ) return; m_userAvatarUrls.insert( url, username ); The::networkAccessManager()->getData( url, this, SLOT(downloaded(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); }
void FileDownloader::fileDownloaded(QNetworkReply* pReply) { if(this->shouldSave) { this->writeToFile->close(); } //emit a signal pReply->deleteLater(); emit downloaded(); }
void QGitHubReleaseAPIPrivate::downloaded(const FileDownloader &fd) { QObject::connect(m_apiDownloader, SIGNAL(error(QString)), this, SLOT(fdError(QString))); QObject::connect(m_apiDownloader, SIGNAL(downloaded(FileDownloader)), this, SLOT(downloaded(FileDownloader))); QObject::connect(m_apiDownloader, SIGNAL(progress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); m_jsonData = fd.downloadedData(); foreach(const FileDownloader::RAWHEADERPAIR &pair, fd.rawHeaderPairs()) { if(pair.first == "ETag") m_eTag = pair.second.mid(2); if(pair.first == "X-RateLimit-Reset") { m_rateLimitReset = QDateTime::fromTime_t(QString(pair.second).toUInt()); } if(pair.first == "X-RateLimit-Limit") m_rateLimit = QString(pair.second).toUInt(); if(pair.first == "X-RateLimit-Remaining") { m_rateLimitRemaining = QString(pair.second).toUInt(); } } QVariant va(parseJSon(m_jsonData, m_errorString)); if(m_errorString.isNull()) { if(m_singleEntryRequested) { m_vdata.append(va); } else if((m_vdata = va.toList()).isEmpty()) { m_errorString = va.toMap()["message"].toString(); emit error(m_errorString); return; } emit available(); } else { emit error(m_errorString); } }
DialogLaunch::DialogLaunch(QWidget *parent) : QDialog(parent), ui(new Ui::DialogLaunch) { ui->setupUi(this); this->loadPositions(); this->ui->pushButtonStart->setEnabled(false); // init the image loader imgl = new imageLoader(this); QObject::connect(imgl, SIGNAL(downloaded()), this, SLOT(loadStreamLogoImage())); }
void MainWindow::fetch(){ ui->cmdFetch->setText("Fetching..."); ui->statusBar->showMessage("Downloading image urls..."); QList<QString> list; list.append(QString("http://9gag.com/")); list.append(QString("http://www.lolhappens.com/")); list.append(QString("http://www.memecenter.com/")); list.append(QString("http://uberhumor.com/")); list.append(QString("http://porkystuff.com/")); m_pImgCtrl = new FileDownloader(QUrl(list[rand()%5]), this); connect(m_pImgCtrl, SIGNAL(downloaded()), SLOT(getImageUrl())); ui->cmdFetch->setEnabled(false); }
void DownloadFile::getRequest( QUrl url ) { QNetworkRequest req(url); if(!file->isOpen()) { file->open(QFile::ReadWrite); } reply = manager->get(req); connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloaded(qint64,qint64))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(emitError(QNetworkReply::NetworkError))); connect(reply, SIGNAL(metaDataChanged()), this, SLOT(gotMetaData())); }
void FileDownloader::fileDownloaded(QNetworkReply *pReply) { if(m_reply->error() != QNetworkReply::NoError) { if(m_reply->error() != QNetworkReply::OperationCanceledError) { emit error(m_reply->errorString()); } else { emit canceled(); } } else { QVariant redirectTarget = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if(!redirectTarget.isNull()) { m_url = m_url.resolved(redirectTarget.toUrl()); qWarning("Redirect to: %s", qPrintable(m_url.toString())); QObject::disconnect(m_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); m_reply->deleteLater(); m_request.setUrl(m_url); m_reply = m_WebCtrl.get(m_request); QObject::connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); emit replyChanged(m_reply); } else { #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) m_rawHeaderPairs = m_reply->rawHeaderPairs(); #else m_rawHeaderPairs.clear(); foreach(const QByteArray &rhk, m_reply->rawHeaderList()) { m_rawHeaderPairs.append(RAWHEADERPAIR(rhk, m_reply->rawHeader(rhk))); } #endif m_DownloadedData = pReply->readAll(); m_reply->deleteLater(); emit downloaded(*this); } } }
void ModuleDownloader::downloadNext() { emit nextFile(m_counter, m_fileCount);//show progress if(m_fileCount == 0) { //oh uhm: nothing to download emit downloaded(m_retData);//finish return; } if(m_counter < m_fileCount) { //download next download(m_urls.at(m_counter));//real download m_counter++; } else { //finished all myDebug() << "finished!!!"; emit downloaded(m_retData);//finish } }
void MainWindow::getImageUrl(){ QString data = m_pImgCtrl->downloadedData(); QRegExp rx("\\<img[^\\>]*src\\s*=\\s*\"([^\"]*)\"[^\\>]*\\>"); QStringList list; int pos = 0; while ((pos = rx.indexIn(data, pos)) != -1){ list << rx.cap(1); pos += rx.matchedLength(); } int randomNo = rand() % list.length(); ui->statusBar->showMessage("Fetching Image"); QUrl imageUrl(list[randomNo]); imageDownloader = new FileDownloader(imageUrl,this); connect(imageDownloader,SIGNAL(downloaded()), SLOT(loadImage())); }