| 1 | 
 #include "preferences.h" | 
 
 
 
 
 
 | 2 | 
 #include "ui_preferences.h" | 
 
 
 
 
 
 | 3 | 
  | 
 
 
 
 
 
 | 4 | 
 Preferences::Preferences(QWidget *parent, QSettings *vagoSettings) : | 
 
 
 
 
 
 | 5 | 
     QDialog(parent), | 
 
 
 
 
 
 | 6 | 
     ui(new Ui::Preferences) | 
 
 
 
 
 
 | 7 | 
 { | 
 
 
 
 
 
 | 8 | 
     ui->setupUi(this); | 
 
 
 
 
 
 | 9 | 
     this->setAttribute(Qt::WA_DeleteOnClose,true ); //destroy itself once finished. | 
 
 
 
 
 
 | 10 | 
  | 
 
 
 
 
 
 | 11 | 
     this->vagoSettings=vagoSettings; | 
 
 
 
 
 
 | 12 | 
  | 
 
 
 
 
 
 | 13 | 
     ui->leAEfolder->setText(this->vagoSettings->value("AeFolder").toString()); | 
 
 
 
 
 
 | 14 | 
     ui->leWorkspace->setText(this->vagoSettings->value("Workspace").toString()); | 
 
 
 
 
 
 | 15 | 
     ui->leWidth->setText(this->vagoSettings->value("WindowWidth").toString()); | 
 
 
 
 
 
 | 16 | 
     ui->leHeight->setText(this->vagoSettings->value("WindowHeight").toString()); | 
 
 
 
 
 
 | 17 | 
     ui->cbOniWindow->setChecked(this->vagoSettings->value("OniWindow").toBool()); | 
 
 
 
 
 
 | 18 | 
     ui->cbSeparate->setChecked(this->vagoSettings->value("SeparateInWorkspace").toBool()); | 
 
 
 
 
 
 | 19 | 
     ui->cbVagoExit->setChecked(this->vagoSettings->value("ConfirmExit").toBool()); | 
 
 
 
 
 
 | 20 | 
  | 
 
 
 
 
 
 | 21 | 
 #ifdef Q_OS_WIN | 
 
 
 
 
 
 | 22 | 
     ui->cbClearButtonYes->hide(); // don't display this mac os only option in windows | 
 
 
 
 
 
 | 23 | 
 #endif | 
 
 
 
 
 
 | 24 | 
  | 
 
 
 
 
 
 | 25 | 
 } | 
 
 
 
 
 
 | 26 | 
  | 
 
 
 
 
 
 | 27 | 
 Preferences::~Preferences() | 
 
 
 
 
 
 | 28 | 
 { | 
 
 
 
 
 
 | 29 | 
     delete ui; | 
 
 
 
 
 
 | 30 | 
 } | 
 
 
 
 
 
 | 31 | 
  | 
 
 
 
 
 
 | 32 | 
 // Need to override to do the verification | 
 
 
 
 
 
 | 33 | 
 // http://stackoverflow.com/questions/3261676/how-to-make-qdialogbuttonbox-not-close-its-parent-qdialog | 
 
 
 
 
 
 | 34 | 
 void Preferences::accept (){ | 
 
 
 
 
 
 | 35 | 
     QStringList options; | 
 
 
 
 
 
 | 36 | 
     QRect screenRes = Util::getScreenResolution(); | 
 
 
 
 
 
 | 37 | 
  | 
 
 
 
 
 
 | 38 | 
     options << ui->leAEfolder->text() << ui->leWorkspace->text() << ui->leWidth->text() << ui->leHeight->text(); | 
 
 
 
 
 
 | 39 | 
  | 
 
 
 
 
 
 | 40 | 
     if(Util::checkEmptySpaces(options)){ | 
 
 
 
 
 
 | 41 | 
         Util::showErrorPopUp("Setting not saved! There are empty settings."); | 
 
 
 
 
 
 | 42 | 
         return; | 
 
 
 
 
 
 | 43 | 
     } | 
 
 
 
 
 
 | 44 | 
  | 
 
 
 
 
 
 | 45 | 
     if(Util::checkIfIntegers(QStringList() << ui->leWidth->text() << ui->leHeight->text() )){ | 
 
 
 
 
 
 | 46 | 
         Util::showErrorPopUp("Setting not saved! Width and Height must be numbers."); | 
 
 
 
 
 
 | 47 | 
         return; | 
 
 
 
 
 
 | 48 | 
     } | 
 
 
 
 
 
 | 49 | 
  | 
 
 
 
 
 
 | 50 | 
     if(ui->leWidth->text().toInt() > screenRes.width() || ui->leHeight->text().toInt() > screenRes.height()){ | 
 
 
 
 
 
 | 51 | 
         Util::showErrorPopUp("Setting not saved! Width or Height specified are greater than actual screen resolution."); | 
 
 
 
 
 
 | 52 | 
         return; | 
 
 
 
 
 
 | 53 | 
     } | 
 
 
 
 
 
 | 54 | 
  | 
 
 
 
 
 
 | 55 | 
     if(ui->leWidth->text().toInt() <= 0  || ui->leHeight->text().toInt() <= 0 ){ | 
 
 
 
 
 
 | 56 | 
         Util::showErrorPopUp("Settings not saved! Width and Height must be greater than 0."); | 
 
 
 
 
 
 | 57 | 
         return; | 
 
 
 
 
 
 | 58 | 
     } | 
 
 
 
 
 
 | 59 | 
  | 
 
 
 
 
 
 | 60 | 
     this->vagoSettings->setValue("AeFolder",ui->leAEfolder->text()); | 
 
 
 
 
 
 | 61 | 
     this->vagoSettings->setValue("Workspace",ui->leWorkspace->text()); | 
 
 
 
 
 
 | 62 | 
     this->vagoSettings->setValue("WindowWidth",ui->leWidth->text()); | 
 
 
 
 
 
 | 63 | 
     this->vagoSettings->setValue("WindowHeight",ui->leHeight->text()); | 
 
 
 
 
 
 | 64 | 
     this->vagoSettings->setValue("OniWindow",ui->cbOniWindow->isChecked()); | 
 
 
 
 
 
 | 65 | 
     this->vagoSettings->setValue("SeparateInWorkspace",ui->cbSeparate->isChecked()); | 
 
 
 
 
 
 | 66 | 
     this->vagoSettings->setValue("ConfirmExit",ui->cbVagoExit->isChecked()); | 
 
 
 
 
 
 | 67 | 
 #ifdef Q_OS_MAC | 
 
 
 
 
 
 | 68 | 
     this->vagoSettings->setValue("UseYesButtonClear",ui->cbClearButtonYes->isChecked()); | 
 
 
 
 
 
 | 69 | 
 #endif | 
 
 
 
 
 
 | 70 | 
  | 
 
 
 
 
 
 | 71 | 
  | 
 
 
 
 
 
 | 72 | 
     Util::showPopUp("You need to restart the application to all changes take effect."); | 
 
 
 
 
 
 | 73 | 
  | 
 
 
 
 
 
 | 74 | 
     QDialog::accept(); | 
 
 
 
 
 
 | 75 | 
 } | 
 
 
 
 
 
 | 76 | 
  | 
 
 
 
 
 
 | 77 | 
 void Preferences::on_pbChooseWorkspace_clicked() | 
 
 
 
 
 
 | 78 | 
 { | 
 
 
 
 
 
 | 79 | 
     QString newDir=QFileDialog::getExistingDirectory(this,"Choose workspace folder..."); | 
 
 
 
 
 
 | 80 | 
     newDir=Util::normalizePath(newDir); | 
 
 
 
 
 
 | 81 | 
  | 
 
 
 
 
 
 | 82 | 
     if(!newDir.isEmpty()){ | 
 
 
 
 
 
 | 83 | 
         ui->leWorkspace->setText(newDir); | 
 
 
 
 
 
 | 84 | 
     } | 
 
 
 
 
 
 | 85 | 
 } | 
 
 
 
 
 
 | 86 | 
  | 
 
 
 
 
 
 | 87 | 
 void Preferences::on_pbChooseAE_clicked() | 
 
 
 
 
 
 | 88 | 
 { | 
 
 
 
 
 
 | 89 | 
     QString newDir=QFileDialog::getExistingDirectory(this,"Choose AE folder..."); | 
 
 
 
 
 
 | 90 | 
     newDir=Util::normalizePath(newDir); | 
 
 
 
 
 
 | 91 | 
  | 
 
 
 
 
 
 | 92 | 
     if(!newDir.isEmpty()){ | 
 
 
 
 
 
 | 93 | 
         ui->leAEfolder->setText(newDir); | 
 
 
 
 
 
 | 94 | 
     } | 
 
 
 
 
 
 | 95 | 
 } | 
 
 
 
 
 
 | 96 | 
  | 
 
 
 
 
 
 | 97 | 
 void Preferences::on_buttonBox_rejected() | 
 
 
 
 
 
 | 98 | 
 { | 
 
 
 
 
 
 | 99 | 
     this->destroy(true,true); | 
 
 
 
 
 
 | 100 | 
 } | 
 
 
 
 
 
 | 101 | 
  |