Skip to content

Commit

Permalink
Merge pull request #23886 from mantidproject/23885_ProjectRecoveryAdd…
Browse files Browse the repository at this point in the history
…ingToOptions

Project Recovery: Adding project recovery preferences
  • Loading branch information
Antti Soininen committed Nov 19, 2018
2 parents 8c2b370 + 38e838d commit d289e75
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
73 changes: 73 additions & 0 deletions MantidPlot/src/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ Description : Preferences dialog
using namespace MantidQt::API;
using Mantid::Kernel::ConfigService;

namespace {
Mantid::Kernel::Logger g_log("ConfigDialog");
}

ConfigDialog::ConfigDialog(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl) {
// get current values from app window
Expand Down Expand Up @@ -734,6 +738,61 @@ void ConfigDialog::initMantidPage() {
initCurveFittingTab();
initSendToProgramTab();
initMantidOptionsTab();
initProjectRecoveryTab();
}

void ConfigDialog::initProjectRecoveryTab() {
projectRecovery = new QWidget();
QVBoxLayout *projRecLayout = new QVBoxLayout(projectRecovery);
QGroupBox *frame = new QGroupBox();
projRecLayout->addWidget(frame);
QGridLayout *grid = new QGridLayout(frame);
mtdTabWidget->addTab(projectRecovery, "Project Recovery");

ckEnableProjectRecovery = new QCheckBox("Enable Project Recovery");
ckEnableProjectRecovery->setChecked(
ConfigService::Instance().getString("projectRecovery.enabled") == "true");
ckEnableProjectRecovery->setToolTip(
"Requires a restart of mantid to take effect");
grid->addWidget(ckEnableProjectRecovery, 0, 0);

lblTimeBetweenCheckpoints = new QLabel("Time between recovery checkpoints");
lblTimeBetweenCheckpoints->setToolTip(
"Requires a restart of mantid to take effect");
grid->addWidget(lblTimeBetweenCheckpoints, 1, 0);
boxTimeBetweenCheckpoints = new QSpinBox();
boxTimeBetweenCheckpoints->setRange(1, 1000);
boxTimeBetweenCheckpoints->setSingleStep(1);
auto secondsBetween = 60;
try {
secondsBetween = std::stoi(
ConfigService::Instance().getString("projectRecovery.secondsBetween"));
} catch (...) {
g_log.warning("projectRecovery.secondsBetween is set to a none number "
"value in the properties file");
}
boxTimeBetweenCheckpoints->setValue(secondsBetween);
boxTimeBetweenCheckpoints->setToolTip(
"Requires a restart of mantid to take effect");
grid->addWidget(boxTimeBetweenCheckpoints, 1, 1);

lblNumCheckpoints = new QLabel("Total number of checkpoints to be made");
lblNumCheckpoints->setToolTip("Requires a restart of mantid to take effect");
grid->addWidget(lblNumCheckpoints, 2, 0);
boxNumCheckpoint = new QSpinBox();
boxNumCheckpoint->setRange(1, 10);
boxNumCheckpoint->setSingleStep(1);
auto numCheckpoint = 5;
try {
numCheckpoint = std::stoi(ConfigService::Instance().getString(
"projectRecovery.numberOfCheckpoints"));
} catch (...) {
g_log.warning("projectRecovery.numberOfCheckpoints is set to a none number "
"value in the properties file");
}
boxNumCheckpoint->setValue(numCheckpoint);
boxNumCheckpoint->setToolTip("Requires a restart of mantid to take effect");
grid->addWidget(boxNumCheckpoint, 2, 1);
}

/**
Expand Down Expand Up @@ -2683,6 +2742,7 @@ void ConfigDialog::apply() {
updateDirSearchSettings();
updateCurveFitSettings();
updateMantidOptionsTab();
updateProjectRecovery();
updateSendToTab();

try {
Expand All @@ -2698,6 +2758,19 @@ void ConfigDialog::apply() {
emit app->configModified();
}

void ConfigDialog::updateProjectRecovery() {
auto &cfgSvc = Mantid::Kernel::ConfigService::Instance();
if (ckEnableProjectRecovery->isChecked()) {
cfgSvc.setString("projectRecovery.enabled", "true");
} else {
cfgSvc.setString("projectRecovery.enabled", "false");
}
cfgSvc.setString("projectRecovery.secondsBetween",
std::to_string(boxTimeBetweenCheckpoints->value()));
cfgSvc.setString("projectRecovery.numberOfCheckpoints",
std::to_string(boxNumCheckpoint->value()));
}

/**
* Update the MD Plotting settings
*/
Expand Down
10 changes: 10 additions & 0 deletions MantidPlot/src/ConfigDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ private slots:
void initMantidPage();
void initDirSearchTab();
void initCurveFittingTab();
void initProjectRecoveryTab();
void updateProjectRecovery();

void initCurvesPage();
void initPlots3DPage();
Expand Down Expand Up @@ -229,6 +231,14 @@ private slots:
QCheckBox *m_sendToPrograms;
QTreeWidget *treeCategories;
QTreeWidget *treePrograms;
/// mantid project recovery pahe
QWidget *projectRecovery;
QLabel *lblWarningToRestartProjRec;
QCheckBox *ckEnableProjectRecovery;
QLabel *lblTimeBetweenCheckpoints;
QSpinBox *boxTimeBetweenCheckpoints;
QLabel *lblNumCheckpoints;
QSpinBox *boxNumCheckpoint;

// MDPlotting
QTabWidget *mdPlottingTabWidget;
Expand Down
1 change: 1 addition & 0 deletions docs/source/release/v3.14.0/ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ New

- Project Recovery can now make a recovery checkpoint on command using mantidplot.app.saveRecoveryCheckpoint() in either the interpreter or script windows in python
- Project Recovery now adds a lock file at the start of saving so if MantidPlot crashes when saving it will no longer use that checkpoint as it is incomplete.
- Project Recovery now has the ability to be changed from inside of MantidPlot without using the config files directly, this can be found in view->preferences->mantid->projectrecovery


Changes
Expand Down

0 comments on commit d289e75

Please sign in to comment.