Skip to content

Commit

Permalink
added disableSaveNexus to keep File->Save in sync, re #1109
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed Nov 20, 2014
1 parent 70d620a commit 852108c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
12 changes: 10 additions & 2 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Expand Up @@ -17592,11 +17592,19 @@ void ApplicationWindow::savedatainNexusFormat(const std::string& wsName,const st
{
}
}
void ApplicationWindow::enablesaveNexus(const QString &wsName)

void ApplicationWindow::enableSaveNexus(const QString &wsName)
{
if(actionSaveFile) actionSaveFile->setEnabled(true);
if (actionSaveFile) actionSaveFile->setEnabled(true);
m_nexusInputWSName=wsName;
}

void ApplicationWindow::disableSaveNexus()
{
if (actionSaveFile)
actionSaveFile->setEnabled(false);
}

/* For zooming the selected graph using the drag canvas tool and mouse drag.
*/
void ApplicationWindow::panOnPlot()
Expand Down
5 changes: 4 additions & 1 deletion Code/Mantid/MantidPlot/src/ApplicationWindow.h
Expand Up @@ -206,7 +206,10 @@ class ApplicationWindow: public QMainWindow, public Scripted
QString endOfLine();
bool autoUpdateTableValues(){return d_auto_update_table_values;};
void setAutoUpdateTableValues(bool on = true);
void enablesaveNexus(const QString& wsName);
// enables File->Save->Nexus action in the main menu and sets the parameter wsName as input workspace for save alg.
void enableSaveNexus(const QString& wsName);
// disables File->Save-Nexus action in the main menu. Useful when de-selecting workspaces
void disableSaveNexus();

public slots:
//! \name Projects and Project Files
Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/MantidPlot/src/Mantid/MantidDock.cpp
Expand Up @@ -1371,6 +1371,16 @@ void MantidDockWidget::treeSelectionChanged()

if(m_saveButton)
m_saveButton->setEnabled(Items.size() > 0);

if (Items.size() > 0)
{
auto item = *(Items.begin());
m_mantidUI->enableSaveNexus(item->text(0));
}
else
{
m_mantidUI->disableSaveNexus();
}
}

/**
Expand Down
14 changes: 12 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Expand Up @@ -1412,7 +1412,10 @@ void MantidUI::executeSaveNexus()
{
QString wsName = getSelectedWorkspaceName();
QHash<QString,QString> presets;
presets["InputWorkspace"] = wsName;
if (!wsName.isEmpty())
{
presets["InputWorkspace"] = wsName;
}
showAlgorithmDialog("SaveNexus", presets);
}

Expand Down Expand Up @@ -2118,11 +2121,18 @@ void MantidUI::saveProject(bool saved)
}
Mantid::API::FrameworkManager::Instance().clear();
}

void MantidUI::enableSaveNexus(const QString& wsName)
{
appWindow()->enablesaveNexus(wsName);
appWindow()->enableSaveNexus(wsName);
}

void MantidUI::disableSaveNexus()
{
appWindow()->disableSaveNexus();
}


/** This method is sueful for saving the currently loaded workspaces to project file on save.
* saves the names of all the workspaces loaded into mantid workspace tree
* into a string and calls save nexus on each workspace to save the data to a nexus file.
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.h
Expand Up @@ -299,6 +299,7 @@ class MantidUI:public QObject

void saveProject(bool save);
void enableSaveNexus(const QString & wsName);
void disableSaveNexus();

signals:
//A signal to indicate that we want a script to produce a dialog
Expand Down

0 comments on commit 852108c

Please sign in to comment.