From: nds Date: Mon, 4 Jul 2016 06:04:07 +0000 (+0300) Subject: Disabling all input fields of geometry creation panels X-Git-Tag: V_2.5.0~247 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b9a4919649b3cd5ba06f64a290b5db18bb07f491;p=modules%2Fshaper.git Disabling all input fields of geometry creation panels --- diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index a941f30d2..58252b77e 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -88,6 +88,7 @@ const static char* DOUBLE_WDG_MAX = "max"; const static char* DOUBLE_WDG_STEP = "step"; const static char* DOUBLE_WDG_DEFAULT_COMPUTED = "computed"; const static char* DOUBLE_WDG_ACCEPT_EXPRESSIONS = "accept_expressions"; +const static char* DOUBLE_WDG_ENABLE_VALUE = "enable_value"; // WDG_TOOLBOX/WDG_SWITCH properties const static char* CONTAINER_PAGE_NAME = "title"; const static char* CONTAINER_PAGE_ICON = "icon"; diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index dba8c5d0f..856c5d193 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -77,6 +77,8 @@ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePr connect(lineEdit(), SIGNAL(textChanged( const QString& )), this, SLOT(onTextChanged( const QString& ))); + + myEnabledBaseColor = palette().color(QPalette::Active, QPalette::Base); } /*! @@ -353,3 +355,13 @@ bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable) return aPreviousValue; } + +void ModuleBase_DoubleSpinBox::setValueEnabled(const bool& theEnable) +{ + setReadOnly(!theEnable); + + QPalette aPal = palette(); + aPal.setColor(QPalette::All, QPalette::Base, + theEnable? myEnabledBaseColor : aPal.color(QPalette::Disabled, QPalette::Base)); + setPalette(aPal); +} diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.h b/src/ModuleBase/ModuleBase_DoubleSpinBox.h index 8c60c6d2d..c26d17f03 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.h +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.h @@ -11,6 +11,8 @@ #include #include +#include + class QKeyEvent; /** @@ -54,6 +56,10 @@ Q_OBJECT /// \return the previous value bool enableKeyPressEvent(const bool& theEnable); + /// Imitation of disable control value. If theEnable is false, the control becomes + /// read only and base color is disabled. + void setValueEnabled(const bool& theEnable); + signals: /// The signal about key release on the control, that corresponds to the attribute void enterReleased(); @@ -80,6 +86,9 @@ signals: /// Precision value int myPrecision; + + /// Cashed color of active base palette + QColor myEnabledBaseColor; }; #endif diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 69cd60c46..b172e101e 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -53,6 +54,8 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, myAttributeID = theData ? theData->widgetId() : ""; myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, true); + myIsValueEnabled = theData->getBooleanAttribute(DOUBLE_WDG_ENABLE_VALUE, true); + connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged())); connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified())); } @@ -78,6 +81,15 @@ bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const return theObject->data()->attribute(attributeID())->isInitialized(); } +bool ModuleBase_ModelWidget::isValueEnabled() const +{ + bool anEnabled = true; + bool aCanDisable = Config_PropManager::boolean("Sketch planes", "disable_input_fields", "true"); + if (aCanDisable) + anEnabled = myIsValueEnabled; + return anEnabled; +} + void ModuleBase_ModelWidget::processValueState() { if (myState == ModifiedInPP || myState == ModifiedInViewer) diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 997c6bca2..cc3438680 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -75,6 +75,11 @@ Q_OBJECT /// \return the boolean result bool isObligatory() const { return myIsObligatory; } + /// Returns true, if the widget value is enabled and might be modified manualy. It returns false if + /// the application preferences allow having disabled value and the internal state tells to disable + /// \return the boolean result + virtual bool isValueEnabled() const; + /// Returns this parameter value in the xml file /// \return the boolean result bool isUseReset() const { return myUseReset; } @@ -310,6 +315,9 @@ protected slots: /// The non-obligatory widgets should not accept the focus in the property panel bool myIsObligatory; + /// Flag about value of the control is enabled (can be modified) + bool myIsValueEnabled; + /// The widget value state ValueState myState; diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index e6408e212..296f0e0ca 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -92,6 +92,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, aControlLay->addRow(myLabel, mySpinBox); connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); + mySpinBox->setValueEnabled(isValueEnabled()); } ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue() diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5b858673c..f357f2541 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -162,6 +162,10 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) Config_PropManager::registerProp("Visualization", "operation_highlight_color", "Multi selector item color in operation", Config_Prop::Color, PartSet_CustomPrs::OPERATION_HIGHLIGHT_COLOR()); + + + Config_PropManager::registerProp("Sketch planes", "disable_input_fields", "Disable input fields", + Config_Prop::Boolean, "true"); } PartSet_Module::~PartSet_Module() diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 6b77f8535..4cfede1e2 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -101,6 +101,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, aGroupLay->addWidget(myXSpin, 0, 1); connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); + myXSpin->setValueEnabled(isValueEnabled()); } { QLabel* aLabel = new QLabel(myGroupBox); @@ -115,6 +116,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, aGroupLay->addWidget(myYSpin, 1, 1); connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); + myYSpin->setValueEnabled(isValueEnabled()); } QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); diff --git a/src/PythonAddons/macros/rectangle/widget.xml b/src/PythonAddons/macros/rectangle/widget.xml index e21dbda1b..890e3e55d 100644 --- a/src/PythonAddons/macros/rectangle/widget.xml +++ b/src/PythonAddons/macros/rectangle/widget.xml @@ -8,8 +8,10 @@ title="Rectangle" tooltip="Create rectangle" icon="icons/Addons/rectangle.png"> - - + + diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index a618c51cd..89b6754ae 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -20,14 +20,17 @@ - + - - + + @@ -41,15 +44,21 @@ icon="icons/Sketch/circle.png"> - - + + - - - + + + @@ -63,29 +72,39 @@ icon="icons/Sketch/arc.png"> - - - + + + - - - + + + - + - + - - + + @@ -102,7 +121,8 @@ clear_in_neutral_point="false"> - +