Browse Source

Add ctkWorkflowButtonBoxWidget::HideGoToButtons

Give the option to hide the "Finish" button
Julien Finet 12 years ago
parent
commit
99ca3fcc53

+ 5 - 0
Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp

@@ -63,6 +63,7 @@ public:
   // Direction for layout (for use with QBoxLayout only)
   QBoxLayout::Direction Direction;
 
+  bool HideGoToButtons;
   bool HideInvalidButtons;
 
   // Functions to add/remove buttons
@@ -84,6 +85,7 @@ ctkWorkflowButtonBoxWidgetPrivate::ctkWorkflowButtonBoxWidgetPrivate(ctkWorkflow
   this->NextButton = 0;
   this->NextButtonDefaultText = "Next";
   this->Direction = QBoxLayout::LeftToRight;
+  this->HideGoToButtons = false;
   this->HideInvalidButtons = false;
 }
 
@@ -243,6 +245,7 @@ void ctkWorkflowButtonBoxWidgetPrivate::updateGoToButtons(ctkWorkflowStep* curre
     bool enable = currentStep && this->Workflow->canGoToStep(goToStep->id(), currentStep);
     bool visible = step ? !(step->buttonBoxHints() & ctkWorkflowWidgetStep::ButtonBoxHidden) : true;
     if ((!enable && this->HideInvalidButtons)
+        || this->HideGoToButtons
         )
       {
       visible = false;
@@ -337,6 +340,8 @@ void ctkWorkflowButtonBoxWidget::setNextButtonDefaultText(const QString& default
 CTK_GET_CPP(ctkWorkflowButtonBoxWidget, ctkWorkflow*, workflow, Workflow);
 CTK_GET_CPP(ctkWorkflowButtonBoxWidget, QPushButton*, backButton, BackButton);
 CTK_GET_CPP(ctkWorkflowButtonBoxWidget, QBoxLayout::Direction, direction, Direction);
+CTK_GET_CPP(ctkWorkflowButtonBoxWidget, bool, hideGoToButtons, HideGoToButtons);
+CTK_SET_CPP(ctkWorkflowButtonBoxWidget, bool, setHideGoToButtons, HideGoToButtons);
 CTK_GET_CPP(ctkWorkflowButtonBoxWidget, bool, hideInvalidButtons, HideInvalidButtons);
 CTK_SET_CPP(ctkWorkflowButtonBoxWidget, bool, setHideInvalidButtons, HideInvalidButtons);
 

+ 12 - 0
Libs/Widgets/ctkWorkflowButtonBoxWidget.h

@@ -64,6 +64,11 @@ class CTK_WIDGETS_EXPORT ctkWorkflowButtonBoxWidget : public QWidget
   Q_PROPERTY(QString nextButtonDefaultText
              READ nextButtonDefaultText WRITE setNextButtonDefaultText)
 
+  /// This property controls whether the goTo buttons are visible or hidden.
+  /// False (visible) by default.
+  /// \sa hideInvalidButtons
+  Q_PROPERTY(bool hideGoToButtons READ hideGoToButtons WRITE setHideGoToButtons)
+
   /// This property controls whether the back, next or goTo buttons are hidden when disabled.
   /// Note that buttons can also be hidden via ctkWorkflowWidgetStep::buttonHints.
   /// \sa ctkWofklowWidgetStep::buttonBoxHints
@@ -109,6 +114,13 @@ public:
   QBoxLayout::Direction direction()const;
   void setDirection(const QBoxLayout::Direction& newDirection);
 
+  /// Return the hideGoToButtons property value.
+  /// \sa hideGoToButtons
+  bool hideGoToButtons()const;
+  /// Set the hideGoToButtons property value.
+  /// \sa hideGoToButtons
+  void setHideGoToButtons(bool hide);
+
   /// If true, invalid buttons are hidden.  If false, invalid buttons are shown but disabled.
   /// Default is false.
   bool hideInvalidButtons()const;