annotate libgui/src/resource-manager.h @ 31706:597f3ee61a48 stable

update Octave Project Developers copyright for the new year
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2023 13:11:27 -0500
parents 29d734430e5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31648
diff changeset
3 // Copyright (C) 2011-2023 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
13539
a4b5cad8f7c6 Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13537
diff changeset
25
21203
710e700cdd7f maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents: 20945
diff changeset
26 #if ! defined (octave_resource_manager_h)
710e700cdd7f maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents: 20945
diff changeset
27 #define octave_resource_manager_h 1
13537
a43ecce77eec Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
28
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 26656
diff changeset
29 #include <QComboBox>
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15161
diff changeset
30 #include <QIcon>
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
31 #include <QPointer>
30426
8d303ace1aff build: Include QScintilla header conditionally on configure result
Markus Mützel <markus.muetzel@gmx.de>
parents: 29524
diff changeset
32 #if defined (HAVE_QSCINTILLA)
8d303ace1aff build: Include QScintilla header conditionally on configure result
Markus Mützel <markus.muetzel@gmx.de>
parents: 29524
diff changeset
33 # include <Qsci/qscilexer.h>
8d303ace1aff build: Include QScintilla header conditionally on configure result
Markus Mützel <markus.muetzel@gmx.de>
parents: 29524
diff changeset
34 #endif
15972
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15914
diff changeset
35 #include <QTranslator>
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
36 #include <QTemporaryFile>
15787
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15300
diff changeset
37
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
38 #include "gui-settings.h"
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
39
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30882
diff changeset
40 OCTAVE_BEGIN_NAMESPACE(octave)
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30882
diff changeset
41
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
42 class resource_manager : public QObject
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
43 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
44 Q_OBJECT
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
45
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
46 protected:
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
47
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
48 public:
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
49
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
50 resource_manager (void);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
51
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
52 // No copying!
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
53
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
54 resource_manager (const resource_manager&) = delete;
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
55
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
56 resource_manager& operator = (const resource_manager&) = delete;
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 15972
diff changeset
57
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
58 ~resource_manager ();
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
59
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
60 QString get_gui_translation_dir (void);
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27618
diff changeset
61
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
62 void config_translators (QTranslator *qt_tr, QTranslator *qsci_tr,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
63 QTranslator *gui_tr);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
64 void config_icon_theme (void);
17515
c8c0dff02538 gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents: 17421
diff changeset
65
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
66 gui_settings * get_settings (void) const;
24282
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
67
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
68 gui_settings * get_default_settings (void) const;
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27618
diff changeset
69
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
70 QString get_settings_directory (void);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
71
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
72 QString get_settings_file (void);
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27618
diff changeset
73
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
74 QString get_default_font_family (void);
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25103
diff changeset
75
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
76 QStringList get_default_font (void);
29162
bb6bb306b8a6 copy lexer settings from default settings file for new languages
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
77
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
78 QPointer<QTemporaryFile>
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
79 create_tmp_file (const QString& extension = QString (),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
80 const QString& contents = QString ());
20774
5c5e085a1ae6 allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents: 19899
diff changeset
81
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
82 void remove_tmp_file (QPointer<QTemporaryFile> tmp_file);
15972
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15914
diff changeset
83
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
84 void reload_settings (void);
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15161
diff changeset
85
29498
5384bb4efc51 rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
86 #if defined (HAVE_QSCINTILLA)
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
87 int get_valid_lexer_styles (QsciLexer *lexer, int *styles);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
88 void read_lexer_settings (QsciLexer *lexer, gui_settings *settings,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
89 int mode = 0, int def = 0);
29498
5384bb4efc51 rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
90 #endif
29162
bb6bb306b8a6 copy lexer settings from default settings file for new languages
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
91
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
92 void set_settings (const QString& file);
13537
a43ecce77eec Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
93
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
94 bool update_settings_key (const QString& new_key, const QString& old_key);
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27618
diff changeset
95
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
96 bool is_first_run (void) const;
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
97
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
98 void update_network_settings (void);
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27618
diff changeset
99
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
100 QIcon icon (const QString& icon_name, bool octave_only = false,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
101 const QString& icon_alt_name = QString ());
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
102
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
103 void get_codecs (QStringList *codecs);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
104
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
105 void combo_encoding (QComboBox *combo, const QString& current = QString ());
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15161
diff changeset
106
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
107 private:
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
108
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
109 /*!
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
110 * Copys the attributes bold, italic and underline from QFont
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
111 * @p attr to the font @p base and returns the result without
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
112 * changing @p base,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
113 * @param attr QFont with the desired attributes
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
114 * @param base QFont with desired family and size
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
115 */
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
116 QFont copy_font_attributes (const QFont& attr, const QFont& base) const;
29498
5384bb4efc51 rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
117
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
118 QString m_settings_directory;
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15894
diff changeset
119
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
120 QString m_settings_file;
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
121
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
122 gui_settings *m_settings;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23927
diff changeset
123
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
124 gui_settings *m_default_settings;
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
125
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
126 QList<QTemporaryFile *> m_temporary_files;
30777
439eb9bd4c04 icon fallback concept without QIcon::fallbackSearchPaths (bug #62106)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 30772
diff changeset
127
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
128 QStringList m_icon_fallbacks;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
129 };
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30882
diff changeset
130
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30882
diff changeset
131 OCTAVE_END_NAMESPACE(octave)
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23927
diff changeset
132
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20774
diff changeset
133 #endif