Mercurial > octave
changeset 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 | bc521cd24922 |
children | 2de2b2ddd032 |
files | libgui/src/dialog.cc libgui/src/find-files-dialog.cc libgui/src/gui-preferences-global.h libgui/src/gui-preferences.h libgui/src/gui-settings.h libgui/src/m-editor/file-editor-tab.cc libgui/src/main-window.cc libgui/src/shortcut-manager.cc |
diffstat | 8 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/dialog.cc Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/dialog.cc Mon Jun 22 20:43:00 2020 +0200 @@ -668,8 +668,7 @@ // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. resource_manager& rmgr = oct_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) setOption(QFileDialog::DontUseNativeDialog); if (multimode == "on") // uigetfile multiselect=on
--- a/libgui/src/find-files-dialog.cc Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/find-files-dialog.cc Mon Jun 22 20:43:00 2020 +0200 @@ -316,8 +316,7 @@ // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts = QFileDialog::DontUseNativeDialog; QString dir =
--- a/libgui/src/gui-preferences-global.h Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/gui-preferences-global.h Mon Jun 22 20:43:00 2020 +0200 @@ -89,8 +89,15 @@ const gui_pref global_status_bar ("show_status_bar", QVariant (true)); +#if defined (Q_OS_MAC) +// prevent native file dialogs on MAC by setting the default "false" and +// setting the flag for ignoring the pref to "true" (3rd argument) +const gui_pref +global_use_native_dialogs ("use_native_file_dialogs", QVariant (false), true); +#else const gui_pref global_use_native_dialogs ("use_native_file_dialogs", QVariant (true)); +#endif const gui_pref global_cursor_blinking ("cursor_blinking", QVariant (true));
--- a/libgui/src/gui-preferences.h Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/gui-preferences.h Mon Jun 22 20:43:00 2020 +0200 @@ -36,8 +36,9 @@ struct gui_pref { - gui_pref (const QString& key_arg, const QVariant& def_arg) - : key (key_arg), def (def_arg) + gui_pref (const QString& key_arg, const QVariant& def_arg, + const bool ignore_arg = false) + : key (key_arg), def (def_arg), ignore (ignore_arg) { } // No copying! @@ -50,6 +51,7 @@ const QString key; // the key name const QVariant def; // the default value + const bool ignore; // when true, ignore, i.e. always take default }; // The version for shortcuts, where the default value is stored as a
--- a/libgui/src/gui-settings.h Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/gui-settings.h Mon Jun 22 20:43:00 2020 +0200 @@ -62,6 +62,9 @@ QVariant value (const gui_pref& pref) const { + if (pref.ignore) + return pref.def; // ignore the current pref and always use default + return value (pref.key, pref.def); }
--- a/libgui/src/m-editor/file-editor-tab.cc Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/m-editor/file-editor-tab.cc Mon Jun 22 20:43:00 2020 +0200 @@ -2350,8 +2350,7 @@ // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) fileDialog->setOption(QFileDialog::DontUseNativeDialog); connect (fileDialog, SIGNAL (filterSelected (const QString&)),
--- a/libgui/src/main-window.cc Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/main-window.cc Mon Jun 22 20:43:00 2020 +0200 @@ -395,8 +395,7 @@ int opts = 0; // No options by default. resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts = QFileDialog::DontUseNativeDialog; QString file @@ -421,8 +420,7 @@ int opts = 0; // No options by default. resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts = QFileDialog::DontUseNativeDialog; QString file = file_arg; @@ -994,8 +992,7 @@ int opts = QFileDialog::ShowDirsOnly; resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts = QFileDialog::DontUseNativeDialog; QString dir @@ -1268,8 +1265,7 @@ fileDialog->setDirectory (m_current_directory_combo_box->itemText (0)); // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) fileDialog->setOption(QFileDialog::DontUseNativeDialog); connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
--- a/libgui/src/shortcut-manager.cc Mon Jun 22 14:11:53 2020 +0900 +++ b/libgui/src/shortcut-manager.cc Mon Jun 22 20:43:00 2020 +0200 @@ -515,8 +515,7 @@ int opts = 0; // No options by default. resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts = QFileDialog::DontUseNativeDialog; if (action == OSC_IMPORT)