# HG changeset patch # User Torsten Lilge # Date 1592851380 -7200 # Node ID 2813ac10ca1e0887b1775cf5cbed0ed56ec0b6ad # Parent bc521cd24922167356dbbb6ccb2d448d28aac0b3 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 diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/dialog.cc --- 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 diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/find-files-dialog.cc --- 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 = diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/gui-preferences-global.h --- 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)); diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/gui-preferences.h --- 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 diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/gui-settings.h --- 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); } diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/m-editor/file-editor-tab.cc --- 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&)), diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/main-window.cc --- 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&)), diff -r bc521cd24922 -r 2813ac10ca1e libgui/src/shortcut-manager.cc --- 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)