GNU Octave  4.2.1
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-2017 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 #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 class resource_manager : public QObject
34 {
35  Q_OBJECT
36 
37 protected:
38 
39 public:
40 
41  resource_manager (void);
42 
44 
45  static QSettings *get_settings (void)
46  {
47  return instance_ok () ? instance->do_get_settings () : 0;
48  }
49 
50  static QIcon icon (const QString& icon_name, bool fallback = true)
51  {
52  if (instance_ok ())
53  return instance->do_icon (icon_name, fallback);
54 
55  return QIcon ();
56  }
57 
58  static QSettings *get_default_settings (void)
59  {
60  return instance_ok () ? instance->do_get_default_settings () : 0;
61  }
62 
63  static QString get_settings_file (void)
64  {
65  return instance_ok () ? instance->do_get_settings_file () : QString ();
66  }
67 
68  static void reload_settings (void)
69  {
70  if (instance_ok ())
72  }
73 
74  static void set_settings (const QString& file)
75  {
76  if (instance_ok ())
77  instance->do_set_settings (file);
78  }
79 
80  static void combo_encoding (QComboBox *combo, QString current = QString ())
81  {
82  if (instance_ok ())
83  instance->do_combo_encoding (combo, current);
84  }
85 
86  static QString get_gui_translation_dir (void);
87 
88  static void config_translators (QTranslator*, QTranslator*, QTranslator*);
89 
90  static void update_network_settings (void)
91  {
92  if (instance_ok ())
94  }
95 
96  static bool is_first_run (void)
97  {
98  return instance_ok () ? instance->do_is_first_run () : true;
99  }
100 
101  static QString storage_class_chars (void) { return "afghip"; }
102  static QStringList storage_class_names (void);
104 
105  static QString terminal_color_chars (void) { return "fbsc"; }
106  static QStringList terminal_color_names (void);
108 
110 
111 public slots:
112 
113  static void cleanup_instance (void) { delete instance; instance = 0; }
114 
115 private:
116 
117  // No copying!
118 
119  static bool instance_ok (void);
120 
122 
123  QString settings_file;
124 
125  QSettings *settings;
126 
127  QSettings *default_settings;
128 
129  QSettings *do_get_settings (void) const;
130 
131  QSettings *do_get_default_settings (void) const;
132 
133  QString do_get_settings_file (void);
134 
135  QString do_get_settings_directory (void);
136 
137  void do_reload_settings (void);
138 
139  void do_set_settings (const QString& file);
140 
141  void do_update_network_settings (void);
142 
143  bool do_is_first_run (void) const;
144 
145  QIcon do_icon (const QString& icon, bool fallback);
146 
147  void do_combo_encoding (QComboBox *combo, QString current);
148 };
149 
150 #endif
void do_combo_encoding(QComboBox *combo, QString current)
bool do_is_first_run(void) const
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
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)
static void combo_encoding(QComboBox *combo, QString current=QString())
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)
static bool is_first_run(void)
static void reload_settings(void)
void do_update_network_settings(void)