--- Vago/trunk/Vago/mainwindow.cpp 2016/10/12 21:35:13 1054 +++ Vago/trunk/Vago/mainwindow.cpp 2016/10/30 14:42:39 1058 @@ -128,9 +128,6 @@ MainWindow::MainWindow(QWidget *parent) ui->statusBar->addPermanentWidget(this->myBar); //this adds automatically in right ui->statusBar->addPermanentWidget(ui->tbAbortConversion); - //Initialize list pointers - this->listToProccess = new QStringList; - // User interface ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button ui->mainToolBar->addWidget(ui->emptySpacerLabel); //trick, we can't add directly a space so we add an empty @@ -138,6 +135,8 @@ MainWindow::MainWindow(QWidget *parent) ui->mainToolBar->addWidget(ui->emptySpacerLabel2); //same as before ui->mainToolBar->addWidget(ui->tbCommand); //add option to manual onisplit commands ui->mainToolBar->addWidget(ui->emptySpacerLabel3); //same as before + ui->mainToolBar->addWidget(ui->tbXmlToolsInterface); //add option to manual onisplit commands + ui->mainToolBar->addWidget(ui->emptySpacerLabel4); //same as before ui->mainToolBar->addWidget(ui->tbOpenFolder); //add option to open folder with files converted etc ui->mainToolBar->setLayoutDirection(Qt::RightToLeft); @@ -207,9 +206,9 @@ void MainWindow::applicationWasLoaded(){ this->win7TaskBarProgress = this->win7TaskBarButton->progress(); //Create a thread for do the conversion in background - this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, this->listToProccess, this->win7TaskBarProgress); + this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, &this->listToProccess, this->win7TaskBarProgress); #else - this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, this->listToProccess); + this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, &this->listToProccess); #endif connectSlots(); @@ -292,6 +291,15 @@ void MainWindow::on_tbOpenFolder_clicked QDesktopServices::openUrl(QUrl("file:///"+this->outputFolder)); } + +void MainWindow::on_tbXmlToolsInterface_clicked() +{ + //We pass no parent because we want to have an independent window for XmlToolsInterface, + //so we can minimize it or maximize indepently from the MainWindow + XmlToolsInterface *xmlToolsWindow = new XmlToolsInterface(this->myLogger); + xmlToolsWindow->show(); //it destroys itself when finished. +} + void MainWindow::on_tbAbortConversion_clicked() { if(Util::showQuestionPopUp(this,"Are you sure you want to abort the current conversion?")){ @@ -741,7 +749,7 @@ void MainWindow::startConversion(){ for(int i=0; irowCount(); i++){ //Only process enabled items if(currTable->item(i,2)->background()!=currTable->disabledBackStyle){ - this->listToProccess->append(currTable->item(i,2)->text()); + this->listToProccess.append(currTable->item(i,2)->text()); } } @@ -1186,8 +1194,12 @@ void MainWindow::closeEvent(QCloseEvent QMessageBox::StandardButton result = askToSaveCurrentProject(); if(result == QMessageBox::StandardButton::Cancel){ event->ignore(); + return; } } + + // Exit application (this will also close all other windows which don't have parent, for instance ManualCommands) + QApplication::quit(); } QMessageBox::StandardButton MainWindow::askToSaveCurrentProject(){ @@ -1224,7 +1236,7 @@ void MainWindow::on_cbBnvLevels_toggled( ui->leBnvLevels->setEnabled(checked); ui->cbGridsLevels->setEnabled(checked); ui->cbGridsLevels->setChecked(checked); - if(checked){ + if(checked && !projectIsLoading){ QString file=QFileDialog::getOpenFileName(this,"Choose the BNV.dae file...","./" , "All Files (*.*)"); if(!file.isEmpty()){ ui->leBnvLevels->setText(file); @@ -1236,7 +1248,7 @@ void MainWindow::on_cbAdditionalSourcesL { ui->leAdditSourcesLevels->setEnabled(checked); - if(checked){ + if(checked && !projectIsLoading){ QStringList filesSelected=QFileDialog::getOpenFileNames(this,"Choose the additional .dae files...","./" , "All Files (*.*)"); QString filesJoined; int size=filesSelected.size(); @@ -1305,8 +1317,9 @@ void MainWindow::rowsWereChangedInDropTa void MainWindow::on_tbCommand_clicked() { - //Show preferences - ManualCommands *commandsWindow = new ManualCommands(this); + //We pass no parent because we want to have an independent window for ManualCommands, + //so we can minimize it or maximize indepently from the MainWindow + ManualCommands *commandsWindow = new ManualCommands(); commandsWindow->show(); //it destroys itself when finished. } @@ -2001,9 +2014,12 @@ QList MainWindow::getA void MainWindow::loadProjectState(const QString &filePath) { + this->projectIsLoading = true; + if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){ QMessageBox::StandardButton result = askToSaveCurrentProject(); if(result == QMessageBox::StandardButton::Cancel){ + this->projectIsLoading = false; return; } } @@ -2017,6 +2033,7 @@ void MainWindow::loadProjectState(const if(result.status!=pugi::status_ok){ UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while loading project file.\n" + QString(result.description())); showErrStatusMessage(statusError); + this->projectIsLoading = false; return; } @@ -2024,6 +2041,7 @@ void MainWindow::loadProjectState(const if(QString(doc.root().first_child().name()) != "VagoProject"){ UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, QString(doc.root().name()) + "The file opened is not a valid VagoProject file. Load aborted."); showErrStatusMessage(statusError); + this->projectIsLoading = false; return; } @@ -2036,12 +2054,14 @@ void MainWindow::loadProjectState(const { UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't find the vagoVersion of the current project. Load aborted.\n" + QString(e.what())); showErrStatusMessage(statusError); + this->projectIsLoading = false; return; } if(!projVagoVersion.startsWith(GlobalVars::LastCompatibleVersion)){ UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "The project that you are trying to load seems it is not compatible with your Vago Version. Please update Vago and try again."); showErrStatusMessage(statusError); + this->projectIsLoading = false; return; } @@ -2057,6 +2077,7 @@ void MainWindow::loadProjectState(const catch(const std::exception& e){ UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't load the vago project. Error: " + QString(e.what())); showErrStatusMessage(statusError); + this->projectIsLoading = false; return; } @@ -2069,6 +2090,8 @@ void MainWindow::loadProjectState(const setVagoWindowTitle(); + this->projectIsLoading = false; + showSuccessStatusMessage("Project loaded sucessfully."); } @@ -2131,7 +2154,7 @@ void MainWindow::loadProjectWidget(pugi: ui->leBnvLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSourceValue")).attribute().value())); ui->cbGridsLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@generateGrids")).attribute().as_bool()); ui->cbAdditionalSourcesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSources")).attribute().as_bool()); - ui->leAdditSourcesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().value())); + ui->leAdditSourcesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSourcesValue")).attribute().value())); } else{ ui->cbFromMisc->setCurrentText(from);