From 12fb41cf3f369890ad6778e965a7f35a49f9f06d Mon Sep 17 00:00:00 2001 From: Leandro Heck <1277920+leoheck@users.noreply.github.com> Date: Sun, 2 Nov 2025 12:50:48 -0300 Subject: [PATCH] Gui: Use system dialogs by default (#24882) * Fix the selector of the FileDialog and add the same default settings for the ColorDialog. * Add option to set the default ColorDialog * Use system dialog by default * Remove new env var * Fix the native file dialog selector * Adjust env variable name * Adjust env variable name --- .../InitializeFreeCADBuildOptions.cmake | 6 +----- src/Gui/CMakeLists.txt | 4 ++-- src/Gui/FileDialog.cpp | 17 +++++++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake index d94ed8af05..994aca31b4 100644 --- a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake +++ b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake @@ -24,11 +24,7 @@ macro(InitializeFreeCADBuildOptions) option(INSTALL_TO_SITEPACKAGES "If ON the freecad root namespace (python) is installed into python's site-packages" ON) option(INSTALL_PREFER_SYMLINKS "If ON then fc_copy_sources macro will create symlinks instead of copying files" OFF) option(OCCT_CMAKE_FALLBACK "disable usage of occt-config files" OFF) - if (WIN32 OR APPLE) - option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." OFF) - else() - option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." ON) - endif() + option(FREECAD_USE_QT_DIALOGS "Use Qt's dialogs instead of the native one." OFF) # == Win32 is default behaviour use the LibPack copied in Source tree ========== if(MSVC) diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 0b2d57427d..8791a8b745 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -1512,8 +1512,8 @@ if(FREECAD_USE_PCH) PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) endif(FREECAD_USE_PCH) -if (FREECAD_USE_QT_FILEDIALOG) - set_source_files_properties(FileDialog.cpp PROPERTIES COMPILE_FLAGS -DUSE_QT_FILEDIALOG) +if (FREECAD_USE_QT_DIALOGS) + set_source_files_properties(FileDialog.cpp PROPERTIES COMPILE_FLAGS -DUSE_QT_DIALOGS) endif() # Suppress some very long Eigen3 warnings of older versions and diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index 2970408871..4a320d7ddb 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -53,23 +53,28 @@ using namespace Gui; bool DialogOptions::dontUseNativeFileDialog() { -#if defined(USE_QT_FILEDIALOG) - bool notNativeDialog = true; +#if defined(USE_QT_DIALOGS) + constexpr bool notNativeDialog = true; #else - bool notNativeDialog = false; + constexpr bool notNativeDialog = false; #endif ParameterGrp::handle group = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog"); - notNativeDialog = group->GetBool("DontUseNativeDialog", notNativeDialog); - return notNativeDialog; + return group->GetBool("DontUseNativeDialog", notNativeDialog); } bool DialogOptions::dontUseNativeColorDialog() { +#if defined(USE_QT_DIALOGS) + constexpr bool notNativeDialog = true; +#else + constexpr bool notNativeDialog = false; +#endif + ParameterGrp::handle group = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog"); - return group->GetBool("DontUseNativeColorDialog", true); + return group->GetBool("DontUseNativeColorDialog", notNativeDialog); } /* TRANSLATOR Gui::FileDialog */