source: s10k/Vago/preferences.cpp@ 1159

Last change on this file since 1159 was 1093, checked in by s10k, 7 years ago

Vago 1.4

File size: 4.1 KB
RevLine 
[771]1#include "preferences.h"
2#include "ui_preferences.h"
3
4Preferences::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());
[897]15 ui->leWidth->setText(this->vagoSettings->value("WindowWidth").toString());
16 ui->leHeight->setText(this->vagoSettings->value("WindowHeight").toString());
[771]17 ui->cbOniWindow->setChecked(this->vagoSettings->value("OniWindow").toBool());
18 ui->cbSeparate->setChecked(this->vagoSettings->value("SeparateInWorkspace").toBool());
[1054]19 ui->cbAskSaveProject->setChecked(this->vagoSettings->value("AskSaveProject").toBool());
20 ui->cbAskOpenLastProject->setChecked(this->vagoSettings->value("AskToOpenLastProject").toBool());
[999]21#ifdef Q_OS_MAC
22 ui->cbUseYesAsDefaultWhenRemovingItems->setChecked(this->vagoSettings->value("useYesAsDefaultWhenRemovingItems").toBool());
23#endif
[771]24
[998]25#ifdef Q_OS_WIN
[999]26 ui->cbUseYesAsDefaultWhenRemovingItems->hide(); // don't display this mac os only option in windows
[998]27#endif
28
[771]29}
30
31Preferences::~Preferences()
32{
33 delete ui;
34}
35
[897]36// Need to override to do the verification
37// http://stackoverflow.com/questions/3261676/how-to-make-qdialogbuttonbox-not-close-its-parent-qdialog
38void Preferences::accept (){
39 QStringList options;
[1093]40 QRect screenRes = Util::System::getScreenResolution();
[897]41
42 options << ui->leAEfolder->text() << ui->leWorkspace->text() << ui->leWidth->text() << ui->leHeight->text();
43
[1093]44 if(Util::Validation::checkEmptySpaces(options)){
45 Util::Dialogs::showError("Setting not saved! There are empty settings.");
[897]46 return;
47 }
48
[1093]49 if(Util::Validation::checkIfIntegers(QStringList() << ui->leWidth->text() << ui->leHeight->text() )){
50 Util::Dialogs::showError("Setting not saved! Width and Height must be numbers.");
[897]51 return;
52 }
53
54 if(ui->leWidth->text().toInt() > screenRes.width() || ui->leHeight->text().toInt() > screenRes.height()){
[1093]55 Util::Dialogs::showError("Setting not saved! Width or Height specified are greater than actual screen resolution.");
[897]56 return;
57 }
58
59 if(ui->leWidth->text().toInt() <= 0 || ui->leHeight->text().toInt() <= 0 ){
[1093]60 Util::Dialogs::showError("Settings not saved! Width and Height must be greater than 0.");
[897]61 return;
62 }
63
[771]64 this->vagoSettings->setValue("AeFolder",ui->leAEfolder->text());
65 this->vagoSettings->setValue("Workspace",ui->leWorkspace->text());
[897]66 this->vagoSettings->setValue("WindowWidth",ui->leWidth->text());
67 this->vagoSettings->setValue("WindowHeight",ui->leHeight->text());
[771]68 this->vagoSettings->setValue("OniWindow",ui->cbOniWindow->isChecked());
69 this->vagoSettings->setValue("SeparateInWorkspace",ui->cbSeparate->isChecked());
[1054]70 this->vagoSettings->setValue("AskSaveProject",ui->cbAskSaveProject->isChecked());
71 this->vagoSettings->setValue("AskToOpenLastProject",ui->cbAskOpenLastProject->isChecked());
[998]72#ifdef Q_OS_MAC
[999]73 this->vagoSettings->setValue("useYesAsDefaultWhenRemovingItems",ui->cbUseYesAsDefaultWhenRemovingItems->isChecked());
[998]74#endif
[771]75
[1093]76 Util::Dialogs::showInfo("You need to restart the application to all changes take effect.");
[897]77
78 QDialog::accept();
[771]79}
80
81void Preferences::on_pbChooseWorkspace_clicked()
82{
83 QString newDir=QFileDialog::getExistingDirectory(this,"Choose workspace folder...");
[1093]84 newDir=Util::FileSystem::normalizePath(newDir);
[771]85
86 if(!newDir.isEmpty()){
87 ui->leWorkspace->setText(newDir);
88 }
89}
90
91void Preferences::on_pbChooseAE_clicked()
92{
93 QString newDir=QFileDialog::getExistingDirectory(this,"Choose AE folder...");
[1093]94 newDir=Util::FileSystem::normalizePath(newDir);
[771]95
96 if(!newDir.isEmpty()){
97 ui->leAEfolder->setText(newDir);
98 }
99}
100
101void Preferences::on_buttonBox_rejected()
102{
103 this->destroy(true,true);
104}
105
Note: See TracBrowser for help on using the repository browser.