Mercurial > octave
annotate libgui/src/resource-manager.cc @ 28777:0d6795d0373d stable
improved detection of standard fixed witdh font (bug #59128)
* resource-manager.cc (get_default_font_family): use QFontDatabase for
the systems standard fixed width font (requires Qt 5.2) or use the
hard coded default Monaco on macOS
* gui-preferences-global.h: use Monaco as default monospace font on macOS;
use Q_OS_xxx macros instead of Q_WS_xxx macros
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Tue, 22 Sep 2020 16:13:25 +0200 |
parents | f2789cae04f3 |
children | 471960b47afb d0a64e67749e |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 2011-2020 The Octave Project Developers |
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 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
27 # include "config.h" |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
28 #endif |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
29 |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
30 #include <string> |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
31 |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
32 #include <QDir> |
13570
7828e1bf5b0d
Default settings are now loaded it there is no user-defined settings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13551
diff
changeset
|
33 #include <QFile> |
28777
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
34 #include <QFontComboBox> |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
35 #include <QFontDatabase> |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
36 #include <QLibraryInfo> |
17943
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
37 #include <QMessageBox> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
38 #include <QNetworkProxy> |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24718
diff
changeset
|
39 #if defined (HAVE_QSTANDARDPATHS) |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
40 # include <QStandardPaths> |
27841
f68c7c56e5f2
add missing include (bug #57420)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
41 #else |
f68c7c56e5f2
add missing include (bug #57420)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
42 # include <QDesktopServices> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
43 #endif |
27841
f68c7c56e5f2
add missing include (bug #57420)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
44 |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
45 #include <QTextCodec> |
14845
9a355dfc7701
Fixed bug with GUI not starting the first time.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14804
diff
changeset
|
46 |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
47 #include "QTerminal.h" |
27560
3fcc650de22f
split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
27556
diff
changeset
|
48 #include "gui-preferences-ed.h" |
3fcc650de22f
split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
27556
diff
changeset
|
49 #include "gui-preferences-global.h" |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
50 #include "octave-qobject.h" |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
51 #include "resource-manager.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
52 #include "variable-editor.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
53 #include "workspace-model.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
54 |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
55 #include "file-ops.h" |
28118
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
56 #include "localcharset-wrapper.h" |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
57 #include "oct-env.h" |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
58 |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
59 #include "defaults.h" |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
60 #include "error.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
61 #include "help.h" |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
62 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
63 namespace octave |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
64 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
65 static QString |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
66 default_qt_settings_file (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
67 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
68 std::string dsf = sys::env::getenv ("OCTAVE_DEFAULT_QT_SETTINGS"); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
69 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
70 if (dsf.empty ()) |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
71 dsf = (config::oct_etc_dir () |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
72 + sys::file_ops::dir_sep_str () |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
73 + "default-qt-settings"); |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
74 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
75 return QString::fromStdString (dsf); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
76 } |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
77 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
78 resource_manager::resource_manager (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
79 : m_settings_directory (), m_settings_file (), m_settings (nullptr), |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
80 m_default_settings (nullptr), m_temporary_files () |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
81 { |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27583
diff
changeset
|
82 // Let gui_settings decide where to put the ini file with gui preferences |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
83 m_default_settings |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27583
diff
changeset
|
84 = new gui_settings (QSettings::IniFormat, QSettings::UserScope, |
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27583
diff
changeset
|
85 "octave", "octave-gui"); |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
86 |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
87 m_settings_file = m_default_settings->fileName (); |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
88 |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
89 QFileInfo sfile (m_settings_file); |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
90 m_settings_directory = sfile.absolutePath (); |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
91 |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
92 QString xdg_config_home |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
93 = QString::fromLocal8Bit (qgetenv ("XDG_CONFIG_HOME")); |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
94 |
26959
3ed8955dcdf9
* resource-manager.cc (ctor): test XDG_CONFIG_HOME before importing old gui settings
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26955
diff
changeset
|
95 if ((! sfile.exists ()) && xdg_config_home.isEmpty ()) |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
96 { |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
97 // File does not exist yet: Look for a settings file at the old |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
98 // location ($HOME/.config/octave/qt-settings) for impoting all |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
99 // available keys into the new settings file. |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
100 // Do not look for an old settings file if XDG_CONFIG_HOME is set, |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27841
diff
changeset
|
101 // since then a nonexistent new settings file does not necessarily |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
102 // indicate a first run of octave with new config file locations. |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24718
diff
changeset
|
103 #if defined (HAVE_QSTANDARDPATHS) |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
104 QString home_path |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
105 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation); |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24718
diff
changeset
|
106 #else |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
107 QString home_path |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
108 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation); |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
109 #endif |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
110 |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
111 QString old_settings_directory = home_path + "/.config/octave"; |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
112 QString old_settings_file = old_settings_directory + "/qt-settings"; |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
113 |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
114 QFile ofile (old_settings_file); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
115 |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
116 if (ofile.exists ()) |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
117 { |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27841
diff
changeset
|
118 // Old settings file exists; create a gui_settings object related |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
119 // to it and copy all available keys to the new settings |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27583
diff
changeset
|
120 gui_settings old_settings (old_settings_file, QSettings::IniFormat); |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
121 |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
122 QStringList keys = old_settings.allKeys (); |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
123 for (int i = 0; i < keys.count(); i++) |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
124 m_default_settings->setValue (keys.at(i), |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
125 old_settings.value(keys.at(i))); |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
126 |
26955
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
127 m_default_settings->sync (); // Done, make sure keys are written |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
128 } |
9e2f69c1a05d
use standard location on each platform for gui preferences file (bug #55855)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26866
diff
changeset
|
129 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
130 } |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
131 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
132 resource_manager::~resource_manager (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
134 delete m_settings; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
135 delete m_default_settings; |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
136 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
137 for (int i = m_temporary_files.count () - 1; i >=0; i--) |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
138 remove_tmp_file (m_temporary_files.at (i)); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
139 } |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
140 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 QString resource_manager::get_gui_translation_dir (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
142 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 // get environment variable for the locale dir (e.g. from run-octave) |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
144 std::string dldir = sys::env::getenv ("OCTAVE_LOCALE_DIR"); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 if (dldir.empty ()) |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
146 dldir = config::oct_locale_dir (); // env-var empty, load the default location |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 return QString::fromStdString (dldir); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 } |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
149 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
150 void resource_manager::config_translators (QTranslator *qt_tr, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 QTranslator *qsci_tr, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 QTranslator *gui_tr) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 bool loaded; |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
155 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 QString qt_trans_dir |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
157 = QLibraryInfo::location (QLibraryInfo::TranslationsPath); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
158 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
159 QString language = "SYSTEM"; // take system language per default |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
160 |
27649
91d43a00620d
eliminate static instance variable from octave_qobject class
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
161 // FIXME: can we somehow ensure that the settings object will always |
91d43a00620d
eliminate static instance variable from octave_qobject class
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
162 // be initialize and valid? |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
163 |
27649
91d43a00620d
eliminate static instance variable from octave_qobject class
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
164 if (m_settings) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
165 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 // get the locale from the settings if already available |
27805
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
167 language = m_settings->value (global_language.key, |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
168 global_language.def).toString (); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
169 } |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
170 |
26866
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
171 // load the translations depending on the settings |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
172 if (language == "SYSTEM") |
26866
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
173 { |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
174 // get the system locale and pass it to the translators for loading |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
175 // the suitable translation files |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
176 QLocale sys_locale = QLocale::system (); |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
177 |
26866
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
178 qt_tr->load (sys_locale, "qt", "_", qt_trans_dir); |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
179 qsci_tr->load (sys_locale, "qscintilla", "_", qt_trans_dir); |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
180 gui_tr->load (sys_locale, "", "", get_gui_translation_dir ()); |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
181 } |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
182 else |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
183 { |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
184 // load the translation files depending on the given locale name |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
185 loaded = qt_tr->load ("qt_" + language, qt_trans_dir); |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
186 if (! loaded) // try lower case |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
187 qt_tr->load ("qt_" + language.toLower (), qt_trans_dir); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23927
diff
changeset
|
188 |
26866
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
189 loaded = qsci_tr->load ("qscintilla_" + language, qt_trans_dir); |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
190 if (! loaded) // try lower case |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
191 qsci_tr->load ("qscintilla_" + language.toLower (), qt_trans_dir); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23927
diff
changeset
|
192 |
26866
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
193 gui_tr->load (language, get_gui_translation_dir ()); |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
194 } |
65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
Torsten <mttl@mailbox.org>
parents:
26842
diff
changeset
|
195 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
196 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
197 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
198 gui_settings * resource_manager::get_settings (void) const |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
199 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
200 return m_settings; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
201 } |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
202 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
203 gui_settings * resource_manager::get_default_settings (void) const |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
204 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
205 return m_default_settings; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
206 } |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
207 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
208 QString resource_manager::get_settings_directory (void) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
209 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
210 return m_settings_directory; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
211 } |
17515
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
212 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
213 QString resource_manager::get_settings_file (void) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
214 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
215 return m_settings_file; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
216 } |
17515
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
217 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
218 QString resource_manager::get_default_font_family (void) |
26008
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
219 { |
28777
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
220 QString default_family; |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
221 |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
222 #if defined (Q_OS_MAC) |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
223 // Use hard coded default on macOS, since selection of fixed width |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
224 // default font is unreliable (see bug #59128). |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
225 |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
226 // Get all available fixed width fonts via a font combobox |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
227 QFontComboBox font_combo_box; |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
228 font_combo_box.setFontFilters (QFontComboBox::MonospacedFonts); |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
229 QStringList fonts; |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
230 |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
231 for (int index = 0; index < font_combo_box.count(); index++) |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
232 fonts << font_combo_box.itemText(index); |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
233 |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
234 // Test for macOS default fixed width font |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
235 if (fonts.contains (global_mono_font.def.toString ())) |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
236 default_family = global_mono_font.def.toString (); |
26008
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
237 #endif |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
238 |
28777
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
239 // If default font is still empty (on all other platforms or |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
240 // if macOS default font is not available): use QFontDatabase |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
241 if (default_family.isEmpty ()) |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
242 { |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
243 // Get the system's default monospaced font |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
244 QFont fixed_font = QFontDatabase::systemFont (QFontDatabase::FixedFont); |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
245 default_family = fixed_font.defaultFamily (); |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
246 } |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
247 |
0d6795d0373d
improved detection of standard fixed witdh font (bug #59128)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28118
diff
changeset
|
248 // Test env variable which has preference |
26008
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
249 std::string env_default_family = sys::env::getenv ("OCTAVE_DEFAULT_FONT"); |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
250 if (! env_default_family.empty ()) |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
251 default_family = QString::fromStdString (env_default_family); |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
252 |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
253 return default_family; |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
254 } |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
255 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
256 void resource_manager::reload_settings (void) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
257 { |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
258 QString default_family = get_default_font_family (); |
26008
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
259 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
260 if (! QFile::exists (m_settings_file)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
261 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
262 QDir ("/").mkpath (m_settings_directory); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
263 QFile qt_settings (default_qt_settings_file ()); |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
264 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
265 if (! qt_settings.open (QFile::ReadOnly)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
266 return; |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
267 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
268 QTextStream in (&qt_settings); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
269 QString settings_text = in.readAll (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
270 qt_settings.close (); |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
271 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
272 default_family = get_default_font_family (); |
25821
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
273 |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
274 QString default_font_size = "10"; |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
275 |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
276 std::string env_default_font_size |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
277 = sys::env::getenv ("OCTAVE_DEFAULT_FONT_SIZE"); |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
278 |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
279 if (! env_default_font_size.empty ()) |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
280 default_font_size = QString::fromStdString (env_default_font_size); |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
281 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
282 // Get the default custom editor |
19916
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
283 #if defined (Q_OS_WIN32) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
284 QString custom_editor = "notepad++ -n%l %f"; |
19916
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
285 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
286 QString custom_editor = "emacs +%l %f"; |
19916
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
287 #endif |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
288 |
25821
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
289 std::string env_default_editor |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
290 = sys::env::getenv ("OCTAVE_DEFAULT_EDITOR"); |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
291 |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
292 if (! env_default_editor.empty ()) |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
293 custom_editor = QString::fromStdString (env_default_editor); |
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
294 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
295 // Replace placeholders |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
296 settings_text.replace ("__default_custom_editor__", custom_editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
297 settings_text.replace ("__default_font__", default_family); |
25821
bd473c0cc34b
allow default font, size, and external editor to be set from environment
John W. Eaton <jwe@octave.org>
parents:
25702
diff
changeset
|
298 settings_text.replace ("__default_font_size__", default_font_size); |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
299 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
300 QFile user_settings (m_settings_file); |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
301 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
302 if (! user_settings.open (QIODevice::WriteOnly)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
303 return; |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
304 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
305 QTextStream out (&user_settings); |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
306 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
307 out << settings_text; |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
308 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
309 user_settings.close (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
310 } |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
311 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
312 set_settings (m_settings_file); |
26008
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
313 |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
314 // Write the default monospace font into the settings for later use by |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
315 // console and editor as fallbacks of their font preferences. |
26008
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
316 if (m_settings) |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
317 m_settings->setValue (global_mono_font.key, default_family); |
38a881b8fbec
do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents:
25821
diff
changeset
|
318 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
319 } |
14804
a565c560e654
Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14712
diff
changeset
|
320 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
321 void resource_manager::set_settings (const QString& file) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
322 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
323 delete m_settings; |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27583
diff
changeset
|
324 m_settings = new gui_settings (file, QSettings::IniFormat); |
17943
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
325 |
26369
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
26291
diff
changeset
|
326 if (! (QFile::exists (m_settings->fileName ()) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
327 && m_settings->isWritable () |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
328 && m_settings->status () == QSettings::NoError)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
329 { |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
330 QString msg |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
331 = QString (QT_TR_NOOP ("The settings file\n%1\n" |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
332 "does not exist and can not be created.\n" |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
333 "Make sure you have read and write permissions to\n%2\n\n" |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
334 "Octave GUI must be closed now.")); |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
335 |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
336 QMessageBox::critical (nullptr, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
337 QString (QT_TR_NOOP ("Octave Critical Error")), |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
338 msg.arg (get_settings_file ()).arg (get_settings_directory ())); |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27272
diff
changeset
|
339 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
340 exit (1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
341 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
342 } |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
343 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
344 bool resource_manager::update_settings_key (const QString& old_key, |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
345 const QString& new_key) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
346 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
347 if (m_settings->contains (old_key)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
348 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
349 QVariant preference = m_settings->value (old_key); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
350 m_settings->setValue (new_key, preference); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
351 m_settings->remove (old_key); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
352 return true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
353 } |
24282
a669809df612
update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
354 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
355 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
356 } |
24282
a669809df612
update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
357 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
358 bool resource_manager::is_first_run (void) const |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
359 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
360 return ! QFile::exists (m_settings_file); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
361 } |
13668
421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
362 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
363 void resource_manager::update_network_settings (void) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
364 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
365 if (m_settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
366 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
367 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy; |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
368 |
27805
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
369 if (m_settings->value (global_use_proxy.key, global_use_proxy.def).toBool ()) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
370 { |
27805
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
371 QString proxyTypeString |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
372 = m_settings->value (global_proxy_type.key, global_proxy_type.def).toString (); |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
373 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
374 if (proxyTypeString == "Socks5Proxy") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
375 proxyType = QNetworkProxy::Socks5Proxy; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
376 else if (proxyTypeString == "HttpProxy") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
377 proxyType = QNetworkProxy::HttpProxy; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
378 } |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
379 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
380 QNetworkProxy proxy; |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
381 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
382 proxy.setType (proxyType); |
27805
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
383 proxy.setHostName (m_settings->value (global_proxy_host.key, |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
384 global_proxy_host.def).toString ()); |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
385 proxy.setPort (m_settings->value (global_proxy_port.key, |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
386 global_proxy_port.def).toInt ()); |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
387 proxy.setUser (m_settings->value (global_proxy_user.key, |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
388 global_proxy_user.def).toString ()); |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
389 proxy.setPassword (m_settings->value (global_proxy_pass.key, |
dccc551aa83b
replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
390 global_proxy_pass.def).toString ()); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
391 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
392 QNetworkProxy::setApplicationProxy (proxy); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
393 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
394 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
395 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
396 // FIXME: Is this an error? If so, what should we do? |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
397 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
398 } |
13613
8728061cd0ec
Icons are now maintained by the ResourceManager.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13609
diff
changeset
|
399 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
400 QIcon resource_manager::icon (const QString& icon_name, bool fallback) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
401 { |
26140
8fb8cb4a03f8
preference for (not) using system icon theme
Torsten <mttl@mailbox.org>
parents:
26008
diff
changeset
|
402 // If system icon theme is not desired, take own icon files |
27672
a36443e94f8a
simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents:
27662
diff
changeset
|
403 if (! m_settings->value (global_icon_theme).toBool ()) |
26140
8fb8cb4a03f8
preference for (not) using system icon theme
Torsten <mttl@mailbox.org>
parents:
26008
diff
changeset
|
404 return QIcon (":/actions/icons/" + icon_name + ".png"); |
8fb8cb4a03f8
preference for (not) using system icon theme
Torsten <mttl@mailbox.org>
parents:
26008
diff
changeset
|
405 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27841
diff
changeset
|
406 // Use system icon theme with own files as fallback except when the |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27841
diff
changeset
|
407 // fallback is explicitly disabled (fallback=false) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
408 if (fallback) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
409 return QIcon::fromTheme (icon_name, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
410 QIcon (":/actions/icons/" + icon_name + ".png")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
411 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
412 return QIcon::fromTheme (icon_name); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
413 } |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
414 |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
415 // get a list of all available encodings |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
416 void resource_manager::get_codecs (QStringList *codecs) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
417 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
418 // get the codec name for each mib |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
419 QList<int> all_mibs = QTextCodec::availableMibs (); |
27676
ea7d36e9f197
use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents:
27672
diff
changeset
|
420 for (auto mib : all_mibs) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
421 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
422 QTextCodec *c = QTextCodec::codecForMib (mib); |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
423 codecs->append (c->name ().toUpper ()); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
424 } |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26226
diff
changeset
|
425 |
27272
9de4741a896e
Do not ignore user preferences for locale encoding on non-Windows platforms.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27271
diff
changeset
|
426 // Append SYSTEM |
28118
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
427 codecs->append (QString ("SYSTEM (") + |
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
428 QString (octave_locale_charset_wrapper ()).toUpper () + |
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
429 QString (")")); |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26226
diff
changeset
|
430 |
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26226
diff
changeset
|
431 // Clean up and sort list of codecs |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
432 codecs->removeDuplicates (); |
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
433 qSort (*codecs); |
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
434 } |
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
435 |
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
436 // initialize a given combo box with available text encodings |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
437 void resource_manager::combo_encoding (QComboBox *combo, |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
438 const QString& current) |
25700
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
439 { |
ba8227df92ae
synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents:
25460
diff
changeset
|
440 QStringList all_codecs; |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
441 get_codecs (&all_codecs); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
442 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
443 // get the value from the settings file if no current encoding is given |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
444 QString enc = current; |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
445 |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
446 // Check for valid codec for the default. If this fails, "SYSTEM" (i.e. |
28118
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
447 // locale_charset) will be chosen. |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
448 // FIXME: The default is "SYSTEM" on all platforms. So can this fallback |
27272
9de4741a896e
Do not ignore user preferences for locale encoding on non-Windows platforms.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27271
diff
changeset
|
449 // logic be removed completely? |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
450 bool default_exists = false; |
26291
f73bcf1d0b5a
make SYSTEM alias for locale encoding if not suported on windows (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26226
diff
changeset
|
451 if (QTextCodec::codecForName (ed_default_enc.def.toString ().toLatin1 ()) |
27271
a4416cd6bb4f
Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26959
diff
changeset
|
452 || (ed_default_enc.def.toString ().startsWith ("SYSTEM"))) |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
453 default_exists = true; |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
454 |
27271
a4416cd6bb4f
Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26959
diff
changeset
|
455 QString default_enc = |
28118
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
456 QString ("SYSTEM (") + |
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
457 QString (octave_locale_charset_wrapper ()).toUpper () + QString (")"); |
f2789cae04f3
Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
458 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
459 if (enc.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
460 { |
27672
a36443e94f8a
simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents:
27662
diff
changeset
|
461 enc = m_settings->value (ed_default_enc).toString (); |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
462 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
463 if (enc.isEmpty ()) // still empty? |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
464 { |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
465 if (default_exists) |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
466 enc = ed_default_enc.def.toString (); |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
467 else |
27271
a4416cd6bb4f
Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26959
diff
changeset
|
468 enc = default_enc; |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
469 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
470 } |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
471 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
472 // fill the combo box |
27676
ea7d36e9f197
use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents:
27672
diff
changeset
|
473 for (const auto& c : all_codecs) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
474 combo->addItem (c); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
475 |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
476 // prepend the default item |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
477 combo->insertSeparator (0); |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
478 if (default_exists) |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
479 combo->insertItem (0, ed_default_enc.def.toString ()); |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
480 else |
27271
a4416cd6bb4f
Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26959
diff
changeset
|
481 combo->insertItem (0, default_enc); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
482 |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
483 // select the default or the current one |
26226
3a90eff58fb5
editor encodings in prefs dialog only in uppercase (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26186
diff
changeset
|
484 int idx = combo->findText (enc, Qt::MatchExactly); |
26186
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
485 if (idx >= 0) |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
486 combo->setCurrentIndex (idx); |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
487 else |
b23954fd0ea6
fix encoding combo box for not supported default encoding (bug #55139)
Torsten <mttl@mailbox.org>
parents:
26172
diff
changeset
|
488 combo->setCurrentIndex (0); |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
489 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
490 combo->setMaxVisibleItems (12); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
491 } |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
492 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
493 QPointer<QTemporaryFile> |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
494 resource_manager::create_tmp_file (const QString& extension, |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
495 const QString& contents) |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
496 { |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
497 QString ext = extension; |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
498 if ((! ext.isEmpty ()) && (! ext.startsWith ('.'))) |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
499 ext = QString (".") + ext; |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
500 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
501 // Create octave dir within temp. dir |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
502 QString tmp_dir = QDir::tempPath () + QDir::separator() + "octave"; |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
503 QDir::temp ().mkdir ("octave"); |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
504 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
505 // Create temp. file |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
506 QPointer<QTemporaryFile> tmp_file |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
507 = new QTemporaryFile (tmp_dir + QDir::separator() + |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
508 "octave_XXXXXX" + ext, this); |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
509 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
510 if (tmp_file->open ()) |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
511 { |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
512 tmp_file->write (contents.toUtf8 ()); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
513 tmp_file->close (); |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
514 |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
515 m_temporary_files << tmp_file; |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
516 } |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
517 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
518 return tmp_file; |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
519 } |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
520 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
521 void resource_manager::remove_tmp_file (QPointer<QTemporaryFile> tmp_file) |
27556
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
522 { |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
523 if (tmp_file) |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
524 { |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
525 if (tmp_file->exists ()) |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
526 tmp_file->remove (); |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
527 |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
528 m_temporary_files.removeAll (tmp_file); |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
529 } |
410622ac120f
improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27412
diff
changeset
|
530 } |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
531 } |