Move all the preference pages to PreferencePages subfolder.
This commit is contained in:
682
src/Gui/PreferencePages/DlgSettings3DView.ui
Normal file
682
src/Gui/PreferencePages/DlgSettings3DView.ui
Normal file
@@ -0,0 +1,682 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettings3DView</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettings3DView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>499</width>
|
||||
<height>520</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>3D View</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBoxGeneral">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutCoord">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_CornerCoordSystem">
|
||||
<property name="toolTip">
|
||||
<string>Main coordinate system will always be shown in
|
||||
lower right corner within opened files</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show coordinate system in the corner</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CornerCoordSystem</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerCoord">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelCoordSize">
|
||||
<property name="text">
|
||||
<string>Relative size : </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="SpinBox_CornerCoordSystemSize">
|
||||
<property name="toolTip">
|
||||
<string>Size of main coordinate system representation
|
||||
in the corner -- in % of height/width of viewport</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true">%</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CornerCoordSystemSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_ShowAxisCross">
|
||||
<property name="toolTip">
|
||||
<string>Axis cross will be shown by default at file
|
||||
opening or creation</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show axis cross by default</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowAxisCross</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_ShowFPS">
|
||||
<property name="toolTip">
|
||||
<string>Time needed for last operation and resulting frame rate
|
||||
will be shown at the lower left corner in opened files</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show counter of frames per second</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowFPS</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox12">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Rendering</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_use_SW_OpenGL">
|
||||
<property name="toolTip">
|
||||
<string>This option is useful for troubleshooting graphics card and driver problems.
|
||||
|
||||
Changing this option requires a restart of the application.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use software OpenGL</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseSoftwareOpenGL</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OpenGL</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_useVBO">
|
||||
<property name="toolTip">
|
||||
<string>If selected, Vertex Buffer Objects (VBO) will be used.
|
||||
A VBO is an OpenGL feature that provides methods for uploading
|
||||
vertex data (position, normal vector, color, etc.) to the graphics card.
|
||||
VBOs offer substantial performance gains because the data resides
|
||||
in the graphics memory rather than the system memory and so it
|
||||
can be rendered directly by GPU.
|
||||
|
||||
Note: Sometimes this feature may lead to a host of different
|
||||
issues ranging from graphical anomalies to GPU crash bugs. Remember to
|
||||
report this setting as enabled when seeking support on the FreeCAD forums</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use OpenGL VBO (Vertex Buffer Object)</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseVBO</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="renderCacheLabel">
|
||||
<property name="text">
|
||||
<string>Render cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QComboBox" name="renderCache">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>'Render Caching' is another way to say 'Rendering Acceleration'.
|
||||
There are 3 options available to achieve this:
|
||||
1) 'Auto' (default), let Coin3D decide where to cache.
|
||||
2) 'Distributed', manually turn on cache for all view provider root node.
|
||||
3) 'Centralized', manually turn off cache in all nodes of all view provider, and
|
||||
only cache at the scene graph root node. This offers the fastest rendering speed
|
||||
but slower response to any scene changes.</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Distributed</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Centralized</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="aliasingLAbel">
|
||||
<property name="text">
|
||||
<string>Anti-Aliasing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Gui::PrefComboBox" name="comboAliasing">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>What kind of multisample anti-aliasing is used</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AntiAliasing</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Line Smoothing</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>MSAA 2x</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>MSAA 4x</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>MSAA 8x</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="transparentRenderLabel">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Transparent objects:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="Gui::PrefComboBox" name="comboTransparentRender">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Render types of transparent objects</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>TransparentObjectRenderType</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>One pass</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Backface pass</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="markerSizeLabel">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Marker size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QComboBox" name="boxMarkerSize">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Size of vertices in the Sketcher workbench</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Eye to eye distance for stereo modes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="Gui::PrefDoubleSpinBox" name="FloatSpinBox_EyeDistance">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Eye-to-eye distance used for stereo projections.
|
||||
The specified value is a factor that will be multiplied with the
|
||||
bounding box size of the 3D object that is currently displayed.</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EyeDistance</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxBacklight">
|
||||
<property name="toolTip">
|
||||
<string>Backlight is enabled with the defined color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Backlight color</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnableBacklight</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="backlightColor">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Backlight color</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BacklightColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QLabel" name="backlightLabel">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Intensity</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="Gui::PrefSlider" name="sliderIntensity">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Intensity of the backlight</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BacklightIntensity</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxCamera">
|
||||
<property name="title">
|
||||
<string>Camera type</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout1">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefRadioButton" name="radioPerspective">
|
||||
<property name="toolTip">
|
||||
<string>Objects will appear in a perspective projection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Perspective renderin&g</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Perspective</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefRadioButton" name="radioOrthographic">
|
||||
<property name="toolTip">
|
||||
<string>Objects will be projected in orthographic projection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Or&thographic rendering</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Orthographic</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>455</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefRadioButton</class>
|
||||
<extends>QRadioButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefColorButton</class>
|
||||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>checkBoxBacklight</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>backlightColor</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>161</x>
|
||||
<y>227</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>290</x>
|
||||
<y>224</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBoxBacklight</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>sliderIntensity</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>92</x>
|
||||
<y>235</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>293</x>
|
||||
<y>256</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBoxBacklight</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>backlightLabel</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>82</x>
|
||||
<y>507</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>316</x>
|
||||
<y>507</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>CheckBox_CornerCoordSystem</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SpinBox_CornerCoordSystemSize</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
169
src/Gui/PreferencePages/DlgSettings3DViewImp.cpp
Normal file
169
src/Gui/PreferencePages/DlgSettings3DViewImp.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QApplication>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include "DlgSettings3DViewImp.h"
|
||||
#include "ui_DlgSettings3DView.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettings3DViewImp */
|
||||
|
||||
bool DlgSettings3DViewImp::showMsg = true;
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettings3DViewImp which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettings3DViewImp::DlgSettings3DViewImp(QWidget* parent)
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettings3DView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettings3DViewImp::~DlgSettings3DViewImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
int index = ui->comboAliasing->currentIndex();
|
||||
hGrp->SetInt("AntiAliasing", index);
|
||||
|
||||
index = ui->renderCache->currentIndex();
|
||||
hGrp->SetInt("RenderCache", index);
|
||||
|
||||
ui->comboTransparentRender->onSave();
|
||||
|
||||
QVariant const &vBoxMarkerSize = ui->boxMarkerSize->itemData(ui->boxMarkerSize->currentIndex());
|
||||
hGrp->SetInt("MarkerSize", vBoxMarkerSize.toInt());
|
||||
|
||||
ui->CheckBox_CornerCoordSystem->onSave();
|
||||
ui->SpinBox_CornerCoordSystemSize->onSave();
|
||||
ui->CheckBox_ShowAxisCross->onSave();
|
||||
ui->CheckBox_ShowFPS->onSave();
|
||||
ui->CheckBox_use_SW_OpenGL->onSave();
|
||||
ui->CheckBox_useVBO->onSave();
|
||||
ui->FloatSpinBox_EyeDistance->onSave();
|
||||
ui->checkBoxBacklight->onSave();
|
||||
ui->backlightColor->onSave();
|
||||
ui->sliderIntensity->onSave();
|
||||
ui->radioPerspective->onSave();
|
||||
ui->radioOrthographic->onSave();
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::loadSettings()
|
||||
{
|
||||
ui->CheckBox_CornerCoordSystem->onRestore();
|
||||
ui->SpinBox_CornerCoordSystemSize->onRestore();
|
||||
ui->CheckBox_ShowAxisCross->onRestore();
|
||||
ui->CheckBox_ShowFPS->onRestore();
|
||||
ui->CheckBox_use_SW_OpenGL->onRestore();
|
||||
ui->CheckBox_useVBO->onRestore();
|
||||
ui->FloatSpinBox_EyeDistance->onRestore();
|
||||
ui->checkBoxBacklight->onRestore();
|
||||
ui->backlightColor->onRestore();
|
||||
ui->sliderIntensity->onRestore();
|
||||
ui->radioPerspective->onRestore();
|
||||
ui->radioOrthographic->onRestore();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
int index = hGrp->GetInt("AntiAliasing", int(Gui::View3DInventorViewer::None));
|
||||
index = Base::clamp(index, 0, ui->comboAliasing->count()-1);
|
||||
ui->comboAliasing->setCurrentIndex(index);
|
||||
// connect after setting current item of the combo box
|
||||
connect(ui->comboAliasing, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettings3DViewImp::onAliasingChanged);
|
||||
|
||||
index = hGrp->GetInt("RenderCache", 0);
|
||||
ui->renderCache->setCurrentIndex(index);
|
||||
|
||||
ui->comboTransparentRender->onRestore();
|
||||
|
||||
int const current = hGrp->GetInt("MarkerSize", 9L);
|
||||
ui->boxMarkerSize->addItem(tr("5px"), QVariant(5));
|
||||
ui->boxMarkerSize->addItem(tr("7px"), QVariant(7));
|
||||
ui->boxMarkerSize->addItem(tr("9px"), QVariant(9));
|
||||
ui->boxMarkerSize->addItem(tr("11px"), QVariant(11));
|
||||
ui->boxMarkerSize->addItem(tr("13px"), QVariant(13));
|
||||
ui->boxMarkerSize->addItem(tr("15px"), QVariant(15));
|
||||
index = ui->boxMarkerSize->findData(QVariant(current));
|
||||
if (index < 0) index = 2;
|
||||
ui->boxMarkerSize->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettings3DViewImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->comboAliasing->blockSignals(true);
|
||||
int aliasing = ui->comboAliasing->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
ui->comboAliasing->setCurrentIndex(aliasing);
|
||||
ui->comboAliasing->blockSignals(false);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::onAliasingChanged(int index)
|
||||
{
|
||||
if (index < 0 || !isVisible())
|
||||
return;
|
||||
// Show this message only once per application session to reduce
|
||||
// annoyance when showing it too often.
|
||||
if (showMsg) {
|
||||
showMsg = false;
|
||||
QMessageBox::information(this, tr("Anti-aliasing"),
|
||||
tr("Open a new viewer or restart %1 to apply anti-aliasing changes.").arg(qApp->applicationName()));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettings3DViewImp.cpp"
|
||||
|
||||
66
src/Gui/PreferencePages/DlgSettings3DViewImp.h
Normal file
66
src/Gui/PreferencePages/DlgSettings3DViewImp.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGS3DVIEWIMP_H
|
||||
#define GUI_DIALOG_DLGSETTINGS3DVIEWIMP_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettings3DView;
|
||||
|
||||
/**
|
||||
* The DlgSettings3DViewImp class implements a preference page to change settings
|
||||
* for the Inventor viewer.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettings3DViewImp : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettings3DViewImp(QWidget* parent = nullptr);
|
||||
~DlgSettings3DViewImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAliasingChanged(int);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettings3DView> ui;
|
||||
static bool showMsg;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGS3DVIEWIMP_H
|
||||
381
src/Gui/PreferencePages/DlgSettingsCacheDirectory.cpp
Normal file
381
src/Gui/PreferencePages/DlgSettingsCacheDirectory.cpp
Normal file
@@ -0,0 +1,381 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QCoreApplication>
|
||||
# include <QDate>
|
||||
# include <QDesktopServices>
|
||||
# include <QDir>
|
||||
# include <QLocale>
|
||||
# include <QMessageBox>
|
||||
# include <QSettings>
|
||||
# include <QUrl>
|
||||
# include <cmath>
|
||||
# include <vector>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/DocumentRecovery.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include "DlgSettingsCacheDirectory.h"
|
||||
#include "ui_DlgSettingsCacheDirectory.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsCacheDirectory */
|
||||
|
||||
QString DlgSettingsCacheDirectory::currentSize;
|
||||
|
||||
DlgSettingsCacheDirectory::DlgSettingsCacheDirectory(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsCacheDirectory)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->labelCache->setToolTip(tr("Notify the user if the cache size exceeds the specified limit"));
|
||||
if (currentSize.isEmpty())
|
||||
currentSize = tr("Unknown");
|
||||
setCurrentCacheSize(currentSize);
|
||||
|
||||
QString path = QString::fromStdString(App::Application::getUserCachePath());
|
||||
ui->cacheLocation->setText(path);
|
||||
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("100 MB"), 100);
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("300 MB"), 300);
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("500 MB"), 500);
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("1 GB"), 1024);
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("2 GB"), 2048);
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("3 GB"), 3072);
|
||||
|
||||
connect(ui->pushButtonCheck, &QPushButton::clicked, this, &DlgSettingsCacheDirectory::runCheck);
|
||||
connect(ui->openButton, &QPushButton::clicked, this, &DlgSettingsCacheDirectory::openDirectory);
|
||||
}
|
||||
|
||||
DlgSettingsCacheDirectory::~DlgSettingsCacheDirectory()
|
||||
{
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::saveSettings()
|
||||
{
|
||||
ApplicationCacheSettings::setCheckPeriod(ui->comboBoxPeriod->currentIndex());
|
||||
ApplicationCacheSettings::setCacheSizeLimit(ui->comboBoxLimit->currentData().toUInt());
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::loadSettings()
|
||||
{
|
||||
int period = ApplicationCacheSettings::getCheckPeriod();
|
||||
if (period >= 0 && period < ui->comboBoxPeriod->count())
|
||||
ui->comboBoxPeriod->setCurrentIndex(period);
|
||||
unsigned int limit = ApplicationCacheSettings::getCacheSizeLimit();
|
||||
int index = ui->comboBoxLimit->findData(limit);
|
||||
|
||||
// if not found then add a new item with this value
|
||||
if (index < 0) {
|
||||
ui->comboBoxLimit->addItem(QString::fromLatin1("%1 MB").arg(limit), limit);
|
||||
index = ui->comboBoxLimit->count() - 1;
|
||||
}
|
||||
ui->comboBoxLimit->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int period = ui->comboBoxPeriod->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
ui->comboBoxPeriod->setCurrentIndex(period);
|
||||
setCurrentCacheSize(currentSize);
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::setCurrentCacheSize(const QString& str)
|
||||
{
|
||||
currentSize = str;
|
||||
ui->labelCurrentCache->setText(tr("Current cache size: %1").arg(str));
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::runCheck()
|
||||
{
|
||||
Gui::Dialog::ApplicationCache cache;
|
||||
unsigned int sizeInMB = ui->comboBoxLimit->currentData().toUInt();
|
||||
cache.setLimit(ApplicationCache::toBytes(sizeInMB));
|
||||
qint64 total = cache.size();
|
||||
setCurrentCacheSize(ApplicationCache::toString(total));
|
||||
|
||||
// When performing the clean-up then recompute the new cache size
|
||||
if (cache.performAction(total)) {
|
||||
total = cache.size();
|
||||
setCurrentCacheSize(ApplicationCache::toString(total));
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsCacheDirectory::openDirectory()
|
||||
{
|
||||
QString path = QString::fromStdString(App::Application::getUserCachePath());
|
||||
QUrl url = QUrl::fromLocalFile(path);
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ApplicationCache::ApplicationCache()
|
||||
{
|
||||
limit = std::pow(1024, 3);
|
||||
setPeriod(Period::Weekly);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ApplicationCache::setPeriod
|
||||
* Set the period to check for the cache size
|
||||
* \param period
|
||||
*/
|
||||
void ApplicationCache::setPeriod(ApplicationCache::Period period)
|
||||
{
|
||||
switch (period) {
|
||||
case Period::Always:
|
||||
numDays = -1;
|
||||
break;
|
||||
case Period::Daily:
|
||||
numDays = 1;
|
||||
break;
|
||||
case Period::Weekly:
|
||||
numDays = 7;
|
||||
break;
|
||||
case Period::Monthly:
|
||||
numDays = 31;
|
||||
break;
|
||||
case Period::Yearly:
|
||||
numDays = 365;
|
||||
break;
|
||||
case Period::Never:
|
||||
numDays = INT_MAX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ApplicationCache::setLimit
|
||||
* Set the limit in bytes to perform a check
|
||||
* \param value
|
||||
*/
|
||||
void ApplicationCache::setLimit(qint64 value)
|
||||
{
|
||||
limit = value;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ApplicationCache::periodicCheckOfSize
|
||||
* Checks if the periodic check should be performed now
|
||||
* \return
|
||||
*/
|
||||
bool ApplicationCache::periodicCheckOfSize() const
|
||||
{
|
||||
QString vendor = QString::fromLatin1(App::Application::Config()["ExeVendor"].c_str());
|
||||
QString application = QString::fromStdString(App::Application::getExecutableName());
|
||||
|
||||
QSettings settings(vendor, application);
|
||||
QString key = QString::fromLatin1("LastCacheCheck");
|
||||
QDate date = settings.value(key).toDate();
|
||||
QDate now = QDate::currentDate();
|
||||
|
||||
// get the days since the last check
|
||||
int days = date.daysTo(now);
|
||||
if (date.isNull()) {
|
||||
days = 1000;
|
||||
}
|
||||
|
||||
if (days >= numDays) {
|
||||
settings.setValue(key, now);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ApplicationCache::performAction
|
||||
* If the cache size \a total is higher than the limit then show a dialog to the user
|
||||
* \param total
|
||||
*/
|
||||
bool ApplicationCache::performAction(qint64 total)
|
||||
{
|
||||
bool performed = false;
|
||||
if (total > limit) {
|
||||
QString path = QString::fromStdString(App::Application::getUserCachePath());
|
||||
QMessageBox msgBox(Gui::getMainWindow());
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setWindowTitle(tr("Cache directory"));
|
||||
|
||||
QString hint = tr("The cache directory %1 exceeds the size of %2.").arg(path, ApplicationCache::toString(limit));
|
||||
QString ask = tr("Do you want to clear it now?");
|
||||
QString warn = tr("Warning: Please make sure that this is the only running %1 instance "
|
||||
"and that no documents are opened as this may result into data loss!").arg(QCoreApplication::applicationName());
|
||||
|
||||
msgBox.setText(QString::fromLatin1("%1 %2\n\n\n%3").arg(hint, ask, warn));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Open);
|
||||
msgBox.setDefaultButton(QMessageBox::No);
|
||||
|
||||
while (true) {
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::Open) {
|
||||
QUrl url = QUrl::fromLocalFile(path);
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
else {
|
||||
if (ret == QMessageBox::Yes) {
|
||||
clearDirectory(path);
|
||||
performed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return performed;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ApplicationCache::size
|
||||
* Determines the size of the cache.
|
||||
* \return
|
||||
*/
|
||||
qint64 ApplicationCache::size() const
|
||||
{
|
||||
qint64 total = dirSize(QString::fromStdString(App::Application::getUserCachePath()));
|
||||
return total;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
*/
|
||||
void ApplicationCache::clearDirectory(const QString& path)
|
||||
{
|
||||
// Add the transient directories and the lock files to the ignore list
|
||||
QDir tmp = QString::fromUtf8(App::Application::getUserCachePath().c_str());
|
||||
tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
|
||||
tmp.setFilter(QDir::Files);
|
||||
|
||||
QList<QFileInfo> dirs;
|
||||
std::vector<App::Document*> docs = App::GetApplication().getDocuments();
|
||||
for (auto it : docs) {
|
||||
QDir dir(QString::fromStdString(it->TransientDir.getStrValue()));
|
||||
QFileInfo fi(dir.absolutePath());
|
||||
dirs.append(fi);
|
||||
}
|
||||
|
||||
DocumentRecoveryCleaner cleaner;
|
||||
cleaner.setIgnoreFiles(tmp.entryList());
|
||||
cleaner.setIgnoreDirectories(dirs);
|
||||
cleaner.clearDirectory(QFileInfo(path));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
*/
|
||||
qint64 ApplicationCache::dirSize(QString dirPath) const
|
||||
{
|
||||
qint64 total = 0;
|
||||
QDir dir(dirPath);
|
||||
|
||||
QDir::Filters fileFilters = QDir::Files;
|
||||
const auto& files = dir.entryList(fileFilters);
|
||||
for (const QString& filePath : files) {
|
||||
QFileInfo fi(dir, filePath);
|
||||
total += fi.size();
|
||||
}
|
||||
|
||||
// traverse sub-directories recursively
|
||||
QDir::Filters dirFilters = QDir::Dirs | QDir::NoDotAndDotDot;
|
||||
const auto& dirs = dir.entryList(dirFilters);
|
||||
for (const QString& subDirPath : dirs)
|
||||
total += dirSize(dirPath + QDir::separator() + subDirPath);
|
||||
return total;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ApplicationCache::applyUserSettings
|
||||
* Set period and limit according to user settings
|
||||
*/
|
||||
void ApplicationCache::applyUserSettings()
|
||||
{
|
||||
int period = ApplicationCacheSettings::getCheckPeriod();
|
||||
setPeriod(static_cast<Period>(period));
|
||||
|
||||
unsigned int sizeInMB = ApplicationCacheSettings::getCacheSizeLimit();
|
||||
setLimit(ApplicationCache::toBytes(sizeInMB));
|
||||
}
|
||||
|
||||
qint64 ApplicationCache::toBytes(unsigned int sizeInMB)
|
||||
{
|
||||
qint64 value = static_cast<qint64>(sizeInMB) * 1024 * 1024;
|
||||
return value;
|
||||
}
|
||||
|
||||
QString ApplicationCache::toString(qint64 size)
|
||||
{
|
||||
QStringList units = {QString::fromLatin1("Bytes"),
|
||||
QString::fromLatin1("KB"),
|
||||
QString::fromLatin1("MB"),
|
||||
QString::fromLatin1("GB")};
|
||||
int i;
|
||||
double outputSize = size;
|
||||
for (i=0; i<units.size()-1; i++) {
|
||||
if (outputSize < 1024)
|
||||
break;
|
||||
outputSize /= 1024;
|
||||
}
|
||||
|
||||
return QString::fromLatin1("%1 %2").arg(QLocale().toString(outputSize, 'f', 2), units[i]);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
unsigned int ApplicationCacheSettings::getCacheSizeLimit()
|
||||
{
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("CacheDirectory");
|
||||
return hGrp->GetUnsigned("Limit", 500);
|
||||
}
|
||||
|
||||
void ApplicationCacheSettings::setCacheSizeLimit(unsigned int limit)
|
||||
{
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("CacheDirectory");
|
||||
hGrp->SetUnsigned("Limit", limit);
|
||||
}
|
||||
|
||||
int ApplicationCacheSettings::getCheckPeriod()
|
||||
{
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("CacheDirectory");
|
||||
return hGrp->GetInt("Period", static_cast<int>(ApplicationCache::Period::Weekly));
|
||||
}
|
||||
|
||||
void ApplicationCacheSettings::setCheckPeriod(int period)
|
||||
{
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("CacheDirectory");
|
||||
hGrp->SetInt("Period", period);
|
||||
}
|
||||
|
||||
|
||||
#include "moc_DlgSettingsCacheDirectory.cpp"
|
||||
109
src/Gui/PreferencePages/DlgSettingsCacheDirectory.h
Normal file
109
src/Gui/PreferencePages/DlgSettingsCacheDirectory.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSCACHEDIRECTORY_H
|
||||
#define GUI_DIALOG_DLGSETTINGSCACHEDIRECTORY_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsCacheDirectory;
|
||||
|
||||
/**
|
||||
* The DlgSettingsCacheDirectory class implements a preference page to change settings
|
||||
* for the cache directory handling.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsCacheDirectory : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsCacheDirectory(QWidget* parent = nullptr);
|
||||
~DlgSettingsCacheDirectory() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void runCheck();
|
||||
void openDirectory();
|
||||
void setCurrentCacheSize(const QString&);
|
||||
|
||||
private:
|
||||
static QString currentSize;
|
||||
std::unique_ptr<Ui_DlgSettingsCacheDirectory> ui;
|
||||
};
|
||||
|
||||
class ApplicationCache : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class Period {
|
||||
Always,
|
||||
Daily,
|
||||
Weekly,
|
||||
Monthly,
|
||||
Yearly,
|
||||
Never
|
||||
};
|
||||
|
||||
ApplicationCache();
|
||||
void applyUserSettings();
|
||||
void setPeriod(Period);
|
||||
void setLimit(qint64);
|
||||
bool periodicCheckOfSize() const;
|
||||
qint64 size() const;
|
||||
bool performAction(qint64);
|
||||
|
||||
static QString toString(qint64 size);
|
||||
static qint64 toBytes(unsigned int);
|
||||
|
||||
private:
|
||||
void clearDirectory(const QString& path);
|
||||
qint64 dirSize(QString dirPath) const;
|
||||
|
||||
private:
|
||||
qint64 limit;
|
||||
int numDays;
|
||||
};
|
||||
|
||||
class ApplicationCacheSettings
|
||||
{
|
||||
public:
|
||||
static unsigned int getCacheSizeLimit();
|
||||
static void setCacheSizeLimit(unsigned int);
|
||||
static int getCheckPeriod();
|
||||
static void setCheckPeriod(int);
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSCACHEDIRECTORY_H
|
||||
201
src/Gui/PreferencePages/DlgSettingsCacheDirectory.ui
Normal file
201
src/Gui/PreferencePages/DlgSettingsCacheDirectory.ui
Normal file
@@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsCacheDirectory</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsCacheDirectory">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>425</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Cache</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox5">
|
||||
<property name="title">
|
||||
<string>Cache directory</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Location:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="cacheLocation">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="openButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Icons/resource.qrc">
|
||||
<normaloff>:/icons/document-open.svg</normaloff>:/icons/document-open.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelPeriod">
|
||||
<property name="text">
|
||||
<string>Check periodically at program start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>118</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2">
|
||||
<widget class="QComboBox" name="comboBoxPeriod">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Always</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Daily</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Weekly</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Monthly</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Yearly</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Never</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelCache">
|
||||
<property name="text">
|
||||
<string>Cache size limit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>118</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2">
|
||||
<widget class="QComboBox" name="comboBoxLimit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCurrentCache">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Current cache size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButtonCheck">
|
||||
<property name="text">
|
||||
<string>Check now...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>169</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="Icons/resource.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
841
src/Gui/PreferencePages/DlgSettingsDocument.ui
Normal file
841
src/Gui/PreferencePages/DlgSettingsDocument.ui
Normal file
@@ -0,0 +1,841 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsDocument</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsDocument">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>607</width>
|
||||
<height>859</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Document</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox5">
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefCheckNewDoc">
|
||||
<property name="toolTip">
|
||||
<string>The application will create a new document when started</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create new document at start up</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CreateNewDoc</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line1">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Document save compression level
|
||||
(0 = none, 9 = highest, 3 = default)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="prefCompression">
|
||||
<property name="toolTip">
|
||||
<string>Compression level for FCStd files</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CompressionLevel</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="Line" name="line1_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefUndoRedo">
|
||||
<property name="toolTip">
|
||||
<string>All changes in documents are stored so that they can be undone/redone</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Using Undo/Redo on documents</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UsingUndo</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel1_2">
|
||||
<property name="text">
|
||||
<string>Maximum Undo/Redo steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="prefUndoRedoSize">
|
||||
<property name="toolTip">
|
||||
<string>How many Undo/Redo steps should be recorded</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>MaxUndoSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefCanAbortRecompute">
|
||||
<property name="toolTip">
|
||||
<string>Allow user aborting document recomputation by pressing ESC.
|
||||
This feature may slightly increase recomputation time.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow aborting recomputation</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CanAbortRecompute</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Storage</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefSaveTransaction">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Saving transactions (Auto-save)</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SaveTransactions</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefDiscardTransaction">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Discard saved transaction after saving document</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>TransactionsDiscard</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefRecovery">
|
||||
<property name="toolTip">
|
||||
<string>If there is a recovery file available the application will
|
||||
automatically run a file recovery when it is started.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run AutoRecovery at startup</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RecoveryEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="prefAutoSaveEnabled">
|
||||
<property name="toolTip">
|
||||
<string>How often a recovery file is written</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save AutoRecovery information every</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AutoSaveEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="prefAutoSaveTimeout">
|
||||
<property name="suffix">
|
||||
<string notr="true"> min</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>60</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AutoSaveTimeout</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Line" name="line1_2_3">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="prefSaveThumbnail">
|
||||
<property name="toolTip">
|
||||
<string>A thumbnail will be stored when document is saved</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save thumbnail into project file when saving document</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SaveThumbnail</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="prefThumbnailSize">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Sets the size of the thumbnail that is stored in the document.
|
||||
Common sizes are 128, 256 and 512</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>64</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>512</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ThumbnailSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefAddLogo">
|
||||
<property name="toolTip">
|
||||
<string>The program logo will be added to the thumbnail</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add the program logo to the generated thumbnail</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AddThumbnailLogo</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="prefSaveBackupFiles">
|
||||
<property name="toolTip">
|
||||
<string>How many backup files will be kept when saving document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Maximum number of backup files to keep when resaving document</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CreateBackupFiles</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="prefCountBackupFiles">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CountBackupFiles</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="prefSaveBackupExtension">
|
||||
<property name="toolTip">
|
||||
<string>Backup files will get extension '.FCbak' and file names
|
||||
get date suffix according to the specified format</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use date and FCBak extension</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseFCBakExtension</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Date format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefLineEdit" name="prefSaveBackupDateFormat">
|
||||
<property name="text">
|
||||
<string notr="true">%Y%m%d-%H%M%S</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SaveBackupDateFormat</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Document objects</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefDuplicateLabel">
|
||||
<property name="toolTip">
|
||||
<string>Allow objects to have same label</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow duplicate object labels in one document</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DuplicateLabels</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="prefPartialLoading">
|
||||
<property name="toolTip">
|
||||
<string>Enable partial loading of external linked documents.
|
||||
Then only referenced objects and their dependencies will be loaded
|
||||
when a linked document is auto-opened together with the main document.
|
||||
A partially loaded document cannot be edited. Double click the document
|
||||
icon in the tree view to fully reload it.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable partial loading of external linked objects</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NoPartialLoading</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Authoring and License</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Author name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefLineEdit" name="prefAuthor">
|
||||
<property name="toolTip">
|
||||
<string>All documents that will be created will get the specified author name.
|
||||
Keep blank for anonymous.
|
||||
You can also use the form: John Doe <john@doe.com></string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefAuthor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::PrefCheckBox" name="prefSetAuthorOnSave">
|
||||
<property name="toolTip">
|
||||
<string>The field 'Last modified by' will be set to specified author when saving the file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set on save</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefSetAuthorOnSave</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Company</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="Gui::PrefLineEdit" name="prefCompany">
|
||||
<property name="toolTip">
|
||||
<string>Default company name to use for new files</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefCompany</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default license</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="Gui::PrefComboBox" name="prefLicenseType">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Default license for new documents</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefLicenseType</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>License URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="Gui::PrefLineEdit" name="prefLicenseUrl">
|
||||
<property name="toolTip">
|
||||
<string>URL describing more about the license</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">http://en.wikipedia.org/wiki/All_rights_reserved</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>prefLicenseUrl</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Document</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>429</width>
|
||||
<height>37</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>prefSaveBackupFiles</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>prefCountBackupFiles</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>150</x>
|
||||
<y>525</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>584</x>
|
||||
<y>527</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>prefAutoSaveEnabled</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>prefAutoSaveTimeout</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>218</x>
|
||||
<y>385</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>582</x>
|
||||
<y>387</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>prefSaveBackupFiles</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>prefSaveBackupExtension</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>280</x>
|
||||
<y>525</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>204</x>
|
||||
<y>559</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>prefSaveBackupFiles</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>prefSaveBackupDateFormat</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>326</x>
|
||||
<y>525</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>584</x>
|
||||
<y>560</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>prefSaveThumbnail</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>prefThumbnailSize</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>313</x>
|
||||
<y>412</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>398</x>
|
||||
<y>452</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
184
src/Gui/PreferencePages/DlgSettingsDocumentImp.cpp
Normal file
184
src/Gui/PreferencePages/DlgSettingsDocumentImp.cpp
Normal file
@@ -0,0 +1,184 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 <zlib.h>
|
||||
#include <App/License.h>
|
||||
#include <Gui/AutoSaver.h>
|
||||
|
||||
#include "DlgSettingsDocumentImp.h"
|
||||
#include "ui_DlgSettingsDocument.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsDocumentImp */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsDocumentImp which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsDocumentImp::DlgSettingsDocumentImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettingsDocument)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
addLicenseTypes();
|
||||
|
||||
ui->prefSaveTransaction->hide();
|
||||
ui->prefDiscardTransaction->hide();
|
||||
|
||||
QString tip = QString::fromLatin1("<html><head/><body><p>%1</p>"
|
||||
"<p>%2: %Y%m%d-%H%M%S</p>"
|
||||
"<p>%3: <a href=\"http://www.cplusplus.com/reference/ctime/strftime/\">C++ strftime</a>"
|
||||
"</p></body></html>").arg(tr("The format of the date to use."), tr("Default"), tr("Format"));
|
||||
ui->prefSaveBackupDateFormat->setToolTip(tip);
|
||||
|
||||
ui->prefCountBackupFiles->setMaximum(INT_MAX);
|
||||
ui->prefCompression->setMinimum(Z_NO_COMPRESSION);
|
||||
ui->prefCompression->setMaximum(Z_BEST_COMPRESSION);
|
||||
connect(ui->prefLicenseType, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsDocumentImp::onLicenseTypeChanged);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsDocumentImp::~DlgSettingsDocumentImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
|
||||
void DlgSettingsDocumentImp::saveSettings()
|
||||
{
|
||||
ui->prefCheckNewDoc->onSave();
|
||||
ui->prefCompression->onSave();
|
||||
|
||||
ui->prefUndoRedo->onSave();
|
||||
ui->prefUndoRedoSize->onSave();
|
||||
ui->prefSaveTransaction->onSave();
|
||||
ui->prefDiscardTransaction->onSave();
|
||||
ui->prefSaveThumbnail->onSave();
|
||||
ui->prefThumbnailSize->onSave();
|
||||
ui->prefAddLogo->onSave();
|
||||
ui->prefSaveBackupFiles->onSave();
|
||||
ui->prefCountBackupFiles->onSave();
|
||||
ui->prefSaveBackupExtension->onSave();
|
||||
ui->prefSaveBackupDateFormat->onSave();
|
||||
ui->prefDuplicateLabel->onSave();
|
||||
ui->prefPartialLoading->onSave();
|
||||
ui->prefLicenseType->onSave();
|
||||
ui->prefLicenseUrl->onSave();
|
||||
ui->prefAuthor->onSave();
|
||||
ui->prefSetAuthorOnSave->onSave();
|
||||
ui->prefCompany->onSave();
|
||||
ui->prefRecovery->onSave();
|
||||
ui->prefAutoSaveEnabled->onSave();
|
||||
ui->prefAutoSaveTimeout->onSave();
|
||||
ui->prefCanAbortRecompute->onSave();
|
||||
|
||||
int timeout = ui->prefAutoSaveTimeout->value();
|
||||
if (!ui->prefAutoSaveEnabled->isChecked())
|
||||
timeout = 0;
|
||||
AutoSaver::instance()->setTimeout(timeout * 60000);
|
||||
}
|
||||
|
||||
void DlgSettingsDocumentImp::loadSettings()
|
||||
{
|
||||
ui->prefCheckNewDoc->onRestore();
|
||||
ui->prefCompression->onRestore();
|
||||
|
||||
ui->prefUndoRedo->onRestore();
|
||||
ui->prefUndoRedoSize->onRestore();
|
||||
ui->prefSaveTransaction->onRestore();
|
||||
ui->prefDiscardTransaction->onRestore();
|
||||
ui->prefSaveThumbnail->onRestore();
|
||||
ui->prefThumbnailSize->onRestore();
|
||||
ui->prefAddLogo->onRestore();
|
||||
ui->prefSaveBackupFiles->onRestore();
|
||||
ui->prefCountBackupFiles->onRestore();
|
||||
ui->prefSaveBackupExtension->onRestore();
|
||||
ui->prefSaveBackupDateFormat->onRestore();
|
||||
ui->prefDuplicateLabel->onRestore();
|
||||
ui->prefPartialLoading->onRestore();
|
||||
ui->prefLicenseType->onRestore();
|
||||
ui->prefLicenseUrl->onRestore();
|
||||
ui->prefAuthor->onRestore();
|
||||
ui->prefSetAuthorOnSave->onRestore();
|
||||
ui->prefCompany->onRestore();
|
||||
ui->prefRecovery->onRestore();
|
||||
ui->prefAutoSaveEnabled->onRestore();
|
||||
ui->prefAutoSaveTimeout->onRestore();
|
||||
ui->prefCanAbortRecompute->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsDocumentImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
int index = ui->prefLicenseType->currentIndex();
|
||||
addLicenseTypes();
|
||||
ui->prefLicenseType->setCurrentIndex(index);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsDocumentImp::addLicenseTypes()
|
||||
{
|
||||
auto add = [&](const char* what) {
|
||||
ui->prefLicenseType->addItem(
|
||||
QApplication::translate("Gui::Dialog::DlgSettingsDocument", what));
|
||||
};
|
||||
|
||||
ui->prefLicenseType->clear();
|
||||
for (const auto& licenseItem : App::licenseItems) {
|
||||
add(licenseItem.at(App::posnOfFullName));
|
||||
}
|
||||
add("Other");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix Url according to changed type
|
||||
*/
|
||||
void DlgSettingsDocumentImp::onLicenseTypeChanged(int index)
|
||||
{
|
||||
if (index >= 0 && index < App::countOfLicenses) {
|
||||
// existing license
|
||||
const char* url {App::licenseItems.at(index).at(App::posnOfUrl)};
|
||||
ui->prefLicenseUrl->setText(QString::fromLatin1(url));
|
||||
ui->prefLicenseUrl->setReadOnly(true);
|
||||
}
|
||||
else {
|
||||
// Other
|
||||
ui->prefLicenseUrl->clear();
|
||||
ui->prefLicenseUrl->setReadOnly(false);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsDocumentImp.cpp"
|
||||
64
src/Gui/PreferencePages/DlgSettingsDocumentImp.h
Normal file
64
src/Gui/PreferencePages/DlgSettingsDocumentImp.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSDOCUMENT_IMP_H
|
||||
#define GUI_DIALOG_DLGSETTINGSDOCUMENT_IMP_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsDocument;
|
||||
|
||||
/**
|
||||
* The DlgSettingsDocumentImp class implements a preference page to change settings
|
||||
* for the document.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettingsDocumentImp : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsDocumentImp( QWidget* parent = nullptr );
|
||||
~DlgSettingsDocumentImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onLicenseTypeChanged(int index);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void addLicenseTypes();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsDocument> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSDOCUMENT_IMP_H
|
||||
353
src/Gui/PreferencePages/DlgSettingsEditor.cpp
Normal file
353
src/Gui/PreferencePages/DlgSettingsEditor.cpp
Normal file
@@ -0,0 +1,353 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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"
|
||||
#ifndef _PreComp_
|
||||
# include <QFontDatabase>
|
||||
#endif
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Gui/PythonEditor.h>
|
||||
#include <Gui/Tools.h>
|
||||
|
||||
#include "DlgSettingsEditor.h"
|
||||
#include "ui_DlgSettingsEditor.h"
|
||||
|
||||
|
||||
using namespace Gui;
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
struct DlgSettingsEditorP
|
||||
{
|
||||
QVector<QPair<QString, unsigned int> > colormap; // Color map
|
||||
};
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
/**
|
||||
* Get some kind of font that is monospaced, suitable for coding.
|
||||
*
|
||||
* Based on
|
||||
* https://stackoverflow.com/questions/18896933/qt-qfont-selection-of-a-monospace-font-doesnt-work
|
||||
*/
|
||||
QFont getMonospaceFont()
|
||||
{
|
||||
QFont font(QString::fromLatin1("monospace"));
|
||||
if (font.fixedPitch())
|
||||
return font;
|
||||
font.setStyleHint(QFont::Monospace);
|
||||
if (font.fixedPitch())
|
||||
return font;
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
if (font.fixedPitch())
|
||||
return font;
|
||||
font.setFamily(QString::fromLatin1("courier"));
|
||||
if (font.fixedPitch())
|
||||
return font;
|
||||
return font; // We failed, but return whatever we have anyway
|
||||
}
|
||||
}
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsEditor */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsEditor which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgSettingsEditor::DlgSettingsEditor( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettingsEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->EnableFolding->hide(); // Switch off until we have an editor with folding
|
||||
|
||||
setupConnections();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
ui->textEdit1->setTabStopWidth(40);
|
||||
#else
|
||||
ui->textEdit1->setTabStopDistance(40.0);
|
||||
#endif
|
||||
|
||||
d = new DlgSettingsEditorP();
|
||||
QColor col;
|
||||
col = qApp->palette().windowText().color();
|
||||
unsigned int lText = App::Color::asPackedRGB<QColor>(col);
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Text")), lText));
|
||||
|
||||
unsigned int lBookmarks = App::Color::asPackedRGB<QColor>(QColor(Qt::cyan));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Bookmark")), lBookmarks));
|
||||
|
||||
unsigned int lBreakpnts = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Breakpoint")), lBreakpnts));
|
||||
|
||||
unsigned int lKeywords = App::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Keyword")), lKeywords));
|
||||
|
||||
unsigned int lComments = App::Color::asPackedRGB<QColor>(QColor(0, 170, 0));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Comment")), lComments));
|
||||
|
||||
unsigned int lBlockCom = App::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Block comment")), lBlockCom));
|
||||
|
||||
unsigned int lNumbers = App::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Number")), lNumbers));
|
||||
|
||||
unsigned int lStrings = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("String")), lStrings));
|
||||
|
||||
unsigned int lCharacter = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Character")), lCharacter));
|
||||
|
||||
unsigned int lClass = App::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Class name")), lClass));
|
||||
|
||||
unsigned int lDefine = App::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Define name")), lDefine));
|
||||
|
||||
unsigned int lOperat = App::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Operator")), lOperat));
|
||||
|
||||
unsigned int lPyOutput = App::Color::asPackedRGB<QColor>(QColor(170, 170, 127));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Python output")), lPyOutput));
|
||||
|
||||
unsigned int lPyError = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Python error")), lPyError));
|
||||
|
||||
unsigned int lCLine = App::Color::asPackedRGB<QColor>(QColor(224, 224, 224));
|
||||
d->colormap.push_back(QPair<QString, unsigned int>
|
||||
(QString::fromLatin1(QT_TR_NOOP("Current line highlight")), lCLine));
|
||||
|
||||
QStringList labels; labels << tr("Items");
|
||||
ui->displayItems->setHeaderLabels(labels);
|
||||
ui->displayItems->header()->hide();
|
||||
for (QVector<QPair<QString, unsigned int> >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it) {
|
||||
auto item = new QTreeWidgetItem(ui->displayItems);
|
||||
item->setText(0, tr((*it).first.toLatin1()));
|
||||
}
|
||||
pythonSyntax = new PythonSyntaxHighlighter(ui->textEdit1);
|
||||
pythonSyntax->setDocument(ui->textEdit1->document());
|
||||
}
|
||||
|
||||
/** Destroys the object and frees any allocated resources */
|
||||
DlgSettingsEditor::~DlgSettingsEditor()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
delete pythonSyntax;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void DlgSettingsEditor::setupConnections()
|
||||
{
|
||||
connect(ui->displayItems, &QTreeWidget::currentItemChanged,
|
||||
this, &DlgSettingsEditor::onDisplayItemsCurrentItemChanged);
|
||||
connect(ui->colorButton, &ColorButton::changed,
|
||||
this, &DlgSettingsEditor::onColorButtonChanged);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
connect(ui->fontFamily, qOverload<const QString&>(&QComboBox::activated),
|
||||
this, &DlgSettingsEditor::onFontFamilyActivated);
|
||||
connect(ui->fontSize, qOverload<const QString&>(&PrefSpinBox::valueChanged),
|
||||
this, &DlgSettingsEditor::onFontSizeValueChanged);
|
||||
#else
|
||||
connect(ui->fontFamily, &QComboBox::textActivated,
|
||||
this, &DlgSettingsEditor::onFontFamilyActivated);
|
||||
connect(ui->fontSize, &PrefSpinBox::textChanged,
|
||||
this, &DlgSettingsEditor::onFontSizeValueChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Searches for the color value corresponding to \e name in current editor
|
||||
* settings ColorMap and assigns it to the color button
|
||||
* @see Gui::ColorButton
|
||||
*/
|
||||
void DlgSettingsEditor::onDisplayItemsCurrentItemChanged(QTreeWidgetItem *item)
|
||||
{
|
||||
int index = ui->displayItems->indexOfTopLevelItem(item);
|
||||
unsigned int col = d->colormap[index].second;
|
||||
ui->colorButton->setColor(App::Color::fromPackedRGB<QColor>(col));
|
||||
}
|
||||
|
||||
/** Updates the color map if a color was changed */
|
||||
void DlgSettingsEditor::onColorButtonChanged()
|
||||
{
|
||||
QColor col = ui->colorButton->color();
|
||||
unsigned int lcol = App::Color::asPackedRGB<QColor>(col);
|
||||
|
||||
int index = ui->displayItems->indexOfTopLevelItem(ui->displayItems->currentItem());
|
||||
d->colormap[index].second = lcol;
|
||||
pythonSyntax->setColor( d->colormap[index].first, col );
|
||||
}
|
||||
|
||||
void DlgSettingsEditor::setEditorTabWidth(int tabWidth)
|
||||
{
|
||||
QFontMetrics metric(font());
|
||||
int fontSize = QtTools::horizontalAdvance(metric, QLatin1Char('0'));
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
ui->textEdit1->setTabStopWidth(tabWidth * fontSize);
|
||||
#else
|
||||
ui->textEdit1->setTabStopDistance(tabWidth * fontSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DlgSettingsEditor::saveSettings()
|
||||
{
|
||||
ui->EnableLineNumber->onSave();
|
||||
ui->EnableBlockCursor->onSave();
|
||||
ui->EnableFolding->onSave();
|
||||
ui->tabSize->onSave();
|
||||
ui->indentSize->onSave();
|
||||
ui->radioTabs->onSave();
|
||||
ui->radioSpaces->onSave();
|
||||
|
||||
// Saves the color map
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor");
|
||||
for (QVector<QPair<QString, unsigned int> >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it) {
|
||||
auto col = static_cast<unsigned long>((*it).second);
|
||||
hGrp->SetUnsigned((*it).first.toLatin1(), col);
|
||||
}
|
||||
|
||||
hGrp->SetInt( "FontSize", ui->fontSize->value() );
|
||||
hGrp->SetASCII( "Font", ui->fontFamily->currentText().toLatin1() );
|
||||
|
||||
setEditorTabWidth(ui->tabSize->value());
|
||||
}
|
||||
|
||||
void DlgSettingsEditor::loadSettings()
|
||||
{
|
||||
ui->EnableLineNumber->onRestore();
|
||||
ui->EnableBlockCursor->onRestore();
|
||||
ui->EnableFolding->onRestore();
|
||||
ui->tabSize->onRestore();
|
||||
ui->indentSize->onRestore();
|
||||
ui->radioTabs->onRestore();
|
||||
ui->radioSpaces->onRestore();
|
||||
|
||||
setEditorTabWidth(ui->tabSize->value());
|
||||
ui->textEdit1->setPlainText(QString::fromLatin1("# Short Python sample\n"
|
||||
"import sys\n"
|
||||
"\n"
|
||||
"def foo(begin, end):\n"
|
||||
" i = begin\n"
|
||||
" while i < end:\n"
|
||||
" print(i)\n"
|
||||
" i = i + 1\n"
|
||||
" print(\"Text\")\n"
|
||||
" return None\n"
|
||||
"\n"
|
||||
"foo(0, 20)\n"));
|
||||
|
||||
// Restores the color map
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor");
|
||||
for (QVector<QPair<QString, unsigned int>>::Iterator it = d->colormap.begin();
|
||||
it != d->colormap.end(); ++it) {
|
||||
auto col = static_cast<unsigned long>((*it).second);
|
||||
col = hGrp->GetUnsigned((*it).first.toLatin1(), col);
|
||||
(*it).second = static_cast<unsigned int>(col);
|
||||
QColor color = App::Color::fromPackedRGB<QColor>(col);
|
||||
pythonSyntax->setColor((*it).first, color);
|
||||
}
|
||||
|
||||
// fill up font styles
|
||||
//
|
||||
ui->fontSize->setValue(10);
|
||||
ui->fontSize->setValue(hGrp->GetInt("FontSize", ui->fontSize->value()));
|
||||
|
||||
QByteArray defaultMonospaceFont = getMonospaceFont().family().toLatin1();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QStringList familyNames = QFontDatabase().families(QFontDatabase::Any);
|
||||
QStringList fixedFamilyNames;
|
||||
for (const auto &name : familyNames) {
|
||||
if (QFontDatabase().isFixedPitch(name)) {
|
||||
fixedFamilyNames.append(name);
|
||||
}
|
||||
}
|
||||
#else
|
||||
QStringList familyNames = QFontDatabase::families(QFontDatabase::Any);
|
||||
QStringList fixedFamilyNames;
|
||||
for (const auto &name : familyNames) {
|
||||
if (QFontDatabase::isFixedPitch(name)) {
|
||||
fixedFamilyNames.append(name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ui->fontFamily->addItems(fixedFamilyNames);
|
||||
int index = fixedFamilyNames.indexOf(
|
||||
QString::fromLatin1(hGrp->GetASCII("Font", defaultMonospaceFont).c_str()));
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
ui->fontFamily->setCurrentIndex(index);
|
||||
onFontFamilyActivated(ui->fontFamily->currentText());
|
||||
ui->displayItems->setCurrentItem(ui->displayItems->topLevelItem(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsEditor::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int index = 0;
|
||||
for (QVector<QPair<QString, unsigned int> >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it)
|
||||
ui->displayItems->topLevelItem(index++)->setText(0, tr((*it).first.toLatin1()));
|
||||
ui->retranslateUi(this);
|
||||
} else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsEditor::onFontFamilyActivated(const QString& fontFamily)
|
||||
{
|
||||
int fontSize = ui->fontSize->value();
|
||||
QFont ft(fontFamily, fontSize);
|
||||
ui->textEdit1->setFont(ft);
|
||||
}
|
||||
|
||||
void DlgSettingsEditor::onFontSizeValueChanged(const QString&)
|
||||
{
|
||||
onFontFamilyActivated(ui->fontFamily->currentText());
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsEditor.cpp"
|
||||
78
src/Gui/PreferencePages/DlgSettingsEditor.h
Normal file
78
src/Gui/PreferencePages/DlgSettingsEditor.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSEDITOR_H
|
||||
#define GUI_DIALOG_DLGSETTINGSEDITOR_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace Gui {
|
||||
class PythonSyntaxHighlighter;
|
||||
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsEditor;
|
||||
|
||||
/** This class implements a preferences page for the editor settings.
|
||||
* Here you can change different color settings and font for editors.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
struct DlgSettingsEditorP;
|
||||
class DlgSettingsEditor : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsEditor( QWidget* parent = nullptr );
|
||||
~DlgSettingsEditor() override;
|
||||
|
||||
public:
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void onDisplayItemsCurrentItemChanged(QTreeWidgetItem *i);
|
||||
void onColorButtonChanged();
|
||||
void onFontFamilyActivated(const QString&);
|
||||
void onFontSizeValueChanged(const QString&);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void setEditorTabWidth(int);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsEditor> ui;
|
||||
DlgSettingsEditorP* d;
|
||||
Gui::PythonSyntaxHighlighter* pythonSyntax;
|
||||
|
||||
DlgSettingsEditor( const DlgSettingsEditor & );
|
||||
DlgSettingsEditor& operator=( const DlgSettingsEditor & );
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSEDITOR_H
|
||||
409
src/Gui/PreferencePages/DlgSettingsEditor.ui
Normal file
409
src/Gui/PreferencePages/DlgSettingsEditor.ui
Normal file
@@ -0,0 +1,409 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsEditor</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>494</width>
|
||||
<height>553</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Editor</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox2">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="EnableLineNumber">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Code lines will be numbered</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable line numbers</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnableLineNumber</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="EnableBlockCursor">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The cursor shape will be a block</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable block cursor</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnableBlockCursor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="EnableFolding">
|
||||
<property name="text">
|
||||
<string>Enable folding</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnableFolding</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Ignored</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBoxIndent">
|
||||
<property name="title">
|
||||
<string>Indentation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Tab size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="tabSize">
|
||||
<property name="toolTip">
|
||||
<string>Tabulator raster (how many spaces)</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>TabSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string>Indent size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="indentSize">
|
||||
<property name="toolTip">
|
||||
<string>How many spaces will be inserted when pressing <Tab></string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>IndentSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="Gui::PrefRadioButton" name="radioTabs">
|
||||
<property name="toolTip">
|
||||
<string>Pressing <Tab> will insert a tabulator with defined tab size</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keep tabs</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Tabs</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="Gui::PrefRadioButton" name="radioSpaces">
|
||||
<property name="toolTip">
|
||||
<string>Pressing <Tab> will insert amount of defined indent size</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Insert spaces</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Spaces</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="GroupBox5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Display items</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="7">
|
||||
<widget class="QTreeWidget" name="displayItems">
|
||||
<property name="toolTip">
|
||||
<string>Color and font settings will be applied to selected type</string>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="TextLabel3">
|
||||
<property name="text">
|
||||
<string>Family:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="fontFamily">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font family to be used for selected code type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="TextLabel4">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::PrefSpinBox" name="fontSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font size to be used for selected code type</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>FontSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Editor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::ColorButton" name="colorButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>140</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Preview:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" rowspan="3" colspan="2">
|
||||
<widget class="QTextEdit" name="textEdit1">
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefRadioButton</class>
|
||||
<extends>QRadioButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>fontFamily</tabstop>
|
||||
<tabstop>EnableLineNumber</tabstop>
|
||||
<tabstop>EnableBlockCursor</tabstop>
|
||||
<tabstop>EnableFolding</tabstop>
|
||||
<tabstop>tabSize</tabstop>
|
||||
<tabstop>indentSize</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
583
src/Gui/PreferencePages/DlgSettingsGeneral.cpp
Normal file
583
src/Gui/PreferencePages/DlgSettingsGeneral.cpp
Normal file
@@ -0,0 +1,583 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <limits>
|
||||
# include <QApplication>
|
||||
# include <QFileDialog>
|
||||
# include <QLocale>
|
||||
# include <QMessageBox>
|
||||
# include <algorithm>
|
||||
# include <boost/filesystem.hpp>
|
||||
#endif
|
||||
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
#include <Gui/Action.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/DlgCreateNewPreferencePackImp.h>
|
||||
#include <Gui/DlgPreferencesImp.h>
|
||||
#include <Gui/DlgPreferencePackManagementImp.h>
|
||||
#include <Gui/DlgRevertToBackupConfigImp.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/PreferencePackManager.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
|
||||
#include "DlgSettingsGeneral.h"
|
||||
#include "ui_DlgSettingsGeneral.h"
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
namespace fs = boost::filesystem;
|
||||
using namespace Base;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsGeneral */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsGeneral which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgSettingsGeneral::DlgSettingsGeneral( QWidget* parent )
|
||||
: PreferencePage(parent)
|
||||
, localeIndex(0)
|
||||
, themeChanged(false)
|
||||
, ui(new Ui_DlgSettingsGeneral)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
recreatePreferencePackMenu();
|
||||
|
||||
connect(ui->ImportConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::onImportConfigClicked);
|
||||
connect(ui->SaveNewPreferencePack, &QPushButton::clicked, this, &DlgSettingsGeneral::saveAsNewPreferencePack);
|
||||
connect(ui->themesCombobox, qOverload<int>(&QComboBox::activated), this, &DlgSettingsGeneral::onThemeChanged);
|
||||
|
||||
ui->ManagePreferencePacks->setToolTip(tr("Manage preference packs"));
|
||||
connect(ui->ManagePreferencePacks, &QPushButton::clicked, this, &DlgSettingsGeneral::onManagePreferencePacksClicked);
|
||||
|
||||
// If there are any saved config file backs, show the revert button, otherwise hide it:
|
||||
const auto & backups = Application::Instance->prefPackManager()->configBackups();
|
||||
ui->RevertToSavedConfig->setEnabled(backups.empty());
|
||||
connect(ui->RevertToSavedConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::revertToSavedConfig);
|
||||
|
||||
connect(ui->comboBox_UnitSystem, qOverload<int>(&QComboBox::currentIndexChanged), this, &DlgSettingsGeneral::onUnitSystemIndexChanged);
|
||||
ui->spinBoxDecimals->setMaximum(std::numeric_limits<double>::digits10 + 1);
|
||||
|
||||
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
|
||||
for (int i = 0; i < num; i++) {
|
||||
QString item = Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i));
|
||||
ui->comboBox_UnitSystem->addItem(item, i);
|
||||
}
|
||||
|
||||
// Enable/disable the fractional inch option depending on system
|
||||
if (UnitsApi::getSchema() == UnitSystem::ImperialBuilding)
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(true);
|
||||
ui->fractionalInchLabel->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(false);
|
||||
ui->fractionalInchLabel->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsGeneral::~DlgSettingsGeneral()
|
||||
{
|
||||
}
|
||||
|
||||
/** Sets the size of the recent file list from the user parameters.
|
||||
* @see RecentFilesAction
|
||||
* @see StdCmdRecentFiles
|
||||
*/
|
||||
void DlgSettingsGeneral::setRecentFileSize()
|
||||
{
|
||||
auto recent = getMainWindow()->findChild<RecentFilesAction *>
|
||||
(QLatin1String("recentFiles"));
|
||||
if (recent) {
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentFiles");
|
||||
recent->resizeList(hGrp->GetInt("RecentFiles", 4));
|
||||
}
|
||||
}
|
||||
|
||||
bool DlgSettingsGeneral::setLanguage()
|
||||
{
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
QString lang = QLocale::languageToString(QLocale().language());
|
||||
QByteArray language = hGrp->GetASCII("Language", (const char*)lang.toLatin1()).c_str();
|
||||
QByteArray current = ui->Languages->itemData(ui->Languages->currentIndex()).toByteArray();
|
||||
if (current != language) {
|
||||
hGrp->SetASCII("Language", current.constData());
|
||||
Translator::instance()->activateLanguage(current.constData());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::setNumberLocale(bool force/* = false*/)
|
||||
{
|
||||
int localeFormat = ui->UseLocaleFormatting->currentIndex();
|
||||
|
||||
// Only make the change if locale setting has changed or if forced
|
||||
// Except if format is "OS" where we don't want to run setLocale
|
||||
if (localeIndex == localeFormat && (!force || localeFormat == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (localeFormat == 0) {
|
||||
Translator::instance()->setLocale(); // Defaults to system locale
|
||||
}
|
||||
else if (localeFormat == 1) {
|
||||
QByteArray current = ui->Languages->itemData(ui->Languages->currentIndex()).toByteArray();
|
||||
Translator::instance()->setLocale(current.constData());
|
||||
}
|
||||
else if (localeFormat == 2) {
|
||||
Translator::instance()->setLocale("C");
|
||||
}
|
||||
else {
|
||||
return; // Prevent localeIndex updating if localeFormat is out of range
|
||||
}
|
||||
localeIndex = localeFormat;
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::setDecimalPointConversion(bool on)
|
||||
{
|
||||
if (Translator::instance()->isEnabledDecimalPointConversion() != on) {
|
||||
Translator::instance()->enableDecimalPointConversion(on);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
int FracInch; // minimum fractional inch to display
|
||||
int viewSystemIndex; // currently selected View System (unit system)
|
||||
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
hGrpu->SetInt("UserSchema", ui->comboBox_UnitSystem->currentIndex());
|
||||
hGrpu->SetInt("Decimals", ui->spinBoxDecimals->value());
|
||||
|
||||
// Set actual value
|
||||
Base::UnitsApi::setDecimals(ui->spinBoxDecimals->value());
|
||||
|
||||
// Convert the combobox index to the its integer denominator. Currently
|
||||
// with 1/2, 1/4, through 1/128, this little equation directly computes the
|
||||
// denominator given the combobox integer.
|
||||
//
|
||||
// The inverse conversion is done when loaded. That way only one thing (the
|
||||
// numerical fractional inch value) needs to be stored.
|
||||
FracInch = std::pow(2, ui->comboBox_FracInch->currentIndex() + 1);
|
||||
hGrpu->SetInt("FracInch", FracInch);
|
||||
|
||||
// Set the actual format value
|
||||
Base::QuantityFormat::setDefaultDenominator(FracInch);
|
||||
|
||||
// Set and save the Unit System
|
||||
viewSystemIndex = ui->comboBox_UnitSystem->currentIndex();
|
||||
UnitsApi::setSchema(static_cast<UnitSystem>(viewSystemIndex));
|
||||
|
||||
ui->SubstituteDecimal->onSave();
|
||||
ui->UseLocaleFormatting->onSave();
|
||||
ui->RecentFiles->onSave();
|
||||
ui->EnableCursorBlinking->onSave();
|
||||
ui->SplashScreen->onSave();
|
||||
|
||||
setRecentFileSize();
|
||||
bool force = setLanguage();
|
||||
// In case type is "Selected language", we need to force locale change
|
||||
setNumberLocale(force);
|
||||
setDecimalPointConversion(ui->SubstituteDecimal->isChecked());
|
||||
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
QVariant size = ui->toolbarIconSize->itemData(ui->toolbarIconSize->currentIndex());
|
||||
int pixel = size.toInt();
|
||||
hGrp->SetInt("ToolbarIconSize", pixel);
|
||||
getMainWindow()->setIconSize(QSize(pixel,pixel));
|
||||
|
||||
int blinkTime{hGrp->GetBool("EnableCursorBlinking", true) ? -1 : 0};
|
||||
qApp->setCursorFlashTime(blinkTime);
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows");
|
||||
bool treeView=false;
|
||||
bool propertyView=false;
|
||||
bool comboView=true;
|
||||
switch(ui->treeMode->currentIndex()) {
|
||||
case 1:
|
||||
treeView = propertyView = true;
|
||||
comboView = false;
|
||||
break;
|
||||
case 2:
|
||||
comboView = true;
|
||||
treeView = propertyView = true;
|
||||
break;
|
||||
}
|
||||
hGrp->GetGroup("ComboView")->SetBool("Enabled",comboView);
|
||||
hGrp->GetGroup("TreeView")->SetBool("Enabled",treeView);
|
||||
hGrp->GetGroup("PropertyView")->SetBool("Enabled",propertyView);
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
hGrp->SetBool("TiledBackground", ui->tiledBackground->isChecked());
|
||||
|
||||
if (themeChanged)
|
||||
saveThemes();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::loadSettings()
|
||||
{
|
||||
int FracInch;
|
||||
int cbIndex;
|
||||
|
||||
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Units");
|
||||
ui->comboBox_UnitSystem->setCurrentIndex(hGrpu->GetInt("UserSchema", 0));
|
||||
ui->spinBoxDecimals->setValue(hGrpu->GetInt("Decimals", Base::UnitsApi::getDecimals()));
|
||||
|
||||
// Get the current user setting for the minimum fractional inch
|
||||
FracInch = hGrpu->GetInt("FracInch", Base::QuantityFormat::getDefaultDenominator());
|
||||
|
||||
// Convert fractional inch to the corresponding combobox index using this
|
||||
// handy little equation.
|
||||
cbIndex = std::log2(FracInch) - 1;
|
||||
ui->comboBox_FracInch->setCurrentIndex(cbIndex);
|
||||
|
||||
|
||||
ui->SubstituteDecimal->onRestore();
|
||||
ui->UseLocaleFormatting->onRestore();
|
||||
ui->RecentFiles->onRestore();
|
||||
ui->EnableCursorBlinking->onRestore();
|
||||
ui->SplashScreen->onRestore();
|
||||
|
||||
// search for the language files
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
auto langToStr = Translator::instance()->activeLanguage();
|
||||
QByteArray language = hGrp->GetASCII("Language", langToStr.c_str()).c_str();
|
||||
|
||||
localeIndex = ui->UseLocaleFormatting->currentIndex();
|
||||
|
||||
int index = 1;
|
||||
TStringMap list = Translator::instance()->supportedLocales();
|
||||
ui->Languages->clear();
|
||||
ui->Languages->addItem(QString::fromLatin1("English"), QByteArray("English"));
|
||||
for (auto it = list.begin(); it != list.end(); ++it, index++) {
|
||||
QByteArray lang = it->first.c_str();
|
||||
QString langname = QString::fromLatin1(lang.constData());
|
||||
|
||||
if (it->second == "sr-CS") {
|
||||
// Qt does not treat sr-CS (Serbian, Latin) as a Latin-script variant by default: this
|
||||
// forces it to do so.
|
||||
it->second = "sr_Latn";
|
||||
}
|
||||
|
||||
QLocale locale(QString::fromLatin1(it->second.c_str()));
|
||||
QString native = locale.nativeLanguageName();
|
||||
if (!native.isEmpty()) {
|
||||
if (native[0].isLetter())
|
||||
native[0] = native[0].toUpper();
|
||||
langname = native;
|
||||
}
|
||||
|
||||
ui->Languages->addItem(langname, lang);
|
||||
if (language == lang) {
|
||||
ui->Languages->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractItemModel* model = ui->Languages->model();
|
||||
if (model)
|
||||
model->sort(0);
|
||||
|
||||
int current = getMainWindow()->iconSize().width();
|
||||
current = hGrp->GetInt("ToolbarIconSize", current);
|
||||
ui->toolbarIconSize->clear();
|
||||
ui->toolbarIconSize->addItem(tr("Small (%1px)").arg(16), QVariant((int)16));
|
||||
ui->toolbarIconSize->addItem(tr("Medium (%1px)").arg(24), QVariant((int)24));
|
||||
ui->toolbarIconSize->addItem(tr("Large (%1px)").arg(32), QVariant((int)32));
|
||||
ui->toolbarIconSize->addItem(tr("Extra large (%1px)").arg(48), QVariant((int)48));
|
||||
index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
if (index < 0) {
|
||||
ui->toolbarIconSize->addItem(tr("Custom (%1px)").arg(current), QVariant((int)current));
|
||||
index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
}
|
||||
ui->toolbarIconSize->setCurrentIndex(index);
|
||||
|
||||
//TreeMode combobox setup.
|
||||
ui->treeMode->clear();
|
||||
ui->treeMode->addItem(tr("Combo View"));
|
||||
ui->treeMode->addItem(tr("TreeView and PropertyView"));
|
||||
ui->treeMode->addItem(tr("Both"));
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows");
|
||||
bool propertyView = hGrp->GetGroup("PropertyView")->GetBool("Enabled",false);
|
||||
bool treeView = hGrp->GetGroup("TreeView")->GetBool("Enabled",false);
|
||||
bool comboView = hGrp->GetGroup("ComboView")->GetBool("Enabled",true);
|
||||
index = 0;
|
||||
if(propertyView || treeView) {
|
||||
index = comboView?2:1;
|
||||
}
|
||||
ui->treeMode->setCurrentIndex(index);
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
ui->tiledBackground->setChecked(hGrp->GetBool("TiledBackground", false));
|
||||
|
||||
loadThemes();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::saveThemes()
|
||||
{
|
||||
// First we save the name of the theme
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
|
||||
std::string theme = ui->themesCombobox->currentText().toStdString();
|
||||
hGrp->SetASCII("Theme", theme);
|
||||
|
||||
// Then we apply the themepack.
|
||||
Application::Instance->prefPackManager()->rescan();
|
||||
auto packs = Application::Instance->prefPackManager()->preferencePacks();
|
||||
|
||||
for (const auto& pack : packs) {
|
||||
if (pack.first == theme) {
|
||||
|
||||
Application::Instance->prefPackManager()->apply(pack.first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the StyleSheet
|
||||
QString sheet = QString::fromStdString(hGrp->GetASCII("StyleSheet"));
|
||||
bool tiledBackground = hGrp->GetBool("TiledBackground", false);
|
||||
Application::Instance->setStyleSheet(sheet, tiledBackground);
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::loadThemes()
|
||||
{
|
||||
ui->themesCombobox->clear();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
|
||||
QString currentTheme = QString::fromLatin1(hGrp->GetASCII("Theme", "").c_str());
|
||||
|
||||
Application::Instance->prefPackManager()->rescan();
|
||||
auto packs = Application::Instance->prefPackManager()->preferencePacks();
|
||||
for (const auto& pack : packs) {
|
||||
if (pack.second.metadata().type() == "Theme") {
|
||||
ui->themesCombobox->addItem(QString::fromStdString(pack.first));
|
||||
}
|
||||
}
|
||||
|
||||
int index = ui->themesCombobox->findText(currentTheme);
|
||||
if (index >= 0 && index < ui->themesCombobox->count()) {
|
||||
ui->themesCombobox->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
int index = ui->UseLocaleFormatting->currentIndex();
|
||||
int index2 = ui->comboBox_UnitSystem->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
ui->UseLocaleFormatting->setCurrentIndex(index);
|
||||
ui->comboBox_UnitSystem->setCurrentIndex(index2);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::recreatePreferencePackMenu()
|
||||
{
|
||||
ui->PreferencePacks->setRowCount(0); // Begin by clearing whatever is there
|
||||
ui->PreferencePacks->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
|
||||
ui->PreferencePacks->setColumnCount(3);
|
||||
ui->PreferencePacks->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
ui->PreferencePacks->horizontalHeader()->setStretchLastSection(false);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
|
||||
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeMode::ResizeToContents);
|
||||
QStringList columnHeaders;
|
||||
columnHeaders << tr("Preference Pack Name")
|
||||
<< tr("Tags")
|
||||
<< QString(); // for the "Load" buttons
|
||||
ui->PreferencePacks->setHorizontalHeaderLabels(columnHeaders);
|
||||
|
||||
// Populate the Preference Packs list
|
||||
Application::Instance->prefPackManager()->rescan();
|
||||
auto packs = Application::Instance->prefPackManager()->preferencePacks();
|
||||
|
||||
// Remove the Themes.
|
||||
std::vector<std::string> packsToRemove;
|
||||
for (const auto& pack : packs) {
|
||||
if (pack.second.metadata().type() == "Theme") {
|
||||
packsToRemove.push_back(pack.first); // Store the keys to remove later
|
||||
}
|
||||
}
|
||||
for (const auto& key : packsToRemove) {
|
||||
packs.erase(key); // Remove the elements from the map
|
||||
}
|
||||
|
||||
ui->PreferencePacks->setRowCount(packs.size());
|
||||
|
||||
int row = 0;
|
||||
QIcon icon = style()->standardIcon(QStyle::SP_DialogApplyButton);
|
||||
for (const auto& pack : packs) {
|
||||
auto name = new QTableWidgetItem(QString::fromStdString(pack.first));
|
||||
name->setToolTip(QString::fromStdString(pack.second.metadata().description()));
|
||||
ui->PreferencePacks->setItem(row, 0, name);
|
||||
auto tags = pack.second.metadata().tag();
|
||||
QString tagString;
|
||||
for (const auto& tag : tags) {
|
||||
if (tagString.isEmpty())
|
||||
tagString.append(QString::fromStdString(tag));
|
||||
else
|
||||
tagString.append(QStringLiteral(", ") + QString::fromStdString(tag));
|
||||
}
|
||||
auto kind = new QTableWidgetItem(tagString);
|
||||
ui->PreferencePacks->setItem(row, 1, kind);
|
||||
auto button = new QPushButton(icon, tr("Apply"));
|
||||
button->setToolTip(tr("Apply the %1 preference pack").arg(QString::fromStdString(pack.first)));
|
||||
connect(button, &QPushButton::clicked, this, [this, pack]() { onLoadPreferencePackClicked(pack.first); });
|
||||
ui->PreferencePacks->setCellWidget(row, 2, button);
|
||||
++row;
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::saveAsNewPreferencePack()
|
||||
{
|
||||
// Create and run a modal New PreferencePack dialog box
|
||||
auto packs = Application::Instance->prefPackManager()->preferencePackNames();
|
||||
newPreferencePackDialog = std::make_unique<DlgCreateNewPreferencePackImp>(this);
|
||||
newPreferencePackDialog->setPreferencePackTemplates(Application::Instance->prefPackManager()->templateFiles());
|
||||
newPreferencePackDialog->setPreferencePackNames(packs);
|
||||
connect(newPreferencePackDialog.get(), &DlgCreateNewPreferencePackImp::accepted, this, &DlgSettingsGeneral::newPreferencePackDialogAccepted);
|
||||
newPreferencePackDialog->open();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::revertToSavedConfig()
|
||||
{
|
||||
revertToBackupConfigDialog = std::make_unique<DlgRevertToBackupConfigImp>(this);
|
||||
connect(revertToBackupConfigDialog.get(), &DlgRevertToBackupConfigImp::accepted, this, [this]() {
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*> (this->window());
|
||||
if (parentDialog) {
|
||||
parentDialog->reload();
|
||||
}
|
||||
});
|
||||
revertToBackupConfigDialog->open();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::newPreferencePackDialogAccepted()
|
||||
{
|
||||
auto preferencePackTemplates = Application::Instance->prefPackManager()->templateFiles();
|
||||
auto selection = newPreferencePackDialog->selectedTemplates();
|
||||
std::vector<PreferencePackManager::TemplateFile> selectedTemplates;
|
||||
std::copy_if(preferencePackTemplates.begin(), preferencePackTemplates.end(), std::back_inserter(selectedTemplates), [selection](PreferencePackManager::TemplateFile& tf) {
|
||||
for (const auto& item : selection) {
|
||||
if (item.group == tf.group && item.name == tf.name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
auto preferencePackName = newPreferencePackDialog->preferencePackName();
|
||||
Application::Instance->prefPackManager()->save(preferencePackName, selectedTemplates);
|
||||
recreatePreferencePackMenu();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onManagePreferencePacksClicked()
|
||||
{
|
||||
if (!this->preferencePackManagementDialog) {
|
||||
this->preferencePackManagementDialog = std::make_unique<DlgPreferencePackManagementImp>(this);
|
||||
connect(this->preferencePackManagementDialog.get(), &DlgPreferencePackManagementImp::packVisibilityChanged,
|
||||
this, &DlgSettingsGeneral::recreatePreferencePackMenu);
|
||||
}
|
||||
this->preferencePackManagementDialog->show();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onImportConfigClicked()
|
||||
{
|
||||
auto path = fs::path(QFileDialog::getOpenFileName(this,
|
||||
tr("Choose a FreeCAD config file to import"),
|
||||
QString(),
|
||||
QString::fromUtf8("*.cfg")).toStdString());
|
||||
if (!path.empty()) {
|
||||
// Create a name from the filename:
|
||||
auto packName = path.filename().stem().string();
|
||||
std::replace(packName.begin(), packName.end(), '_', ' ');
|
||||
auto existingPacks = Application::Instance->prefPackManager()->preferencePackNames();
|
||||
if (std::find(existingPacks.begin(), existingPacks.end(), packName)
|
||||
!= existingPacks.end()) {
|
||||
auto result = QMessageBox::question(
|
||||
this, tr("File exists"),
|
||||
tr("A preference pack with that name already exists. Overwrite?"));
|
||||
if (result == QMessageBox::No) { // Maybe someday ask for a new name?
|
||||
return;
|
||||
}
|
||||
}
|
||||
Application::Instance->prefPackManager()->importConfig(packName, path);
|
||||
recreatePreferencePackMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onLoadPreferencePackClicked(const std::string& packName)
|
||||
{
|
||||
if (Application::Instance->prefPackManager()->apply(packName)) {
|
||||
auto parentDialog = qobject_cast<DlgPreferencesImp*> (this->window());
|
||||
if (parentDialog)
|
||||
parentDialog->reload();
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onUnitSystemIndexChanged(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return; // happens when clearing the combo box in retranslateUi()
|
||||
|
||||
// Enable/disable the fractional inch option depending on system
|
||||
if (static_cast<UnitSystem>(index) == UnitSystem::ImperialBuilding)
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(true);
|
||||
ui->fractionalInchLabel->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBox_FracInch->setVisible(false);
|
||||
ui->fractionalInchLabel->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::onThemeChanged(int index) {
|
||||
Q_UNUSED(index);
|
||||
themeChanged = true;
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsGeneral.cpp"
|
||||
94
src/Gui/PreferencePages/DlgSettingsGeneral.h
Normal file
94
src/Gui/PreferencePages/DlgSettingsGeneral.h
Normal file
@@ -0,0 +1,94 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_DIALOG_DLGSETTINGSGENERAL_H
|
||||
#define GUI_DIALOG_DLGSETTINGSGENERAL_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class QTabWidget;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsGeneral;
|
||||
class DlgCreateNewPreferencePackImp;
|
||||
class DlgPreferencePackManagementImp;
|
||||
class DlgRevertToBackupConfigImp;
|
||||
|
||||
/** This class implements the settings for the application.
|
||||
* You can change window style, size of pixmaps, size of recent file list and so on
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsGeneral : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsGeneral( QWidget* parent = nullptr );
|
||||
~DlgSettingsGeneral() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
void saveThemes();
|
||||
void loadThemes();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onLoadPreferencePackClicked(const std::string &packName);
|
||||
void recreatePreferencePackMenu();
|
||||
void newPreferencePackDialogAccepted();
|
||||
void onManagePreferencePacksClicked();
|
||||
void onImportConfigClicked();
|
||||
void onThemeChanged(int index);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onUnitSystemIndexChanged(int index);
|
||||
|
||||
private:
|
||||
void setRecentFileSize();
|
||||
void saveAsNewPreferencePack();
|
||||
void revertToSavedConfig();
|
||||
bool setLanguage(); //Returns true if language has been changed
|
||||
void setNumberLocale(bool force = false);
|
||||
void setDecimalPointConversion(bool on);
|
||||
|
||||
private:
|
||||
int localeIndex;
|
||||
bool themeChanged;
|
||||
std::unique_ptr<Ui_DlgSettingsGeneral> ui;
|
||||
std::unique_ptr<DlgCreateNewPreferencePackImp> newPreferencePackDialog;
|
||||
std::unique_ptr<DlgPreferencePackManagementImp> preferencePackManagementDialog;
|
||||
std::unique_ptr<DlgRevertToBackupConfigImp> revertToBackupConfigDialog;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSGENERAL_H
|
||||
518
src/Gui/PreferencePages/DlgSettingsGeneral.ui
Normal file
518
src/Gui/PreferencePages/DlgSettingsGeneral.ui
Normal file
@@ -0,0 +1,518 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsGeneral</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsGeneral">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>660</width>
|
||||
<height>930</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox7">
|
||||
<property name="title">
|
||||
<string>Language and number format</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="TextLabel1_4">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="Languages">
|
||||
<property name="toolTip">
|
||||
<string>Language of the application's user interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="unitSystemLabel">
|
||||
<property name="text">
|
||||
<string>Unit system:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox_UnitSystem">
|
||||
<property name="toolTip">
|
||||
<string>Unit system that should be used for all parts of the application</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="decimalsLabel">
|
||||
<property name="text">
|
||||
<string>Number of decimals:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxDecimals">
|
||||
<property name="toolTip">
|
||||
<string>Number of decimals that should be shown for numbers and dimensions</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="fractionalInchLabel">
|
||||
<property name="text">
|
||||
<string>Minimum fractional inch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox_FracInch">
|
||||
<property name="toolTip">
|
||||
<string>Minimum fractional inch to be displayed</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/2"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/4"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/8"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/16"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/32"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/64"</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">1/128"</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="TextLabel1_5">
|
||||
<property name="text">
|
||||
<string>Number format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefComboBox" name="UseLocaleFormatting">
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseLocaleFormatting</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>General</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Operating system</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Selected language</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>C/POSIX</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::PrefCheckBox" name="SubstituteDecimal">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, numerical keypad decimal separator
|
||||
will be substituted with locale separator, except
|
||||
in Python Console and Macro Editor where a
|
||||
dot/period will always be printed.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Substitute decimal separator</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SubstituteDecimalSeparator</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>General</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox3">
|
||||
<property name="title">
|
||||
<string>Application</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="themesLabel">
|
||||
<property name="text">
|
||||
<string>Theme:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="themesCombobox">
|
||||
<property name="toolTip">
|
||||
<string>Customize how user interface will look like</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="iconSizeLabel">
|
||||
<property name="text">
|
||||
<string>Size of toolbar icons:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="toolbarIconSize">
|
||||
<property name="toolTip">
|
||||
<string>Choose your preference for toolbar icon size. You can adjust
|
||||
this according to your screen size or personal taste</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="treeModeLabel">
|
||||
<property name="text">
|
||||
<string>Tree view mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="treeMode">
|
||||
<property name="toolTip">
|
||||
<string>Customize how tree view is shown in the panel (restart required).
|
||||
|
||||
'ComboView': combine tree view and property view into one panel.
|
||||
'TreeView and PropertyView': split tree view and property view into separate panel.
|
||||
'Both': keep all three panels, and you can have two sets of tree view and property view.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="recentFileListLabel">
|
||||
<property name="text">
|
||||
<string>Size of recent file list:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="RecentFiles">
|
||||
<property name="toolTip">
|
||||
<string>How many files should be listed in recent files list</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RecentFiles</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>RecentFiles</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="tiledBackground">
|
||||
<property name="toolTip">
|
||||
<string>Background of the main window (when no document is opened) will consist of tiles of a special image.
|
||||
See the FreeCAD Wiki for details about the image.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable tiled background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Gui::PrefCheckBox" name="EnableCursorBlinking">
|
||||
<property name="toolTip">
|
||||
<string>The text cursor will be blinking</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable cursor blinking</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnableCursorBlinking</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>General</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="SplashScreen">
|
||||
<property name="toolTip">
|
||||
<string>A Splash screen is a small loading window that is shown
|
||||
when FreeCAD is launching. If this option is checked, FreeCAD will
|
||||
display the splash screen</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable splash screen at start up</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowSplasher</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>General</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Preference packs</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="PreferencePacks">
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>100</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderMinimumSectionSize">
|
||||
<number>16</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>24</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ImportConfig">
|
||||
<property name="text">
|
||||
<string>Import config...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="SaveNewPreferencePack">
|
||||
<property name="text">
|
||||
<string>Save new...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ManagePreferencePacks">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Manage...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="RevertToSavedConfig">
|
||||
<property name="text">
|
||||
<string>Revert...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>Languages</tabstop>
|
||||
<tabstop>RecentFiles</tabstop>
|
||||
<tabstop>EnableCursorBlinking</tabstop>
|
||||
<tabstop>SplashScreen</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
410
src/Gui/PreferencePages/DlgSettingsMacro.ui
Normal file
410
src/Gui/PreferencePages/DlgSettingsMacro.ui
Normal file
@@ -0,0 +1,410 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsMacro</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsMacro">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>391</width>
|
||||
<height>407</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Macro</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>General macro settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="PrefCheckBox_LocalEnv">
|
||||
<property name="toolTip">
|
||||
<string>Variables defined by macros are created as local variables</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run macros in local environment</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>LocalEnvironment</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox6">
|
||||
<property name="title">
|
||||
<string>Macro recording settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox8">
|
||||
<property name="title">
|
||||
<string>Macro path</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefFileChooser" name="MacroPath">
|
||||
<property name="toolTip">
|
||||
<string>The directory in which the application will search for macros</string>
|
||||
</property>
|
||||
<property name="mode">
|
||||
<enum>Gui::FileChooser::Directory</enum>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>MacroPath</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox7">
|
||||
<property name="title">
|
||||
<string>Gui commands</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="PrefCheckBox_RecordGui">
|
||||
<property name="toolTip">
|
||||
<string>Recorded macros will also contain user interface commands</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Record GUI commands</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RecordGui</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="PrefCheckBox_GuiAsComment">
|
||||
<property name="toolTip">
|
||||
<string>Recorded macros will also contain user interface commands as comments</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Record as comment</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>GuiAsComment</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox4">
|
||||
<property name="title">
|
||||
<string>Logging Commands</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="PConsoleCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Commands executed by macro scripts are shown in Python console</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show script commands in python console</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ScriptToPyConsole</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="FileLogCheckBox">
|
||||
<property name="text">
|
||||
<string>Log all commands issued by menus to file:</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ScriptToFile</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefFileChooser" name="MacroPath_2">
|
||||
<property name="fileName" stdset="0">
|
||||
<string>FullScript.FCScript</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ScriptFile</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Macro</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="recentmacrosgroupBox">
|
||||
<property name="title">
|
||||
<string>Recent macros menu</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="recentmacrosgridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="recentMacroListLabel">
|
||||
<property name="text">
|
||||
<string>Size of recent macro list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="Gui::PrefSpinBox" name="RecentMacros">
|
||||
<property name="toolTip">
|
||||
<string>How many macros should be listed in recent macros list</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RecentMacros</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>RecentMacros</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="recentMacroListShortcutCountLabel">
|
||||
<property name="text">
|
||||
<string>Keyboard shortcut count</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="Gui::PrefSpinBox" name="ShortcutCount">
|
||||
<property name="toolTip">
|
||||
<string>How many recent macros should have shortcuts</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShortcutCount</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>RecentMacros</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="ShorcutModifiersLabel">
|
||||
<property name="text">
|
||||
<string>Keyboard Modifiers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="5" colspan="3">
|
||||
<widget class="Gui::ModifierLineEdit" name="ShortcutModifiers">
|
||||
<property name="toolTip">
|
||||
<string>Keyboard modifiers, default = Ctrl+Shift+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer>
|
||||
<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::ModifierLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<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>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>PrefCheckBox_RecordGui</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>PrefCheckBox_GuiAsComment</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
120
src/Gui/PreferencePages/DlgSettingsMacroImp.cpp
Normal file
120
src/Gui/PreferencePages/DlgSettingsMacroImp.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 <Gui/Action.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include "DlgSettingsMacroImp.h"
|
||||
#include "ui_DlgSettingsMacro.h"
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsMacroImp */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsMacroImp which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsMacroImp::DlgSettingsMacroImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettingsMacro)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Was never implemented, so hide it
|
||||
ui->FileLogCheckBox->hide();
|
||||
ui->MacroPath_2->hide();
|
||||
|
||||
if (ui->MacroPath->fileName().isEmpty()) {
|
||||
QDir d(QString::fromUtf8(App::GetApplication().getUserMacroDir().c_str()));
|
||||
ui->MacroPath->setFileName(d.path());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsMacroImp::~DlgSettingsMacroImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
/** Sets the size of the recent macros list from the user parameters.
|
||||
* @see RecentMacrosAction
|
||||
* @see StdCmdRecentMacros
|
||||
*/
|
||||
void DlgSettingsMacroImp::setRecentMacroSize()
|
||||
{
|
||||
auto recent = getMainWindow()->findChild<RecentMacrosAction *>(QLatin1String("recentMacros"));
|
||||
if (recent) {
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros");
|
||||
recent->resizeList(hGrp->GetInt("RecentMacros", 4));
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsMacroImp::saveSettings()
|
||||
{
|
||||
ui->PrefCheckBox_LocalEnv->onSave();
|
||||
ui->MacroPath->onSave();
|
||||
ui->PrefCheckBox_RecordGui->onSave();
|
||||
ui->PrefCheckBox_GuiAsComment->onSave();
|
||||
ui->PConsoleCheckBox->onSave();
|
||||
ui->FileLogCheckBox->onSave();
|
||||
ui->MacroPath_2->onSave();
|
||||
ui->RecentMacros->onSave();
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros");
|
||||
hGrp->SetASCII("ShortcutModifiers", qPrintable(ui->ShortcutModifiers->text()));
|
||||
ui->ShortcutCount->onSave();
|
||||
setRecentMacroSize();
|
||||
}
|
||||
|
||||
void DlgSettingsMacroImp::loadSettings()
|
||||
{
|
||||
ui->PrefCheckBox_LocalEnv->onRestore();
|
||||
ui->MacroPath->onRestore();
|
||||
ui->PrefCheckBox_RecordGui->onRestore();
|
||||
ui->PrefCheckBox_GuiAsComment->onRestore();
|
||||
ui->PConsoleCheckBox->onRestore();
|
||||
ui->FileLogCheckBox->onRestore();
|
||||
ui->MacroPath_2->onRestore();
|
||||
ui->RecentMacros->onRestore();
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentMacros");
|
||||
ui->ShortcutModifiers->setText(QString::fromStdString(hGrp->GetASCII("ShortcutModifiers", "Ctrl+Shift+")));
|
||||
ui->ShortcutCount->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsMacroImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsMacroImp.cpp"
|
||||
61
src/Gui/PreferencePages/DlgSettingsMacroImp.h
Normal file
61
src/Gui/PreferencePages/DlgSettingsMacroImp.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSMACROIMP_H
|
||||
#define GUI_DIALOG_DLGSETTINGSMACROIMP_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsMacro;
|
||||
|
||||
/**
|
||||
* The DlgSettingsMacroImp class implements a preference page to change settings
|
||||
* for macro stuff.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettingsMacroImp : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsMacroImp( QWidget* parent = nullptr );
|
||||
~DlgSettingsMacroImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsMacro> ui;
|
||||
void setRecentMacroSize();
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSMACROIMP_H
|
||||
378
src/Gui/PreferencePages/DlgSettingsNavigation.cpp
Normal file
378
src/Gui/PreferencePages/DlgSettingsNavigation.cpp
Normal file
@@ -0,0 +1,378 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QApplication>
|
||||
# include <QDoubleSpinBox>
|
||||
# include <QGridLayout>
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/View3DSettings.h>
|
||||
#include <Gui/NavigationStyle.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include "DlgSettingsNavigation.h"
|
||||
#include "ui_DlgSettingsNavigation.h"
|
||||
|
||||
#include "../ui_MouseButtons.h"
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsNavigation */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsNavigation which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent)
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettingsNavigation)
|
||||
, q0(0), q1(0), q2(0), q3(1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->naviCubeBaseColor->setAllowTransparency(true);
|
||||
retranslate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsNavigation::~DlgSettingsNavigation()
|
||||
{
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::saveSettings()
|
||||
{
|
||||
// must be done as very first because we create a new instance of NavigatorStyle
|
||||
// where we set some attributes afterwards
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
QVariant data = ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(),
|
||||
Qt::UserRole);
|
||||
hGrp->SetASCII("NavigationStyle", (const char*)data.toByteArray());
|
||||
|
||||
int index = ui->comboOrbitStyle->currentIndex();
|
||||
hGrp->SetInt("OrbitStyle", index);
|
||||
index = ui->comboRotationMode->currentIndex();
|
||||
hGrp->SetInt("RotationMode", index);
|
||||
|
||||
ui->checkBoxZoomAtCursor->onSave();
|
||||
ui->checkBoxInvertZoom->onSave();
|
||||
ui->checkBoxDisableTilt->onSave();
|
||||
ui->checkBoxShowRotationCenter->onSave();
|
||||
ui->spinBoxZoomStep->onSave();
|
||||
ui->checkBoxUseAutoRotation->onSave();
|
||||
ui->qspinNewDocScale->onSave();
|
||||
ui->prefStepByTurn->onSave();
|
||||
ui->naviCubeCorner->onSave();
|
||||
ui->naviCubeToNearest->onSave();
|
||||
ui->prefCubeSize->onSave();
|
||||
ui->naviCubeBaseColor->onSave();
|
||||
|
||||
bool showNaviCube = ui->groupBoxNaviCube->isChecked();
|
||||
hGrp->SetBool("ShowNaviCube", showNaviCube);
|
||||
|
||||
QVariant camera = ui->comboNewDocView->itemData(ui->comboNewDocView->currentIndex(),
|
||||
Qt::UserRole);
|
||||
hGrp->SetASCII("NewDocumentCameraOrientation", (const char*)camera.toByteArray());
|
||||
if (camera == QByteArray("Custom")) {
|
||||
ParameterGrp::handle hCustom = hGrp->GetGroup("Custom");
|
||||
hCustom->SetFloat("Q0", q0);
|
||||
hCustom->SetFloat("Q1", q1);
|
||||
hCustom->SetFloat("Q2", q2);
|
||||
hCustom->SetFloat("Q3", q3);
|
||||
}
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NaviCube");
|
||||
if (ui->naviCubeFontName->currentIndex()) {
|
||||
hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1());
|
||||
} else {
|
||||
hGrp->RemoveASCII("FontString");
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::loadSettings()
|
||||
{
|
||||
ui->checkBoxZoomAtCursor->onRestore();
|
||||
ui->checkBoxInvertZoom->onRestore();
|
||||
ui->checkBoxDisableTilt->onRestore();
|
||||
ui->checkBoxShowRotationCenter->onRestore();
|
||||
ui->spinBoxZoomStep->onRestore();
|
||||
ui->checkBoxUseAutoRotation->onRestore();
|
||||
ui->qspinNewDocScale->onRestore();
|
||||
ui->prefStepByTurn->onRestore();
|
||||
ui->naviCubeCorner->onRestore();
|
||||
ui->naviCubeToNearest->onRestore();
|
||||
ui->prefCubeSize->onRestore();
|
||||
ui->naviCubeBaseColor->onRestore();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
std::string model = hGrp->GetASCII("NavigationStyle", CADNavigationStyle::getClassTypeId().getName());
|
||||
int index = ui->comboNavigationStyle->findData(QByteArray(model.c_str()));
|
||||
if (index > -1) ui->comboNavigationStyle->setCurrentIndex(index);
|
||||
|
||||
index = hGrp->GetInt("OrbitStyle", int(NavigationStyle::Trackball));
|
||||
index = Base::clamp(index, 0, ui->comboOrbitStyle->count()-1);
|
||||
ui->comboOrbitStyle->setCurrentIndex(index);
|
||||
|
||||
index = hGrp->GetInt("RotationMode", 1);
|
||||
ui->comboRotationMode->setCurrentIndex(index);
|
||||
|
||||
bool showNaviCube = hGrp->GetBool("ShowNaviCube", true);
|
||||
ui->groupBoxNaviCube->setChecked(showNaviCube);
|
||||
|
||||
ui->comboNewDocView->addItem(tr("Isometric"), QByteArray("Isometric"));
|
||||
ui->comboNewDocView->addItem(tr("Dimetric"), QByteArray("Dimetric"));
|
||||
ui->comboNewDocView->addItem(tr("Trimetric"), QByteArray("Trimetric"));
|
||||
ui->comboNewDocView->addItem(tr("Top"), QByteArray("Top"));
|
||||
ui->comboNewDocView->addItem(tr("Front"), QByteArray("Front"));
|
||||
ui->comboNewDocView->addItem(tr("Left"), QByteArray("Left"));
|
||||
ui->comboNewDocView->addItem(tr("Right"), QByteArray("Right"));
|
||||
ui->comboNewDocView->addItem(tr("Rear"), QByteArray("Rear"));
|
||||
ui->comboNewDocView->addItem(tr("Bottom"), QByteArray("Bottom"));
|
||||
ui->comboNewDocView->addItem(tr("Custom"), QByteArray("Custom"));
|
||||
std::string camera = hGrp->GetASCII("NewDocumentCameraOrientation", "Trimetric");
|
||||
index = ui->comboNewDocView->findData(QByteArray(camera.c_str()));
|
||||
if (index > -1) ui->comboNewDocView->setCurrentIndex(index);
|
||||
if (camera == "Custom") {
|
||||
ParameterGrp::handle hCustom = hGrp->GetGroup("Custom");
|
||||
q0 = hCustom->GetFloat("Q0", q0);
|
||||
q1 = hCustom->GetFloat("Q1", q1);
|
||||
q2 = hCustom->GetFloat("Q2", q2);
|
||||
q3 = hCustom->GetFloat("Q3", q3);
|
||||
}
|
||||
|
||||
connect(ui->comboNewDocView, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &DlgSettingsNavigation::onNewDocViewChanged);
|
||||
connect(ui->mouseButton, &QPushButton::clicked,
|
||||
this, &DlgSettingsNavigation::onMouseButtonClicked);
|
||||
|
||||
// fill up font styles
|
||||
|
||||
// we purposely allow all available fonts on the system
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QStringList familyNames = QFontDatabase().families(QFontDatabase::Any);
|
||||
#else
|
||||
QStringList familyNames = QFontDatabase::families(QFontDatabase::Any);
|
||||
#endif
|
||||
ui->naviCubeFontName->addItems(familyNames);
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NaviCube");
|
||||
int indexFamilyNames = familyNames.indexOf(
|
||||
QString::fromStdString(hGrp->GetASCII("FontString")));
|
||||
ui->naviCubeFontName->setCurrentIndex(indexFamilyNames + 1);
|
||||
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::onMouseButtonClicked()
|
||||
{
|
||||
QDialog dlg(this);
|
||||
Ui_MouseButtons uimb;
|
||||
uimb.setupUi(&dlg);
|
||||
|
||||
QVariant data =
|
||||
ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole);
|
||||
void* instance = Base::Type::createInstanceByName((const char*)data.toByteArray());
|
||||
std::unique_ptr<UserNavigationStyle> ns(static_cast<UserNavigationStyle*>(instance));
|
||||
uimb.groupBox->setTitle(uimb.groupBox->title() + QString::fromLatin1(" ")
|
||||
+ ui->comboNavigationStyle->currentText());
|
||||
QString descr;
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::SELECTION));
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.selectionLabel->setText(QString::fromLatin1("<b>%1</b>").arg(descr));
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::PANNING));
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.panningLabel->setText(QString::fromLatin1("<b>%1</b>").arg(descr));
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::DRAGGING));
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.rotationLabel->setText(QString::fromLatin1("<b>%1</b>").arg(descr));
|
||||
descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::ZOOMING));
|
||||
descr.replace(QLatin1String("\n"), QLatin1String("<p>"));
|
||||
uimb.zoomingLabel->setText(QString::fromLatin1("<b>%1</b>").arg(descr));
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsNavigation::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int navigation = ui->comboNavigationStyle->currentIndex();
|
||||
int orbit = ui->comboOrbitStyle->currentIndex();
|
||||
int corner = ui->naviCubeCorner->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
retranslate();
|
||||
ui->comboNavigationStyle->setCurrentIndex(navigation);
|
||||
ui->comboOrbitStyle->setCurrentIndex(orbit);
|
||||
ui->naviCubeCorner->setCurrentIndex(corner);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::retranslate()
|
||||
{
|
||||
ui->comboNavigationStyle->clear();
|
||||
|
||||
// add submenu at the end to select navigation style
|
||||
std::map<Base::Type, std::string> styles = UserNavigationStyle::getUserFriendlyNames();
|
||||
for (const auto & style : styles) {
|
||||
QByteArray data(style.first.getName());
|
||||
QString name = QApplication::translate(style.first.getName(), style.second.c_str());
|
||||
|
||||
ui->comboNavigationStyle->addItem(name, data);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsNavigation::onNewDocViewChanged(int index)
|
||||
{
|
||||
QVariant camera = ui->comboNewDocView->itemData(index, Qt::UserRole);
|
||||
if (camera == QByteArray("Custom")) {
|
||||
CameraDialog dlg(this);
|
||||
dlg.setValues(q0, q1, q2, q3);
|
||||
if (dlg.exec()) {
|
||||
dlg.getValues(q0, q1, q2, q3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
CameraDialog::CameraDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
this->setWindowTitle(tr("Camera settings"));
|
||||
|
||||
QGridLayout *gridLayout;
|
||||
gridLayout = new QGridLayout(this);
|
||||
|
||||
QGroupBox *groupBox;
|
||||
groupBox = new QGroupBox(this);
|
||||
groupBox->setTitle(tr("Orientation"));
|
||||
gridLayout->addWidget(groupBox, 0, 0, 1, 1);
|
||||
|
||||
QDialogButtonBox *buttonBox;
|
||||
buttonBox = new QDialogButtonBox(this);
|
||||
buttonBox->setOrientation(Qt::Horizontal);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||
gridLayout->addWidget(buttonBox, 3, 0, 1, 1);
|
||||
|
||||
QGridLayout *layout;
|
||||
layout = new QGridLayout(groupBox);
|
||||
|
||||
// Q0
|
||||
auto label0 = new QLabel(groupBox);
|
||||
label0->setText(tr("Q0"));
|
||||
layout->addWidget(label0, 0, 0, 1, 1);
|
||||
|
||||
sb0 = new QDoubleSpinBox(groupBox);
|
||||
sb0->setRange(-1, 1);
|
||||
sb0->setSingleStep(0.1);
|
||||
layout->addWidget(sb0, 0, 1, 1, 1);
|
||||
|
||||
// Q1
|
||||
auto label1 = new QLabel(groupBox);
|
||||
label1->setText(tr("Q1"));
|
||||
layout->addWidget(label1, 1, 0, 1, 1);
|
||||
|
||||
sb1 = new QDoubleSpinBox(groupBox);
|
||||
sb1->setRange(-1, 1);
|
||||
sb1->setSingleStep(0.1);
|
||||
layout->addWidget(sb1, 1, 1, 1, 1);
|
||||
|
||||
// Q2
|
||||
auto label2 = new QLabel(groupBox);
|
||||
label2->setText(tr("Q2"));
|
||||
layout->addWidget(label2, 2, 0, 1, 1);
|
||||
|
||||
sb2 = new QDoubleSpinBox(groupBox);
|
||||
sb2->setRange(-1, 1);
|
||||
sb2->setSingleStep(0.1);
|
||||
layout->addWidget(sb2, 2, 1, 1, 1);
|
||||
|
||||
// Q3
|
||||
auto label3 = new QLabel(groupBox);
|
||||
label3->setText(tr("Q3"));
|
||||
layout->addWidget(label3, 3, 0, 1, 1);
|
||||
|
||||
sb3 = new QDoubleSpinBox(groupBox);
|
||||
sb3->setRange(-1, 1);
|
||||
sb3->setSingleStep(0.1);
|
||||
layout->addWidget(sb3, 3, 1, 1, 1);
|
||||
|
||||
auto currentViewButton = new QPushButton(this);
|
||||
currentViewButton->setText(tr("Current view"));
|
||||
currentViewButton->setObjectName(QString::fromLatin1("currentView"));
|
||||
layout->addWidget(currentViewButton, 4, 1, 2, 1);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(currentViewButton, &QPushButton::clicked, this,
|
||||
&CameraDialog::onCurrentViewClicked);
|
||||
}
|
||||
|
||||
CameraDialog::~CameraDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void CameraDialog::setValues(double q0, double q1, double q2, double q3)
|
||||
{
|
||||
sb0->setValue(q0);
|
||||
sb1->setValue(q1);
|
||||
sb2->setValue(q2);
|
||||
sb3->setValue(q3);
|
||||
}
|
||||
|
||||
void CameraDialog::getValues(double& q0, double& q1, double& q2, double& q3) const
|
||||
{
|
||||
q0 = sb0->value();
|
||||
q1 = sb1->value();
|
||||
q2 = sb2->value();
|
||||
q3 = sb3->value();
|
||||
}
|
||||
|
||||
void CameraDialog::onCurrentViewClicked()
|
||||
{
|
||||
auto mdi = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (mdi) {
|
||||
SbRotation rot = mdi->getViewer()->getCameraOrientation();
|
||||
const float* q = rot.getValue();
|
||||
sb0->setValue(q[0]);
|
||||
sb1->setValue(q[1]);
|
||||
sb2->setValue(q[2]);
|
||||
sb3->setValue(q[3]);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsNavigation.cpp"
|
||||
90
src/Gui/PreferencePages/DlgSettingsNavigation.h
Normal file
90
src/Gui/PreferencePages/DlgSettingsNavigation.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSNAVIGATION_H
|
||||
#define GUI_DIALOG_DLGSETTINGSNAVIGATION_H
|
||||
|
||||
#include <memory>
|
||||
#include "PropertyPage.h"
|
||||
#include <QDialog>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsNavigation;
|
||||
|
||||
/**
|
||||
* The Ui_DlgSettingsNavigation class implements a preference page to change settings
|
||||
* for the Inventor viewer.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsNavigation : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsNavigation(QWidget* parent = nullptr);
|
||||
~DlgSettingsNavigation() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
private:
|
||||
void onMouseButtonClicked();
|
||||
void onNewDocViewChanged(int);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
void retranslate();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsNavigation> ui;
|
||||
double q0, q1, q2, q3;
|
||||
};
|
||||
|
||||
class CameraDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CameraDialog(QWidget* parent=nullptr);
|
||||
~CameraDialog() override;
|
||||
void setValues(double q0, double q1, double q2, double q3);
|
||||
void getValues(double& q0, double& q1, double& q2, double& q3) const;
|
||||
|
||||
|
||||
private:
|
||||
void onCurrentViewClicked();
|
||||
|
||||
private:
|
||||
QDoubleSpinBox* sb0;
|
||||
QDoubleSpinBox* sb1;
|
||||
QDoubleSpinBox* sb2;
|
||||
QDoubleSpinBox* sb3;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSNAVIGATION_H
|
||||
695
src/Gui/PreferencePages/DlgSettingsNavigation.ui
Normal file
695
src/Gui/PreferencePages/DlgSettingsNavigation.ui
Normal file
@@ -0,0 +1,695 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsNavigation</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsNavigation">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<height>423</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Navigation</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxNaviCube">
|
||||
<property name="title">
|
||||
<string>Navigation cube</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="stepLabel">
|
||||
<property name="text">
|
||||
<string>Steps by turn</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="prefStepByTurn">
|
||||
<property name="toolTip">
|
||||
<string>Number of steps by turn when using arrows (default = 8 : step angle = 360/8 = 45 deg)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>36</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NaviStepByTurn</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NaviCube</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="cornerLabel">
|
||||
<property name="text">
|
||||
<string>Corner</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="Gui::PrefComboBox" name="naviCubeCorner">
|
||||
<property name="toolTip">
|
||||
<string>Corner where navigation cube is shown</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CornerNaviCube</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NaviCube</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom right</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="naviCubeToNearest">
|
||||
<property name="toolTip">
|
||||
<string>Rotates to nearest possible state when clicking a cube face</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rotate to nearest</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NaviRotateToNearest</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NaviCube</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="FontNameLabel">
|
||||
<property name="text">
|
||||
<string>Font name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Gui::PrefComboBox" name="naviCubeFontName">
|
||||
<property name="toolTip">
|
||||
<string>Font name of the navigation cube</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>FontString</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NaviCube</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="CubeSizeLabel">
|
||||
<property name="text">
|
||||
<string>Cube size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="prefCubeSize">
|
||||
<property name="toolTip">
|
||||
<string>Size of the navigation cube</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>132</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CubeSize</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NaviCube</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="BaseColorLabel">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="naviCubeBaseColor">
|
||||
<property name="toolTip">
|
||||
<string>Base color for all elements</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color alpha="128">
|
||||
<red>226</red>
|
||||
<green>232</green>
|
||||
<blue>239</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BaseColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NaviCube</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox12">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Navigation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="navigationLabel">
|
||||
<property name="text">
|
||||
<string>3D Navigation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mouseButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>List the mouse button configs for each chosen navigation setting.
|
||||
Select a set and then press the button to view said configurations.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mouse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="comboNavigationStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Navigation settings set</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="orbitLabel">
|
||||
<property name="text">
|
||||
<string>Orbit style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="comboOrbitStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rotation orbit style.
|
||||
Trackball: moving the mouse horizontally will rotate the part around the y-axis
|
||||
Turntable: the part will be rotated around the z-axis (with constrained axes).
|
||||
Free Turntable: the part will be rotated around the z-axis.</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Turntable</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Trackball</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Free Turntable</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelRotationMode">
|
||||
<property name="text">
|
||||
<string>Rotation mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="comboRotationMode">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rotations in 3D will use current cursor position as center for rotation</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Window center</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Drag at cursor</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Object center</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="newDocViewLabel">
|
||||
<property name="text">
|
||||
<string>Default camera orientation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="comboNewDocView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Default camera orientation when creating a new document or selecting the home view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Camera zoom</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="PrefUnitSpinBox" name="qspinNewDocScale" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Sets camera zoom for new documents.
|
||||
The value is the diameter of the sphere to fit on the screen.</string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string>mm</string>
|
||||
</property>
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.000010000000000</double>
|
||||
</property>
|
||||
<property name="maximum" stdset="0">
|
||||
<double>10000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NewDocumentCameraScale</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
<property name="rawValue" stdset="0">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxUseAutoRotation">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable animated rotations</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable animation</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseAutoRotation</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxZoomAtCursor">
|
||||
<property name="toolTip">
|
||||
<string>Zoom operations will be performed at position of mouse pointer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom at cursor</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ZoomAtCursor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string> Zoom step</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Gui::PrefDoubleSpinBox" name="spinBoxZoomStep">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>How much will be zoomed.
|
||||
Zoom step of '1' means a factor of 7.5 for every zoom step.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.200000000000000</double>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ZoomStep</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxInvertZoom">
|
||||
<property name="toolTip">
|
||||
<string>Direction of zoom operations will be inverted</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Invert zoom</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>InvertZoom</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxDisableTilt">
|
||||
<property name="toolTip">
|
||||
<string>Prevents view tilting when pinch-zooming.
|
||||
Affects only gesture navigation style.
|
||||
Mouse tilting is not disabled by this setting.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable touchscreen tilt gesture</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DisableTouchTilt</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxShowRotationCenter">
|
||||
<property name="toolTip">
|
||||
<string>Show the rotation center when dragging.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable rotation center indication</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowRotationCenter</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>96</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefColorButton</class>
|
||||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PrefUnitSpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
112
src/Gui/PreferencePages/DlgSettingsNotificationArea.cpp
Normal file
112
src/Gui/PreferencePages/DlgSettingsNotificationArea.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "DlgSettingsNotificationArea.h"
|
||||
#include "ui_DlgSettingsNotificationArea.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsNotificationArea */
|
||||
|
||||
DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent)
|
||||
: PreferencePage(parent),
|
||||
ui(new Ui_DlgSettingsNotificationArea)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
adaptUiToAreaEnabledState(ui->NotificationAreaEnabled->isChecked());
|
||||
connect(ui->NotificationAreaEnabled, &QCheckBox::stateChanged, [this](int state) {
|
||||
bool enabled = state == Qt::CheckState::Checked;
|
||||
this->adaptUiToAreaEnabledState(enabled);
|
||||
|
||||
if (enabled) {
|
||||
this->requireRestart();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DlgSettingsNotificationArea::~DlgSettingsNotificationArea()
|
||||
{}
|
||||
|
||||
void DlgSettingsNotificationArea::saveSettings()
|
||||
{
|
||||
ui->NotificationAreaEnabled->onSave();
|
||||
ui->NonIntrusiveNotificationsEnabled->onSave();
|
||||
ui->maxDuration->onSave();
|
||||
ui->minDuration->onSave();
|
||||
ui->maxNotifications->onSave();
|
||||
ui->maxWidgetMessages->onSave();
|
||||
ui->autoRemoveUserNotifications->onSave();
|
||||
ui->notificationWidth->onSave();
|
||||
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->onSave();
|
||||
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->onSave();
|
||||
ui->developerErrorSubscriptionEnabled->onSave();
|
||||
ui->developerWarningSubscriptionEnabled->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsNotificationArea::loadSettings()
|
||||
{
|
||||
ui->NotificationAreaEnabled->onRestore();
|
||||
ui->NonIntrusiveNotificationsEnabled->onRestore();
|
||||
ui->maxDuration->onRestore();
|
||||
ui->minDuration->onRestore();
|
||||
ui->maxNotifications->onRestore();
|
||||
ui->maxWidgetMessages->onRestore();
|
||||
ui->autoRemoveUserNotifications->onRestore();
|
||||
ui->notificationWidth->onRestore();
|
||||
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->onRestore();
|
||||
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->onRestore();
|
||||
ui->developerErrorSubscriptionEnabled->onRestore();
|
||||
ui->developerWarningSubscriptionEnabled->onRestore();
|
||||
}
|
||||
|
||||
void DlgSettingsNotificationArea::adaptUiToAreaEnabledState(bool enabled)
|
||||
{
|
||||
ui->NonIntrusiveNotificationsEnabled->setEnabled(enabled);
|
||||
ui->maxDuration->setEnabled(enabled);
|
||||
ui->maxDuration->setEnabled(enabled);
|
||||
ui->minDuration->setEnabled(enabled);
|
||||
ui->maxNotifications->setEnabled(enabled);
|
||||
ui->maxWidgetMessages->setEnabled(enabled);
|
||||
ui->autoRemoveUserNotifications->setEnabled(enabled);
|
||||
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->setEnabled(enabled);
|
||||
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->setEnabled(enabled);
|
||||
ui->developerErrorSubscriptionEnabled->setEnabled(enabled);
|
||||
ui->developerWarningSubscriptionEnabled->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void DlgSettingsNotificationArea::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsNotificationArea.cpp"
|
||||
62
src/Gui/PreferencePages/DlgSettingsNotificationArea.h
Normal file
62
src/Gui/PreferencePages/DlgSettingsNotificationArea.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H
|
||||
#define GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsNotificationArea;
|
||||
|
||||
/**
|
||||
* The DlgSettingsNotificationArea class implements a preference page to change settings
|
||||
* for the Notification Area.
|
||||
*/
|
||||
class DlgSettingsNotificationArea : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsNotificationArea(QWidget* parent = nullptr);
|
||||
~DlgSettingsNotificationArea() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void adaptUiToAreaEnabledState(bool enabled);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsNotificationArea> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSNOTIFICATIONAREA_H
|
||||
354
src/Gui/PreferencePages/DlgSettingsNotificationArea.ui
Normal file
354
src/Gui/PreferencePages/DlgSettingsNotificationArea.ui
Normal file
@@ -0,0 +1,354 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsNotificationArea</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsNotificationArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>654</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Notification Area</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox11">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="NotificationAreaEnabled">
|
||||
<property name="toolTip">
|
||||
<string>The Notification area will appear in the status bar</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable Notification Area</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NotificationAreaEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="NonIntrusiveNotificationsEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Non-intrusive notifications will appear next to the notification area in the status bar</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable non-intrusive notifications</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NonIntrusiveNotificationsEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="GroupBoxSubscriptions">
|
||||
<property name="title">
|
||||
<string>Additional data sources</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="developerErrorSubscriptionEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Errors intended for developers will appear in the notification area</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Debug errors</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DeveloperErrorSubscriptionEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="developerWarningSubscriptionEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Warnings intended for developers will appear in the notification area</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Debug warnings</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DeveloperWarningSubscriptionEnabled</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Non-Intrusive Notifications</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Minimum Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Maximum Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="maxDuration">
|
||||
<property name="toolTip">
|
||||
<string>Duration during which the notification will be shown (unless mouse buttons are clicked)</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>120</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NotificationTime</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="minDuration">
|
||||
<property name="toolTip">
|
||||
<string>Minimum duration during which the notification will be shown (unless notification clicked)</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>s</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>MinimumOnScreenTime</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Maximum Number of Notifications:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="maxNotifications">
|
||||
<property name="toolTip">
|
||||
<string>Maximum number of notifications that will be simultaneously present on the screen</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>MaxOpenNotifications</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_width">
|
||||
<property name="text">
|
||||
<string>Notification width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="notificationWidth">
|
||||
<property name="toolTip">
|
||||
<string>Width of the notification in pixels</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>300</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>800</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NotificiationWidth</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="hideNonIntrusiveNotificationsWhenWindowDeactivated">
|
||||
<property name="toolTip">
|
||||
<string>Any open non-intrusive notifications will disappear when another window is activated</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide when other window is activated</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>HideNonIntrusiveNotificationsWhenWindowDeactivated</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="preventNonIntrusiveNotificationsWhenWindowNotActive">
|
||||
<property name="toolTip">
|
||||
<string>Prevent non-intrusive notifications from appearing when the FreeCAD Window is not the active window</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Do not show when inactive</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PreventNonIntrusiveNotificationsWhenWindowNotActive</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Message List</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="maxWidgetMessages">
|
||||
<property name="toolTip">
|
||||
<string>Limit the number of messages that will be kept in the list. If 0 there is no limit.</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>MaxWidgetMessages</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Maximum Messages (0 = no limit):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="autoRemoveUserNotifications">
|
||||
<property name="toolTip">
|
||||
<string>Removes the user notifications from the message list after the non-intrusive maximum duration has lapsed.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto-remove User Notifications</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AutoRemoveUserNotifications</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>NotificationArea</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>63</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
66
src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp
Normal file
66
src/Gui/PreferencePages/DlgSettingsPythonConsole.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 "DlgSettingsPythonConsole.h"
|
||||
#include "ui_DlgSettingsPythonConsole.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsPythonConsole */
|
||||
|
||||
DlgSettingsPythonConsole::DlgSettingsPythonConsole(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsPythonConsole)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
DlgSettingsPythonConsole::~DlgSettingsPythonConsole()
|
||||
{
|
||||
}
|
||||
|
||||
void DlgSettingsPythonConsole::saveSettings()
|
||||
{
|
||||
ui->PythonWordWrap->onSave();
|
||||
ui->PythonBlockCursor->onSave();
|
||||
ui->PythonSaveHistory->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsPythonConsole::loadSettings()
|
||||
{
|
||||
ui->PythonWordWrap->onRestore();
|
||||
ui->PythonBlockCursor->onRestore();
|
||||
ui->PythonSaveHistory->onRestore();
|
||||
}
|
||||
|
||||
void DlgSettingsPythonConsole::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsPythonConsole.cpp"
|
||||
60
src/Gui/PreferencePages/DlgSettingsPythonConsole.h
Normal file
60
src/Gui/PreferencePages/DlgSettingsPythonConsole.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H
|
||||
#define GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsPythonConsole;
|
||||
|
||||
/**
|
||||
* The DlgSettingsPythonConsole class implements a preference page to change settings
|
||||
* for the Python console.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsPythonConsole : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsPythonConsole(QWidget* parent = nullptr);
|
||||
~DlgSettingsPythonConsole() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsPythonConsole> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H
|
||||
108
src/Gui/PreferencePages/DlgSettingsPythonConsole.ui
Normal file
108
src/Gui/PreferencePages/DlgSettingsPythonConsole.ui
Normal file
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsPythonConsole</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsPythonConsole">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>654</width>
|
||||
<height>259</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Python console</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="GroupBox11">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="PythonWordWrap">
|
||||
<property name="toolTip">
|
||||
<string>Words will be wrapped when they exceed available
|
||||
horizontal space in Python console</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable word wrap</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PythonWordWrap</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>PythonConsole</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="PythonBlockCursor">
|
||||
<property name="toolTip">
|
||||
<string>The cursor shape will be a block</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable block cursor</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PythonBlockCursor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>PythonConsole</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="PythonSaveHistory">
|
||||
<property name="toolTip">
|
||||
<string>Saves Python history across sessions</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save history</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SavePythonHistory</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>PythonConsole</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>63</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
110
src/Gui/PreferencePages/DlgSettingsReportView.cpp
Normal file
110
src/Gui/PreferencePages/DlgSettingsReportView.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 "DlgSettingsReportView.h"
|
||||
#include "ui_DlgSettingsReportView.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsReportView */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsReportView which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgSettingsReportView::DlgSettingsReportView( QWidget* parent )
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsReportView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->colorText->setColor(qApp->palette().windowText().color());
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsReportView::~DlgSettingsReportView()
|
||||
{
|
||||
}
|
||||
|
||||
void DlgSettingsReportView::saveSettings()
|
||||
{
|
||||
ui->checkMessage->onSave();
|
||||
ui->checkLogging->onSave();
|
||||
ui->checkWarning->onSave();
|
||||
ui->checkError->onSave();
|
||||
ui->checkShowReportViewOnWarning->onSave();
|
||||
ui->checkShowReportViewOnError->onSave();
|
||||
ui->checkShowReportViewOnNormalMessage->onSave();
|
||||
ui->checkShowReportViewOnLogMessage->onSave();
|
||||
ui->checkShowReportTimecode->onSave();
|
||||
ui->colorText->onSave();
|
||||
ui->colorLogging->onSave();
|
||||
ui->colorWarning->onSave();
|
||||
ui->colorError->onSave();
|
||||
ui->pythonOutput->onSave();
|
||||
ui->pythonError->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsReportView::loadSettings()
|
||||
{
|
||||
ui->checkMessage->onRestore();
|
||||
ui->checkLogging->onRestore();
|
||||
ui->checkWarning->onRestore();
|
||||
ui->checkError->onRestore();
|
||||
ui->checkShowReportViewOnWarning->onRestore();
|
||||
ui->checkShowReportViewOnError->onRestore();
|
||||
ui->checkShowReportViewOnNormalMessage->onRestore();
|
||||
ui->checkShowReportViewOnLogMessage->onRestore();
|
||||
ui->checkShowReportTimecode->onRestore();
|
||||
ui->colorText->onRestore();
|
||||
ui->colorLogging->onRestore();
|
||||
ui->colorWarning->onRestore();
|
||||
ui->colorError->onRestore();
|
||||
ui->pythonOutput->blockSignals(true);
|
||||
ui->pythonOutput->onRestore();
|
||||
ui->pythonOutput->blockSignals(false);
|
||||
ui->pythonError->blockSignals(true);
|
||||
ui->pythonError->onRestore();
|
||||
ui->pythonError->blockSignals(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsReportView::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsReportView.cpp"
|
||||
59
src/Gui/PreferencePages/DlgSettingsReportView.h
Normal file
59
src/Gui/PreferencePages/DlgSettingsReportView.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLG_SETTINGS_REPORT_VIEW
|
||||
#define GUI_DIALOG_DLG_SETTINGS_REPORT_VIEW
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsReportView;
|
||||
|
||||
/** The DlgSettingsReportView class implements the available settings for the
|
||||
* Report View to change.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsReportView : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsReportView( QWidget* parent = nullptr );
|
||||
~DlgSettingsReportView() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsReportView> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif //GUI_DIALOG_DLG_SETTINGS_REPORT_VIEW
|
||||
601
src/Gui/PreferencePages/DlgSettingsReportView.ui
Normal file
601
src/Gui/PreferencePages/DlgSettingsReportView.ui
Normal file
@@ -0,0 +1,601 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsReportView</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsReportView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Report view</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox1">
|
||||
<property name="title">
|
||||
<string>Output</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkMessage">
|
||||
<property name="toolTip">
|
||||
<string>Normal messages will be recorded</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Record normal messages</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkMessage</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkLogging">
|
||||
<property name="toolTip">
|
||||
<string>Log messages will be recorded</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Record log messages</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkLogging</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkWarning">
|
||||
<property name="toolTip">
|
||||
<string>Warnings will be recorded</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Record warnings</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkWarning</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkError">
|
||||
<property name="toolTip">
|
||||
<string>Error messages will be recorded</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Record error messages</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkError</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnError">
|
||||
<property name="toolTip">
|
||||
<string>When an error has occurred, the Report View dialog becomes visible
|
||||
on-screen while displaying the error</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show report view on error</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkShowReportViewOnError</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnWarning">
|
||||
<property name="toolTip">
|
||||
<string>When a warning has occurred, the Report View dialog becomes visible
|
||||
on-screen while displaying the warning</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show report view on warning</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkShowReportViewOnWarning</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnNormalMessage">
|
||||
<property name="toolTip">
|
||||
<string>When a normal message has occurred, the Report View dialog becomes visible
|
||||
on-screen while displaying the message</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show report view on normal message</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkShowReportViewOnNormalMessage</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnLogMessage">
|
||||
<property name="toolTip">
|
||||
<string>When a log message has occurred, the Report View dialog becomes visible
|
||||
on-screen while displaying the log message</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show report view on log message</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkShowReportViewOnLogMessage</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkShowReportTimecode">
|
||||
<property name="toolTip">
|
||||
<string>Include a timecode for each report</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Include a timecode for each entry</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>checkShowReportTimecode</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox2">
|
||||
<property name="title">
|
||||
<string>Colors</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Normal messages:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Ignored</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>214</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="colorText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font color for normal messages in Report view panel</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>colorText</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string>Log messages:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Ignored</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>211</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="colorLogging">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font color for log messages in Report view panel</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>colorLogging</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel3">
|
||||
<property name="text">
|
||||
<string>Warnings:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Ignored</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>211</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="colorWarning">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font color for warning messages in Report view panel</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>170</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>colorWarning</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="textLabel4">
|
||||
<property name="text">
|
||||
<string>Errors:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>211</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="colorError">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Font color for error messages in Report view panel</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>colorError</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Python interpreter</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="pythonOutput">
|
||||
<property name="toolTip">
|
||||
<string>Internal Python output will be redirected
|
||||
from Python console to Report view panel</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redirect internal Python output to report view</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RedirectPythonOutput</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="pythonError">
|
||||
<property name="toolTip">
|
||||
<string>Internal Python error messages will be redirected
|
||||
from Python console to Report view panel</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redirect internal Python errors to report view</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RedirectPythonErrors</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>OutputWindow</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>410</width>
|
||||
<height>71</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefColorButton</class>
|
||||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>checkLogging</tabstop>
|
||||
<tabstop>checkWarning</tabstop>
|
||||
<tabstop>checkError</tabstop>
|
||||
<tabstop>checkShowReportViewOnWarning</tabstop>
|
||||
<tabstop>checkShowReportViewOnError</tabstop>
|
||||
<tabstop>checkShowReportViewOnNormalMessage</tabstop>
|
||||
<tabstop>checkShowReportViewOnLogMessage</tabstop>
|
||||
<tabstop>checkShowReportTimecode</tabstop>
|
||||
<tabstop>colorText</tabstop>
|
||||
<tabstop>colorLogging</tabstop>
|
||||
<tabstop>colorWarning</tabstop>
|
||||
<tabstop>colorError</tabstop>
|
||||
<tabstop>pythonOutput</tabstop>
|
||||
<tabstop>pythonError</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
84
src/Gui/PreferencePages/DlgSettingsSelection.cpp
Normal file
84
src/Gui/PreferencePages/DlgSettingsSelection.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 <App/Application.h>
|
||||
|
||||
#include "DlgSettingsSelection.h"
|
||||
#include "ui_DlgSettingsSelection.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsSelection */
|
||||
|
||||
DlgSettingsSelection::DlgSettingsSelection(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsSelection)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
DlgSettingsSelection::~DlgSettingsSelection()
|
||||
{
|
||||
}
|
||||
|
||||
void DlgSettingsSelection::saveSettings()
|
||||
{
|
||||
ui->checkBoxPreselection->onSave();
|
||||
ui->checkBoxSelection->onSave();
|
||||
ui->HighlightColor->onSave();
|
||||
ui->SelectionColor->onSave();
|
||||
ui->spinPickRadius->onSave();
|
||||
ui->checkBoxAutoSwitch->onSave();
|
||||
ui->checkBoxAutoExpand->onSave();
|
||||
ui->checkBoxPreselect->onSave();
|
||||
ui->checkBoxRecord->onSave();
|
||||
ui->checkBoxSelectionCheckBoxes->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsSelection::loadSettings()
|
||||
{
|
||||
ui->checkBoxPreselection->onRestore();
|
||||
ui->checkBoxSelection->onRestore();
|
||||
ui->HighlightColor->onRestore();
|
||||
ui->SelectionColor->onRestore();
|
||||
ui->spinPickRadius->onRestore();
|
||||
ui->checkBoxAutoSwitch->onRestore();
|
||||
ui->checkBoxAutoExpand->onRestore();
|
||||
ui->checkBoxPreselect->onRestore();
|
||||
ui->checkBoxRecord->onRestore();
|
||||
ui->checkBoxSelectionCheckBoxes->onRestore();
|
||||
}
|
||||
|
||||
void DlgSettingsSelection::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsSelection.cpp"
|
||||
62
src/Gui/PreferencePages/DlgSettingsSelection.h
Normal file
62
src/Gui/PreferencePages/DlgSettingsSelection.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSSELECTION_H
|
||||
#define GUI_DIALOG_DLGSETTINGSSELECTION_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsSelection;
|
||||
|
||||
/**
|
||||
* The Ui_DlgSettingsSelection class implements a preference page to change settings
|
||||
* for the selection.
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsSelection : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgSettingsSelection(QWidget* parent = nullptr);
|
||||
~DlgSettingsSelection() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsSelection> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSSELECTION_H
|
||||
293
src/Gui/PreferencePages/DlgSettingsSelection.ui
Normal file
293
src/Gui/PreferencePages/DlgSettingsSelection.ui
Normal file
@@ -0,0 +1,293 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsSelection</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsSelection">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>670</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxPreselection">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>240</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable preselection, highlighted with specified color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable preselection</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnablePreselection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="HighlightColor">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>225</red>
|
||||
<green>225</green>
|
||||
<blue>20</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>HighlightColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxSelection">
|
||||
<property name="toolTip">
|
||||
<string>Enable selection, highlighted with specified color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable selection</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>EnableSelection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="SelectionColor">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>28</red>
|
||||
<green>173</green>
|
||||
<blue>28</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SelectionColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
||||
<item>
|
||||
<widget class="QLabel" name="spinPickRadiusLabel">
|
||||
<property name="text">
|
||||
<string>Pick radius (px):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizSpacer_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefDoubleSpinBox" name="spinPickRadius">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Area for picking elements in 3D view.
|
||||
Larger value eases to pick things, but can make small features impossible to select.
|
||||
</string>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhPreferNumbers</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>200.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PickRadius</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxAutoSwitch">
|
||||
<property name="text">
|
||||
<string>Auto switch to the 3D view containing the selected item</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SyncView</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxAutoExpand">
|
||||
<property name="text">
|
||||
<string>Auto expand tree item when the corresponding object is selected in 3D view</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SyncSelection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxPreselect">
|
||||
<property name="text">
|
||||
<string>Preselect the object in 3D view when mouse over the tree item</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PreSelection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxRecord">
|
||||
<property name="text">
|
||||
<string>Record selection in tree view in order to go back/forward using navigation button</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RecordSelection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxSelectionCheckBoxes">
|
||||
<property name="text">
|
||||
<string>Add checkboxes for selection in document tree</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CheckBoxesSelection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>245</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefColorButton</class>
|
||||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>checkBoxPreselection</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>HighlightColor</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBoxSelection</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SelectionColor</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
167
src/Gui/PreferencePages/DlgSettingsViewColor.cpp
Normal file
167
src/Gui/PreferencePages/DlgSettingsViewColor.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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"
|
||||
#ifndef _PreComp_
|
||||
# include <QPushButton>
|
||||
#endif
|
||||
|
||||
#include "DlgSettingsViewColor.h"
|
||||
#include "ui_DlgSettingsViewColor.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsViewColor */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsViewColor which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*/
|
||||
DlgSettingsViewColor::DlgSettingsViewColor(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgSettingsViewColor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->SwitchGradientColors, &QPushButton::pressed, this,
|
||||
&DlgSettingsViewColor::onSwitchGradientColorsPressed);
|
||||
|
||||
connect(ui->radioButtonSimple, &QRadioButton::toggled, this,
|
||||
&DlgSettingsViewColor::onRadioButtonSimpleToggled);
|
||||
|
||||
connect(ui->radioButtonGradient, &QRadioButton::toggled, this,
|
||||
&DlgSettingsViewColor::onRadioButtonGradientToggled);
|
||||
|
||||
connect(ui->rbRadialGradient, &QRadioButton::toggled, this,
|
||||
&DlgSettingsViewColor::onRadioButtonRadialGradientToggled);
|
||||
|
||||
connect(ui->checkMidColor, &QCheckBox::toggled, this,
|
||||
&DlgSettingsViewColor::onCheckMidColorToggled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsViewColor::~DlgSettingsViewColor()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::saveSettings()
|
||||
{
|
||||
ui->SelectionColor_Background->onSave();
|
||||
ui->backgroundColorFrom->onSave();
|
||||
ui->backgroundColorTo->onSave();
|
||||
ui->backgroundColorMid->onSave();
|
||||
ui->radioButtonSimple->onSave();
|
||||
ui->radioButtonGradient->onSave();
|
||||
ui->rbRadialGradient->onSave();
|
||||
ui->checkMidColor->onSave();
|
||||
ui->TreeEditColor->onSave();
|
||||
ui->TreeActiveColor->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::loadSettings()
|
||||
{
|
||||
ui->SelectionColor_Background->onRestore();
|
||||
ui->backgroundColorFrom->onRestore();
|
||||
ui->backgroundColorTo->onRestore();
|
||||
ui->backgroundColorMid->onRestore();
|
||||
ui->radioButtonSimple->onRestore();
|
||||
ui->radioButtonGradient->onRestore();
|
||||
ui->rbRadialGradient->onRestore();
|
||||
ui->checkMidColor->onRestore();
|
||||
ui->TreeEditColor->onRestore();
|
||||
ui->TreeActiveColor->onRestore();
|
||||
|
||||
if (ui->radioButtonSimple->isChecked())
|
||||
onRadioButtonSimpleToggled(true);
|
||||
else if(ui->radioButtonGradient->isChecked())
|
||||
onRadioButtonGradientToggled(true);
|
||||
else
|
||||
onRadioButtonRadialGradientToggled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsViewColor::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::onSwitchGradientColorsPressed()
|
||||
{
|
||||
QColor tempColor = ui->backgroundColorFrom->color();
|
||||
ui->backgroundColorFrom->setColor(ui->backgroundColorTo->color());
|
||||
ui->backgroundColorTo->setColor(tempColor);
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::onCheckMidColorToggled(bool val)
|
||||
{
|
||||
ui->color2Label->setEnabled(val);
|
||||
ui->backgroundColorMid->setEnabled(val);
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::onRadioButtonSimpleToggled(bool val)
|
||||
{
|
||||
setGradientColorVisibility(!val);
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::onRadioButtonGradientToggled(bool val)
|
||||
{
|
||||
setGradientColorVisibility(val);
|
||||
ui->color1Label->setText(tr("Top:"));
|
||||
ui->color2Label->setText(tr("Middle:"));
|
||||
ui->color3Label->setText(tr("Bottom:"));
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::onRadioButtonRadialGradientToggled(bool val)
|
||||
{
|
||||
setGradientColorVisibility(val);
|
||||
ui->color1Label->setText(tr("Central:"));
|
||||
ui->color2Label->setText(tr("Midway:"));
|
||||
ui->color3Label->setText(tr("End:"));
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::setGradientColorVisibility(bool val)
|
||||
{
|
||||
ui->SelectionColor_Background->setVisible(!val);
|
||||
ui->color1Label->setVisible(val);
|
||||
ui->backgroundColorFrom->setVisible(val);
|
||||
ui->color2Label->setVisible(val);
|
||||
ui->backgroundColorMid->setVisible(val);
|
||||
ui->color3Label->setVisible(val);
|
||||
ui->backgroundColorTo->setVisible(val);
|
||||
ui->checkMidColor->setVisible(val);
|
||||
ui->SwitchGradientColors->setVisible(val);
|
||||
|
||||
if (val)
|
||||
onCheckMidColorToggled(ui->checkMidColor->isChecked());
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsViewColor.cpp"
|
||||
70
src/Gui/PreferencePages/DlgSettingsViewColor.h
Normal file
70
src/Gui/PreferencePages/DlgSettingsViewColor.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* 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 GUI_DIALOG_DLGSETTINGSVIEWCOLOR_H
|
||||
#define GUI_DIALOG_DLGSETTINGSVIEWCOLOR_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgSettingsViewColor;
|
||||
|
||||
/**
|
||||
* The DlgSettingsViewColor class implements a preference page to change color settings
|
||||
* for the Inventor viewer like background and selection.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class DlgSettingsViewColor : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsViewColor(QWidget* parent = nullptr);
|
||||
~DlgSettingsViewColor() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onSwitchGradientColorsPressed();
|
||||
void onRadioButtonSimpleToggled(bool val);
|
||||
void onRadioButtonGradientToggled(bool val);
|
||||
void onRadioButtonRadialGradientToggled(bool val);
|
||||
void onCheckMidColorToggled(bool val);
|
||||
|
||||
private:
|
||||
void setGradientColorVisibility(bool val);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsViewColor> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSVIEWCOLOR_H
|
||||
459
src/Gui/PreferencePages/DlgSettingsViewColor.ui
Normal file
459
src/Gui/PreferencePages/DlgSettingsViewColor.ui
Normal file
@@ -0,0 +1,459 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsViewColor</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsViewColor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>405</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Colors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxColor">
|
||||
<property name="toolTip">
|
||||
<string>Background color for the model view</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Background color</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="Gui::PrefRadioButton" name="radioButtonSimple">
|
||||
<property name="toolTip">
|
||||
<string>Background will have selected color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Simple color</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Simple</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefRadioButton" name="radioButtonGradient">
|
||||
<property name="toolTip">
|
||||
<string>Background will have selected color gradient</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Linear gradient</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Gradient</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefRadioButton" name="rbRadialGradient">
|
||||
<property name="toolTip">
|
||||
<string>Background will have selected color gradient</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radial gradient</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>RadialGradient</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefColorButton" name="SelectionColor_Background">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Background will have selected color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>20</red>
|
||||
<green>20</green>
|
||||
<blue>163</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BackgroundColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QToolButton" name="SwitchGradientColors">
|
||||
<property name="toolTip">
|
||||
<string>Switches the colors of the gradient</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/button_sort.svg</normaloff>:/icons/button_sort.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="color1Label">
|
||||
<property name="text">
|
||||
<string>Top:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="backgroundColorFrom">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>51</red>
|
||||
<green>51</green>
|
||||
<blue>101</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BackgroundColor2</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="color2Label">
|
||||
<property name="text">
|
||||
<string>Middle:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="backgroundColorMid">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>111</red>
|
||||
<green>111</green>
|
||||
<blue>147</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BackgroundColor4</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="Gui::PrefCheckBox" name="checkMidColor">
|
||||
<property name="toolTip">
|
||||
<string>Color gradient will get selected color as middle color</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Middle color</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseBackgroundColorMid</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="color3Label">
|
||||
<property name="text">
|
||||
<string>Bottom:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="backgroundColorTo">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>151</red>
|
||||
<green>151</green>
|
||||
<blue>170</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BackgroundColor3</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxTree">
|
||||
<property name="title">
|
||||
<string>Tree view</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>240</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Object being edited</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="TreeEditColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Background color for objects in tree view that are currently edited</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>TreeEditColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Active container</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="TreeActiveColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Background color for active containers in tree view</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>230</red>
|
||||
<green>230</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>TreeActiveColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>TreeView</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="spacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>183</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefColorButton</class>
|
||||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefRadioButton</class>
|
||||
<extends>QRadioButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>checkBoxPreselection</tabstop>
|
||||
<tabstop>HighlightColor</tabstop>
|
||||
<tabstop>checkBoxSelection</tabstop>
|
||||
<tabstop>SelectionColor</tabstop>
|
||||
<tabstop>SelectionColor_Background</tabstop>
|
||||
<tabstop>backgroundColorFrom</tabstop>
|
||||
<tabstop>backgroundColorTo</tabstop>
|
||||
<tabstop>checkMidColor</tabstop>
|
||||
<tabstop>backgroundColorMid</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
150
src/Gui/PreferencePages/DlgSettingsWorkbenches.ui
Normal file
150
src/Gui/PreferencePages/DlgSettingsWorkbenches.ui
Normal file
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Gui::Dialog::DlgSettingsWorkbenches</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgSettingsWorkbenches">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>607</width>
|
||||
<height>859</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Available Workbenches</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="noteLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>You can reorder workbenches by drag and drop. Additional workbenches can be installed through the addon manager.</p><p>
|
||||
Currently, your system has the following workbenches:</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="ListWidgetDragBugFix" name="wbList"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="autoModuleLabel">
|
||||
<property name="text">
|
||||
<string>Start up workbench:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="AutoloadModuleCombo">
|
||||
<property name="toolTip">
|
||||
<string>Choose which workbench will be activated and shown
|
||||
after FreeCAD launches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="WorkbenchSelectorPositionLabel">
|
||||
<property name="text">
|
||||
<string>Workbench selector position :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="WorkbenchSelectorPosition">
|
||||
<property name="toolTip">
|
||||
<string>Customize where the workbench selector appears (restart required).
|
||||
|
||||
'Toolbar': In the toolbars, as a movable toolbar.
|
||||
'Left Corner': In the menu bar, on the left corner.
|
||||
'Right Corner': In the menu bar, on the right corner.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_WbByTab">
|
||||
<property name="toolTip">
|
||||
<string>If checked, application will remember which workbench is active for each tab of the viewport</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remember active workbench by tab</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SaveWBbyTab</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ListWidgetDragBugFix</class>
|
||||
<extends>QListWidget</extends>
|
||||
<header>ListWidgetDragBugFix.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
593
src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp
Normal file
593
src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp
Normal file
@@ -0,0 +1,593 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2020 Chris Hennes (chennes@pioneerlibrarysystem.org) *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/UserSettings.h>
|
||||
#include <Gui/Workbench.h>
|
||||
#include <Gui/WorkbenchManager.h>
|
||||
|
||||
#include "DlgSettingsWorkbenchesImp.h"
|
||||
#include "ui_DlgSettingsWorkbenches.h"
|
||||
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
namespace Gui::Dialog {
|
||||
class wbListItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit wbListItem(const QString& wbName, bool enabled, bool startupWb, bool autoLoad, int index, QWidget* parent = nullptr);
|
||||
~wbListItem() override;
|
||||
|
||||
bool isEnabled();
|
||||
bool isAutoLoading();
|
||||
void setStartupWb(bool val);
|
||||
|
||||
void setShortcutLabel(int index);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onLoadClicked();
|
||||
void onWbToggled(bool checked);
|
||||
|
||||
Q_SIGNALS:
|
||||
void wbToggled(const QString& wbName, bool enabled);
|
||||
|
||||
private:
|
||||
QCheckBox* enableCheckBox;
|
||||
QCheckBox* autoloadCheckBox;
|
||||
QLabel* iconLabel;
|
||||
QLabel* textLabel;
|
||||
QLabel* shortcutLabel;
|
||||
QLabel* loadLabel;
|
||||
QPushButton* loadButton;
|
||||
};
|
||||
}
|
||||
|
||||
wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool autoLoad, int index, QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
this->setObjectName(wbName);
|
||||
|
||||
auto wbTooltip = Application::Instance->workbenchToolTip(wbName);
|
||||
auto wbDisplayName = Application::Instance->workbenchMenuText(wbName);
|
||||
|
||||
// 1: Enable checkbox
|
||||
enableCheckBox = new QCheckBox(this);
|
||||
enableCheckBox->setToolTip(tr("If unchecked, %1 will not appear in the available workbenches.").arg(wbDisplayName));
|
||||
enableCheckBox->setChecked(enabled);
|
||||
if (startupWb) {
|
||||
enableCheckBox->setChecked(true);
|
||||
enableCheckBox->setEnabled(false);
|
||||
enableCheckBox->setToolTip(tr("This is the current startup module, and must be enabled. See Preferences/General/Autoload to change."));
|
||||
}
|
||||
connect(enableCheckBox, &QCheckBox::toggled, this, [this](bool checked) { onWbToggled(checked); });
|
||||
|
||||
QWidget* subWidget = new QWidget(this);
|
||||
// 2: Workbench Icon
|
||||
auto wbIcon = Application::Instance->workbenchIcon(wbName);
|
||||
iconLabel = new QLabel(wbDisplayName, this);
|
||||
iconLabel->setPixmap(wbIcon.scaled(QSize(20, 20), Qt::AspectRatioMode::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
|
||||
iconLabel->setToolTip(wbTooltip);
|
||||
iconLabel->setContentsMargins(5, 0, 0, 5); // Left, top, right, bottom
|
||||
iconLabel->setEnabled(enableCheckBox->isChecked());
|
||||
|
||||
// 3: Workbench Display Name
|
||||
textLabel = new QLabel(wbDisplayName, this);
|
||||
textLabel->setToolTip(wbTooltip);
|
||||
QFont font = textLabel->font();
|
||||
font.setBold(true);
|
||||
textLabel->setFont(font);
|
||||
textLabel->setEnabled(enableCheckBox->isChecked());
|
||||
|
||||
// 4: shortcut
|
||||
shortcutLabel = new QLabel(QString::fromLatin1("(W, %1)").arg(index + 1), this);
|
||||
shortcutLabel->setToolTip(tr("Shortcut to activate this workbench."));
|
||||
shortcutLabel->setEnabled(enableCheckBox->isChecked());
|
||||
shortcutLabel->setVisible(index < 9);
|
||||
|
||||
auto subLayout = new QHBoxLayout(subWidget);
|
||||
subLayout->addWidget(iconLabel);
|
||||
subLayout->addWidget(textLabel);
|
||||
subLayout->addWidget(shortcutLabel);
|
||||
subLayout->setAlignment(Qt::AlignLeft);
|
||||
subLayout->setContentsMargins(5, 0, 0, 5);
|
||||
subWidget->setMinimumSize(250, 0);
|
||||
|
||||
// 5: Autoloaded checkBox.
|
||||
autoloadCheckBox = new QCheckBox(this);
|
||||
autoloadCheckBox->setText(tr("Auto-load"));
|
||||
autoloadCheckBox->setToolTip(tr("If checked, %1 will be loaded automatically when FreeCAD starts up").arg(wbDisplayName));
|
||||
autoloadCheckBox->setEnabled(enableCheckBox->isChecked());
|
||||
|
||||
if (startupWb) { // Figure out whether to check and/or disable this checkBox:
|
||||
autoloadCheckBox->setChecked(true);
|
||||
autoloadCheckBox->setEnabled(false);
|
||||
autoloadCheckBox->setToolTip(tr("This is the current startup module, and must be autoloaded. See Preferences/General/Autoload to change."));
|
||||
}
|
||||
else if (autoLoad) {
|
||||
autoloadCheckBox->setChecked(true);
|
||||
}
|
||||
|
||||
// 6: Load button/loaded indicator
|
||||
loadLabel = new QLabel(tr("Loaded"), this);
|
||||
loadLabel->setAlignment(Qt::AlignCenter);
|
||||
loadLabel->setEnabled(enableCheckBox->isChecked());
|
||||
loadButton = new QPushButton(tr("Load"), this);
|
||||
loadButton->setToolTip(tr("To preserve resources, FreeCAD does not load workbenches until they are used. Loading them may provide access to additional preferences related to their functionality."));
|
||||
loadButton->setEnabled(enableCheckBox->isChecked());
|
||||
connect(loadButton, &QPushButton::clicked, this, [this]() { onLoadClicked(); });
|
||||
if (WorkbenchManager::instance()->getWorkbench(wbName.toStdString())) {
|
||||
loadButton->setVisible(false);
|
||||
}
|
||||
else {
|
||||
loadLabel->setVisible(false);
|
||||
}
|
||||
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->addWidget(enableCheckBox);
|
||||
layout->addWidget(subWidget);
|
||||
layout->addWidget(autoloadCheckBox);
|
||||
layout->addWidget(loadButton);
|
||||
layout->addWidget(loadLabel);
|
||||
layout->setAlignment(Qt::AlignLeft);
|
||||
layout->setContentsMargins(10, 0, 0, 0);
|
||||
}
|
||||
|
||||
wbListItem::~wbListItem()
|
||||
{
|
||||
}
|
||||
|
||||
bool wbListItem::isEnabled()
|
||||
{
|
||||
return enableCheckBox->isChecked();
|
||||
}
|
||||
|
||||
bool wbListItem::isAutoLoading()
|
||||
{
|
||||
return autoloadCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void wbListItem::setStartupWb(bool val)
|
||||
{
|
||||
if(val)
|
||||
autoloadCheckBox->setChecked(true);
|
||||
|
||||
enableCheckBox->setEnabled(!val);
|
||||
autoloadCheckBox->setEnabled(!val && textLabel->isEnabled());
|
||||
}
|
||||
|
||||
void wbListItem::setShortcutLabel(int index)
|
||||
{
|
||||
shortcutLabel->setText(QString::fromLatin1("(W, %1)").arg(index + 1));
|
||||
shortcutLabel->setVisible(index < 9);
|
||||
}
|
||||
|
||||
void wbListItem::onLoadClicked()
|
||||
{
|
||||
// activate selected workbench
|
||||
Workbench* originalActiveWB = WorkbenchManager::instance()->active();
|
||||
Application::Instance->activateWorkbench(objectName().toStdString().c_str());
|
||||
Application::Instance->activateWorkbench(originalActiveWB->name().c_str());
|
||||
|
||||
// replace load button with loaded indicator
|
||||
loadButton->setVisible(false);
|
||||
loadLabel->setVisible(true);
|
||||
}
|
||||
|
||||
void wbListItem::onWbToggled(bool checked)
|
||||
{
|
||||
// activate/deactivate the widgets
|
||||
iconLabel->setEnabled(checked);
|
||||
textLabel->setEnabled(checked);
|
||||
shortcutLabel->setEnabled(checked);
|
||||
loadLabel->setEnabled(checked);
|
||||
loadButton->setEnabled(checked);
|
||||
autoloadCheckBox->setEnabled(checked);
|
||||
|
||||
// Reset the start combo items.
|
||||
Q_EMIT wbToggled(objectName(), checked);
|
||||
}
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::DlgSettingsWorkbenchesImp */
|
||||
|
||||
/**
|
||||
* Constructs a DlgSettingsWorkbenchesImp
|
||||
*/
|
||||
DlgSettingsWorkbenchesImp::DlgSettingsWorkbenchesImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgSettingsWorkbenches)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->wbList->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
ui->wbList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
ui->wbList->viewport()->setAcceptDrops(true);
|
||||
ui->wbList->setDropIndicatorShown(true);
|
||||
ui->wbList->setDragEnabled(true);
|
||||
ui->wbList->setDefaultDropAction(Qt::MoveAction);
|
||||
|
||||
connect(ui->wbList->model(), &QAbstractItemModel::rowsMoved, this, &DlgSettingsWorkbenchesImp::wbItemMoved);
|
||||
connect(ui->AutoloadModuleCombo, qOverload<int>(&QComboBox::activated), this, &DlgSettingsWorkbenchesImp::onStartWbChanged);
|
||||
connect(ui->WorkbenchSelectorPosition, qOverload<int>(&QComboBox::activated), this, &DlgSettingsWorkbenchesImp::onWbSelectorChanged);
|
||||
connect(ui->CheckBox_WbByTab, &QCheckBox::toggled, this, &DlgSettingsWorkbenchesImp::onWbByTabToggled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgSettingsWorkbenchesImp::~DlgSettingsWorkbenchesImp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DlgSettingsWorkbenchesImp::saveSettings()
|
||||
{
|
||||
std::ostringstream orderedStr, disabledStr, autoloadStr;
|
||||
|
||||
auto addStrToOss = [](std::string wbName, std::ostringstream& oss) {
|
||||
if (oss.str().find(wbName) == std::string::npos) {
|
||||
if (!oss.str().empty()) {
|
||||
oss << ",";
|
||||
}
|
||||
oss << wbName;
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (!wbItem)
|
||||
continue;
|
||||
std::string wbName = wbItem->objectName().toStdString();
|
||||
|
||||
if (wbItem->isEnabled()) {
|
||||
addStrToOss(wbName, orderedStr);
|
||||
}
|
||||
else {
|
||||
addStrToOss(wbName, disabledStr);
|
||||
}
|
||||
|
||||
if (wbItem->isAutoLoading()) {
|
||||
addStrToOss(wbName, autoloadStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (orderedStr.str().empty()) //make sure that we have at least one enabled workbench. This should not be necessary because startup wb cannot be disabled.
|
||||
orderedStr << "NoneWorkbench";
|
||||
else {
|
||||
if (!disabledStr.str().empty())
|
||||
disabledStr << ",";
|
||||
disabledStr << "NoneWorkbench";
|
||||
}
|
||||
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
hGrp->SetASCII("Ordered", orderedStr.str().c_str());
|
||||
hGrp->SetASCII("Disabled", disabledStr.str().c_str());
|
||||
|
||||
//Update the list of workbenches in the WorkbenchGroup and in the WorkbenchComboBox & workbench QMenu
|
||||
Application::Instance->signalRefreshWorkbenches();
|
||||
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
SetASCII("BackgroundAutoloadModules", autoloadStr.str().c_str());
|
||||
|
||||
saveWorkbenchSelector();
|
||||
|
||||
int index = ui->AutoloadModuleCombo->currentIndex();
|
||||
QVariant data = ui->AutoloadModuleCombo->itemData(index);
|
||||
QString startWbName = data.toString();
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
SetASCII("AutoloadModule", startWbName.toLatin1());
|
||||
|
||||
ui->CheckBox_WbByTab->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::loadSettings()
|
||||
{
|
||||
loadWorkbenchSelector();
|
||||
|
||||
// There are two different "autoload" settings: the first, in FreeCAD since 2004,
|
||||
// controls the module the user sees first when starting FreeCAD, and defaults to the Start workbench
|
||||
std::string start = App::Application::Config()["StartWorkbench"];
|
||||
_startupModule = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
GetASCII("AutoloadModule", start.c_str());
|
||||
|
||||
// The second autoload setting does a background autoload of any number of other modules
|
||||
std::string autoloadCSV = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
GetASCII("BackgroundAutoloadModules", "");
|
||||
|
||||
// Tokenize the comma-separated list
|
||||
_backgroundAutoloadedModules.clear();
|
||||
std::stringstream stream(autoloadCSV);
|
||||
std::string workbench;
|
||||
while (std::getline(stream, workbench, ','))
|
||||
_backgroundAutoloadedModules.push_back(workbench);
|
||||
|
||||
buildWorkbenchList();
|
||||
|
||||
//We set the startup setting after building the list so that we can put only the enabled wb.
|
||||
setStartWorkbenchComboItems();
|
||||
|
||||
{
|
||||
QSignalBlocker sigblk(ui->CheckBox_WbByTab);
|
||||
ui->CheckBox_WbByTab->onRestore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Build the list of unloaded workbenches.
|
||||
*/
|
||||
void DlgSettingsWorkbenchesImp::buildWorkbenchList()
|
||||
{
|
||||
QSignalBlocker sigblk(ui->wbList);
|
||||
|
||||
QStringList enabledWbs = getEnabledWorkbenches();
|
||||
QStringList disabledWbs = getDisabledWorkbenches();
|
||||
|
||||
//First we add the enabled wbs in their saved order.
|
||||
for (const auto& wbName : enabledWbs) {
|
||||
addWorkbench(wbName, true);
|
||||
}
|
||||
//Second we add workbenches that are disabled in alphabetical order.
|
||||
for (const auto& wbName : disabledWbs) {
|
||||
if (wbName.toStdString() != "NoneWorkbench") {
|
||||
addWorkbench(wbName, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::addWorkbench(const QString& wbName, bool enabled)
|
||||
{
|
||||
bool isStartupWb = wbName.toStdString() == _startupModule;
|
||||
bool autoLoad = std::find(_backgroundAutoloadedModules.begin(), _backgroundAutoloadedModules.end(),
|
||||
wbName.toStdString()) != _backgroundAutoloadedModules.end();
|
||||
wbListItem* widget = new wbListItem(wbName, enabled, isStartupWb, autoLoad, ui->wbList->count(), this);
|
||||
connect(widget, &wbListItem::wbToggled, this, &DlgSettingsWorkbenchesImp::wbToggled);
|
||||
auto wItem = new QListWidgetItem();
|
||||
wItem->setSizeHint(widget->sizeHint());
|
||||
ui->wbList->addItem(wItem);
|
||||
ui->wbList->setItemWidget(wItem, widget);
|
||||
}
|
||||
|
||||
QStringList DlgSettingsWorkbenchesImp::getEnabledWorkbenches()
|
||||
{
|
||||
QStringList disabled_wbs_list = getDisabledWorkbenches();
|
||||
QStringList enabled_wbs_list;
|
||||
QStringList wbs_ordered_list;
|
||||
QString wbs_ordered;
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
wbs_ordered = QString::fromStdString(hGrp->GetASCII("Ordered", ""));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
wbs_ordered_list = wbs_ordered.split(QLatin1String(","), Qt::SkipEmptyParts);
|
||||
#else
|
||||
wbs_ordered_list = wbs_ordered.split(QLatin1String(","), QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
QStringList workbenches = Application::Instance->workbenches();
|
||||
workbenches.sort();
|
||||
|
||||
//First we add the wb that are ordered.
|
||||
for(auto& wbName : wbs_ordered_list) {
|
||||
if (workbenches.contains(wbName) && !disabled_wbs_list.contains(wbName)) { //Some wb may have been removed
|
||||
enabled_wbs_list.append(wbName);
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("Ignoring unknown %s workbench found in user preferences.\n", wbName.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//Then we add the wbs that are not ordered and not disabled in alphabetical order
|
||||
for(auto& wbName : workbenches) {
|
||||
if (!enabled_wbs_list.contains(wbName) && !disabled_wbs_list.contains(wbName))
|
||||
enabled_wbs_list.append(wbName);
|
||||
}
|
||||
|
||||
return enabled_wbs_list;
|
||||
}
|
||||
|
||||
QStringList DlgSettingsWorkbenchesImp::getDisabledWorkbenches()
|
||||
{
|
||||
QString disabled_wbs;
|
||||
QStringList unfiltered_disabled_wbs_list;
|
||||
QStringList disabled_wbs_list;
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
|
||||
disabled_wbs = QString::fromStdString(hGrp->GetASCII("Disabled", "NoneWorkbench,TestWorkbench"));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
unfiltered_disabled_wbs_list = disabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts);
|
||||
#else
|
||||
unfiltered_disabled_wbs_list = disabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
QStringList workbenches = Application::Instance->workbenches();
|
||||
|
||||
for (auto& wbName : unfiltered_disabled_wbs_list) {
|
||||
if (workbenches.contains(wbName)) { //Some wb may have been removed
|
||||
disabled_wbs_list.append(wbName);
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("Ignoring unknown %s workbench found in user preferences.\n", wbName.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
disabled_wbs_list.sort();
|
||||
|
||||
return disabled_wbs_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsWorkbenchesImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::saveWorkbenchSelector()
|
||||
{
|
||||
//save workbench selector position
|
||||
auto index = ui->WorkbenchSelectorPosition->currentIndex();
|
||||
WorkbenchSwitcher::setIndex(index);
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::loadWorkbenchSelector()
|
||||
{
|
||||
QSignalBlocker sigblk(ui->WorkbenchSelectorPosition);
|
||||
|
||||
//workbench selector position combobox setup
|
||||
ui->WorkbenchSelectorPosition->clear();
|
||||
ui->WorkbenchSelectorPosition->addItem(tr("Toolbar"));
|
||||
ui->WorkbenchSelectorPosition->addItem(tr("Left corner"));
|
||||
ui->WorkbenchSelectorPosition->addItem(tr("Right corner"));
|
||||
ui->WorkbenchSelectorPosition->setCurrentIndex(WorkbenchSwitcher::getIndex());
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::wbToggled(const QString& wbName, bool enabled)
|
||||
{
|
||||
setStartWorkbenchComboItems();
|
||||
|
||||
//reorder the list of items.
|
||||
int wbIndex = 0;
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem && wbItem->objectName() == wbName) {
|
||||
wbIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
int destinationIndex = ui->wbList->count();
|
||||
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem && !wbItem->isEnabled() && (enabled || ((wbItem->objectName()).toStdString() > wbName.toStdString()))) {
|
||||
//If the wb was enabled, then it was in the disabled wbs. So it moves to the row of the currently first disabled wb
|
||||
//If the wb was disabled. Then it goes to the disabled wb where it belongs alphabetically.
|
||||
destinationIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->wbList->model()->moveRow(QModelIndex(), wbIndex, QModelIndex(), destinationIndex);
|
||||
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems()
|
||||
{
|
||||
ui->AutoloadModuleCombo->clear();
|
||||
|
||||
// fills the combo box with activated workbenches.
|
||||
QStringList enabledWbs;
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem && wbItem->isEnabled()) {
|
||||
enabledWbs << wbItem->objectName();
|
||||
}
|
||||
}
|
||||
|
||||
QMap<QString, QString> menuText;
|
||||
for (const auto& it : enabledWbs) {
|
||||
QString text = Application::Instance->workbenchMenuText(it);
|
||||
menuText[text] = it;
|
||||
}
|
||||
|
||||
{ // add special workbench to selection
|
||||
QPixmap px = Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench"));
|
||||
QString key = QString::fromLatin1("<last>");
|
||||
QString value = QString::fromLatin1("$LastModule");
|
||||
if (px.isNull()) {
|
||||
ui->AutoloadModuleCombo->addItem(key, QVariant(value));
|
||||
}
|
||||
else {
|
||||
ui->AutoloadModuleCombo->addItem(px, key, QVariant(value));
|
||||
}
|
||||
}
|
||||
|
||||
for (QMap<QString, QString>::Iterator it = menuText.begin(); it != menuText.end(); ++it) {
|
||||
QPixmap px = Application::Instance->workbenchIcon(it.value());
|
||||
if (px.isNull()) {
|
||||
ui->AutoloadModuleCombo->addItem(it.key(), QVariant(it.value()));
|
||||
}
|
||||
else {
|
||||
ui->AutoloadModuleCombo->addItem(px, it.key(), QVariant(it.value()));
|
||||
}
|
||||
}
|
||||
|
||||
ui->AutoloadModuleCombo->setCurrentIndex(ui->AutoloadModuleCombo->findData(QString::fromStdString(_startupModule)));
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::wbItemMoved()
|
||||
{
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem) {
|
||||
wbItem->setShortcutLabel(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::onStartWbChanged(int index)
|
||||
{
|
||||
//Update _startupModule
|
||||
QVariant data = ui->AutoloadModuleCombo->itemData(index);
|
||||
QString wbName = data.toString();
|
||||
_startupModule = wbName.toStdString();
|
||||
|
||||
//Change wb that user can't deactivate.
|
||||
for (int i = 0; i < ui->wbList->count(); i++) {
|
||||
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
|
||||
if (wbItem) {
|
||||
wbItem->setStartupWb(wbItem->objectName() == wbName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::onWbSelectorChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
requireRestart();
|
||||
}
|
||||
|
||||
void DlgSettingsWorkbenchesImp::onWbByTabToggled(bool val)
|
||||
{
|
||||
Q_UNUSED(val);
|
||||
requireRestart();
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsWorkbenchesImp.cpp"
|
||||
#include "DlgSettingsWorkbenchesImp.moc"
|
||||
82
src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.h
Normal file
82
src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2020 Chris Hennes (chennes@pioneerlibrarysystem.org) *
|
||||
* Copyright (c) 2023 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_DIALOG_DLGSETTINGSWORKBENCHES_IMP_H
|
||||
#define GUI_DIALOG_DLGSETTINGSWORKBENCHES_IMP_H
|
||||
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Gui::Dialog {
|
||||
class Ui_DlgSettingsWorkbenches;
|
||||
|
||||
/**
|
||||
* The DlgSettingsWorkbenchesImp class implements a pseudo-preference page explain why
|
||||
* the remaining preference pages aren't loaded yet, and to help the user do so on demand.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
class DlgSettingsWorkbenchesImp : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgSettingsWorkbenchesImp( QWidget* parent = nullptr );
|
||||
~DlgSettingsWorkbenchesImp() override;
|
||||
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
|
||||
static QStringList getEnabledWorkbenches();
|
||||
static QStringList getDisabledWorkbenches();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void wbToggled(const QString& wbName, bool enabled);
|
||||
void wbItemMoved();
|
||||
void onWbSelectorChanged(int index);
|
||||
void onStartWbChanged(int index);
|
||||
void onWbByTabToggled(bool val);
|
||||
|
||||
protected:
|
||||
void buildWorkbenchList();
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void addWorkbench(const QString& it, bool enabled);
|
||||
|
||||
void setStartWorkbenchComboItems();
|
||||
|
||||
void saveWorkbenchSelector();
|
||||
void loadWorkbenchSelector();
|
||||
|
||||
|
||||
std::vector<std::string> _backgroundAutoloadedModules;
|
||||
std::string _startupModule;
|
||||
|
||||
std::unique_ptr<Ui_DlgSettingsWorkbenches> ui;
|
||||
};
|
||||
|
||||
} // namespace Gui::Dialog
|
||||
|
||||
#endif // GUI_DIALOG_DLGSETTINGSWORKBENCHES_IMP_H
|
||||
Reference in New Issue
Block a user