From: vsv Date: Fri, 8 Nov 2019 11:04:52 +0000 (+0300) Subject: 5.2.3 Sketcher: ambiguity of the red cross in case of over-constraint X-Git-Tag: V9_5_0a1~166^2~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92320a2d9ad962f028deeeb85c7ddfe0f1735d4c;p=modules%2Fshaper.git 5.2.3 Sketcher: ambiguity of the red cross in case of over-constraint --- diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 0a8f4aba4..5637a9891 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -35,6 +35,7 @@ const static char* PROPERTY_PANEL_ID = "property_panel_id"; // Widgets const static char* WDG_INFO = "label"; +const static char* WDG_UNDOLABEL = "undo_label"; const static char* WDG_DOUBLEVALUE = "doublevalue"; const static char* WDG_DOUBLEVALUELABEL = "labelvalue"; const static char* WDG_INTEGERVALUE = "integervalue"; @@ -95,6 +96,7 @@ const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP; const static char* ATTR_ICON = FEATURE_ICON; const static char* ATTR_LABEL = "label"; const static char* ATTR_STYLE_SHEET = "styleSheet"; +const static char* ATTR_HTML_STYLE = "isHTML"; const static char* ATTR_DEFAULT = "default"; const static char* ATTR_INTERNAL = "internal"; const static char* ATTR_OBLIGATORY = "obligatory"; diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index fe127695d..265c140f5 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -108,6 +108,7 @@ SET(PROJECT_HEADERS ModuleBase_WidgetSelectionFilter.h ModuleBase_IStepPrs.h ModuleBase_SelectionFilterType.h + ModuleBase_WidgetUndoLabel.h ) SET(PROJECT_MOC_HEADERS @@ -158,6 +159,7 @@ SET(PROJECT_MOC_HEADERS ModuleBase_WidgetRadiobox.h ModuleBase_WidgetPointInput.h ModuleBase_WidgetSelectionFilter.h + ModuleBase_WidgetUndoLabel.h ) SET(PROJECT_SOURCES @@ -228,6 +230,7 @@ SET(PROJECT_SOURCES ModuleBase_WidgetPointInput.cpp ModuleBase_WidgetSelectionFilter.cpp ModuleBase_IStepPrs.cpp + ModuleBase_WidgetUndoLabel.cpp ) SET(TEXT_RESOURCES diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 56ca62630..466b06641 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -152,6 +152,15 @@ Q_OBJECT //! \param theAIS the object which has to be activated virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS) = 0; + //! Undo last command + virtual void undo() = 0; + + //! Set enabled state of cancel button in property panel + virtual void setCancelEnabled(bool toEnable) = 0; + + //! Returns current state of cancel button + virtual bool isCancelEnabled() const = 0; + signals: /// Signal selection changed. void selectionChanged(); diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 0cc45bf09..7f51a61a7 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -303,6 +304,8 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std:: result = new ModuleBase_WidgetLabel(theParent, myWidgetApi); } else if (theType == WDG_DOUBLEVALUE) { result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi); + } else if (theType == WDG_UNDOLABEL) { + result = new ModuleBase_WidgetUndoLabel(theParent, myWorkshop, myWidgetApi); } else if (theType == WDG_DOUBLEVALUELABEL) { result = new ModuleBase_WidgetLabelValue(theParent, myWidgetApi); } else if (theType == WDG_INTEGERVALUE) { diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.cpp b/src/ModuleBase/ModuleBase_WidgetLabel.cpp index b717bf103..135d006a3 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLabel.cpp @@ -37,6 +37,8 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent, : ModuleBase_ModelWidget(theParent, theData) { QString aText = translate(theData->getProperty("title")); + bool aIsHtml = theData->getBooleanAttribute(ATTR_HTML_STYLE, false); + QString aLabelIcon = QString::fromStdString(theData->getProperty("icon")); myLabel = new QLabel(aText, theParent); if (!aLabelIcon.isEmpty()) { @@ -48,13 +50,15 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent, myLabel->setWordWrap(true); myLabel->setIndent(5); myLabel->setContentsMargins(0,0,0,4); + if (aIsHtml) + myLabel->setTextFormat(Qt::RichText); QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); aLayout->addWidget(myLabel); setLayout(aLayout); - std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET).c_str(); + std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET); if (!aStyleSheet.empty()) myLabel->setStyleSheet(QString("QLabel {%1}").arg(aStyleSheet.c_str())); } diff --git a/src/ModuleBase/ModuleBase_WidgetUndoLabel.cpp b/src/ModuleBase/ModuleBase_WidgetUndoLabel.cpp new file mode 100644 index 000000000..3f5a35bfa --- /dev/null +++ b/src/ModuleBase/ModuleBase_WidgetUndoLabel.cpp @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library 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. +// +// 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "ModuleBase_WidgetUndoLabel.h" +#include "ModuleBase_IWorkshop.h" + +#include +#include +#include +#include + +ModuleBase_WidgetUndoLabel::ModuleBase_WidgetUndoLabel(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData) + : ModuleBase_WidgetLabel(theParent, theData), + myWorkshop(theWorkshop) +{ + myUndoBtn = new QPushButton(tr("Undo"), this); + myUndoBtn->hide(); + layout()->addWidget(myUndoBtn); + connect(myUndoBtn, SIGNAL(clicked(bool)), SLOT(onUndo())); +} + + +bool ModuleBase_WidgetUndoLabel::restoreValueCustom() +{ + bool aRes = ModuleBase_WidgetLabel::restoreValueCustom(); + bool aError = myLabel->text().length() > 0; + myUndoBtn->setVisible(aError); + myWorkshop->setCancelEnabled(!aError); + return aRes; +} + + +void ModuleBase_WidgetUndoLabel::onUndo() +{ + myWorkshop->undo(); +} \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_WidgetUndoLabel.h b/src/ModuleBase/ModuleBase_WidgetUndoLabel.h new file mode 100644 index 000000000..efa46ee6a --- /dev/null +++ b/src/ModuleBase/ModuleBase_WidgetUndoLabel.h @@ -0,0 +1,55 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library 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. +// +// 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef ModuleBase_WidgetUndoLabel_H +#define ModuleBase_WidgetUndoLabel_H + +#include "ModuleBase.h" +#include "ModuleBase_WidgetLabel.h" + +class QPushButton; +class ModuleBase_IWorkshop; + +/** +* \ingroup GUI +* Implementation of model widget for a label control +*/ +class MODULEBASE_EXPORT ModuleBase_WidgetUndoLabel : public ModuleBase_WidgetLabel +{ + Q_OBJECT +public: + /// Constructor + /// \param theParent the parent object + /// \param theData the widget configuation. The attribute of the model widget is obtained from + ModuleBase_WidgetUndoLabel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData); + + virtual ~ModuleBase_WidgetUndoLabel() {} + + virtual bool restoreValueCustom(); + +private slots: + void onUndo(); + +private: + ModuleBase_IWorkshop* myWorkshop; + QPushButton* myUndoBtn; +}; + +#endif \ No newline at end of file diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 39f2a2b80..fa1b2ad66 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -25,8 +25,7 @@ - -