Skip to content

Commit

Permalink
Merge pull request FreeCAD#10171 from qewer33/master
Browse files Browse the repository at this point in the history
StartPage: Add new file templates and fix javascript error
  • Loading branch information
chennes committed Aug 16, 2023
2 parents 0658e42 + 58b9a9f commit 7d92236
Show file tree
Hide file tree
Showing 15 changed files with 342 additions and 186 deletions.
30 changes: 2 additions & 28 deletions src/Mod/Start/Gui/DlgStartPreferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_7">
<widget class="Gui::PrefCheckBox" name="checkBox_6">
<property name="toolTip">
<string>Displays help tips in the Start workbench Documents tab</string>
</property>
Expand Down Expand Up @@ -184,7 +184,7 @@ By using &quot;;;&quot; to separate paths, you can add several folders here</str
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_8">
<widget class="Gui::PrefCheckBox" name="checkBox_7">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
Expand Down Expand Up @@ -592,32 +592,6 @@ By using &quot;;;&quot; to separate paths, you can add several folders here</str
</item>
</layout>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Use gradient for New File icon</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="Gui::PrefCheckBox" name="checkBox_6">
<property name="toolTip">
<string>If this is selected, the 'New File' icon shows a gradient icon instead of the normal icon</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>NewFileGradient</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Start/Gui/DlgStartPreferencesImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ void DlgStartPreferencesImp::saveSettings()
ui->checkBox_5->onSave();
ui->checkBox_6->onSave();
ui->checkBox_7->onSave();
ui->checkBox_8->onSave();
ui->lineEdit->onSave();
ui->spinBox->onSave();
}
Expand Down Expand Up @@ -144,7 +143,6 @@ void DlgStartPreferencesImp::loadSettings()
ui->checkBox_5->onRestore();
ui->checkBox_6->onRestore();
ui->checkBox_7->onRestore();
ui->checkBox_8->onRestore();
ui->lineEdit->onRestore();
ui->spinBox->onRestore();
}
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Start/StartPage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ SET(StartPage_ImageResources
images/installed.png
images/new_file_thumbnail.svg
images/settings.png
images/new_empty_file.png
images/new_import_file.png
images/new_parametric_part.png
images/new_csg_part.png
images/new_2d_draft.png
images/new_architecture.png
)

SET(StartPage_Resources
Expand Down
40 changes: 37 additions & 3 deletions src/Mod/Start/StartPage/LoadNew.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,42 @@

import FreeCAD
import FreeCADGui
from StartPage import StartPage

FreeCADGui.runCommand('Std_New')
# template will be given before this script is run
template_name = str(template)

from StartPage import StartPage
StartPage.postStart()
match template_name:
case "empty_file":
FreeCADGui.runCommand('Std_New')
StartPage.postStart()
case "import_file":
FreeCADGui.runCommand('Std_New')
StartPage.postStart()
FreeCADGui.runCommand("Std_Import")
case "parametric_part":
FreeCADGui.runCommand('Std_New')
FreeCADGui.activateWorkbench("PartDesignWorkbench")
FreeCADGui.runCommand("PartDesign_Body")
FreeCADGui.Selection.addSelection('Unnamed','Body')
FreeCADGui.runCommand('PartDesign_NewSketch',0)
FreeCADGui.Selection.clearSelection()
StartPage.postStart(False)
case "csg_part":
FreeCADGui.runCommand('Std_New')
FreeCADGui.activateWorkbench("PartWorkbench")
StartPage.postStart(False)
case "2d_draft":
FreeCADGui.runCommand('Std_New')
FreeCADGui.activateWorkbench("DraftWorkbench")
FreeCADGui.runCommand("Std_ViewTop")
StartPage.postStart(False)
case "architecture":
FreeCADGui.runCommand('Std_New')
try:
import BimCommands
except Exception:
FreeCADGui.activateWorkbench("ArchWorkbench")
else:
FreeCADGui.activateWorkbench("BIMWorkbench")
StartPage.postStart(False)
Loading

0 comments on commit 7d92236

Please sign in to comment.