Assembly: Esc pref
This commit is contained in:
@@ -42,6 +42,13 @@
|
||||
#include <Gui/QtAll.h>
|
||||
#endif
|
||||
|
||||
#include <QWidgetAction>
|
||||
|
||||
// all of Inventor
|
||||
#ifndef __InventorAll__
|
||||
#include <Gui/InventorAll.h>
|
||||
#endif
|
||||
|
||||
#endif //_PreComp_
|
||||
|
||||
#endif // POINTSGUI_PRECOMPILED_H
|
||||
|
||||
@@ -13,8 +13,57 @@
|
||||
<property name="windowTitle">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="verticalLayout_1">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxEnableEscape">
|
||||
<property name="toolTip">
|
||||
<string>Allow to leave edit mode when pressing Esc button</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Esc leave edit mode</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>LeaveEditWithEscape</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Assembly</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="groundFirstPartLabel">
|
||||
<property name="text">
|
||||
<string>Ground first part:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="groundFirstPart">
|
||||
<property name="toolTip">
|
||||
<string>When you insert the first part in the assembly, you can choose to ground the part automatically.</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -29,6 +78,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <Inventor/events/SoKeyboardEvent.h>
|
||||
#endif
|
||||
|
||||
#include <App/Link.h>
|
||||
@@ -235,6 +236,21 @@ App::DocumentObject* ViewProviderAssembly::getActivePart() const
|
||||
return activeView->getActiveObject<App::DocumentObject*>(PARTKEY);
|
||||
}
|
||||
|
||||
bool ViewProviderAssembly::keyPressed(bool pressed, int key)
|
||||
{
|
||||
if (key == SoKeyboardEvent::ESCAPE) {
|
||||
if (isInEditMode()) {
|
||||
|
||||
ParameterGrp::handle hPgr = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Assembly");
|
||||
|
||||
return !hPgr->GetBool("LeaveEditWithEscape", true);
|
||||
}
|
||||
}
|
||||
|
||||
return false; // handle all other key events
|
||||
}
|
||||
|
||||
bool ViewProviderAssembly::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
|
||||
{
|
||||
// Initialize or end the dragging of parts
|
||||
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
App::DocumentObject* getActivePart() const;
|
||||
|
||||
|
||||
/// is called when the Provider is in edit and a key event ocours. Only ESC ends edit.
|
||||
bool keyPressed(bool pressed, int key) override;
|
||||
/// is called when the provider is in edit and the mouse is moved
|
||||
bool mouseMove(const SbVec2s& pos, Gui::View3DInventorViewer* viewer) override;
|
||||
/// is called when the Provider is in edit and the mouse is clicked
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
from UtilsAssembly import tr
|
||||
|
||||
|
||||
def preferences():
|
||||
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Assembly")
|
||||
@@ -34,7 +36,15 @@ class PreferencesPage:
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":preferences/Assembly.ui")
|
||||
|
||||
def saveSettings(self):
|
||||
pass
|
||||
pref = preferences()
|
||||
pref.SetBool("LeaveEditWithEscape", self.form.checkBoxEnableEscape.isChecked())
|
||||
pref.SetInt("GroundFirstPart", self.form.groundFirstPart.currentIndex())
|
||||
|
||||
def loadSettings(self):
|
||||
pass
|
||||
pref = preferences()
|
||||
self.form.checkBoxEnableEscape.setChecked(pref.GetBool("LeaveEditWithEscape", True))
|
||||
self.form.groundFirstPart.clear()
|
||||
self.form.groundFirstPart.addItem(tr("Assembly", "Ask"))
|
||||
self.form.groundFirstPart.addItem(tr("Assembly", "Always"))
|
||||
self.form.groundFirstPart.addItem(tr("Assembly", "Never"))
|
||||
self.form.groundFirstPart.setCurrentIndex(pref.GetInt("GroundFirstPart", 0))
|
||||
|
||||
@@ -27,6 +27,10 @@ import Part
|
||||
if App.GuiUp:
|
||||
import FreeCADGui as Gui
|
||||
|
||||
import PySide.QtCore as QtCore
|
||||
import PySide.QtGui as QtGui
|
||||
|
||||
|
||||
# translate = App.Qt.translate
|
||||
|
||||
__title__ = "Assembly utilitary functions"
|
||||
@@ -34,6 +38,10 @@ __author__ = "Ondsel"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
|
||||
def tr(context, text, comment=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, comment)
|
||||
|
||||
|
||||
def activeAssembly():
|
||||
doc = Gui.ActiveDocument
|
||||
|
||||
|
||||
Reference in New Issue
Block a user