Skip to content

Commit

Permalink
Made the load button optional.
Browse files Browse the repository at this point in the history
This should make the widget more applicable to a wider
number of interfaces.

Refs #7681
  • Loading branch information
Samuel Jackson committed Aug 15, 2013
1 parent 99c8c1a commit a88bba0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@
<string>_sqw.nxs</string>
</stringlist>
</property>
<property name="showLoad">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace MantidQt
Q_PROPERTY(QString loadLabelText READ getLoadBtnText WRITE setLoadBtnText)
Q_PROPERTY(QStringList workspaceSuffixes READ getWSSuffixes WRITE setWSSuffixes)
Q_PROPERTY(QStringList fileBrowserSuffixes READ getFBSuffixes WRITE setFBSuffixes)
Q_PROPERTY(bool showLoad READ willShowLoad WRITE setShowLoad)

public:
DataSelector(QWidget *parent = 0);
Expand Down Expand Up @@ -79,6 +80,10 @@ namespace MantidQt
void readSettings(const QString & group);
/// Save settings in the given group
void saveSettings(const QString & group);
/// Check if the widget will show the load button
bool willShowLoad();
/// Set if the load button should be shown
void setShowLoad(bool load);

signals:
/// Signal emitted when files were found but widget isn't autoloading
Expand Down Expand Up @@ -109,8 +114,10 @@ namespace MantidQt
Ui::DataSelector m_uiForm;
/// Algorithm Runner used to run the load algorithm
MantidQt::API::AlgorithmRunner m_algRunner;
/// Flag to enable auto loading. By Default this is set to true.
/// Flag to enable auto loading. By default this is set to true.
bool m_autoLoad;
/// Flag to show or hide the load button. By default this is set to true.
bool m_showLoad;
};

} /* namespace MantidWidgets */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@
</item>
<item>
<widget class="QPushButton" name="pbLoadFile">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Load</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -92,7 +98,6 @@
</widget>
</item>
</layout>
<zorder>wsWorkspaceInput</zorder>
<zorder>stackedDataSelect</zorder>
<zorder>cbInputType</zorder>
</widget>
Expand Down
26 changes: 25 additions & 1 deletion Code/Mantid/MantidQt/MantidWidgets/src/DataSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MantidQt
{

DataSelector::DataSelector(QWidget *parent)
: API::MantidWidget(parent), m_algRunner(), m_autoLoad(true)
: API::MantidWidget(parent), m_algRunner(), m_autoLoad(true), m_showLoad(true)
{
m_uiForm.setupUi(this);
connect(m_uiForm.cbInputType, SIGNAL(currentIndexChanged(int)), this, SLOT(handleViewChanged(int)));
Expand Down Expand Up @@ -278,5 +278,29 @@ namespace MantidQt
m_uiForm.rfFileInput->saveSettings(group);
}


/**
* Check if the load button will be shown on the interface
*
* @return If the load button will be shown or not
*/
bool DataSelector::willShowLoad()
{
return m_showLoad;
}

/**
* Set if the load button will be shown or not
* This will change if the button widget is visible and enabled.
*
* @param load :: Whether the load button will be shown
*/
void DataSelector::setShowLoad(bool load)
{
m_uiForm.pbLoadFile->setEnabled(load);
m_uiForm.pbLoadFile->setVisible(load);
m_showLoad = load;
}

} /* namespace MantidWidgets */
} /* namespace MantidQt */

0 comments on commit a88bba0

Please sign in to comment.