--- Vago/trunk/Vago/preferences.cpp 2013/03/31 19:02:16 771 +++ Vago/trunk/Vago/preferences.cpp 2014/04/26 12:40:47 999 @@ -12,9 +12,18 @@ Preferences::Preferences(QWidget *parent ui->leAEfolder->setText(this->vagoSettings->value("AeFolder").toString()); ui->leWorkspace->setText(this->vagoSettings->value("Workspace").toString()); + ui->leWidth->setText(this->vagoSettings->value("WindowWidth").toString()); + ui->leHeight->setText(this->vagoSettings->value("WindowHeight").toString()); ui->cbOniWindow->setChecked(this->vagoSettings->value("OniWindow").toBool()); ui->cbSeparate->setChecked(this->vagoSettings->value("SeparateInWorkspace").toBool()); ui->cbVagoExit->setChecked(this->vagoSettings->value("ConfirmExit").toBool()); +#ifdef Q_OS_MAC + ui->cbUseYesAsDefaultWhenRemovingItems->setChecked(this->vagoSettings->value("useYesAsDefaultWhenRemovingItems").toBool()); +#endif + +#ifdef Q_OS_WIN + ui->cbUseYesAsDefaultWhenRemovingItems->hide(); // don't display this mac os only option in windows +#endif } @@ -23,15 +32,49 @@ Preferences::~Preferences() delete ui; } -void Preferences::on_buttonBox_accepted() -{ +// Need to override to do the verification +// http://stackoverflow.com/questions/3261676/how-to-make-qdialogbuttonbox-not-close-its-parent-qdialog +void Preferences::accept (){ + QStringList options; + QRect screenRes = Util::getScreenResolution(); + + options << ui->leAEfolder->text() << ui->leWorkspace->text() << ui->leWidth->text() << ui->leHeight->text(); + + if(Util::checkEmptySpaces(options)){ + Util::showErrorPopUp("Setting not saved! There are empty settings."); + return; + } + + if(Util::checkIfIntegers(QStringList() << ui->leWidth->text() << ui->leHeight->text() )){ + Util::showErrorPopUp("Setting not saved! Width and Height must be numbers."); + return; + } + + if(ui->leWidth->text().toInt() > screenRes.width() || ui->leHeight->text().toInt() > screenRes.height()){ + Util::showErrorPopUp("Setting not saved! Width or Height specified are greater than actual screen resolution."); + return; + } + + if(ui->leWidth->text().toInt() <= 0 || ui->leHeight->text().toInt() <= 0 ){ + Util::showErrorPopUp("Settings not saved! Width and Height must be greater than 0."); + return; + } + this->vagoSettings->setValue("AeFolder",ui->leAEfolder->text()); this->vagoSettings->setValue("Workspace",ui->leWorkspace->text()); + this->vagoSettings->setValue("WindowWidth",ui->leWidth->text()); + this->vagoSettings->setValue("WindowHeight",ui->leHeight->text()); this->vagoSettings->setValue("OniWindow",ui->cbOniWindow->isChecked()); this->vagoSettings->setValue("SeparateInWorkspace",ui->cbSeparate->isChecked()); this->vagoSettings->setValue("ConfirmExit",ui->cbVagoExit->isChecked()); +#ifdef Q_OS_MAC + this->vagoSettings->setValue("useYesAsDefaultWhenRemovingItems",ui->cbUseYesAsDefaultWhenRemovingItems->isChecked()); +#endif + Util::showPopUp("You need to restart the application to all changes take effect."); + + QDialog::accept(); } void Preferences::on_pbChooseWorkspace_clicked()