Skip to content

Commit

Permalink
re #10715 Added correct setting and saving of instrument and facility.
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDraper committed Dec 9, 2014
1 parent 46c12f0 commit 0933059
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
16 changes: 13 additions & 3 deletions Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.cpp
Expand Up @@ -27,9 +27,8 @@ void FirstTimeSetup::initLayout()

connect(m_uiForm.pbConfirm, SIGNAL(clicked()), this, SLOT(confirm()));
connect(m_uiForm.pbCancel, SIGNAL(clicked()), this, SLOT(cancel()));
connect(m_uiForm.cbFacility, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(facilitySelected(const QString &)));
connect(m_uiForm.pbMUD, SIGNAL(clicked()), this, SLOT(openManageUserDirectories()));

connect(m_uiForm.pbMUD, SIGNAL(clicked()), this, SLOT(openManageUserDirectories()));
connect(m_uiForm.clbReleaseNotes, SIGNAL(clicked()), this, SLOT(openReleaseNotes()));
connect(m_uiForm.clbSampleDatasets, SIGNAL(clicked()), this, SLOT(openSampleDatasets()));
connect(m_uiForm.clbMantidIntroduction, SIGNAL(clicked()), this, SLOT(openMantidIntroduction()));
Expand All @@ -50,6 +49,17 @@ void FirstTimeSetup::initLayout()
{
m_uiForm.cbFacility->addItem(QString::fromStdString(*it));
}

Mantid::Kernel::ConfigServiceImpl& config = Mantid::Kernel::ConfigService::Instance();
std::string facility = config.getString("default.facility", true);
m_uiForm.cbFacility->setCurrentIndex(m_uiForm.cbFacility->findText(
QString::fromStdString(facility)));

std::string instrument = config.getString("default.instrument", true);
m_uiForm.cbInstrument->updateInstrumentOnSelection(false);
m_uiForm.cbInstrument->setCurrentIndex(m_uiForm.cbInstrument->findText(
QString::fromStdString(instrument)));
connect(m_uiForm.cbFacility, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(facilitySelected(const QString &)));
}

void FirstTimeSetup::confirm()
Expand Down Expand Up @@ -78,7 +88,7 @@ void FirstTimeSetup::cancel()

void FirstTimeSetup::facilitySelected(const QString & facility)
{
Mantid::Kernel::ConfigService::Instance().setString("default.facility", facility.toStdString());
m_uiForm.cbInstrument->fillWithInstrumentsFromFacility(facility);
}

void FirstTimeSetup::openManageUserDirectories()
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/FirstTimeSetup.ui
Expand Up @@ -488,7 +488,7 @@ color: rgb(0, 0, 0);</string>
<string>Do not show again until next release</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down
Expand Up @@ -64,6 +64,8 @@ namespace MantidQt
QStringList getTechniques() const;
/// Set the list of techniques
void setTechniques(const QStringList & techniques);
/// Sets whether to update the default instrument on selection change
void updateInstrumentOnSelection(const bool storeChanges);

public slots:
/// Update list for a new facility
Expand Down Expand Up @@ -92,6 +94,8 @@ namespace MantidQt
const Mantid::Kernel::FacilityInfo *m_currentFacility;
/// Should the object be initialized
bool m_init;
/// should the default instrument be changed when the selection changes
bool m_storeChanges;
};

}
Expand Down
14 changes: 12 additions & 2 deletions Code/Mantid/MantidQt/MantidWidgets/src/InstrumentSelector.cpp
Expand Up @@ -31,7 +31,7 @@ namespace MantidWidgets
*/
InstrumentSelector::InstrumentSelector(QWidget *parent, bool init)
: QComboBox(parent), m_changeObserver(*this, &InstrumentSelector::handleConfigChange),
m_techniques(), m_currentFacility(NULL), m_init(init)
m_techniques(), m_currentFacility(NULL), m_init(init),m_storeChanges(true)
{
setEditable(false);
if( init )
Expand Down Expand Up @@ -171,6 +171,16 @@ namespace MantidWidgets
this->blockSignals(false);
}

/**
* Sets whether to update the default instrument on selection change
* @param storeChanges :: True = store change on selection change
*/
void InstrumentSelector::updateInstrumentOnSelection(const bool storeChanges)
{
m_storeChanges = storeChanges;
}


//------------------------------------------------------
// Private slot member functions
//------------------------------------------------------
Expand All @@ -180,7 +190,7 @@ namespace MantidWidgets
*/
void InstrumentSelector::updateDefaultInstrument(const QString & name) const
{
if( !name.isEmpty() )
if( !name.isEmpty() && m_storeChanges)
{
ConfigService::Instance().setString("default.instrument", name.toStdString());
}
Expand Down

0 comments on commit 0933059

Please sign in to comment.