Mercurial > octave
annotate libgui/src/resource-manager.h @ 31649:deb553ac2c54
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Dec 2022 15:45:27 -0500 |
parents | 431f80aba37a 29d734430e5f |
children |
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 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30426
diff
changeset
|
3 // Copyright (C) 2011-2022 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> |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
30 #include <QPointer> |
30426
8d303ace1aff
build: Include QScintilla header conditionally on configure result
Markus Mützel <markus.muetzel@gmx.de>
parents:
29524
diff
changeset
|
31 #if defined (HAVE_QSCINTILLA) |
8d303ace1aff
build: Include QScintilla header conditionally on configure result
Markus Mützel <markus.muetzel@gmx.de>
parents:
29524
diff
changeset
|
32 # include <Qsci/qscilexer.h> |
8d303ace1aff
build: Include QScintilla header conditionally on configure result
Markus Mützel <markus.muetzel@gmx.de>
parents:
29524
diff
changeset
|
33 #endif |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15914
diff
changeset
|
34 #include <QTranslator> |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
35 #include <QTemporaryFile> |
15787
b081fbe80174
provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents:
15300
diff
changeset
|
36 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30882
diff
changeset
|
37 OCTAVE_BEGIN_NAMESPACE(octave) |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30882
diff
changeset
|
38 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
39 class resource_manager : public QObject |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
15972
diff
changeset
|
40 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
41 Q_OBJECT |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
42 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
43 protected: |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
44 |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
45 public: |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
46 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
47 resource_manager (void); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
48 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
49 // No copying! |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
15972
diff
changeset
|
50 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
51 resource_manager (const resource_manager&) = delete; |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
52 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
53 resource_manager& operator = (const resource_manager&) = delete; |
17515
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
54 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
55 ~resource_manager (); |
24282
a669809df612
update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
56 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
57 QString get_gui_translation_dir (void); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
58 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
59 void config_translators (QTranslator *qt_tr, QTranslator *qsci_tr, |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
60 QTranslator *gui_tr); |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25103
diff
changeset
|
61 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
62 QPointer<QTemporaryFile> |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
63 create_tmp_file (const QString& extension = QString (), |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
64 const QString& contents = QString ()); |
29162
bb6bb306b8a6
copy lexer settings from default settings file for new languages
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27923
diff
changeset
|
65 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
66 void remove_tmp_file (QPointer<QTemporaryFile> tmp_file); |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
67 |
29498
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
68 #if defined (HAVE_QSCINTILLA) |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
69 int get_valid_lexer_styles (QsciLexer *lexer, int *styles); |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31617
diff
changeset
|
70 void read_lexer_settings (QsciLexer *lexer, 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
|
71 #endif |
29162
bb6bb306b8a6
copy lexer settings from default settings file for new languages
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27923
diff
changeset
|
72 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
73 bool update_settings_key (const QString& new_key, const QString& old_key); |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
74 |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
75 void update_network_settings (void); |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
76 |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
77 void get_codecs (QStringList *codecs); |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
78 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27618
diff
changeset
|
79 void combo_encoding (QComboBox *combo, const QString& current = QString ()); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
80 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
81 private: |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
82 |
29498
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
83 /*! |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
84 * Copys the attributes bold, italic and underline from QFont |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
85 * @p attr to the font @p base and returns the result without |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
86 * changing @p base, |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
87 * @param attr QFont with the desired attributes |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
88 * @param base QFont with desired family and size |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
89 */ |
5384bb4efc51
rearrange default lexer settings and add second color mode to gui editor
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29359
diff
changeset
|
90 QFont copy_font_attributes (const QFont& attr, const QFont& base) const; |
15914
85f9aca30c76
gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents:
15894
diff
changeset
|
91 |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
92 QList<QTemporaryFile *> m_temporary_files; |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 }; |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30882
diff
changeset
|
94 |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30882
diff
changeset
|
95 OCTAVE_END_NAMESPACE(octave) |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23927
diff
changeset
|
96 |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20774
diff
changeset
|
97 #endif |