--- Vago/trunk/Vago/mainwindow.cpp 2014/04/25 21:05:54 998 +++ Vago/trunk/Vago/mainwindow.cpp 2016/03/24 22:28:41 1035 @@ -9,26 +9,24 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); - this->AppDir=getOSIndependentAppPath(); + this->myLogger = new Logger(Util::getAppPath()); //start logger - this->myLogger = new Logger(this->AppDir); //start logger - - this->myLogger->writeString("Detected AppDir: "+this->AppDir); + this->myLogger->writeString("Detected AppDir: "+Util::getAppPath()); this->myLogger->writeString("True app dir: "+QDir::currentPath()); this->setWindowTitle("Vago v"+GlobalVars::AppVersion); - if(!QFile::exists(this->AppDir+"/"+GlobalVars::OniSplitString)){ + if(!QFile::exists(Util::getAppPath()+"/"+GlobalVars::OniSplitString)){ Util::showErrorPopUp("OniSplit not found. Please download it at "+GlobalVars::ModsDomain+" and put it in the same folder of Vago. \n\nProgram will now exit."); exit(1); } - if(!QFile::exists(this->AppDir+"/"+GlobalVars::XmlToolsString)){ + if(!QFile::exists(Util::getAppPath()+"/"+GlobalVars::XmlToolsString)){ Util::showErrorPopUp("xmlTools not found. Please download it at "+GlobalVars::ModsDomain+" and put it in the same folder of Vago. \n\nProgram will now exit."); exit(1); } - this->vagoSettings = new QSettings(this->AppDir + "/" + this->VagoSettingsName, QSettings::IniFormat); + this->vagoSettings = new QSettings(Util::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); //First Execution? Old configuration? Settings missed? bool iniChanged=false; @@ -37,7 +35,7 @@ MainWindow::MainWindow(QWidget *parent) iniChanged=true; } if(!this->vagoSettings->contains("Workspace")){ - this->vagoSettings->setValue("Workspace", this->AppDir+"/VagoWorkspace"); + this->vagoSettings->setValue("Workspace", Util::getAppPath()+"/VagoWorkspace"); iniChanged=true; } if(!this->vagoSettings->contains("AeFolder")){ @@ -78,8 +76,8 @@ MainWindow::MainWindow(QWidget *parent) iniChanged=true; } #ifdef Q_OS_MAC - if(!this->vagoSettings->contains("UseYesButtonClear")){ - this->vagoSettings->setValue("UseYesButtonClear", false); + if(!this->vagoSettings->contains("useYesAsDefaultWhenRemovingItems")){ + this->vagoSettings->setValue("useYesAsDefaultWhenRemovingItems", false); iniChanged=true; } #endif @@ -96,7 +94,7 @@ MainWindow::MainWindow(QWidget *parent) this->startedWindowWidth=this->vagoSettings->value("WindowWidth").toInt(); this->startedWindowHeight=this->vagoSettings->value("WindowHeight").toInt(); #ifdef Q_OS_MAC - this->useYesAsDefaultInClearButton=this->vagoSettings->value("UseYesButtonClear").toBool(); + this->useYesAsDefaultWhenRemovingItems=this->vagoSettings->value("useYesAsDefaultWhenRemovingItems").toBool(); #endif //Create our workspace if it doesn't exists yet @@ -120,7 +118,7 @@ MainWindow::MainWindow(QWidget *parent) this->listToProccess = new QStringList; //Create a thread for do the conversion in background - this->myConverter = new Converter(this->AppDir,this->myLogger,this->listToProccess); + this->myConverter = new Converter(Util::getAppPath(),this->myLogger,this->listToProccess); // User interface ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button @@ -188,7 +186,7 @@ void MainWindow::on_actionAE_Package_Cre void MainWindow::on_actionSound_Wizard_triggered() { - SoundWizard myWizard (this->AppDir, this->workspaceWizardsLocation, this->myLogger, &this->commandMap); + SoundWizard myWizard (Util::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap); myWizard.exec(); } @@ -1069,7 +1067,7 @@ void MainWindow::removeTableContents(Dro } #ifdef Q_OS_MAC - if(this->useYesAsDefaultInClearButton){ + if(this->useYesAsDefaultWhenRemovingItems){ defaultButton = QMessageBox::Yes; } else{ @@ -1088,12 +1086,24 @@ void MainWindow::removeTableContents(Dro } void MainWindow::clearTableContents(DropTableWidget *myTable){ + + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os + if(myTable->rowCount()==0){ Util::showPopUp("Nothing to clear."); return; } - if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?")){ +#ifdef Q_OS_MAC + if(this->useYesAsDefaultWhenRemovingItems){ + defaultButton = QMessageBox::Yes; + } + else{ + defaultButton = QMessageBox::No; + } +#endif + + if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){ myTable->clearContents(); myTable->setRowCount(0); } @@ -1176,8 +1186,8 @@ void MainWindow::on_cbWithTRBS_ONCC_togg void MainWindow::on_actionCheck_OniSplit_version_triggered() { QProcess *myProcess = new QProcess(); - myProcess->setWorkingDirectory(this->AppDir); - myProcess->start(GlobalVars::OniSplitExeName+" -version"); + myProcess->setWorkingDirectory(Util::getAppPath()); + myProcess->start(Util::getOniSplitExeName()+" -version"); myProcess->waitForFinished(-1); QString result=myProcess->readAllStandardOutput(); delete myProcess; @@ -1187,8 +1197,8 @@ void MainWindow::on_actionCheck_OniSplit void MainWindow::on_actionCheck_xmlTools_version_triggered() { QProcess *myProcess = new QProcess(); - myProcess->setWorkingDirectory(this->AppDir); - myProcess->start(GlobalVars::XmlToolsExeName+" version"); + myProcess->setWorkingDirectory(Util::getAppPath()); + myProcess->start(Util::getXmlToolsExeName()+" version"); myProcess->waitForFinished(-1); QString result=myProcess->readLine(); delete myProcess; @@ -1560,23 +1570,6 @@ void MainWindow::setConverterButtonsSize ui->pbConvertMisc->setMinimumHeight(height); } -/** - Gets application directory. In mac os gets the .app directory - **/ -QString MainWindow::getOSIndependentAppPath(){ -#ifdef Q_OS_MAC - QDir dir = QDir::current(); - if(dir.absolutePath().contains(".app")){ // include bundle, but we don't want it - dir.cdUp(); - dir.cdUp(); - dir.cdUp(); - } - return dir.absolutePath(); -#else - return QDir::currentPath(); -#endif -} - void MainWindow::connectSlots(){ //This signal is for thread that is working setup the progress bar (make it visible and set it's min-max)