void MainWindow::startDownload() { QTreeWidgetItem* tmpItem = new QTreeWidgetItem(QStringList() << currentVideo->getName() << currentVideo->title() << ui.downloadComboFormat->currentText()); tmpItem->setSizeHint(0, QSize(16, 24)); currentVideo->setTreeItem(tmpItem); currentVideo->setQuality(ui.downloadComboQuality->currentIndex()); currentVideo->setConverter(cg->formats.at(ui.downloadComboFormat->currentIndex())._converter->createNewInstance(),cg->formats.at(ui.downloadComboFormat->currentIndex())._mode); QString target; if (cg->settings.value("NeverAskForPath", false).toBool() == false) { target = QFileDialog::getSaveFileName(this, tr("Select Target"), cg->settings.value("savedPath", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString() +"/" + currentVideo->getSaveTitle()); } else { target = cg->settings.value("savedPath", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString() +"/"+currentVideo->getSaveTitle(); } if (!target.isEmpty()) { if (cg->settings.value("saveLastPath", true) == true) { QString targetDir = target; targetDir.remove(targetDir.split("/", QString::SkipEmptyParts).last()).replace(QRegExp("/+"), "/"); ui.settingsSavedPath->setText(targetDir); } currentVideo->setTargetPath(target); if (cg->settings.value("UseMetadata", false).toBool() == true) { if (ui.downloadComboFormat->currentIndex() == 4 || ui.downloadComboFormat->currentIndex() == 5) { metadataDialog = new QDialog; mdui.setupUi(metadataDialog); mdui.title->setText(currentVideo->title()); metadataDialog->setModal(true); metadataDialog->exec(); currentVideo->setMetaTitle(mdui.title->text()); currentVideo->setMetaArtist(mdui.artist->text()); delete metadataDialog; } } cg->addDownload(currentVideo); ui.downloadTree->insertTopLevelItem(0, tmpItem); currentVideo->_progressBar = new QProgressBar(); currentVideo->_progressBar->setValue(0); currentVideo->_progressBar->setMaximum(1); ui.downloadTree->setItemWidget(tmpItem, 3, currentVideo->_progressBar); ((QProgressBar*) ui.downloadTree->itemWidget(tmpItem, 3))->setMaximum(100); connect(currentVideo, SIGNAL(progressChanged(int,int)),ui.downloadTree, SLOT(update())); connect(currentVideo, SIGNAL(downloadFinished()), currentVideo, SLOT(startConvert())); connect(currentVideo, SIGNAL(conversionFinished(video*)), this, SLOT(handleFinishedConversion(video*))); currentVideo = NULL; ui.downloadLineEdit->clear(); } }
video::video() { handler = new http_handler; connect(handler, SIGNAL(allDownloadsFinished()), this, SLOT(handleDownloads())); connect(handler, SIGNAL(error(QString)), this, SLOT(networkError(QString))); connect(this, SIGNAL(downloadFinished()), this, SLOT(startConvert())); _treeItem = NULL; _downloadPaused = false; _isRestarted = false; }
void MainWindow::on_actionConvert_Movies_triggered() { qDebug() << "on_actionConvert_Movies_triggered"; setUiToConvertingVideo(true); QList<MovieInfo> movies; for (int i = 0; i < ui->tblMovies->count(); i++) { movies << ui->tblMovies->item(i)->data(Qt::UserRole).value<MovieInfo>(); } int idx = ui->cbQuality->currentIndex(); VideoProfile data = ui->cbQuality->itemData(idx).value<VideoProfile>(); this->movieConvertThread = new MovieConvertThread(movies, data); connect(this->movieConvertThread , SIGNAL(finished()) , this , SLOT(on_movieConverterThread_finished())); connect(this->movieConvertThread , SIGNAL(startConvert(MovieInfo)) , this , SLOT(on_movieConverterThread_startConvert(MovieInfo))); connect(this->movieConvertThread , SIGNAL(finishedConvert(MovieInfo, bool)) , this , SLOT(on_movieConverterThread_finishedConvert(MovieInfo, bool))); connect(this->movieConvertThread , SIGNAL(progressMovie(int)) , ui->pbMovie , SLOT(setValue(int))); connect(this->movieConvertThread , SIGNAL(progressOverall(int)) , ui->pbTotal , SLOT(setValue(int))); ui->pbMovie->setValue(0); ui->pbTotal->setValue(0); movieConvertThread->start(); }