Skip to content

Commit

Permalink
ftr: allow user to load settings
Browse files Browse the repository at this point in the history
- add 'load settings' option in Menu bar

- update UI with the newly loaded settings
  • Loading branch information
rish9511 committed Dec 14, 2017
1 parent 55b96d6 commit 3dc97b4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/mzroll/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Controller::Controller()
updateUi();
connect(mw->peakDetectionDialog, &PeakDetectionDialog::updateSettings, this, &Controller::updatePeakDetectionSettings);
connect(mw->settingsForm, &SettingsForm::updateSettings,this,&Controller::updateOptionsDialogSettings);
connect(mw, &MainWindow::loadedSettings, this, &Controller::updateUi);
}


Expand Down
31 changes: 31 additions & 0 deletions src/gui/mzroll/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,9 @@ void MainWindow::createMenus() {
connect(saveSettings, &QAction::triggered, this ,&MainWindow::saveSettings);
fileMenu->addAction(saveSettings);

QAction* loadSettings = new QAction("Load Settings", this);
connect(loadSettings, &QAction::triggered, this ,&MainWindow::loadSettings);
fileMenu->addAction(loadSettings);

QAction* settingsAct = new QAction(tr("Options"), this);
settingsAct->setToolTip(tr("Set program options"));
Expand Down Expand Up @@ -2489,6 +2492,34 @@ void MainWindow::saveSettings()

}

void MainWindow::loadSettings()
{
bool fileLoaded = false;
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, "Load Settings", QString());

QFile file(fileName);

if(file.open(QIODevice::ReadOnly)) {

QByteArray bArr = file.readAll();
file.close();

if(mavenParameters->loadSettings(bArr.data()))
fileLoaded = true;

}

if(fileLoaded)
emit loadedSettings();

else {
// display an error message
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
msgBox.setText("Loading the file failed");
msgBox.exec();
}
}
void MainWindow::showButtonLog() {
QObject* obj = sender();
LOGD << obj->objectName().toStdString();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/mzroll/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ Q_OBJECT
void undoAlignment(QList<PeakGroup>);
void reBoot();
void metaCsvFileLoaded();
void loadedSettings();

protected:
void closeEvent(QCloseEvent *event);
Expand Down Expand Up @@ -383,6 +384,7 @@ public Q_SLOTS:
QWidget* eicWidgetController();
QWidget* pathwayWidgetController();
void saveSettings();
void loadSettings();

private Q_SLOTS:
void createMenus();
Expand Down

0 comments on commit 3dc97b4

Please sign in to comment.