GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
resource-manager.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2013 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef RESOURCEMANAGER_H
24 #define RESOURCEMANAGER_H
25 
26 #include <QDesktopServices>
27 #include <QIcon>
28 #include <QMap>
29 #include <QSettings>
30 #include <QTranslator>
31 
32 class resource_manager : public QObject
33 {
34  Q_OBJECT
35 
36 protected:
37 
38 public:
39 
40  resource_manager (void);
41 
43 
44  static QSettings *get_settings (void)
45  {
46  return instance_ok () ? instance->do_get_settings () : 0;
47  }
48 
49  static QSettings *get_default_settings (void)
50  {
51  return instance_ok () ? instance->do_get_default_settings () : 0;
52  }
53 
54  static QString get_settings_file (void)
55  {
56  return instance_ok () ? instance->do_get_settings_file () : QString ();
57  }
58 
59  static void reload_settings (void)
60  {
61  if (instance_ok ())
63  }
64 
65  static void set_settings (const QString& file)
66  {
67  if (instance_ok ())
68  instance->do_set_settings (file);
69  }
70 
71  static QString get_gui_translation_dir (void);
72 
73  static void config_translators (QTranslator*, QTranslator*, QTranslator*);
74 
75  static void update_network_settings (void)
76  {
77  if (instance_ok ())
79  }
80 
81  static bool is_first_run (void)
82  {
83  return instance_ok () ? instance->do_is_first_run () : true;
84  }
85 
86  static QString storage_class_chars (void) { return "afghip"; }
87  static QStringList storage_class_names (void);
89 
90  static QString terminal_color_chars (void) { return "fbsc"; }
91  static QStringList terminal_color_names (void);
93 
94 private:
95 
97 
98  static void cleanup_instance (void) { delete instance; instance = 0; }
99 
100  // No copying!
101 
103 
105 
106  static bool instance_ok (void);
107 
109 
110  QString settings_file;
111 
112  QSettings *settings;
113 
114  QSettings *default_settings;
115 
116  QSettings *do_get_settings (void) const;
117 
118  QSettings *do_get_default_settings (void) const;
119 
120  QString do_get_settings_file (void);
121 
122  QString do_get_settings_directory (void);
123 
124  void do_reload_settings (void);
125 
126  void do_set_settings (const QString& file);
127 
128  void do_update_network_settings (void);
129 
130  bool do_is_first_run (void) const;
131 
132 };
133 
134 #endif // RESOURCEMANAGER_H