settings.hh
Go to the documentation of this file.
1 // Copyright (c) 2015-2018, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef GEPETTO_GUI_SETTINGS_HH
18 #define GEPETTO_GUI_SETTINGS_HH
19 
20 #include <ostream>
21 #include <string>
22 #include <QString>
23 #include <QStringList>
24 
26 
27 namespace gepetto {
28  namespace gui {
29  class MainWindow;
30 
37  struct Settings {
38  std::string configurationFile;
39  std::string predifinedRobotConf;
40  std::string predifinedEnvConf;
41  std::string stateConf;
42 
43  bool verbose;
44  bool noPlugin;
47 
49 
52 
55  QString avconv;
56  QStringList avConvInputOptions;
57  QStringList avConvOutputOptions;
59 
61 
62  QString appStyle;
63 
65  Settings (const char* installDirectory);
66 
71  void setupPaths () const;
72 
74  QString getQSettingsFileName (const std::string& settingsName) const;
75 
85  int initSettings (int argc, char * argv[]);
86 
88  void fromFiles ();
89 
91  void writeSettings ();
92 
94  QVariant getSetting (const QString & key,
95  const QVariant & defaultValue = QVariant());
96 
98  QStringList pluginsToInit_;
99  QStringList pyplugins_;
100  QStringList pyscripts_;
101 
102  void setMainWindow (MainWindow* main);
103 
104  void initPlugins ();
105 
106  std::ostream& print (std::ostream& os);
107 
109  void readRobotFile ();
111  void readEnvFile ();
132  void readSettingFile ();
133 
134  void saveState () const;
135  void restoreState () const;
136  void restoreDockWidgetsState () const;
137 
138  void writeRobotFile ();
139  void writeEnvFile ();
140  void writeSettingFile ();
141 
142  const char** makeOmniORBargs (int &argc);
143 
144  private:
145  void addRobotFromString (const std::string& rbtStr);
146  void addEnvFromString (const std::string& envStr);
147  void addPlugin (const QString& plg, bool init);
148  void addPyPlugin (const QString& plg, bool init);
149  void addPyScript (const QString& fileName);
150  void addOmniORB (const QString& arg, const QString& value);
151 
152  inline void log (const QString& t);
153  inline void logError (const QString& t);
154 
155  MainWindow* mw;
156  QStringList omniORBargv_;
157  };
158  } // namespace gui
159 } // namespace gepetto
160 
161 #endif // GEPETTO_GUI_SETTINGS_HH
int refreshRate
Definition: settings.hh:48
void setupPaths() const
QString getQSettingsFileName(const std::string &settingsName) const
Get the filename of a configuration file.
std::string predifinedRobotConf
Definition: settings.hh:39
void restoreState() const
bool autoWriteSettings
Definition: settings.hh:45
bool useNameService
Definition: settings.hh:46
QStringList avConvInputOptions
Definition: settings.hh:56
QString avconv
Definition: settings.hh:55
void fromFiles()
Update settings from setting files.
QStringList pyplugins_
Definition: settings.hh:99
Class.
Definition: mainwindow.hh:43
QVariant getSetting(const QString &key, const QVariant &defaultValue=QVariant())
Get a setting.
QString installDirectory
Definition: settings.hh:60
std::string captureDirectory
Path to avconv binary (maybe ffmpeg on some distributions).
Definition: settings.hh:51
Definition: settings.hh:37
Settings(const char *installDirectory)
Set up default values.
std::string configurationFile
Definition: settings.hh:38
void restoreDockWidgetsState() const
void saveState() const
Definition: action-search-bar.hh:27
std::string predifinedEnvConf
Definition: settings.hh:40
std::string stateConf
Definition: settings.hh:41
void writeSettings()
Write the settings to configuration files.
void setMainWindow(MainWindow *main)
QString appStyle
Definition: settings.hh:62
Definition: pluginmanagerdialog.hh:35
QStringList pyscripts_
Definition: settings.hh:100
int initSettings(int argc, char *argv[])
bool verbose
Definition: settings.hh:43
QStringList avConvOutputOptions
Definition: settings.hh:57
std::string captureExtension
Definition: settings.hh:51
std::string captureFilename
Definition: settings.hh:51
bool noPlugin
Definition: settings.hh:44
const char ** makeOmniORBargs(int &argc)
PluginManager pluginManager_
Definition: settings.hh:97
QStringList pluginsToInit_
Definition: settings.hh:98
std::ostream & print(std::ostream &os)