| 499 | } |
| 500 | |
| 501 | void MainWindow::processQueue() { |
| 502 | if(ui->listWidget_queue->count() == 0) |
| 503 | return; |
| 504 | |
| 505 | if(!(ui->checkBox_queue_generateNormal->isChecked() || |
| 506 | ui->checkBox_queue_generateSpec->isChecked() || |
| 507 | ui->checkBox_queue_generateDisplace->isChecked())) { |
| 508 | QMessageBox::information(this, "Nothing to do", "Select at least one map type to generate from the \"Save\" section"); |
| 509 | return; |
| 510 | } |
| 511 | |
| 512 | if(!exportPath.isValid()) { |
| 513 | QMessageBox::information(this, "Invalid Export Path", "Export path is invalid!"); |
| 514 | return; |
| 515 | } |
| 516 | |
| 517 | //enable stop button |
| 518 | ui->pushButton_stopProcessingQueue->setEnabled(true); |
| 519 | //show progress bar and adjust maximum to queue size |
| 520 | ui->progressBar_Queue->show(); |
| 521 | ui->progressBar_Queue->setMaximum(ui->listWidget_queue->count()); |
| 522 | |
| 523 | for(int i = 0; i < ui->listWidget_queue->count() && !stopQueue; i++) |
| 524 | { |
| 525 | QueueItem *item = (QueueItem*)(ui->listWidget_queue->item(i)); |
| 526 | |
| 527 | //display status |
| 528 | ui->statusBar->showMessage("Processing Image \"" + item->text() + "\""); |
| 529 | ui->progressBar_Queue->setValue(i + 1); |
| 530 | ui->listWidget_queue->item(i)->setSelected(true); |
| 531 | |
| 532 | //load image |
| 533 | load(item->getUrl()); |
| 534 | |
| 535 | //save maps |
| 536 | QUrl exportUrl = QUrl::fromLocalFile(exportPath.toLocalFile() + "/" + item->text()); |
| 537 | std::cout << "[Queue] Image " << i + 1 << " exported: " |
| 538 | << exportUrl.toLocalFile().toStdString() << std::endl; |
| 539 | save(exportUrl); |
| 540 | |
| 541 | //user interface should stay responsive |
| 542 | QCoreApplication::processEvents(); |
| 543 | } |
| 544 | |
| 545 | //disable stop button |
| 546 | ui->pushButton_stopProcessingQueue->setEnabled(false); |
| 547 | stopQueue = false; |
| 548 | //hide queue progress bar |
| 549 | ui->progressBar_Queue->hide(); |
| 550 | |
| 551 | //enable "Open Export Folder" gui button |
| 552 | ui->pushButton_openExportFolder->setEnabled(true); |
| 553 | } |
| 554 | |
| 555 | //tell the queue to stop processing |
| 556 | void MainWindow::stopProcessingQueue() { |