From ea639b8c7a68ab43dabd8dd216e0493f7cc4a974 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Sat, 23 Feb 2019 23:08:51 +0100
Subject: [PATCH] new dialog box to edit settings

---
 src/CMakeLists.txt                          |  2 +
 src/gui/edit/edit_settings/edit_settings.ui | 73 +++++++++++++++++++++
 src/gui/edit/edit_settings/editsettings.cpp | 49 ++++++++++++++
 src/gui/edit/edit_settings/editsettings.h   | 52 +++++++++++++++
 src/gui/mainwindow.cpp                      |  7 ++
 src/gui/mainwindow.h                        | 14 ++--
 6 files changed, 192 insertions(+), 5 deletions(-)
 create mode 100644 src/gui/edit/edit_settings/edit_settings.ui
 create mode 100644 src/gui/edit/edit_settings/editsettings.cpp
 create mode 100644 src/gui/edit/edit_settings/editsettings.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 54b490bde..c020859ce 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -172,6 +172,7 @@ SET(XTPCPP_SRCS
   ./gui/choose_modification_dialog/choosemodificationdialog.cpp
   ./gui/edit/edit_label_methods/editlabelmethods.cpp
   ./gui/edit/edit_modifications/editmodifications.cpp
+  ./gui/edit/edit_settings/editsettings.cpp
   ./gui/edit/edit_tandem_preset_dialog/edittandempresetdialog.cpp
   ./gui/export/export_masschroq_dialog/exportmasschroqdialog.cpp
   ./gui/export/export_masschroq_dialog/masschroqfileparameters.cpp
@@ -216,6 +217,7 @@ SET (GUI_UIS
   ./gui/choose_modification_dialog/choose_modification_dialog.ui
   ./gui/edit/edit_label_methods/edit_label_methods.ui
   ./gui/edit/edit_modifications/edit_modifications.ui
+  ./gui/edit/edit_settings/edit_settings.ui
   ./gui/edit/edit_tandem_preset_dialog/edit_tandem_preset_dialog.ui
   ./gui/export/export_masschroq_dialog/export_masschroq_dialog.ui
   ./gui/export/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
diff --git a/src/gui/edit/edit_settings/edit_settings.ui b/src/gui/edit/edit_settings/edit_settings.ui
new file mode 100644
index 000000000..8ca058e2c
--- /dev/null
+++ b/src/gui/edit/edit_settings/edit_settings.ui
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditSettingsDialog</class>
+ <widget class="QDialog" name="EditSettingsDialog">
+  <property name="windowModality">
+   <enum>Qt::ApplicationModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>About</string>
+  </property>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>9</x>
+     <y>263</y>
+     <width>166</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Horizontal</enum>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+ </widget>
+ <resources>
+  <include location="../../xtpcpp.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>EditSettingsDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>EditSettingsDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/src/gui/edit/edit_settings/editsettings.cpp b/src/gui/edit/edit_settings/editsettings.cpp
new file mode 100644
index 000000000..a8809f459
--- /dev/null
+++ b/src/gui/edit/edit_settings/editsettings.cpp
@@ -0,0 +1,49 @@
+/**
+ * \file gui/edit/edit_settings/editsettings.cpp
+ * \date 23/2/2019
+ * \author Olivier Langella
+ * \brief dialog box to edit global settings
+ */
+
+/*******************************************************************************
+ * Copyright (c) 2019 Olivier Langella <olivier.langella@u-psud.fr>.
+ *
+ * This file is part of XTPcpp.
+ *
+ *     XTPcpp is free software: you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ *
+ *     XTPcpp is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Contributors:
+ *     Olivier Langella <olivier.langella@u-psud.fr> - initial API and
+ *implementation
+ ******************************************************************************/
+
+#include "editsettings.h"
+#include <QDebug>
+
+#include "ui_edit_settings.h"
+
+EditSettings::EditSettings(QWidget *parent)
+  : QDialog(parent), ui(new Ui::EditSettingsDialog)
+{
+  ui->setupUi(this);
+}
+
+
+EditSettings::~EditSettings()
+{
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+
+  delete ui;
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+}
diff --git a/src/gui/edit/edit_settings/editsettings.h b/src/gui/edit/edit_settings/editsettings.h
new file mode 100644
index 000000000..63dd425ab
--- /dev/null
+++ b/src/gui/edit/edit_settings/editsettings.h
@@ -0,0 +1,52 @@
+/**
+ * \file gui/edit/edit_settings/editsettings.h
+ * \date 23/2/2019
+ * \author Olivier Langella
+ * \brief dialog box to edit global settings
+ */
+
+/*******************************************************************************
+ * Copyright (c) 2019 Olivier Langella <olivier.langella@u-psud.fr>.
+ *
+ * This file is part of XTPcpp.
+ *
+ *     XTPcpp is free software: you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ *
+ *     XTPcpp is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Contributors:
+ *     Olivier Langella <olivier.langella@u-psud.fr> - initial API and
+ *implementation
+ ******************************************************************************/
+
+#pragma once
+
+#include <QDialog>
+
+namespace Ui
+{
+class EditSettingsDialog;
+}
+
+class EditSettings : public QDialog
+{
+  Q_OBJECT
+
+  
+  private:
+  Ui::EditSettingsDialog *ui;
+
+  
+  public:
+  explicit EditSettings(QWidget *parent = 0);
+  ~EditSettings();
+};
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index 620e86e62..26493e67a 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -742,6 +742,13 @@ void
 MainWindow::doActionSettings()
 {
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+  if(_p_edit_settings == nullptr)
+    {
+      _p_edit_settings = new EditSettings(this);
+    }
+  _p_edit_settings->show();
+  _p_edit_settings->raise();
+  _p_edit_settings->activateWindow();
 
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h
index de18b677a..d57cce777 100644
--- a/src/gui/mainwindow.h
+++ b/src/gui/mainwindow.h
@@ -41,12 +41,13 @@
 #include "tandem_run_dialog/tandemrundialog.h"
 #include "core/tandem_run/tandemrunbatch.h"
 #include "utils/httpversion.h"
+#include "gui/edit/edit_settings/editsettings.h"
 #include "gui/export/export_masschroq_dialog/exportmasschroqdialog.h"
 
 
 namespace Ui
 {
-  class Main;
+class Main;
 }
 
 class MainWindow : public QMainWindow
@@ -107,15 +108,17 @@ class MainWindow : public QMainWindow
                              AutomaticFilterParameters param,
                              QStringList file_list);
   void operateWritingXpipFile(QString filename, ProjectSp project_sp);
-  void operateWritingOdsFile(QString filename, QString format,
-                             ProjectSp project_sp);
-  void operateWritingMassChroqFile(QString filename, ProjectSp project_sp,
+  void
+  operateWritingOdsFile(QString filename, QString format, ProjectSp project_sp);
+  void operateWritingMassChroqFile(QString filename,
+                                   ProjectSp project_sp,
                                    MasschroqFileParameters params);
   void operateWritingMassChroqPrmFile(QString filename, ProjectSp project_sp);
   void operateWritingProticFile(QString filename, ProjectSp project_sp);
   void operateWritingMcqrSpectralCountFile(QString filename,
                                            ProjectSp project_sp);
-  void operateWritingFastaFile(QString filename, ProjectSp project_sp,
+  void operateWritingFastaFile(QString filename,
+                               ProjectSp project_sp,
                                ExportFastaType type);
   void operateGrouping(ProjectSp project_sp);
   void operateRunningXtandem(TandemRunBatch tandem_run_batch);
@@ -143,6 +146,7 @@ class MainWindow : public QMainWindow
   WaitingMessageDialog *_p_waiting_message_dialog;
   AboutDialog *_p_about_dialog          = nullptr;
   TandemRunDialog *_p_tandem_run_dialog = nullptr;
+  EditSettings *_p_edit_settings        = nullptr;
 
   HttpVersion m_onlineVersion;
 };
-- 
GitLab