Skip to content

Commit

Permalink
Re #8637. Add a text label that can be used to report status.
Browse files Browse the repository at this point in the history
And add reporting of what operation the interface is undertaking where
it might take a noticeable amount of time.
  • Loading branch information
RussellTaylor committed Jan 31, 2014
1 parent de9205b commit 3a794e0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
Expand Up @@ -176,6 +176,16 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusText">
<property name="text">
<string notr="true"/>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
Expand Down
57 changes: 41 additions & 16 deletions Code/Mantid/MantidQt/CustomInterfaces/src/StepScan.cpp
Expand Up @@ -196,6 +196,8 @@ void StepScan::loadFile(bool async)
return;
}

m_uiForm.statusText->setText("<i><font color='darkblue'>Loading data...</font></i>");

if ( async )
{
connect(m_algRunner, SIGNAL(algorithmComplete(bool)), SLOT(loadFileComplete(bool)));
Expand All @@ -211,6 +213,7 @@ void StepScan::loadFile(bool async)

void StepScan::loadFileComplete(bool error)
{
m_uiForm.statusText->clear();
disconnect(m_algRunner, SIGNAL(algorithmComplete(bool)), this, SLOT(loadFileComplete(bool)));

if ( m_inputWSName == "__multifiles" && !error ) error = mergeRuns();
Expand All @@ -225,29 +228,50 @@ void StepScan::loadFileComplete(bool error)
}
}

// Small class to handle disabling mouse clicks and showing the busy cursor in an RAII manner.
// Used in the runStepScanAlg below to ensure these things are unset when the method is exited.
class DisableGUI_RAII
{
public:
DisableGUI_RAII(StepScan * gui) : the_gui(gui)
namespace {
class ScopedStatusText
{
QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
the_gui->setAttribute( Qt::WA_TransparentForMouseEvents );
}
public:
ScopedStatusText(QLabel * label, QString labelText) : status_label(label)
{
status_label->setText("<i><font color='darkblue'>" + labelText + "</font></i>");
}

~ScopedStatusText()
{
status_label->clear();
}

private:
QLabel * const status_label;
};

~DisableGUI_RAII()

// Small class to handle disabling mouse clicks and showing the busy cursor in an RAII manner.
// Used in the runStepScanAlg below to ensure these things are unset when the method is exited.
class DisableGUI_RAII
{
QApplication::restoreOverrideCursor();
the_gui->setAttribute( Qt::WA_TransparentForMouseEvents, false );
}
public:
DisableGUI_RAII(StepScan * gui) : the_gui(gui)
{
QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
the_gui->setAttribute( Qt::WA_TransparentForMouseEvents );
}

private:
StepScan * const the_gui;
};
~DisableGUI_RAII()
{
QApplication::restoreOverrideCursor();
the_gui->setAttribute( Qt::WA_TransparentForMouseEvents, false );
}

private:
StepScan * const the_gui;
};
}

bool StepScan::mergeRuns()
{
ScopedStatusText _merging(this->m_uiForm.statusText,"Merging runs...");
// This can be slow and will lock the GUI, but will probably be so rarely used that it's
// not worth making it asynchronous
// Block mouse clicks while the algorithm runs. Also set the busy cursor.
Expand Down Expand Up @@ -459,6 +483,7 @@ void StepScan::runStepScanAlg()
loadFile(false);
}
stepScan->setPropertyValue("InputWorkspace", m_inputWSName);
ScopedStatusText _merging(this->m_uiForm.statusText,"Analyzing scan...");
algSuccessful = stepScan->execute();
}

Expand Down

0 comments on commit 3a794e0

Please sign in to comment.