00001 #include "settings.h" 00002 #include "../Mainwindow/mainwindow.h" 00003 00004 Settings::Settings() 00005 { 00006 printIntroPage = false; 00007 printEmptySolution = false; 00008 printNewPageSolution = false; 00009 } 00010 00011 void Settings::setMainWindow(MainWindow *main) 00012 { 00013 mainwindow = main; 00014 } 00015 00016 bool Settings::read() 00017 { 00018 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "FrieSoft", "AllevoTwo"); 00019 00020 checkautomatically = settings.value("program/checkForUpdates").toBool(); 00021 userIsTeacher = settings.value("program/teacher").toBool(); 00022 00023 QString wspcdir = settings.value("projects/workspace").toString(); 00024 workspacedir = QDir(wspcdir); 00025 00026 if(mainwindow) 00027 { 00028 mainwindow->restoreLastGemoetry(settings.value("geometry").toByteArray()); 00029 if(wspcdir == QString() || !workspacedir.exists()) 00030 { 00031 mainwindow->showSettingsDialog(); 00032 } 00033 } 00034 00035 return true; 00036 } 00037 00038 bool Settings::write() 00039 { 00040 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "FrieSoft", "AllevoTwo"); 00041 settings.setValue("geometry", mainwindow->saveGeometry()); 00042 00043 settings.setValue("program/checkForUpdates", checkautomatically); 00044 settings.setValue("program/teacher", userIsTeacher); 00045 00046 settings.setValue("projects/workspace", workspacedir.absolutePath()); 00047 00048 return true; 00049 } 00050 00051 QString Settings::chooseWorkspacePath() 00052 { 00053 return QFileDialog::getExistingDirectory(NULL, tr("Arbeitsbereich festlegen"), workspace().absolutePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); 00054 }