// 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";
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";
ModuleBase_WidgetSelectionFilter.h
ModuleBase_IStepPrs.h
ModuleBase_SelectionFilterType.h
+ ModuleBase_WidgetUndoLabel.h
)
SET(PROJECT_MOC_HEADERS
ModuleBase_WidgetRadiobox.h
ModuleBase_WidgetPointInput.h
ModuleBase_WidgetSelectionFilter.h
+ ModuleBase_WidgetUndoLabel.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetPointInput.cpp
ModuleBase_WidgetSelectionFilter.cpp
ModuleBase_IStepPrs.cpp
+ ModuleBase_WidgetUndoLabel.cpp
)
SET(TEXT_RESOURCES
//! \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();
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetConcealedObjects.h>
#include <ModuleBase_WidgetLabel.h>
+#include <ModuleBase_WidgetUndoLabel.h>
#include <ModuleBase_WidgetToolbox.h>
#include <ModuleBase_WidgetRadiobox.h>
#include <ModuleBase_PageBase.h>
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) {
: 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()) {
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()));
}
--- /dev/null
+// 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 <QPushButton>
+#include <QLayout>
+#include <QString>
+#include <QLabel>
+
+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
--- /dev/null
+// 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
<sketch-start-label id="External" geometrical_selection="true" title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch">
<validator id="GeomValidators_Face" parameters="plane"/>
</sketch-start-label>
- <!-- <label id="SolverDOF"/> -->
- <label id="SolverError" styleSheet="color : red; font : bold"/>
+ <undo_label id="SolverError" isHTML="true" />
<validator id="SketchPlugin_SolverErrorValidator"/>
</feature>
/// The value parameter for the constraint
inline static const std::string& CONSTRAINTS()
{
- static const std::string MY_ERROR_VALUE("The constraint is conflicting with others. "
- "To fix this, you can either undo your operation or remove a conflicting constraint.");
+ static const std::string MY_ERROR_VALUE("<b>The constraint is conflicting with others. "
+ "To fix this, you can either <font color='red'>undo (Ctrl+Z)</font> your operation or "
+ "<font color='red'>remove</font> a conflicting constraint.</b>");
return MY_ERROR_VALUE;
}
/// Cyclic dependency of copied features with their originals
inline static const std::string& INFINITE_LOOP()
{
static const std::string MY_ERROR_VALUE(
- "There is a circular reference between copied sketch entities and their originals. "
- "To fix this, you can either undo your operation or remove wrong constraint.");
+ "<b>There is a circular reference between copied sketch entities and their originals. "
+ "To fix this, you can either <font color='red'>undo (Ctrl+Z)</font> your operation or "
+ "<font color='red'>remove</font> wrong constraint.</b>");
return MY_ERROR_VALUE;
}
/// Constraints should use objects instead of features as attributes
{
Handle(AIS_InteractiveObject) anIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
myWorkshop->selectionActivate()->activate(anIO, false);
-}
\ No newline at end of file
+}
+
+
+void XGUI_ModuleConnector::undo()
+{
+ myWorkshop->onUndo();
+}
+
+void XGUI_ModuleConnector::setCancelEnabled(bool toEnable)
+{
+ XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+ QAction* aAbortAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll);
+ QAction* aAbortAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort);
+ if (aAbortAction) {
+ aAbortAction->setEnabled(toEnable);
+ }
+ if (aAbortAllAction) {
+ aAbortAllAction->setEnabled(toEnable);
+ }
+}
+
+bool XGUI_ModuleConnector::isCancelEnabled() const
+{
+ XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+ QAction* aAbortAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll);
+ QAction* aAbortAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort);
+ bool isEnabled = false;
+ if (aAbortAction) {
+ isEnabled = true;
+ }
+ if (aAbortAllAction) {
+ isEnabled &= true;
+ }
+ return isEnabled;
+}
//! \param theAIS the object which has to be activated
virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS);
+ //! Undo last command
+ virtual void undo();
+
+ //! Set enabled state of cancel button in property panel
+ virtual void setCancelEnabled(bool toEnable);
+
+ //! Returns current state of cancel button
+ virtual bool isCancelEnabled() const;
+
private:
QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;