--- Vago/trunk/Vago/mainwindow.cpp 2013/04/06 23:30:00 793 +++ Vago/trunk/Vago/mainwindow.cpp 2013/04/13 13:44:29 815 @@ -9,19 +9,26 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); + this->AppDir=getOSIndependentAppPath(); + + this->myLogger = new Logger(this->AppDir); //start logger + + this->myLogger->writeString("Detected AppDir: "+this->AppDir); + this->myLogger->writeString("True app dir: "+QDir::currentPath()); + this->setWindowTitle("Vago v"+GlobalVars::AppVersion); - if(!QFile::exists(QDir::currentPath()+"/"+GlobalVars::OniSplitString)){ + if(!QFile::exists(this->AppDir+"/"+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(QDir::currentPath()+"/"+GlobalVars::XmlToolsString)){ + if(!QFile::exists(this->AppDir+"/"+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(QDir::currentPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); + this->vagoSettings = new QSettings(this->AppDir + "/" + this->VagoSettingsName, QSettings::IniFormat); //First Execution? Old configuration? Settings missed? bool iniChanged=false; @@ -30,7 +37,7 @@ MainWindow::MainWindow(QWidget *parent) iniChanged=true; } if(!this->vagoSettings->contains("Workspace")){ - this->vagoSettings->setValue("Workspace", QDir::currentPath()+"/VagoWorkspace"); + this->vagoSettings->setValue("Workspace", this->AppDir+"/VagoWorkspace"); iniChanged=true; } if(!this->vagoSettings->contains("AeFolder")){ @@ -88,13 +95,11 @@ MainWindow::MainWindow(QWidget *parent) ui->statusBar->addPermanentWidget(myBar); //this adds automatically in right - this->myLogger = new Logger(); //start logger - //Initialize list pointers this->listToProccess = new QStringList; //Create a thread for do the conversion in background - this->myConverter = new Converter(this->myLogger,this->listToProccess); + this->myConverter = new Converter(this->AppDir,this->myLogger,this->listToProccess); // User interface ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button @@ -119,6 +124,8 @@ MainWindow::MainWindow(QWidget *parent) ui->actionMac_Windows_demo->setChecked(true); resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better // because the components on mac use more space +#else + resize(640,480); #endif connectSlots(); @@ -158,7 +165,7 @@ void MainWindow::on_actionAE_Package_Cre void MainWindow::on_actionSound_Wizard_triggered() { - SoundWizard myWizard (this->workspaceWizardsLocation, this->myLogger, &this->commandMap); + SoundWizard myWizard (this->AppDir, this->workspaceWizardsLocation, this->myLogger, &this->commandMap); myWizard.exec(); } @@ -1128,6 +1135,7 @@ void MainWindow::on_cbAdditionalSourcesL void MainWindow::on_actionCheck_OniSplit_version_triggered() { QProcess *myProcess = new QProcess(); + myProcess->setWorkingDirectory(this->AppDir); myProcess->start(GlobalVars::OniSplitExeName+" -version"); myProcess->waitForFinished(-1); QString result=myProcess->readAllStandardOutput(); @@ -1138,6 +1146,7 @@ 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->waitForFinished(-1); QString result=myProcess->readLine(); @@ -1497,6 +1506,23 @@ void MainWindow::setConverterButtonsSize ui->pbConvertMisc->setMinimumHeight(height); } +/** + Gets application directory. In mac os gets the .app directory + **/ +QString MainWindow::getOSIndependentAppPath(){ +#ifdef Q_WS_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)