GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
resource-manager.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2018 Jacob Dawid
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_resource_manager_h)
24 #define octave_resource_manager_h 1
25 
26 #include <QDesktopServices>
27 #include <QIcon>
28 #include <QComboBox>
29 #include <QMap>
30 #include <QSettings>
31 #include <QTranslator>
32 
33 namespace octave
34 {
35  class resource_manager : public QObject
36  {
37  Q_OBJECT
38 
39  protected:
40 
41  public:
42 
43  resource_manager (void);
44 
45  // No copying!
46 
47  resource_manager (const resource_manager&) = delete;
48 
50 
52 
53  static QSettings * get_settings (void)
54  {
55  return instance_ok () ? instance->do_get_settings () : nullptr;
56  }
57 
58  static QIcon icon (const QString& icon_name, bool fallback = true)
59  {
60  if (instance_ok ())
61  return instance->do_icon (icon_name, fallback);
62 
63  return QIcon ();
64  }
65 
66  static QSettings * get_default_settings (void)
67  {
68  return instance_ok () ? instance->do_get_default_settings () : nullptr;
69  }
70 
71  static QString get_settings_file (void)
72  {
73  return instance_ok () ? instance->do_get_settings_file () : QString ();
74  }
75 
76  static void reload_settings (void)
77  {
78  if (instance_ok ())
80  }
81 
82  static void set_settings (const QString& file)
83  {
84  if (instance_ok ())
86  }
87 
88  static bool update_settings_key (const QString& new_key,
89  const QString& old_key)
90  {
91  return (instance_ok ()
92  ? instance->do_update_settings_key (new_key, old_key)
93  : false);
94  }
95 
96  static void combo_encoding (QComboBox *combo, QString current = QString ())
97  {
98  if (instance_ok ())
99  instance->do_combo_encoding (combo, current);
100  }
101 
102  static QString get_gui_translation_dir (void);
103 
104  static void config_translators (QTranslator*, QTranslator*, QTranslator*);
105 
106  static void update_network_settings (void)
107  {
108  if (instance_ok ())
110  }
111 
112  static bool is_first_run (void)
113  {
114  return instance_ok () ? instance->do_is_first_run () : true;
115  }
116 
117  static QString storage_class_chars (void) { return "afghip"; }
118  static QStringList storage_class_names (void);
120 
121  static QString terminal_color_chars (void) { return "fbsc"; }
122  static QStringList terminal_color_names (void);
124 
126 
127  public slots:
128 
129  static void cleanup_instance (void) { delete instance; instance = nullptr; }
130 
131  static QString varedit_color_chars (void) {return "fbsha"; }
132  static QStringList varedit_color_names (void);
134 
135  private:
136 
137  static bool instance_ok (void);
138 
139  QSettings * do_get_settings (void) const;
140 
141  QSettings * do_get_default_settings (void) const;
142 
143  QString do_get_settings_directory (void);
144 
145  QString do_get_settings_file (void);
146 
147  void do_reload_settings (void);
148 
149  void do_set_settings (const QString& file);
150 
151  bool do_update_settings_key (const QString& new_key, const QString& old_key);
152 
153  bool do_is_first_run (void) const;
154 
155  void do_update_network_settings (void);
156 
157  QIcon do_icon (const QString& icon, bool fallback);
158 
159  void do_combo_encoding (QComboBox *combo, QString current);
160 
162 
164 
165  QSettings *m_settings;
166 
167  QSettings *m_default_settings;
168  };
169 }
170 
171 // FIXME: This is temporary and should be removed when all classes that
172 // use the resource_manager class are also inside the octave namespace.
174 
175 #endif
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
static void combo_encoding(QComboBox *combo, QString current=QString())
static void config_translators(QTranslator *, QTranslator *, QTranslator *)
static QList< QColor > terminal_default_colors(void)
static void update_network_settings(void)
static QSettings * get_default_settings(void)
static void set_settings(const QString &file)
bool do_is_first_run(void) const
QSettings * do_get_settings(void) const
QString do_get_settings_directory(void)
static QList< QColor > varedit_default_colors(void)
QString do_get_settings_file(void)
static QString storage_class_chars(void)
static QString get_settings_file(void)
static void reload_settings(void)
static QString terminal_color_chars(void)
static QList< QColor > storage_class_default_colors(void)
static QStringList storage_class_names(void)
static resource_manager * instance
static void cleanup_instance(void)
static QStringList varedit_color_names(void)
void do_combo_encoding(QComboBox *combo, QString current)
static QIcon icon(const QString &icon_name, bool fallback=true)
static bool is_first_run(void)
static QString varedit_color_chars(void)
resource_manager & operator=(const resource_manager &)=delete
static QSettings * get_settings(void)
static bool instance_ok(void)
static bool update_settings_key(const QString &new_key, const QString &old_key)
QIcon do_icon(const QString &icon, bool fallback)
QSettings * do_get_default_settings(void) const
static QStringList terminal_color_names(void)
static QString get_gui_translation_dir(void)
bool do_update_settings_key(const QString &new_key, const QString &old_key)
void do_set_settings(const QString &file)