annotate libgui/src/gui-preferences-global.h @ 28497:2813ac10ca1e stable

force non-native file dialogs on Mac ignoring current user pref (bug #52840) * gui-preferences-global.h: for MacOS, use the new third parameter of the gui_pref constructor for global_use_native_dialog indicating that the pref will be ignored and the default value (no nativ file dialogs) will always be taken * gui-preferences.h (gui_pref): struct with a new boolean ignore key, which is false when not given in the constructor; (value): if ignore flag is true, just return the defaut and ignore the value from the settings file * dialog.cc (FileDialog): use reimplemented value method from gui_settings, not the one from QSettings * find-files-dialog.cc (browse_folders): dito * file-editor-tab.cc (save_file_as): dito * main-window.cc (handle_save_workspace_request): dito; (handle_load_workspace_request): dito; (browse_for_directory): dito: (request_open_file): dito; * shortcut-manager.cc (import_export): dito
author Torsten Lilge <ttl-octave@mailbox.org>
date Mon, 22 Jun 2020 20:43:00 +0200
parents bd51beb6205e
children 2de2b2ddd032
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 2017-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 ////////////////////////////////////////////////////////////////////////
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if ! defined (octave_gui_preferences_global_h)
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #define octave_gui_preferences_global_h 1
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "gui-preferences.h"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 // Global preferences
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 // Get the default monospaced font
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #if defined (Q_WS_X11)
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 const QString global_font_family = "Monospace";
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #elif defined (Q_WS_WIN) || defined (Q_WS_MAC)
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 const QString global_font_family = "Courier";
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #else
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 const QString global_font_family = "Courier";
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #endif
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 const gui_pref
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 global_mono_font ("monospace_font", global_font_family);
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
45 // Style
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
46
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
47 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
48 global_style ("style", QVariant ("default"));
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 const QString
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 global_toolbar_style ("QToolBar {"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 "spacing-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 "spacing-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 "margin-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 "margin-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 "padding-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 "padding-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 "border-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 "border-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 "}");
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 const QString
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 global_menubar_style ("QMenuBar {"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 "spacing-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 "spacing-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 "margin-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 "margin-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 "padding-top: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 "padding-bottom: 0px;"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 "}");
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 // Icon size (in preferences: values -1, 0, 1)
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 const QStyle::PixelMetric global_icon_sizes[3] =
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 {
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 QStyle::PM_SmallIconSize,
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 QStyle::PM_ToolBarIconSize,
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 QStyle::PM_LargeIconSize
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 };
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 const gui_pref
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 global_icon_size ("toolbar_icon_size", QVariant (0));
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 const gui_pref
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 global_icon_theme ("use_system_icon_theme", QVariant (true));
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
87 // Other
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 const gui_pref
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
90 global_status_bar ("show_status_bar", QVariant (true));
27570
775412096ae4 use symbolic constants for file dock widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
91
28497
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
92 #if defined (Q_OS_MAC)
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
93 // prevent native file dialogs on MAC by setting the default "false" and
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
94 // setting the flag for ignoring the pref to "true" (3rd argument)
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
95 const gui_pref
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
96 global_use_native_dialogs ("use_native_file_dialogs", QVariant (false), true);
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
97 #else
27570
775412096ae4 use symbolic constants for file dock widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
98 const gui_pref
775412096ae4 use symbolic constants for file dock widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
99 global_use_native_dialogs ("use_native_file_dialogs", QVariant (true));
28497
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
100 #endif
27570
775412096ae4 use symbolic constants for file dock widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
101
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27570
diff changeset
102 const gui_pref
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27570
diff changeset
103 global_cursor_blinking ("cursor_blinking", QVariant (true));
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27570
diff changeset
104
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
105 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
106 global_language ("language", QVariant ("SYSTEM"));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
107
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
108 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
109 global_ov_startup_dir ("octave_startup_dir", QVariant (QString ()));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
110 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
111 global_restore_ov_dir ("restore_octave_dir", QVariant (false));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
112
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
113 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
114 global_use_custom_editor ("useCustomFileEditor", QVariant (false));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
115 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
116 global_custom_editor ("customFileEditor", QVariant ("emacs +%l %f"));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
117
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
118 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
119 global_prompt_to_exit ("prompt_to_exit", QVariant (false));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
120
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
121 // Proxy
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
122
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
123 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
124 global_proxy_host ("proxyHostName", QVariant (QString ()));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
125 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
126 global_use_proxy ("useProxyServer", QVariant (false));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
127 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
128 global_proxy_type ("proxyType", QVariant (QString ()));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
129 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
130 global_proxy_port ("proxyPort", QVariant (80));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
131 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
132 global_proxy_user ("proxyUserName", QVariant (QString ()));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
133 const gui_pref
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
134 global_proxy_pass ("proxyPassword", QVariant (QString ()));
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27583
diff changeset
135
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 #endif