DlgSettingsGeneral.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #include <Interface_Static.hxx>
00027 
00028 #include <Base/Parameter.h>
00029 #include <App/Application.h>
00030 
00031 #include "DlgSettingsGeneral.h"
00032 #include "ui_DlgSettingsGeneral.h"
00033 
00034 using namespace PartGui;
00035 
00036 DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent)
00037   : PreferencePage(parent)
00038 {
00039     ui = new Ui_DlgSettingsGeneral();
00040     ui->setupUi(this);
00041 }
00042 
00046 DlgSettingsGeneral::~DlgSettingsGeneral()
00047 {
00048     // no need to delete child widgets, Qt does it all for us
00049     delete ui;
00050 }
00051 
00052 void DlgSettingsGeneral::saveSettings()
00053 {
00054     int unit = ui->comboBoxUnits->currentIndex();
00055     Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
00056         .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
00057     hGrp->SetInt("Unit", unit);
00058     switch (unit) {
00059         case 1:
00060             Interface_Static::SetCVal("write.iges.unit","M");
00061             Interface_Static::SetCVal("write.step.unit","M");
00062             break;
00063         case 2:
00064             Interface_Static::SetCVal("write.iges.unit","IN");
00065             Interface_Static::SetCVal("write.step.unit","IN");
00066             break;
00067         default:
00068             Interface_Static::SetCVal("write.iges.unit","MM");
00069             Interface_Static::SetCVal("write.step.unit","MM");
00070             break;
00071     }
00072 }
00073 
00074 void DlgSettingsGeneral::loadSettings()
00075 {
00076     Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
00077         .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
00078     int unit = hGrp->GetInt("Unit", 0);
00079     ui->comboBoxUnits->setCurrentIndex(unit);
00080 }
00081 
00085 void DlgSettingsGeneral::changeEvent(QEvent *e)
00086 {
00087     if (e->type() == QEvent::LanguageChange) {
00088         ui->retranslateUi(this);
00089     }
00090     else {
00091         QWidget::changeEvent(e);
00092     }
00093 }
00094 #include "moc_DlgSettingsGeneral.cpp"
00095 

Generated on Wed Nov 23 19:00:07 2011 for FreeCAD by  doxygen 1.6.1