fw4spl
SPreferencesConfiguration.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2014-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "uiPreferences/config.hpp"
10 
11 #include <fwCom/Signals.hpp>
12 
13 #include <fwGui/IActionSrv.hpp>
14 
15 #include <fwTools/Failed.hpp>
16 
17 #include <QCheckBox>
18 #include <QComboBox>
19 #include <QLineEdit>
20 #include <QObject>
21 #include <QPointer>
22 
23 #include <vector>
24 
25 namespace fwData
26 {
27 class String;
28 }
29 
30 namespace uiPreferences
31 {
32 
33 namespace action
34 {
35 
84 class UIPREFERENCES_CLASS_API SPreferencesConfiguration : public QObject,
85  public ::fwGui::IActionSrv
86 {
87 Q_OBJECT
88 public:
89 
91 
93  UIPREFERENCES_API SPreferencesConfiguration() noexcept;
94 
96  UIPREFERENCES_API virtual ~SPreferencesConfiguration() noexcept;
97 
99  typedef ::fwCom::Signal< void () > ParametersModifiedSignalType;
100  UIPREFERENCES_API static const ::fwCom::Signals::SignalKeyType s_PARAMETERS_MODIFIED_SIG;
101 
102 protected:
103 
105  virtual void starting() override;
106 
108  virtual void stopping() override;
109 
111  virtual void updating() override;
112 
114  virtual void swapping() override;
115 
117  virtual void configuring() override;
118 
120  virtual void info( std::ostream& _sstream ) override;
121 
122  void onSelectDir(QPointer<QLineEdit> lineEdit);
123 
124 private:
125 
126  enum class PreferenceType : std::int8_t
127  {
128  TEXT,
129  CHECKBOX,
130  U_INT,
131  PATH,
132  COMBOBOX,
133  DOUBLE
134  };
135 
136  struct PreferenceElt
137  {
138  PreferenceType m_type;
139  QPointer<QLineEdit> m_lineEdit;
140  QPointer<QCheckBox> m_checkBox;
141  QPointer<QComboBox> m_comboBox;
142  SPTR(::fwData::String) m_dataPreference;
143  std::string m_preferenceKey;
144  std::string m_name;
145  std::string m_defaultValue;
146  };
147 
148  ParametersModifiedSignalType::sptr m_sigParametersModified;
149 
150  typedef std::vector<PreferenceElt> PreferenceEltType;
151  PreferenceEltType m_preferences;
152 };
153 
154 } // namespace action
155 } // namespace uiPreferences
#define SPTR(_cls_)
This action shows a dialog to configure preferences of an application.
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
STL namespace.
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
Contains the representation of the data objects used in the framework.
The namespace uiPreferences contains editors to manage the preferences configuration.
This class contains an std::string value.