ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/mainwindow.cpp
(Generate patch)

Comparing Vago/trunk/Vago/mainwindow.cpp (file contents):
Revision 771 by s10k, Sun Mar 31 19:02:16 2013 UTC vs.
Revision 801 by s10k, Sun Apr 7 15:36:17 2013 UTC

# Line 9 | Line 9 | MainWindow::MainWindow(QWidget *parent)
9   {
10      ui->setupUi(this);
11  
12 <    this->setWindowTitle("Vago v"+GlobalVars::AppVersion);
12 >    this->AppDir=getOSIndependentAppPath();
13  
14 <    // QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale ());
14 >    this->setWindowTitle("Vago v"+GlobalVars::AppVersion);
15  
16 <    if(!QFile::exists(QDir::currentPath()+"/"+GlobalVars::OniSplitExeName)){
16 >    if(!QFile::exists(this->AppDir+"/"+GlobalVars::OniSplitString)){
17          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.");
18          exit(1);
19      }
20  
21 <    if(!QFile::exists(QDir::currentPath()+"/"+GlobalVars::XmlToolsExeName)){
21 >    if(!QFile::exists(this->AppDir+"/"+GlobalVars::XmlToolsString)){
22          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.");
23          exit(1);
24      }
25  
26 <    this->vagoSettings = new QSettings(QDir::currentPath() + "/" + this->VagoSettingsName, QSettings::IniFormat);
26 >    this->vagoSettings = new QSettings(this->AppDir + "/" + this->VagoSettingsName, QSettings::IniFormat);
27  
28      //First Execution? Old configuration? Settings missed?
29      bool iniChanged=false;
# Line 32 | Line 32 | MainWindow::MainWindow(QWidget *parent)
32          iniChanged=true;
33      }
34      if(!this->vagoSettings->contains("Workspace")){
35 <        this->vagoSettings->setValue("Workspace", QDir::currentPath()+"/VagoWorkspace");
35 >        this->vagoSettings->setValue("Workspace", this->AppDir+"/VagoWorkspace");
36          iniChanged=true;
37      }
38      if(!this->vagoSettings->contains("AeFolder")){
# Line 41 | Line 41 | MainWindow::MainWindow(QWidget *parent)
41          QString aefolder=Util::normalizePath(QFileDialog::getExistingDirectory(this,"Choose Anniversary Edition (AE) folder..."));
42  
43          if(aefolder.isEmpty()){
44 <            Util::showErrorPopUp("AE folder is mandatory. Application will exit.");
44 >            Util::showErrorPopUp("AE folder is mandatory. Application will now exit.");
45              exit(1);
46          }
47  
# Line 98 | Line 98 | MainWindow::MainWindow(QWidget *parent)
98      //Create a thread for do the conversion in background
99      this->myConverter = new Converter(this->myLogger,this->listToProccess);
100  
101 +    // User interface
102      ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button
103      ui->mainToolBar->addWidget(ui->emptySpacerLabel); //trick, we can't add directly a space so we add an empty
104      ui->mainToolBar->addWidget(ui->tbOni); //add oni launch buttonlabel
# Line 108 | Line 109 | MainWindow::MainWindow(QWidget *parent)
109  
110      ui->mainToolBar->setLayoutDirection(Qt::RightToLeft);
111  
112 +    setConverterButtonsSize();
113 +
114 + #ifdef Q_WS_MAC
115 +    // 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
116 +    ui->tbOni->setIcon(QIcon(":/new/icons/oni_icon_mac.png")); // Oni executable on mac have a different icon than windows
117 +    // Set mac platform the first one in the menu, and also make it checkable by default
118 +    ui->menuTarget_Platform->removeAction(ui->actionWindows);
119 +    ui->menuTarget_Platform->addAction(ui->actionWindows);
120 +    ui->actionWindows->setChecked(false);
121 +    ui->actionMac_Windows_demo->setChecked(true);
122 +    resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better
123 +    // because the components on mac use more space
124 + #else
125 +    resize(640,480);
126 + #endif
127 +
128      connectSlots();
129  
130      //Commands Mapping
# Line 145 | Line 162 | void MainWindow::on_actionAE_Package_Cre
162  
163   void MainWindow::on_actionSound_Wizard_triggered()
164   {
165 <    SoundWizard myWizard (this->workspaceWizardsLocation, this->myLogger, &this->commandMap);
165 >    SoundWizard myWizard (this->AppDir, this->workspaceWizardsLocation, this->myLogger, &this->commandMap);
166      myWizard.exec();
167   }
168  
# Line 153 | Line 170 | void MainWindow::on_tbOni_clicked()
170   {
171      QStringList arguments;
172  
173 <    if(this->vagoSettings->value("OniWindow").toBool()){ //Run in a window?
173 >    if(this->vagoSettings->value("OniWindow").toBool()){ // Run in a window?
174          arguments << "-noswitch";
175      }
176 + #ifdef Q_WS_WIN
177      else{
178 <        arguments << "-switch";
178 >        arguments << "-switch"; // only supported on windows. Was added by daodan dll.
179      }
180 + #endif
181  
182 <    arguments << " -debugfiles";
182 >    arguments << "-debugfiles";
183  
184 <    if(!QProcess::startDetached(this->AeLocation+"/Oni.exe",arguments,this->AeLocation)){
184 >    if(!QProcess::startDetached(this->AeLocation+"/"+GlobalVars::OniExe,arguments,this->AeLocation)){
185          showErrStatusMessage("Oni could not be started!");
186      }
187   }
# Line 171 | Line 190 | void MainWindow::on_tbAE_clicked()
190   {
191      // If the app turn out someday to a native app use QProcess::startDetached instead...
192  
193 <    if(!QDesktopServices::openUrl(this->AeLocation+"/AEInstaller/bin/AEInstaller2.jar")){
193 >    if(!QDesktopServices::openUrl("file:///"+this->AeLocation+"/AEInstaller/bin/AEInstaller2.jar")){
194          showErrStatusMessage("Could not start AE Installer!");
195      }
196   }
# Line 1469 | Line 1488 | QString MainWindow::getCommand(DropTable
1488  
1489   }
1490  
1491 + /**
1492 +  This is OS indepented. It maintain size ratio over the Windows and Mac.
1493 +  **/
1494 + void MainWindow::setConverterButtonsSize(){
1495 +    int height=ui->pbConvertGeneral->sizeHint().height()*1.3;
1496 +    ui->pbConvertGeneral->setMinimumHeight(height);
1497 +    ui->pbConvertTextures->setMinimumHeight(height);
1498 +    ui->pbConvertModels->setMinimumHeight(height);
1499 +    ui->pbConvertAnimations->setMinimumHeight(height);
1500 +    ui->pbConvertLevels->setMinimumHeight(height);
1501 +    ui->pbConvertMisc->setMinimumHeight(height);
1502 + }
1503 +
1504 + /**
1505 +  Gets application directory. In mac os gets the .app directory
1506 +  **/
1507 + QString MainWindow::getOSIndependentAppPath(){
1508 + #ifdef Q_WS_MAC
1509 +    QDir dir = QDir::current();
1510 +    if(dir.absolutePath().contains(".app")){ // include bundle, but we don't want it
1511 +        dir.cdUp();
1512 +        dir.cdUp();
1513 +    }
1514 +    return dir.absolutePath();
1515 + #else
1516 +    return  QDir::currentPath();
1517 + #endif
1518 + }
1519 +
1520   void MainWindow::connectSlots(){
1521  
1522      //This signal is for thread that is working setup the progress bar (make it visible and set it's min-max)

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)