Mercurial > octave
annotate libgui/src/resource-manager.cc @ 23927:e3a36f84d01d
provide variable-editor widget for the GUI
This patch is the work of
RĂ¼diger Sonderfeld <ruediger on savannah>
Philip Nienhuis
Michael Barnes <mjbcode@runbox.com>
jwe
* libgui/src/variable-editor.cc, libgui/src/variable-editor.h,
libgui/src/variable-editor-model.cc,
libgui/src/variable-editor-model.h:: New files.
* libgui/src/module.mk: Update.
* main-window.cc, main-window.h (main_window::main_window):
Initialize variable_editor_window.
(main_window::~main_window): Delete variable_editor_window.
(main_window::connect_uiwidget_links): Connect variable window signals
to octave_qt_link slots and callbacks. Add variable editor to menus.
(main_window::variable_editor_callback,
main_window::force_refresh_workspace, main_window::edit_variable,
main_window::clear_variable_editor_cache): New functions.
(main_window::configure_shortcuts): Also configure variable editor
shortcuts.
* resource-manager.cc, resource-manager.h (varedit_color_chars,
varedit_color_names, varedit_default_colors): New functions.
* settings-dialog.ui: New configuration info for variable editor.
* settings-dialog.cc, settings-dialog.h
(settings_dialog::read_varedit_colors,
settings_dialog::write_varedit_colors): New functions.
(settings_dialog::settings_dialog,
settings_dialog::write_changed_settings): Also handle settings for
variable editor.
* workspace-model.h (workspace_model::prompt_variable_editor):
New signal.
* workspace-view.cc, workspace-view.h
(workspace_view::workspace_view): Also connect eidt_variable_signal to
edit_variable slot.
(workspace_view::contextmenu_requested): Handle opening variabl in
variable editor.
(workspace_view::handle_contextmenu_edit): New function.
(workspace_view::edit_variable_signal): New signal.
* octave-link.cc, octave-link.h (Fopenvar): New function.
(octave_link::post_event, octave_link::do_post_event): New variants
for methods with two, three, or four arguments.
(octave_link::set_workspace): New argument, update_variable_editor.
(octave_link::openvar): New function.
(octave_link::do_openvar): New pure virtual.
* octave-qt-link.cc, octave-qt-link.h
(octave_qt_link::do_set_workspace): New argument,
update_variable_editor.
(octave_qt_link::do_set_workspace): Optionally emit
refresh_variable_editor signal
(octave_qt_link::do_openvar): New function.
(octave_qt_link::open_variable,
octave_qt_link::refresh_variable_editor): New signals.
* gui.txi: Document openvar.
* variables.cc, variables.h (symbol_exist): New function.
* action-container.h (action_container::method_arg2_elem,
action_container::method_arg3_elem,
action_container::method_arg4_elem): New classes.
(action_container::add_method): New variants for two, three, or four
arguments.
author | Michael Barnes <mjbcode@runbox.com> |
---|---|
date | Fri, 19 May 2017 18:15:48 +0200 |
parents | 336f89b6208b |
children | bffd7d826887 |
rev | line source |
---|---|
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
1 /* |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2011-2017 Jacob Dawid |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
4 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
5 This file is part of Octave. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
6 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
10 (at your option) any later version. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
15 GNU General Public License for more details. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
16 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
20 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
21 */ |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
25 #endif |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
26 |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
27 #include <string> |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
28 |
13570
7828e1bf5b0d
Default settings are now loaded it there is no user-defined settings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13551
diff
changeset
|
29 #include <QFile> |
14845
9a355dfc7701
Fixed bug with GUI not starting the first time.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14804
diff
changeset
|
30 #include <QDir> |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
31 #include <QNetworkProxy> |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
32 #include <QLibraryInfo> |
17943
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
33 #include <QMessageBox> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
34 #if defined (HAVE_QT5) |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
35 # include <QStandardPaths> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
36 #endif |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
37 #include <QTextCodec> |
14845
9a355dfc7701
Fixed bug with GUI not starting the first time.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14804
diff
changeset
|
38 |
15161
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
39 #include "error.h" |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
40 #include "file-ops.h" |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
41 #include "help.h" |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
42 #include "oct-env.h" |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
43 |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
44 #include "defaults.h" |
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
45 |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
46 #include "QTerminal.h" |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
47 #include "workspace-model.h" |
23927
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
48 #include "variable-editor.h" |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
49 #include "resource-manager.h" |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
50 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
51 resource_manager *resource_manager::instance = nullptr; |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
52 |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
53 static QString |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
54 default_qt_settings_file (void) |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
55 { |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 std::string dsf = octave::sys::env::getenv ("OCTAVE_DEFAULT_QT_SETTINGS"); |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
57 |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
58 if (dsf.empty ()) |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
59 dsf = (octave::config::oct_etc_dir () |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
60 + octave::sys::file_ops::dir_sep_str () |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
61 + "default-qt-settings"); |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
62 |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
63 return QString::fromStdString (dsf); |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
64 } |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
65 |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
66 resource_manager::resource_manager (void) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23717
diff
changeset
|
67 : settings_directory (), settings_file (), settings (nullptr), |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23717
diff
changeset
|
68 default_settings (nullptr) |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
69 { |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
70 #if defined (HAVE_QT4) |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
71 QString home_path |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
72 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
73 #else |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
74 QString home_path |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
75 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
76 #endif |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
77 |
17938
cd97a7ef7355
remove trailing slash from settings directory string
John W. Eaton <jwe@octave.org>
parents:
17930
diff
changeset
|
78 settings_directory = home_path + "/.config/octave"; |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
79 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
80 settings_file = settings_directory + "/qt-settings"; |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
81 |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
82 default_settings = new QSettings (default_qt_settings_file (), |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
83 QSettings::IniFormat); |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
84 } |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
85 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
86 resource_manager::~resource_manager (void) |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
87 { |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
88 delete settings; |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
89 delete default_settings; |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
90 } |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
91 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
92 QString |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
93 resource_manager::get_gui_translation_dir (void) |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
94 { |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
95 // get environment variable for the locale dir (e.g. from run-octave) |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 std::string dldir = octave::sys::env::getenv ("OCTAVE_LOCALE_DIR"); |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
97 if (dldir.empty ()) |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
98 dldir = octave::config::oct_locale_dir (); // env-var empty, load the default location |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
99 return QString::fromStdString (dldir); |
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
100 } |
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
101 |
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
102 void |
16858
cd29604214c5
Use the Qscintilla langiage file if available
Torsten <ttl@justmail.de>
parents:
16641
diff
changeset
|
103 resource_manager::config_translators (QTranslator *qt_tr, |
cd29604214c5
Use the Qscintilla langiage file if available
Torsten <ttl@justmail.de>
parents:
16641
diff
changeset
|
104 QTranslator *qsci_tr, |
cd29604214c5
Use the Qscintilla langiage file if available
Torsten <ttl@justmail.de>
parents:
16641
diff
changeset
|
105 QTranslator *gui_tr) |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
106 { |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
107 bool loaded; |
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
108 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 QString qt_trans_dir |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 = QLibraryInfo::location (QLibraryInfo::TranslationsPath); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
111 |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
112 QString language = "SYSTEM"; // take system language per default |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
113 |
15972
22ab4fe661d7
gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents:
15927
diff
changeset
|
114 QSettings *settings = resource_manager::get_settings (); |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
115 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
116 if (settings) |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
117 { |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
118 // get the locale from the settings if already available |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
119 language = settings->value ("language", "SYSTEM").toString (); |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
120 } |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
121 |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
122 if (language == "SYSTEM") |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
123 language = QLocale::system ().name (); // get system wide locale |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
124 |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
125 // load the translator file for qt strings |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
126 loaded = qt_tr->load ("qt_" + language, qt_trans_dir); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
127 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20774
diff
changeset
|
128 if (! loaded) // try lower case |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
129 qt_tr->load ("qt_" + language.toLower (), qt_trans_dir); |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
130 |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
131 // load the translator file for qscintilla settings |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
132 loaded = qsci_tr->load ("qscintilla_" + language, qt_trans_dir); |
16863
c82b3614eace
try harder to load the qt translation files at start up
Torsten <ttl@justmail.de>
parents:
16858
diff
changeset
|
133 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20774
diff
changeset
|
134 if (! loaded) // try lower case |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
135 qsci_tr->load ("qscintilla_" + language.toLower (), qt_trans_dir); |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
136 |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
137 // load the translator file for gui strings |
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
18004
diff
changeset
|
138 gui_tr->load (language, get_gui_translation_dir ()); |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
139 } |
15161
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
140 |
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
141 bool |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
142 resource_manager::instance_ok (void) |
15161
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
143 { |
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
144 bool retval = true; |
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
145 |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
146 if (! instance) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
147 instance = new resource_manager (); |
15161
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
148 |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
149 if (! instance) |
15161
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
150 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19916
diff
changeset
|
151 error ("unable to create resource_manager object!"); |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
152 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
153 retval = false; |
15161
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
154 } |
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
155 |
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
156 return retval; |
ad9523348676
Make resource_manager a singleton with Octave conventions
Mike Miller <mtmiller@ieee.org>
parents:
15159
diff
changeset
|
157 } |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
158 |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
159 QSettings * |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
160 resource_manager::do_get_settings (void) const |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
161 { |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
162 return settings; |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
163 } |
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
164 |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
165 QSettings * |
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
166 resource_manager::do_get_default_settings (void) const |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
167 { |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
168 return default_settings; |
13537
a43ecce77eec
Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
169 } |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
170 |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
171 QString |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
172 resource_manager::do_get_settings_directory (void) |
15159
098546e95a5e
allow location of default settings file to be configurable
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
173 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
174 return settings_directory; |
17515
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
175 } |
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
176 |
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
177 QString |
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
178 resource_manager::do_get_settings_file (void) |
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
179 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
180 return settings_file; |
17515
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
181 } |
c8c0dff02538
gui: welcome wizard with new message text
Torsten <ttl@justmail.de>
parents:
17421
diff
changeset
|
182 |
13539
a4b5cad8f7c6
Added command line parser class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13537
diff
changeset
|
183 void |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
184 resource_manager::do_reload_settings (void) |
13668
421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
185 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
186 if (! QFile::exists (settings_file)) |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
187 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
188 QDir ("/").mkpath (settings_directory); |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
189 QFile qt_settings (default_qt_settings_file ()); |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
190 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20774
diff
changeset
|
191 if (! qt_settings.open (QFile::ReadOnly)) |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
192 return; |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
193 |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
194 QTextStream in (&qt_settings); |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
195 QString settings_text = in.readAll (); |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
196 qt_settings.close (); |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
197 |
19916
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
198 // Get the default monospaced font |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
199 #if defined (HAVE_QFONT_MONOSPACE) |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
200 QFont fixed_font; |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
201 fixed_font.setStyleHint (QFont::Monospace); |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
202 QString default_family = fixed_font.defaultFamily (); |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
203 #elif defined (Q_WS_X11) || defined (Q_WS_WIN) |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
204 QString default_family = "Courier New"; |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
205 #elif defined (Q_WS_MAC) |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
206 QString default_family = "Courier"; |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
207 #else |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
208 QString default_family = "courier"; |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
209 #endif |
19916
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
210 |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
211 // Get the default custom editor |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
212 #if defined (Q_OS_WIN32) |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
213 QString custom_editor = "notepad++ -n%l %f"; |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
214 #else |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
215 QString custom_editor = "emacs +%l %f"; |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
216 #endif |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
217 |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
218 // Replace placeholders |
6049bdfa8d56
make notepad++ the custom default editor in windows
Torsten <ttl@justmail.de>
parents:
19899
diff
changeset
|
219 settings_text.replace ("__default_custom_editor__", custom_editor); |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
220 settings_text.replace ("__default_font__", default_family); |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
221 settings_text.replace ("__default_font_size__", "10"); |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
222 |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
223 QFile user_settings (settings_file); |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
224 |
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
225 if (! user_settings.open (QIODevice::WriteOnly)) |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
226 return; |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
227 |
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
228 QTextStream out (&user_settings); |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
229 |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
230 out << settings_text; |
18036
c97ee13f1027
fix build for systems without QFont::Monospace
John W. Eaton <jwe@octave.org>
parents:
18020
diff
changeset
|
231 |
18004
b001d9e9fd17
add systems default monospace font for terminal and editor to default settings
Torsten <ttl@justmail.de>
parents:
17943
diff
changeset
|
232 user_settings.close (); |
15367
501a9cc2c68f
maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15300
diff
changeset
|
233 } |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
234 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
235 do_set_settings (settings_file); |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
236 } |
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
|
237 |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
238 void |
15300
fd27e10b9b05
pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents:
15204
diff
changeset
|
239 resource_manager::do_set_settings (const QString& file) |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
240 { |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
241 delete settings; |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
242 settings = new QSettings (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
|
243 |
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
244 if (! (settings |
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
245 && QFile::exists (settings->fileName ()) |
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
246 && settings->isWritable () |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
247 && settings->status () == QSettings::NoError)) |
17943
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
248 { |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
249 QString msg = QString (QT_TR_NOOP ( |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
250 "The settings file\n%1\n" |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
251 "does not exist and can not be created.\n" |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
252 "Make sure you have read and write permissions to\n%2\n\n" |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
253 "Octave GUI must be closed now.")); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23717
diff
changeset
|
254 QMessageBox::critical (nullptr, QString (QT_TR_NOOP ("Octave Critical Error")), |
17943
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
255 msg.arg (do_get_settings_file ()).arg (do_get_settings_directory ())); |
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
256 exit (1); |
efe3e288a20c
check the creation of settings object for success before starting the gui
Torsten <ttl@justmail.de>
parents:
17938
diff
changeset
|
257 } |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
258 } |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
259 |
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
260 bool |
16593
e13051d7a472
allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents:
16379
diff
changeset
|
261 resource_manager::do_is_first_run (void) const |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
262 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
263 return ! QFile::exists (settings_file); |
13668
421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
264 } |
421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
265 |
421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13665
diff
changeset
|
266 void |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
267 resource_manager::do_update_network_settings (void) |
13607
fd31226d4c3a
Proxy settings can now be configured.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13571
diff
changeset
|
268 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
269 if (settings) |
13607
fd31226d4c3a
Proxy settings can now be configured.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13571
diff
changeset
|
270 { |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
271 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy; |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
272 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
273 if (settings->value ("useProxyServer",false).toBool ()) |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
274 { |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
275 QString proxyTypeString = settings->value ("proxyType").toString (); |
15164
bc801a44bb1f
follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents:
15161
diff
changeset
|
276 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
277 if (proxyTypeString == "Socks5Proxy") |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
278 proxyType = QNetworkProxy::Socks5Proxy; |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
279 else if (proxyTypeString == "HttpProxy") |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
280 proxyType = QNetworkProxy::HttpProxy; |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
281 } |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
282 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
283 QNetworkProxy proxy; |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
284 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
285 proxy.setType (proxyType); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
286 proxy.setHostName (settings->value ("proxyHostName").toString ()); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
287 proxy.setPort (settings->value ("proxyPort",80).toInt ()); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
288 proxy.setUser (settings->value ("proxyUserName").toString ()); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
289 proxy.setPassword (settings->value ("proxyPassword").toString ()); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
290 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
291 QNetworkProxy::setApplicationProxy (proxy); |
13607
fd31226d4c3a
Proxy settings can now be configured.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13571
diff
changeset
|
292 } |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
293 else |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
294 { |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
295 // FIXME: Is this an error? If so, what should we do? |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
296 } |
13607
fd31226d4c3a
Proxy settings can now be configured.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13571
diff
changeset
|
297 } |
13613
8728061cd0ec
Icons are now maintained by the ResourceManager.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13609
diff
changeset
|
298 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
299 QStringList |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
300 resource_manager::storage_class_names (void) |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
301 { |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
302 return workspace_model::storage_class_names (); |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
303 } |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
304 |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
305 QList<QColor> |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
306 resource_manager::storage_class_default_colors (void) |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
307 { |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
308 return workspace_model::storage_class_default_colors (); |
16610
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
309 } |
a1f613e5066d
workspace view colors based upon variable scope (derived from Dan's patch #8013)
Torsten <ttl@justmail.de>
parents:
16593
diff
changeset
|
310 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
311 QStringList |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
312 resource_manager::terminal_color_names (void) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
313 { |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
314 return QTerminal::color_names (); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
315 } |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
316 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
317 QList<QColor> |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
318 resource_manager::terminal_default_colors (void) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
319 { |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
320 return QTerminal::default_colors (); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16610
diff
changeset
|
321 } |
19899 | 322 |
23927
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
323 QList<QColor> |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
324 resource_manager::varedit_default_colors(void) |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
325 { |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
326 return variable_editor::default_colors (); |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
327 } |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
328 |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
329 QStringList |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
330 resource_manager::varedit_color_names(void) |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
331 { |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
332 return variable_editor::color_names (); |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
333 } |
e3a36f84d01d
provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents:
23807
diff
changeset
|
334 |
19899 | 335 QIcon |
336 resource_manager::do_icon (const QString& icon_name, bool fallback) | |
337 { | |
338 if (fallback) | |
339 return QIcon::fromTheme (icon_name, | |
340 QIcon (":/actions/icons/" + icon_name + ".png")); | |
341 else | |
342 return QIcon::fromTheme (icon_name); | |
343 } | |
20774
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
344 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
345 // initialize a given combo box with available text encodings |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
346 void |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
347 resource_manager::do_combo_encoding (QComboBox *combo, QString current) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
348 { |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
349 // get the codec name for each mib |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
350 QList<int> all_mibs = QTextCodec::availableMibs (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
351 QStringList all_codecs; |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
352 foreach (int mib, all_mibs) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
353 { |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
354 QTextCodec *c = QTextCodec::codecForMib (mib); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
355 all_codecs << c->name ().toUpper (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
356 } |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
357 all_codecs.removeDuplicates (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
358 qSort (all_codecs); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
359 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
360 // the default encoding |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
361 #if defined (Q_OS_WIN32) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
362 QString def_enc = "SYSTEM"; |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
363 #else |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
364 QString def_enc = "UTF-8"; |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
365 #endif |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
366 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
367 // get the value from the settings file if no current encoding is given |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
368 QString enc = current; |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
369 if (enc.isEmpty ()) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
370 { |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
371 enc = settings->value ("editor/default_encoding",def_enc).toString (); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
372 if (enc.isEmpty ()) // still empty? |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
373 enc = def_enc; // take default |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
374 } |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
375 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
376 // fill the combo box |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
377 foreach (QString c, all_codecs) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
378 combo->addItem (c); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
379 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
380 // prepend the default item |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
381 combo->insertSeparator (0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
382 combo->insertItem (0, def_enc); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
383 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
384 // select the current/default item |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
385 int idx = combo->findText (enc); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
386 if (idx >= 0) |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
387 combo->setCurrentIndex (idx); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
388 else |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
389 combo->setCurrentIndex (0); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
390 |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
391 combo->setMaxVisibleItems (12); |
5c5e085a1ae6
allow selecting an encoding when saving a file (bug #45688)
Torsten <ttl@justmail.de>
parents:
20428
diff
changeset
|
392 } |