Skip to content

Commit

Permalink
FEM: Add preferences dialog
Browse files Browse the repository at this point in the history
This patch add FEM preferrences dialog. There is currently only
one option to define if internal or external editor should be used to
open CalculiX input .inp files. Disabling internal editor allows to
define path to external editor.

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Apr 3, 2015
1 parent b36c34b commit d13c279
Show file tree
Hide file tree
Showing 8 changed files with 2,035 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/Mod/Fem/Gui/AppFemGui.cpp
Expand Up @@ -30,7 +30,9 @@
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Gui/Application.h>
#include <Gui/WidgetFactory.h>
#include <Gui/Language/Translator.h>
#include "DlgSettingsFemImp.h"
#include "ViewProviderFemMesh.h"
#include "ViewProviderFemMeshShape.h"
#include "ViewProviderFemMeshShapeNetgen.h"
Expand Down Expand Up @@ -103,6 +105,8 @@ void FemGuiExport initFemGui()

Base::Interpreter().loadModule("FemLib");

// register preferences pages
new Gui::PrefPageProducer<FemGui::DlgSettingsFemImp> ("FEM");

// add resources and reloads the translators
loadFemResource();
Expand Down
5 changes: 5 additions & 0 deletions src/Mod/Fem/Gui/CMakeLists.txt
Expand Up @@ -41,6 +41,7 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS})


set(FemGui_MOC_HDRS
DlgSettingsFemImp.h
Hypothesis.h
TaskObjectName.h
TaskCreateNodeSet.h
Expand All @@ -61,6 +62,7 @@ fc_wrap_cpp(FemGui_MOC_SRCS ${FemGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${FemGui_MOC_SRCS})

set(FemGui_UIC_SRCS
DlgSettingsFem.ui
Hypothesis.ui
TaskCreateNodeSet.ui
TaskObjectName.ui
Expand All @@ -76,6 +78,9 @@ qt4_wrap_ui(FemGui_UIC_HDRS ${FemGui_UIC_SRCS})

SET(FemGui_DLG_SRCS
${FemGui_UIC_HDRS}
DlgSettingsFem.ui
DlgSettingsFemImp.cpp
DlgSettingsFemImp.h
Hypothesis.ui
Hypothesis.cpp
Hypothesis.h
Expand Down
200 changes: 200 additions & 0 deletions src/Mod/Fem/Gui/DlgSettingsFem.ui
@@ -0,0 +1,200 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FemGui::DlgSettingsFemImp</class>
<widget class="QWidget" name="FemGui::DlgSettingsFemImp">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>555</width>
<height>429</height>
</rect>
</property>
<property name="windowTitle">
<string>FEM</string>
</property>
<layout class="QGridLayout" name="gridLayout1">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="0">
<widget class="QGroupBox" name="gb_calculix">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>CalculiX</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<layout class="QGridLayout" name="gl_calculix">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="cb_int_editor">
<property name="text">
<string>Use internal editor for .inp files</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseInternalEditor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hl_ext_editor">
<item>
<widget class="QLabel" name="l_ext_editor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>External editor:</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefFileChooser" name="fc_ext_editor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ExternalEditorPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefFileChooser</class>
<extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Resources/Fem.qrc"/>
</resources>
<connections>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
<receiver>l_ext_editor</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>100</x>
<y>47</y>
</hint>
<hint type="destinationlabel">
<x>99</x>
<y>76</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
<receiver>l_ext_editor</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>125</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>120</x>
<y>74</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
<receiver>fc_ext_editor</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>327</x>
<y>54</y>
</hint>
<hint type="destinationlabel">
<x>323</x>
<y>79</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
<receiver>fc_ext_editor</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>409</x>
<y>50</y>
</hint>
<hint type="destinationlabel">
<x>406</x>
<y>78</y>
</hint>
</hints>
</connection>
</connections>
</ui>
69 changes: 69 additions & 0 deletions src/Mod/Fem/Gui/DlgSettingsFemImp.cpp
@@ -0,0 +1,69 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Author: Przemo Firszt <przemo@firszt.eu> *
* Based on src/Mod/Raytracing/Gui/DlgSettingsRayImp.cpp *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/


#include "PreCompiled.h"

#include "DlgSettingsFemImp.h"
#include <Gui/PrefWidgets.h>

using namespace FemGui;

DlgSettingsFemImp::DlgSettingsFemImp( QWidget* parent )
: PreferencePage( parent )
{
this->setupUi(this);
}

DlgSettingsFemImp::~DlgSettingsFemImp()
{
// no need to delete child widgets, Qt does it all for us
}

void DlgSettingsFemImp::saveSettings()
{
cb_int_editor->onSave();
fc_ext_editor->onSave();
}

void DlgSettingsFemImp::loadSettings()
{
cb_int_editor->onRestore();
fc_ext_editor->onRestore();
}

/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgSettingsFemImp::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
retranslateUi(this);
}
else {
QWidget::changeEvent(e);
}
}

#include "moc_DlgSettingsFemImp.cpp"
50 changes: 50 additions & 0 deletions src/Mod/Fem/Gui/DlgSettingsFemImp.h
@@ -0,0 +1,50 @@
/**************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Author: Przemo Firszt <przemo@firszt.eu> *
* Based on src/Mod/Raytracing/Gui/DlgSettingsRayImp.h *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/


#ifndef FEMGUI_DLGSETTINGSFEMIMP_H
#define FEMGUI_DLGSETTINGSFEMIMP_H

#include "ui_DlgSettingsFem.h"
#include <Gui/PropertyPage.h>

namespace FemGui {

class DlgSettingsFemImp : public Gui::Dialog::PreferencePage, public Ui_DlgSettingsFemImp
{
Q_OBJECT

public:
DlgSettingsFemImp( QWidget* parent = 0 );
~DlgSettingsFemImp();

protected:
void saveSettings();
void loadSettings();
void changeEvent(QEvent *e);
};

} // namespace FemGui

#endif // FEMGUI_DLGSETTINGSFEMIMP_H
1 change: 1 addition & 0 deletions src/Mod/Fem/Gui/Resources/Fem.qrc
Expand Up @@ -17,6 +17,7 @@
<file>icons/Fem_Result.svg</file>
<file>icons/Fem_ResultDisplacement.svg</file>
<file>icons/Fem_ResultStress.svg</file>
<file>icons/preferences-fem.svg</file>
<file>translations/Fem_af.qm</file>
<file>translations/Fem_de.qm</file>
<file>translations/Fem_fi.qm</file>
Expand Down

0 comments on commit d13c279

Please sign in to comment.