GNU Octave  4.0.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-2015 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 QIcon icon (const QString& icon_name, bool fallback = true)
50  {
51  if (instance_ok ())
52  return instance->do_icon (icon_name, fallback);
53 
54  return QIcon ();
55  }
56 
57  static QSettings *get_default_settings (void)
58  {
59  return instance_ok () ? instance->do_get_default_settings () : 0;
60  }
61 
62  static QString get_settings_file (void)
63  {
64  return instance_ok () ? instance->do_get_settings_file () : QString ();
65  }
66 
67  static void reload_settings (void)
68  {
69  if (instance_ok ())
71  }
72 
73  static void set_settings (const QString& file)
74  {
75  if (instance_ok ())
76  instance->do_set_settings (file);
77  }
78 
79  static QString get_gui_translation_dir (void);
80 
81  static void config_translators (QTranslator*, QTranslator*, QTranslator*);
82 
83  static void update_network_settings (void)
84  {
85  if (instance_ok ())
87  }
88 
89  static bool is_first_run (void)
90  {
91  return instance_ok () ? instance->do_is_first_run () : true;
92  }
93 
94  static QString storage_class_chars (void) { return "afghip"; }
95  static QStringList storage_class_names (void);
97 
98  static QString terminal_color_chars (void) { return "fbsc"; }
99  static QStringList terminal_color_names (void);
101 
102 private:
103 
105 
106  static void cleanup_instance (void) { delete instance; instance = 0; }
107 
108  // No copying!
109 
111 
113 
114  static bool instance_ok (void);
115 
117 
118  QString settings_file;
119 
120  QSettings *settings;
121 
122  QSettings *default_settings;
123 
124  QSettings *do_get_settings (void) const;
125 
126  QSettings *do_get_default_settings (void) const;
127 
128  QString do_get_settings_file (void);
129 
130  QString do_get_settings_directory (void);
131 
132  void do_reload_settings (void);
133 
134  void do_set_settings (const QString& file);
135 
136  void do_update_network_settings (void);
137 
138  bool do_is_first_run (void) const;
139 
140  QIcon do_icon (const QString& icon, bool fallback);
141 
142 };
143 
144 #endif // RESOURCEMANAGER_H
bool do_is_first_run(void) const
static void cleanup_instance(void)
static QString terminal_color_chars(void)
static QSettings * get_default_settings(void)
static QString get_settings_file(void)
void do_set_settings(const QString &file)
QString do_get_settings_file(void)
static QString get_gui_translation_dir(void)
static void config_translators(QTranslator *, QTranslator *, QTranslator *)
static QStringList terminal_color_names(void)
QSettings * do_get_settings(void) const
static void set_settings(const QString &file)
static QList< QColor > storage_class_default_colors(void)
QSettings * do_get_default_settings(void) const
QSettings * default_settings
QString do_get_settings_directory(void)
static QSettings * get_settings(void)
static QList< QColor > terminal_default_colors(void)
void do_reload_settings(void)
QSettings * settings
static resource_manager * instance
static bool instance_ok(void)
QIcon do_icon(const QString &icon, bool fallback)
static QIcon icon(const QString &icon_name, bool fallback=true)
static QString storage_class_chars(void)
static void update_network_settings(void)
static QStringList storage_class_names(void)
resource_manager & operator=(const resource_manager &)
static bool is_first_run(void)
static void reload_settings(void)
void do_update_network_settings(void)