| 9 |
|
{ |
| 10 |
|
ui->setupUi(this); |
| 11 |
|
|
| 12 |
< |
this->AppDir=getOSIndependentAppPath(); |
| 12 |
> |
this->myLogger = new Logger(Util::getAppPath()); //start logger |
| 13 |
|
|
| 14 |
< |
this->myLogger = new Logger(this->AppDir); //start logger |
| 15 |
< |
|
| 16 |
< |
this->myLogger->writeString("Detected AppDir: "+this->AppDir); |
| 14 |
> |
this->myLogger->writeString("Detected AppDir: "+Util::getAppPath()); |
| 15 |
|
this->myLogger->writeString("True app dir: "+QDir::currentPath()); |
| 16 |
|
|
| 17 |
|
this->setWindowTitle("Vago v"+GlobalVars::AppVersion); |
| 18 |
|
|
| 19 |
< |
if(!QFile::exists(this->AppDir+"/"+GlobalVars::OniSplitString)){ |
| 19 |
> |
if(!QFile::exists(Util::getAppPath()+"/"+GlobalVars::OniSplitString)){ |
| 20 |
|
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."); |
| 21 |
|
exit(1); |
| 22 |
|
} |
| 23 |
|
|
| 24 |
< |
if(!QFile::exists(this->AppDir+"/"+GlobalVars::XmlToolsString)){ |
| 24 |
> |
if(!QFile::exists(Util::getAppPath()+"/"+GlobalVars::XmlToolsString)){ |
| 25 |
|
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."); |
| 26 |
|
exit(1); |
| 27 |
|
} |
| 28 |
|
|
| 29 |
< |
this->vagoSettings = new QSettings(this->AppDir + "/" + this->VagoSettingsName, QSettings::IniFormat); |
| 29 |
> |
this->vagoSettings = new QSettings(Util::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); |
| 30 |
|
|
| 31 |
|
//First Execution? Old configuration? Settings missed? |
| 32 |
|
bool iniChanged=false; |
| 35 |
|
iniChanged=true; |
| 36 |
|
} |
| 37 |
|
if(!this->vagoSettings->contains("Workspace")){ |
| 38 |
< |
this->vagoSettings->setValue("Workspace", this->AppDir+"/VagoWorkspace"); |
| 38 |
> |
this->vagoSettings->setValue("Workspace", Util::getAppPath()+"/VagoWorkspace"); |
| 39 |
|
iniChanged=true; |
| 40 |
|
} |
| 41 |
|
if(!this->vagoSettings->contains("AeFolder")){ |
| 75 |
|
this->vagoSettings->setValue("ConfirmExit", false); |
| 76 |
|
iniChanged=true; |
| 77 |
|
} |
| 78 |
+ |
#ifdef Q_OS_MAC |
| 79 |
+ |
if(!this->vagoSettings->contains("useYesAsDefaultWhenRemovingItems")){ |
| 80 |
+ |
this->vagoSettings->setValue("useYesAsDefaultWhenRemovingItems", false); |
| 81 |
+ |
iniChanged=true; |
| 82 |
+ |
} |
| 83 |
+ |
#endif |
| 84 |
|
|
| 85 |
|
if(iniChanged){ |
| 86 |
|
this->vagoSettings->sync(); |
| 93 |
|
this->outputFolder=this->workspaceLocation; |
| 94 |
|
this->startedWindowWidth=this->vagoSettings->value("WindowWidth").toInt(); |
| 95 |
|
this->startedWindowHeight=this->vagoSettings->value("WindowHeight").toInt(); |
| 96 |
+ |
#ifdef Q_OS_MAC |
| 97 |
+ |
this->useYesAsDefaultWhenRemovingItems=this->vagoSettings->value("useYesAsDefaultWhenRemovingItems").toBool(); |
| 98 |
+ |
#endif |
| 99 |
|
|
| 100 |
|
//Create our workspace if it doesn't exists yet |
| 101 |
|
if(!QDir(this->workspaceLocation).exists()){ |
| 118 |
|
this->listToProccess = new QStringList; |
| 119 |
|
|
| 120 |
|
//Create a thread for do the conversion in background |
| 121 |
< |
this->myConverter = new Converter(this->AppDir,this->myLogger,this->listToProccess); |
| 121 |
> |
this->myConverter = new Converter(Util::getAppPath(),this->myLogger,this->listToProccess); |
| 122 |
|
|
| 123 |
|
// User interface |
| 124 |
|
ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button |
| 133 |
|
|
| 134 |
|
setConverterButtonsSize(); |
| 135 |
|
|
| 136 |
< |
#ifdef Q_WS_MAC |
| 136 |
> |
#ifdef Q_OS_MAC |
| 137 |
|
// 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 |
| 138 |
|
ui->tbOni->setIcon(QIcon(":/new/icons/oni_icon_mac.png")); // Oni executable on mac have a different icon than windows |
| 139 |
|
// Set mac platform the first one in the menu, and also make it checkable by default |
| 186 |
|
|
| 187 |
|
void MainWindow::on_actionSound_Wizard_triggered() |
| 188 |
|
{ |
| 189 |
< |
SoundWizard myWizard (this->AppDir, this->workspaceWizardsLocation, this->myLogger, &this->commandMap); |
| 189 |
> |
SoundWizard myWizard (Util::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap); |
| 190 |
|
myWizard.exec(); |
| 191 |
|
} |
| 192 |
|
|
| 197 |
|
if(this->vagoSettings->value("OniWindow").toBool()){ // Run in a window? |
| 198 |
|
arguments << "-noswitch"; |
| 199 |
|
} |
| 200 |
< |
#ifdef Q_WS_WIN |
| 200 |
> |
#ifdef Q_OS_WIN |
| 201 |
|
else{ |
| 202 |
|
arguments << "-switch"; // only supported on windows. Was added by daodan dll. |
| 203 |
|
} |
| 537 |
|
|
| 538 |
|
command+=":"+ui->leSpecificFilesLevels->text(); |
| 539 |
|
} |
| 540 |
< |
command+=" "+myOutputFolder+" "+file; |
| 540 |
> |
|
| 541 |
> |
if(from=="DAT" && to=="ONI FILES"){ // extract files to a subdir with the files name ex: level0_Final |
| 542 |
> |
command += " " + myOutputFolder.insert(myOutputFolder.size()-2,QString(Util::cutName(file)).replace(".dat","")) + " " + file; |
| 543 |
> |
} |
| 544 |
> |
else{ |
| 545 |
> |
command+=" "+myOutputFolder+" "+file; |
| 546 |
> |
} |
| 547 |
|
|
| 548 |
|
} |
| 549 |
|
|
| 1059 |
|
void MainWindow::removeTableContents(DropTableWidget *myTable){ |
| 1060 |
|
int size = myTable->selectionModel()->selectedRows().size(); |
| 1061 |
|
|
| 1062 |
+ |
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os |
| 1063 |
+ |
|
| 1064 |
|
if(size==0){ |
| 1065 |
|
Util::showPopUp("Select a row first."); |
| 1066 |
|
return; |
| 1067 |
|
} |
| 1068 |
|
|
| 1069 |
< |
if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?")){ |
| 1069 |
> |
#ifdef Q_OS_MAC |
| 1070 |
> |
if(this->useYesAsDefaultWhenRemovingItems){ |
| 1071 |
> |
defaultButton = QMessageBox::Yes; |
| 1072 |
> |
} |
| 1073 |
> |
else{ |
| 1074 |
> |
defaultButton = QMessageBox::No; |
| 1075 |
> |
} |
| 1076 |
> |
#endif |
| 1077 |
> |
|
| 1078 |
> |
|
| 1079 |
> |
if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?",defaultButton)){ |
| 1080 |
|
for(int i=0; i<size; i++){ |
| 1081 |
|
//myTable->removeRow(myTable->selectedItems().at(size-i-1)->row()); |
| 1082 |
|
myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row()); |
| 1086 |
|
} |
| 1087 |
|
|
| 1088 |
|
void MainWindow::clearTableContents(DropTableWidget *myTable){ |
| 1089 |
+ |
|
| 1090 |
+ |
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os |
| 1091 |
+ |
|
| 1092 |
|
if(myTable->rowCount()==0){ |
| 1093 |
|
Util::showPopUp("Nothing to clear."); |
| 1094 |
|
return; |
| 1095 |
|
} |
| 1096 |
|
|
| 1097 |
< |
if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?")){ |
| 1097 |
> |
#ifdef Q_OS_MAC |
| 1098 |
> |
if(this->useYesAsDefaultWhenRemovingItems){ |
| 1099 |
> |
defaultButton = QMessageBox::Yes; |
| 1100 |
> |
} |
| 1101 |
> |
else{ |
| 1102 |
> |
defaultButton = QMessageBox::No; |
| 1103 |
> |
} |
| 1104 |
> |
#endif |
| 1105 |
> |
|
| 1106 |
> |
if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){ |
| 1107 |
|
myTable->clearContents(); |
| 1108 |
|
myTable->setRowCount(0); |
| 1109 |
|
} |
| 1186 |
|
void MainWindow::on_actionCheck_OniSplit_version_triggered() |
| 1187 |
|
{ |
| 1188 |
|
QProcess *myProcess = new QProcess(); |
| 1189 |
< |
myProcess->setWorkingDirectory(this->AppDir); |
| 1190 |
< |
myProcess->start(GlobalVars::OniSplitExeName+" -version"); |
| 1189 |
> |
myProcess->setWorkingDirectory(Util::getAppPath()); |
| 1190 |
> |
myProcess->start(Util::getOniSplitExeName()+" -version"); |
| 1191 |
|
myProcess->waitForFinished(-1); |
| 1192 |
|
QString result=myProcess->readAllStandardOutput(); |
| 1193 |
|
delete myProcess; |
| 1197 |
|
void MainWindow::on_actionCheck_xmlTools_version_triggered() |
| 1198 |
|
{ |
| 1199 |
|
QProcess *myProcess = new QProcess(); |
| 1200 |
< |
myProcess->setWorkingDirectory(this->AppDir); |
| 1201 |
< |
myProcess->start(GlobalVars::XmlToolsExeName+" version"); |
| 1200 |
> |
myProcess->setWorkingDirectory(Util::getAppPath()); |
| 1201 |
> |
myProcess->start(Util::getXmlToolsExeName()+" version"); |
| 1202 |
|
myProcess->waitForFinished(-1); |
| 1203 |
|
QString result=myProcess->readLine(); |
| 1204 |
|
delete myProcess; |
| 1207 |
|
|
| 1208 |
|
/** |
| 1209 |
|
Update items loaded |
| 1210 |
< |
**/ |
| 1211 |
< |
void MainWindow::on_tabWidget_selected(const QString &arg1) |
| 1210 |
> |
**/ |
| 1211 |
> |
void MainWindow::on_tabWidget_currentChanged(int index) |
| 1212 |
|
{ |
| 1213 |
< |
if(arg1.compare("General",Qt::CaseSensitive)==0){ //case sentive is faster |
| 1213 |
> |
QString tabtext = ui->tabWidget->tabText(index); |
| 1214 |
> |
|
| 1215 |
> |
if(tabtext.compare("XML",Qt::CaseSensitive)==0){ //case sentive is faster |
| 1216 |
|
updateItemsLoaded(ui->twSourcesXML); |
| 1217 |
|
} |
| 1218 |
< |
else if(arg1.compare("Textures",Qt::CaseSensitive)==0){ |
| 1218 |
> |
else if(tabtext.compare("Textures",Qt::CaseSensitive)==0){ |
| 1219 |
|
updateItemsLoaded(ui->twSourcesTextures); |
| 1220 |
|
} |
| 1221 |
< |
else if(arg1.compare("Objects",Qt::CaseSensitive)==0){ |
| 1221 |
> |
else if(tabtext.compare("Characters",Qt::CaseSensitive)==0){ |
| 1222 |
> |
updateItemsLoaded(ui->twSourcesCharacters); |
| 1223 |
> |
} |
| 1224 |
> |
else if(tabtext.compare("Objects",Qt::CaseSensitive)==0){ |
| 1225 |
|
updateItemsLoaded(ui->twSourcesObjects); |
| 1226 |
|
} |
| 1227 |
< |
else if(arg1.compare("Levels",Qt::CaseSensitive)==0){ |
| 1227 |
> |
else if(tabtext.compare("Levels",Qt::CaseSensitive)==0){ |
| 1228 |
|
updateItemsLoaded(ui->twSourcesLevels); |
| 1229 |
|
} |
| 1230 |
|
else{ |
| 1570 |
|
ui->pbConvertMisc->setMinimumHeight(height); |
| 1571 |
|
} |
| 1572 |
|
|
| 1531 |
– |
/** |
| 1532 |
– |
Gets application directory. In mac os gets the .app directory |
| 1533 |
– |
**/ |
| 1534 |
– |
QString MainWindow::getOSIndependentAppPath(){ |
| 1535 |
– |
#ifdef Q_WS_MAC |
| 1536 |
– |
QDir dir = QDir::current(); |
| 1537 |
– |
if(dir.absolutePath().contains(".app")){ // include bundle, but we don't want it |
| 1538 |
– |
dir.cdUp(); |
| 1539 |
– |
dir.cdUp(); |
| 1540 |
– |
dir.cdUp(); |
| 1541 |
– |
} |
| 1542 |
– |
return dir.absolutePath(); |
| 1543 |
– |
#else |
| 1544 |
– |
return QDir::currentPath(); |
| 1545 |
– |
#endif |
| 1546 |
– |
} |
| 1547 |
– |
|
| 1573 |
|
void MainWindow::connectSlots(){ |
| 1574 |
|
|
| 1575 |
|
//This signal is for thread that is working setup the progress bar (make it visible and set it's min-max) |