diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonSequentialFitDialog.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonSequentialFitDialog.h index e920d1c7be39..3c188706d007 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonSequentialFitDialog.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonSequentialFitDialog.h @@ -45,11 +45,19 @@ namespace MantidWidgets virtual ~MuonSequentialFitDialog(); private: + enum ControlButtonType { + Start, + Stop + }; + // -- FUNCTIONS ----------------------------------------------------------- /// Check if all the input field are valid bool isInputValid(); + /// Set the type of the control button + void setControlButtonType(ControlButtonType type); + // -- VARIABLES ----------------------------------------------------------- /// UI form @@ -70,6 +78,11 @@ namespace MantidWidgets /// Enables/disables start button depending on wether we are allowed to start void updateControlButtonState(); + /// Start fitting process + void startFit(); + + /// Stop fitting process + void stopFit(); }; diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/MuonSequentialFitDialog.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/MuonSequentialFitDialog.cpp index 24e44434d944..ed86f79038c8 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/MuonSequentialFitDialog.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/MuonSequentialFitDialog.cpp @@ -14,11 +14,12 @@ namespace MantidWidgets * Constructor */ MuonSequentialFitDialog::MuonSequentialFitDialog(QWidget* parent) : - QDialog(parent) + QDialog(parent) { m_ui.setupUi(this); // TODO: set initial values + setControlButtonType(Start); // After initial values are set, update depending elements accordingly. We don't rely on // slot/signal update, as element might be left with default values which means these will @@ -84,6 +85,43 @@ namespace MantidWidgets m_ui.controlButton->setEnabled( isInputValid() ); } + /** + * Set the type of the control button. It is Start button when fitting has not been started, + * and Stop button when fitting is running. + * @param type :: New type of the button + */ + void MuonSequentialFitDialog::setControlButtonType(ControlButtonType type) + { + // Disconnect everything connected to pressed() signal of the button + disconnect( m_ui.controlButton, SIGNAL( pressed() ), 0, 0); + + // Connect to appropriate slot + auto buttonSlot = (type == Start) ? SLOT( startFit() ) : SLOT( stopFit() ); + connect( m_ui.controlButton, SIGNAL( pressed() ), this, buttonSlot ); + + // Set appropriate text + QString buttonText = (type == Start) ? "Start" : "Stop"; + m_ui.controlButton->setText(buttonText); + } + + /** + * Start fitting process. + */ + void MuonSequentialFitDialog::startFit() + { + g_log.notice("Seq. fitting started"); + setControlButtonType(Stop); + } + + /** + * Stop fitting process. + */ + void MuonSequentialFitDialog::stopFit() + { + g_log.notice("Seq. fitting stopped"); + setControlButtonType(Start); + } + /** * Destructor */