--- Vago/trunk/Vago/mainwindow.cpp 2013/03/31 19:02:16 771 +++ Vago/trunk/Vago/mainwindow.cpp 2013/04/10 22:01:56 803 @@ -9,21 +9,26 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); - this->setWindowTitle("Vago v"+GlobalVars::AppVersion); + this->AppDir=getOSIndependentAppPath(); + + this->myLogger = new Logger(this->AppDir); //start logger - // QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale ()); + this->myLogger->writeString("Detected AppDir: "+this->AppDir); + this->myLogger->writeString("True app dir: "+QDir::currentPath()); - if(!QFile::exists(QDir::currentPath()+"/"+GlobalVars::OniSplitExeName)){ + this->setWindowTitle("Vago v"+GlobalVars::AppVersion); + + 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::XmlToolsExeName)){ + 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; @@ -32,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")){ @@ -41,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent) QString aefolder=Util::normalizePath(QFileDialog::getExistingDirectory(this,"Choose Anniversary Edition (AE) folder...")); if(aefolder.isEmpty()){ - Util::showErrorPopUp("AE folder is mandatory. Application will exit."); + Util::showErrorPopUp("AE folder is mandatory. Application will now exit."); exit(1); } @@ -90,14 +95,13 @@ 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); + // 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 ui->mainToolBar->addWidget(ui->tbOni); //add oni launch buttonlabel @@ -108,6 +112,22 @@ MainWindow::MainWindow(QWidget *parent) ui->mainToolBar->setLayoutDirection(Qt::RightToLeft); + setConverterButtonsSize(); + +#ifdef Q_WS_MAC + // setUnifiedTitleAndToolBarOnMac(true); // Qt suggests to use it on mac | http://www.slideshare.net/qtbynokia/how-to-make-your-qt-app-look-native // align on left doesn't work if active + ui->tbOni->setIcon(QIcon(":/new/icons/oni_icon_mac.png")); // Oni executable on mac have a different icon than windows + // Set mac platform the first one in the menu, and also make it checkable by default + ui->menuTarget_Platform->removeAction(ui->actionWindows); + ui->menuTarget_Platform->addAction(ui->actionWindows); + ui->actionWindows->setChecked(false); + 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(); //Commands Mapping @@ -145,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(); } @@ -153,16 +173,18 @@ void MainWindow::on_tbOni_clicked() { QStringList arguments; - if(this->vagoSettings->value("OniWindow").toBool()){ //Run in a window? + if(this->vagoSettings->value("OniWindow").toBool()){ // Run in a window? arguments << "-noswitch"; } +#ifdef Q_WS_WIN else{ - arguments << "-switch"; + arguments << "-switch"; // only supported on windows. Was added by daodan dll. } +#endif - arguments << " -debugfiles"; + arguments << "-debugfiles"; - if(!QProcess::startDetached(this->AeLocation+"/Oni.exe",arguments,this->AeLocation)){ + if(!QProcess::startDetached(this->AeLocation+"/"+GlobalVars::OniExe,arguments,this->AeLocation)){ showErrStatusMessage("Oni could not be started!"); } } @@ -171,7 +193,7 @@ void MainWindow::on_tbAE_clicked() { // If the app turn out someday to a native app use QProcess::startDetached instead... - if(!QDesktopServices::openUrl(this->AeLocation+"/AEInstaller/bin/AEInstaller2.jar")){ + if(!QDesktopServices::openUrl("file:///"+this->AeLocation+"/AEInstaller/bin/AEInstaller2.jar")){ showErrStatusMessage("Could not start AE Installer!"); } } @@ -1469,6 +1491,36 @@ QString MainWindow::getCommand(DropTable } +/** + This is OS indepented. It maintain size ratio over the Windows and Mac. + **/ +void MainWindow::setConverterButtonsSize(){ + int height=ui->pbConvertGeneral->sizeHint().height()*1.3; + ui->pbConvertGeneral->setMinimumHeight(height); + ui->pbConvertTextures->setMinimumHeight(height); + ui->pbConvertModels->setMinimumHeight(height); + ui->pbConvertAnimations->setMinimumHeight(height); + ui->pbConvertLevels->setMinimumHeight(height); + 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)