Browse Source

Merge topic 'workflow_widget'

  ENH: WorkflowWidget - ContentMargins associated with clientArea and stepArea are set to zero
  STYLE: WorkflowWidget - Remove extra call to updateButtons in ctkWorkflowButtonBoxWidget
  ENH: WorkflowWidget - Add ButtonBoxHint::ButtonBoxHidden to ctkWorkflowStep
Jean-Christophe Fillion-Robin 15 years ago
parent
commit
9780c2e007

+ 0 - 1
Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp

@@ -330,7 +330,6 @@ void ctkWorkflowButtonBoxWidget::setNextButtonDefaultText(const QString& default
 {
   CTK_D(ctkWorkflowButtonBoxWidget);
   d->NextButtonDefaultText = defaultText;
-  this->updateButtons();
   if (d->Workflow)
     {
     this->updateButtons();

+ 19 - 10
Libs/Widgets/ctkWorkflowWidget.cpp

@@ -64,12 +64,12 @@ public:
   QWidget* errorSection;
   QWidget* buttonSection;
 
-  QLabel* titleLabel;
-  QLabel* subTitleLabel;
-  QLabel* preTextLabel;
+  QLabel*  titleLabel;
+  QLabel*  subTitleLabel;
+  QLabel*  preTextLabel;
   QWidget* clientArea;
-  QLabel* postTextLabel;
-  QLabel* errorLabel;
+  QLabel*  postTextLabel;
+  QLabel*  errorLabel;
 
   // orientation for layout of this widget, and of the client area
   // (for use with QBoxLayout only)
@@ -136,6 +136,7 @@ ctkWorkflowWidget::ctkWorkflowWidget(QWidget* _parent) : Superclass(_parent)
 
   // layout components vertically by default
   QBoxLayout* layout = new QBoxLayout(d->direction);
+  layout->setContentsMargins(0, 0, 0, 0);
   this->setLayout(layout);
   layout->addWidget(d->titleSection);
   layout->addWidget(d->subTitleSection);
@@ -240,6 +241,7 @@ QWidget* ctkWorkflowWidget::clientArea()
     if (!d->clientSection->layout())
       {
       d->clientSection->setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
+      d->clientSection->layout()->setContentsMargins(0, 0, 0, 0);
       }
     d->clientSection->layout()->addWidget(d->clientArea);
     }
@@ -260,6 +262,7 @@ void ctkWorkflowWidget::addWidget(QWidget* widget)
     if (!clientArea->layout())
       {
       clientArea->setLayout(new QBoxLayout(d->clientAreaDirection));
+      clientArea->layout()->setContentsMargins(0, 0, 0, 0);
       }
 
     clientArea->layout()->addWidget(widget);
@@ -275,8 +278,6 @@ void ctkWorkflowWidget::updateClientArea(ctkWorkflowStep* currentStep)
   // to normal, for the next time
   CTK_D(ctkWorkflowWidget);
 
-  //ctkWorkflowStep* currentStep = d->workflow->currentStep();
-
   if (currentStep)
     {
     d->stepShownPreviously = d->stepShownCurrently;
@@ -297,11 +298,12 @@ void ctkWorkflowWidget::updateClientArea(ctkWorkflowStep* currentStep)
           }
         }
       }
+    ctkWorkflowWidgetStep* currentWidgetStep = qobject_cast<ctkWorkflowWidgetStep*>(currentStep);
     // show/enable the current step
-    if (ctkWorkflowWidgetStep* step = qobject_cast<ctkWorkflowWidgetStep*>(currentStep))
+    if (currentWidgetStep)
       {
-      step->showUserInterface();
-      if (QWidget* stepArea = step->stepArea())
+      currentWidgetStep->showUserInterface();
+      if (QWidget* stepArea = currentWidgetStep->stepArea())
         {
         // add the step's client area to the widget if we haven't before
         if (!this->isAncestorOf(stepArea))
@@ -317,6 +319,13 @@ void ctkWorkflowWidget::updateClientArea(ctkWorkflowStep* currentStep)
     // update the button box widget if we have one
     if (d->buttonBoxWidget)
       {
+      // Hide button bar if specified by the steps
+      bool hideButtonBar = false;
+      if(currentWidgetStep)
+        {
+        hideButtonBar = currentWidgetStep->buttonBoxHints() & ctkWorkflowWidgetStep::ButtonBoxHidden;
+        }
+      d->buttonBoxWidget->setHidden(hideButtonBar);
       d->buttonBoxWidget->updateButtons();
       }
     }

+ 2 - 1
Libs/Widgets/ctkWorkflowWidgetStep.h

@@ -67,7 +67,8 @@ public:
     BackButtonHidden = 0x1,
     BackButtonDisabled = 0x2,
     NextButtonHidden = 0x4,
-    NextButtonDisabled = 0x8
+    NextButtonDisabled = 0x8,
+    ButtonBoxHidden = 0x10
   };
   Q_DECLARE_FLAGS(ButtonBoxHints, ButtonBoxHint)