diff --git a/.github/workflows/sub_lint.yml b/.github/workflows/sub_lint.yml
index f16e21ed34..ab28e819da 100644
--- a/.github/workflows/sub_lint.yml
+++ b/.github/workflows/sub_lint.yml
@@ -83,7 +83,7 @@ on:
-build/endif_comment,
+build/explicit_make_pair,
-build/forward_decl,
- +build/header_guard,
+ -build/header_guard,
+build/include,
-build/include_subdir,
-build/include_alpha,
@@ -91,9 +91,10 @@ on:
+build/include_what_you_use,
+build/namespaces_headers,
+build/namespaces_literals,
- +build/namespaces,
+ -build/namespaces,
+build/printf_format,
+build/storage_class,
+ -legal/copyright,
+readability/alt_tokens,
-readability/braces,
+readability/casting,
@@ -442,7 +443,7 @@ jobs:
blackFails=0
pip install --break-system-packages black
set +e
- black --check ${{ inputs.changedPythonFiles }} &> ${{ env.logdir }}black.log
+ black --line-length 100 --check ${{ inputs.changedPythonFiles }} &> ${{ env.logdir }}black.log
exitCode=$?
set -e
# If black has run successfully, write the Log to the console with the Problem Matchers
@@ -728,14 +729,19 @@ jobs:
- name: Clazy
if: inputs.checkClazy && inputs.changedCppFiles != '' && always()
continue-on-error: ${{ inputs.clazyFailSilent }}
+ env:
+ CLAZY_HEADER_FILTER: "^$"
run: |
clazyErrors=0
clazyWarnings=0
clazyNotes=0
sudo apt-get install -y --no-install-recommends clazy
#TODO: check where this "clazy.yaml" goes ; shall this be put in the fixes ?
- # Run clazy on all cpp files
- clazy-standalone --export-fixes=clazy.yaml -checks=${{ inputs.clazyChecks }} -p build/ ${{ inputs.changedCppFiles }} &>> ${{ env.logdir }}clazy.log || true
+ # Run clazy on all changed cpp files, ignoring any included headers
+ for file in ${{ inputs.changedCppFiles }}
+ do
+ clazy-standalone --export-fixes=clazy.yaml -checks=${{ inputs.clazyChecks }} -p build/compile_commands.json $file &>> ${{ env.logdir }}clazy.log || true
+ done
# If clazy has run successfully, write the Log to the console with the Problem Matchers
if [ -f ${{ env.logdir }}clazy.log ]
then
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 023bc14284..4654bbb76a 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -62,7 +62,7 @@ repos:
- id: check-added-large-files
- id: mixed-line-ending
- repo: https://github.com/psf/black
- rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
+ rev: 8a737e727ac5ab2f1d4cf5876720ed276dc8dc4b # frozen: 25.1.0
hooks:
- id: black
args: ['--line-length', '100']
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d2c106b426..f4dd28e0c3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,6 +84,7 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIB
if(BUILD_GUI)
SetupCoin3D()
+ SetupPivy()
SetupSpaceball()
SetupShibokenAndPyside()
SetupMatplotlib()
diff --git a/cMake/FindKDL.cmake b/cMake/FindKDL.cmake
index 0bc567329c..789d0ffab2 100644
--- a/cMake/FindKDL.cmake
+++ b/cMake/FindKDL.cmake
@@ -9,7 +9,7 @@
IF ( CMAKE_PKGCONFIG_EXECUTABLE )
MESSAGE( STATUS "Detecting KDL" )
-
+
SET(ENV{PKG_CONFIG_PATH} "${KDL_INSTALL}/lib/pkgconfig/")
MESSAGE( "Looking for KDL in: ${KDL_INSTALL}")
PKGCONFIG( "orocos-kdl >= 1.4.0" KDL_FOUND KDL_INCLUDE_DIRS KDL_DEFINES KDL_LINK_DIRS KDL_LIBS )
diff --git a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake
index feb517c756..9fa104f6df 100644
--- a/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake
+++ b/cMake/FreeCAD_Helpers/CompilerChecksAndSetups.cmake
@@ -82,6 +82,15 @@ macro(CompilerChecksAndSetups)
endif()
endif()
endif(BUILD_DYNAMIC_LINK_PYTHON)
+
+ if(BUILD_USE_LIBCXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ endif()
+
+ if(BUILD_ENABLE_TIME_TRACE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftime-trace")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftime-trace")
+ endif()
endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
if(CMAKE_COMPILER_IS_CLANGXX)
diff --git a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
index 606df314b7..56d95da9a7 100644
--- a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
+++ b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake
@@ -147,7 +147,7 @@ macro(InitializeFreeCADBuildOptions)
set(FREECAD_3DCONNEXION_SUPPORT "NavLib" CACHE STRING "Select version of the 3Dconnexion device integration")
set_property(CACHE FREECAD_3DCONNEXION_SUPPORT PROPERTY STRINGS "None" "NavLib" "Legacy" "Both")
else(MSVC OR APPLE)
- set(FREECAD_USE_3DCONNEXION_LEGACY ON)
+ option(FREECAD_USE_3DCONNEXION_LEGACY "Enable support for 3Dconnexion devices." ON)
endif(MSVC OR APPLE)
if(FREECAD_3DCONNEXION_SUPPORT STREQUAL "NavLib")
diff --git a/cMake/FreeCAD_Helpers/SetupBoost.cmake b/cMake/FreeCAD_Helpers/SetupBoost.cmake
index 0bb1343c3f..4e07e2e7c0 100644
--- a/cMake/FreeCAD_Helpers/SetupBoost.cmake
+++ b/cMake/FreeCAD_Helpers/SetupBoost.cmake
@@ -3,7 +3,7 @@ macro(SetupBoost)
set(_boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS})
- set (BOOST_COMPONENTS filesystem program_options regex system thread date_time)
+ set (BOOST_COMPONENTS program_options regex system thread date_time)
find_package(Boost ${BOOST_MIN_VERSION}
COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
diff --git a/cMake/FreeCAD_Helpers/SetupCoin3D.cmake b/cMake/FreeCAD_Helpers/SetupCoin3D.cmake
index d271ba8940..ef159ac749 100644
--- a/cMake/FreeCAD_Helpers/SetupCoin3D.cmake
+++ b/cMake/FreeCAD_Helpers/SetupCoin3D.cmake
@@ -30,6 +30,10 @@ macro(SetupCoin3D)
set(COIN3D_MICRO_VERSION "${CMAKE_MATCH_1}")
set(COIN3D_VERSION "${COIN3D_MAJOR_VERSION}.${COIN3D_MINOR_VERSION}.${COIN3D_MICRO_VERSION}")
ENDIF ()
+endmacro(SetupCoin3D)
+
+macro(SetupPivy)
+ # -------------------------------- Pivy --------------------------------
IF (NOT PIVY_VERSION)
message(STATUS "Checking Pivy version by importing it in a Python program...")
@@ -44,4 +48,30 @@ macro(SetupCoin3D)
endif ()
ENDIF ()
-endmacro(SetupCoin3D)
+ message(STATUS "Checking Pivy Coin3D version by importing it in a Python program...")
+ execute_process(
+ COMMAND ${Python3_EXECUTABLE} -c "import pivy as p; print(p.SoDB.getVersion(),end='')"
+ OUTPUT_VARIABLE PIVY_COIN_VERSION
+ RESULT_VARIABLE RETURN_CODE)
+ if (RETURN_CODE EQUAL 0)
+ message(STATUS "Found Pivy Coin3D ${PIVY_COIN_VERSION}")
+ else ()
+ message(ERROR "Failed to get Pivy Coin3D version using ${Python3_EXECUTABLE}")
+ endif ()
+
+ if (${PIVY_COIN_VERSION} MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
+ set(PIVY_COIN_MAJOR_VERSION ${CMAKE_MATCH_1})
+ set(PIVY_COIN_MINOR_VERSION ${CMAKE_MATCH_2})
+ set(PIVY_COIN_MICRO_VERSION ${CMAKE_MATCH_3})
+ set(PIVY_COIN_VERSION "${PIVY_COIN_MAJOR_VERSION}.${PIVY_COIN_MINOR_VERSION}.${PIVY_COIN_MICRO_VERSION}")
+ else ()
+ message(FATAL_ERROR "Failed to match Pivy Coin3D version string output")
+ endif ()
+
+ if (NOT (
+ (${COIN3D_MAJOR_VERSION} EQUAL ${PIVY_COIN_MAJOR_VERSION}) AND
+ (${COIN3D_MINOR_VERSION} EQUAL ${PIVY_COIN_MINOR_VERSION}) AND
+ (${COIN3D_MICRO_VERSION} EQUAL ${PIVY_COIN_MICRO_VERSION})))
+ message(FATAL_ERROR "Coin3D version ${COIN3D_VERSION} mismatches Pivy Coin3D ${PIVY_COIN_VERSION}.")
+ endif ()
+endmacro(SetupPivy)
diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake
index 351909a1b1..f7ad80837a 100644
--- a/cMake/FreeCadMacros.cmake
+++ b/cMake/FreeCadMacros.cmake
@@ -126,7 +126,7 @@ ENDMACRO(fc_target_copy_resource_flat)
# It would be a bit cleaner to generate these files in ${CMAKE_CURRENT_BINARY_DIR}
macro(generate_from_xml BASE_NAME)
- set(TOOL_PATH "${CMAKE_SOURCE_DIR}/src/Tools/generate.py")
+ set(TOOL_PATH "${CMAKE_SOURCE_DIR}/src/Tools/bindings/generate.py")
file(TO_NATIVE_PATH "${TOOL_PATH}" TOOL_NATIVE_PATH)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${BASE_NAME}.xml" SOURCE_NATIVE_PATH)
@@ -147,7 +147,7 @@ macro(generate_from_xml BASE_NAME)
COMMAND ${PYTHON_EXECUTABLE} "${TOOL_NATIVE_PATH}" --outputPath "${OUTPUT_NATIVE_PATH}" ${BASE_NAME}.xml
MAIN_DEPENDENCY "${BASE_NAME}.xml"
DEPENDS
- "${CMAKE_SOURCE_DIR}/src/Tools/generateTemplates/templateClassPyExport.py"
+ "${CMAKE_SOURCE_DIR}/src/Tools/bindings/templates/templateClassPyExport.py"
"${TOOL_PATH}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building ${BASE_NAME}.h/.cpp out of ${BASE_NAME}.xml"
diff --git a/contrib/clion/pixi/pixi-default.bash b/contrib/clion/pixi/pixi-default.bash
new file mode 100755
index 0000000000..b14ef9cd8c
--- /dev/null
+++ b/contrib/clion/pixi/pixi-default.bash
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# Change to the directory of this script (any subdirectory in the repository should work)
+cd "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
+
+# If the line above does not work then try uncommenting the line below and insert the absolute path to your FreeCAD repository
+# cd "absolute/path/to/FreeCAD"
+
+# Activate pixi default environment
+eval "$(pixi shell-hook)"
diff --git a/contrib/clion/pixi/pixi-default.bat b/contrib/clion/pixi/pixi-default.bat
new file mode 100644
index 0000000000..559711a83f
--- /dev/null
+++ b/contrib/clion/pixi/pixi-default.bat
@@ -0,0 +1,10 @@
+@echo off
+REM Change to the directory of this script (any subdirectory in the repository should work)
+cd /d "%~dp0"
+
+REM Activate pixi default environment
+REM Write the output of pixi shell-hook to a temporary batch file and execute it
+set TEMP_BATCH_FILE=%TEMP%\pixi_shell_hook_freecad.bat
+pixi shell-hook > "%TEMP_BATCH_FILE%"
+call "%TEMP_BATCH_FILE%"
+del "%TEMP_BATCH_FILE%"
\ No newline at end of file
diff --git a/src/3rdParty/OndselSolver b/src/3rdParty/OndselSolver
index 2e3659c4bc..09d6175a2b 160000
--- a/src/3rdParty/OndselSolver
+++ b/src/3rdParty/OndselSolver
@@ -1 +1 @@
-Subproject commit 2e3659c4bce3e6885269e0cb3d640261b2a91108
+Subproject commit 09d6175a2ba69e7016fcecc4f384946a2f84f92d
diff --git a/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp b/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp
index 481110f4b2..08794202cd 100644
--- a/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp
+++ b/src/3rdParty/salomesmesh/src/DriverSTL/SMESH_File.cpp
@@ -34,9 +34,10 @@
#include
#endif
-#include
+#include
+#include
-namespace boofs = boost::filesystem;
+namespace stdfs = std::filesystem;
//================================================================================
/*!
@@ -168,8 +169,8 @@ bool SMESH_File::remove()
{
close();
- boost::system::error_code err;
- boofs::remove( _name, err );
+ std::error_code err;
+ stdfs::remove( _name, err );
_error = err.message();
return !err;
@@ -185,8 +186,8 @@ long SMESH_File::size()
{
if ( _size >= 0 ) return _size; // size of an open file
- boost::system::error_code err;
- boost::uintmax_t size = boofs::file_size( _name, err );
+ std::error_code err;
+ std::uintmax_t size = stdfs::file_size( _name, err );
_error = err.message();
return err ? -1 : (long) size;
@@ -200,8 +201,8 @@ long SMESH_File::size()
bool SMESH_File::exists()
{
- boost::system::error_code err;
- bool res = boofs::exists( _name, err );
+ std::error_code err;
+ bool res = stdfs::exists( _name, err );
_error = err.message();
return err ? false : res;
@@ -215,8 +216,8 @@ bool SMESH_File::exists()
bool SMESH_File::isDirectory()
{
- boost::system::error_code err;
- bool res = boofs::is_directory( _name, err );
+ std::error_code err;
+ bool res = stdfs::is_directory( _name, err );
_error = err.message();
return err ? false : res;
diff --git a/src/3rdParty/salomesmesh/src/SMESH/DriverGMF.cpp b/src/3rdParty/salomesmesh/src/SMESH/DriverGMF.cpp
index f108cbbcb2..372ea90d50 100644
--- a/src/3rdParty/salomesmesh/src/SMESH/DriverGMF.cpp
+++ b/src/3rdParty/salomesmesh/src/SMESH/DriverGMF.cpp
@@ -25,7 +25,7 @@
#include "DriverGMF.hxx"
-#include
+#include
extern "C"
{
@@ -55,7 +55,7 @@ namespace DriverGMF
bool isExtensionCorrect( const std::string& fileName )
{
- std::string ext = boost::filesystem::path(fileName).extension().string();
+ std::string ext = std::filesystem::path(fileName).extension().string();
switch ( ext.size() ) {
case 5: return ( ext == ".mesh" || ext == ".solb" );
case 6: return ( ext == ".meshb" );
diff --git a/src/App/Application.cpp b/src/App/Application.cpp
index 967bf5bcb2..90b69881cc 100644
--- a/src/App/Application.cpp
+++ b/src/App/Application.cpp
@@ -35,8 +35,10 @@
# endif
# include
# include
+# include
# include
# include
+# include
#endif
#ifdef FC_OS_WIN32
@@ -452,7 +454,7 @@ void Application::renameDocument(const char *OldName, const char *NewName)
throw Base::RuntimeError("Renaming document internal name is no longer allowed!");
}
-Document* Application::newDocument(const char * Name, const char * UserName, bool createView, bool tempDoc)
+Document* Application::newDocument(const char * Name, const char * UserName, DocumentCreateFlags CreateFlags)
{
auto getNameAndLabel = [this](const char * Name, const char * UserName) -> std::tuple {
bool defaultName = (!Name || Name[0] == '\0');
@@ -486,10 +488,10 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo
auto tuple = getNameAndLabel(Name, UserName);
std::string name = std::get<0>(tuple);
std::string userName = std::get<1>(tuple);
- name = getUniqueDocumentName(name.c_str(), tempDoc);
+ name = getUniqueDocumentName(name.c_str(), CreateFlags.temporary);
// return the temporary document if it exists
- if (tempDoc) {
+ if (CreateFlags.temporary) {
auto it = DocMap.find(name);
if (it != DocMap.end() && it->second->testStatus(Document::TempDoc))
return it->second;
@@ -497,7 +499,7 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo
// create the FreeCAD document
std::unique_ptr newDoc(new Document(name.c_str()));
- newDoc->setStatus(Document::TempDoc, tempDoc);
+ newDoc->setStatus(Document::TempDoc, CreateFlags.temporary);
auto oldActiveDoc = _pActiveDoc;
auto doc = newDoc.release(); // now owned by the Application
@@ -538,13 +540,13 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo
Py::Module("FreeCAD").setAttr(std::string("ActiveDocument"), active);
}
- signalNewDocument(*_pActiveDoc, createView);
+ signalNewDocument(*_pActiveDoc, CreateFlags.createView);
// set the UserName after notifying all observers
_pActiveDoc->Label.setValue(userName);
// set the old document active again if the new is temporary
- if (tempDoc && oldActiveDoc)
+ if (CreateFlags.temporary && oldActiveDoc)
setActiveDocument(oldActiveDoc);
return doc;
@@ -700,9 +702,9 @@ public:
}
};
-Document* Application::openDocument(const char * FileName, bool createView) {
+Document* Application::openDocument(const char * FileName, DocumentCreateFlags createFlags) {
std::vector filenames(1,FileName);
- auto docs = openDocuments(filenames, nullptr, nullptr, nullptr, createView);
+ auto docs = openDocuments(filenames, nullptr, nullptr, nullptr, createFlags);
if(!docs.empty())
return docs.front();
return nullptr;
@@ -747,7 +749,7 @@ std::vector Application::openDocuments(const std::vector
const std::vector *paths,
const std::vector *labels,
std::vector *errs,
- bool createView)
+ DocumentCreateFlags createFlags)
{
std::vector res(filenames.size(), nullptr);
if (filenames.empty())
@@ -811,7 +813,7 @@ std::vector Application::openDocuments(const std::vector
label = (*labels)[count].c_str();
}
- auto doc = openDocumentPrivate(path, name.c_str(), label, isMainDoc, createView, std::move(objNames));
+ auto doc = openDocumentPrivate(path, name.c_str(), label, isMainDoc, createFlags, std::move(objNames));
FC_DURATION_PLUS(timing.d1,t1);
if (doc) {
timings[doc].d1 += timing.d1;
@@ -950,7 +952,7 @@ std::vector Application::openDocuments(const std::vector
Document* Application::openDocumentPrivate(const char * FileName,
const char *propFileName, const char *label,
- bool isMainDoc, bool createView,
+ bool isMainDoc, DocumentCreateFlags createFlags,
std::vector &&objNames)
{
FileInfo File(FileName);
@@ -1021,8 +1023,8 @@ Document* Application::openDocumentPrivate(const char * FileName,
// to only contain valid ASCII characters but the user name will be kept.
if(!label)
label = name.c_str();
- Document* newDoc = newDocument(name.c_str(),label,isMainDoc && createView);
+ Document* newDoc = newDocument(name.c_str(), label, createFlags);
newDoc->FileName.setValue(propFileName==FileName?File.filePath():propFileName);
try {
@@ -1144,6 +1146,17 @@ std::string Application::getExecutableName()
return mConfig["ExeName"];
}
+std::string Application::getNameWithVersion()
+{
+ auto appname = QCoreApplication::applicationName().toStdString();
+ auto config = App::Application::Config();
+ auto major = config["BuildVersionMajor"];
+ auto minor = config["BuildVersionMinor"];
+ auto point = config["BuildVersionPoint"];
+ auto suffix = config["BuildVersionSuffix"];
+ return fmt::format("{} {}.{}.{}{}", appname, major, minor, point, suffix);
+}
+
std::string Application::getTempPath()
{
return mConfig["AppTempPath"];
@@ -2060,6 +2073,7 @@ void Application::initTypes()
App::PropertyElectricalInductance ::init();
App::PropertyElectricalResistance ::init();
App::PropertyElectricCharge ::init();
+ App::PropertySurfaceChargeDensity ::init();
App::PropertyElectricCurrent ::init();
App::PropertyElectricPotential ::init();
App::PropertyElectromagneticPotential ::init();
@@ -2420,11 +2434,6 @@ void processProgramOptions(const variables_map& vm, std::map Mods = vm["module-path"].as< vector >();
string temp;
@@ -2590,7 +2599,7 @@ void Application::initConfig(int argc, char ** argv)
// Now it's time to read-in the file branding.xml if it exists
Branding brand;
QString binDir = QString::fromUtf8((mConfig["AppHomePath"] + "bin").c_str());
- QFileInfo fi(binDir, QString::fromLatin1("branding.xml"));
+ QFileInfo fi(binDir, QStringLiteral("branding.xml"));
if (fi.exists() && brand.readFile(fi.absoluteFilePath())) {
Branding::XmlConfig cfg = brand.getUserDefines();
for (Branding::XmlConfig::iterator it = cfg.begin(); it != cfg.end(); ++it) {
@@ -2599,7 +2608,17 @@ void Application::initConfig(int argc, char ** argv)
}
variables_map vm;
- parseProgramOptions(argc, argv, mConfig["ExeName"], vm);
+ {
+ BOOST_SCOPE_EXIT_ALL(&) {
+ // console-mode needs to be set (if possible) also in case parseProgramOptions
+ // throws, as it's needed when reporting such exceptions
+ if (vm.count("console")) {
+ mConfig["Console"] = "1";
+ mConfig["RunMode"] = "Cmd";
+ }
+ };
+ parseProgramOptions(argc, argv, mConfig["ExeName"], vm);
+ }
if (vm.count("keep-deprecated-paths")) {
mConfig["KeepDeprecatedPaths"] = "1";
@@ -3136,7 +3155,7 @@ QString getOldGenericDataLocation(QString home)
return QString::fromStdString(converter.to_bytes(szPath));
}
#elif defined(FC_OS_MACOSX)
- QFileInfo fi(home, QString::fromLatin1("Library/Preferences"));
+ QFileInfo fi(home, QStringLiteral("Library/Preferences"));
home = fi.absoluteFilePath();
#endif
@@ -3202,7 +3221,7 @@ QString findUserHomePath(const QString& userHome)
* Returns the path where to store application files to.
* If \a customHome is not empty it will be used, otherwise a path starting from \a stdHome will be used.
*/
-boost::filesystem::path findPath(const QString& stdHome, const QString& customHome,
+std::filesystem::path findPath(const QString& stdHome, const QString& customHome,
const std::vector& paths, bool create)
{
QString dataPath = customHome;
@@ -3210,7 +3229,7 @@ boost::filesystem::path findPath(const QString& stdHome, const QString& customHo
dataPath = stdHome;
}
- boost::filesystem::path appData(Base::FileInfo::stringToPath(dataPath.toStdString()));
+ std::filesystem::path appData(Base::FileInfo::stringToPath(dataPath.toStdString()));
// If a custom user home path is given then don't modify it
if (customHome.isEmpty()) {
@@ -3219,10 +3238,10 @@ boost::filesystem::path findPath(const QString& stdHome, const QString& customHo
}
// In order to write to our data path, we must create some directories, first.
- if (create && !boost::filesystem::exists(appData) && !Py_IsInitialized()) {
+ if (create && !std::filesystem::exists(appData) && !Py_IsInitialized()) {
try {
- boost::filesystem::create_directories(appData);
- } catch (const boost::filesystem::filesystem_error& e) {
+ std::filesystem::create_directories(appData);
+ } catch (const std::filesystem::filesystem_error& e) {
throw Base::FileSystemError("Could not create directories. Failed with: " + e.code().message());
}
}
@@ -3243,9 +3262,9 @@ boost::filesystem::path findPath(const QString& stdHome, const QString& customHo
std::tuple getCustomPaths()
{
QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
- QString userHome = env.value(QString::fromLatin1("FREECAD_USER_HOME"));
- QString userData = env.value(QString::fromLatin1("FREECAD_USER_DATA"));
- QString userTemp = env.value(QString::fromLatin1("FREECAD_USER_TEMP"));
+ QString userHome = env.value(QStringLiteral("FREECAD_USER_HOME"));
+ QString userData = env.value(QStringLiteral("FREECAD_USER_DATA"));
+ QString userTemp = env.value(QStringLiteral("FREECAD_USER_TEMP"));
auto toNativePath = [](QString& path) {
if (!path.isEmpty()) {
@@ -3270,8 +3289,8 @@ std::tuple getCustomPaths()
// if FREECAD_USER_HOME is set but not FREECAD_USER_TEMP
if (!userHome.isEmpty() && userTemp.isEmpty()) {
QDir dir(userHome);
- dir.mkdir(QString::fromLatin1("temp"));
- QFileInfo fi(dir, QString::fromLatin1("temp"));
+ dir.mkdir(QStringLiteral("temp"));
+ QFileInfo fi(dir, QStringLiteral("temp"));
userTemp = fi.absoluteFilePath();
}
@@ -3354,13 +3373,13 @@ void Application::ExtractUserPath()
// User data path
//
- boost::filesystem::path data = findPath(dataHome, customData, subdirs, true);
+ std::filesystem::path data = findPath(dataHome, customData, subdirs, true);
mConfig["UserAppData"] = Base::FileInfo::pathToString(data) + PATHSEP;
// User config path
//
- boost::filesystem::path config = findPath(configHome, customHome, subdirs, true);
+ std::filesystem::path config = findPath(configHome, customHome, subdirs, true);
mConfig["UserConfigPath"] = Base::FileInfo::pathToString(config) + PATHSEP;
@@ -3368,14 +3387,14 @@ void Application::ExtractUserPath()
//
std::vector cachedirs = subdirs;
cachedirs.emplace_back("Cache");
- boost::filesystem::path cache = findPath(cacheHome, customTemp, cachedirs, true);
+ std::filesystem::path cache = findPath(cacheHome, customTemp, cachedirs, true);
mConfig["UserCachePath"] = Base::FileInfo::pathToString(cache) + PATHSEP;
// Set application tmp. directory
//
std::vector empty;
- boost::filesystem::path tmp = findPath(tempPath, customTemp, empty, true);
+ std::filesystem::path tmp = findPath(tempPath, customTemp, empty, true);
mConfig["AppTempPath"] = Base::FileInfo::pathToString(tmp) + PATHSEP;
@@ -3383,7 +3402,7 @@ void Application::ExtractUserPath()
//
std::vector macrodirs = subdirs;
macrodirs.emplace_back("Macro");
- boost::filesystem::path macro = findPath(dataHome, customData, macrodirs, true);
+ std::filesystem::path macro = findPath(dataHome, customData, macrodirs, true);
mConfig["UserMacroPath"] = Base::FileInfo::pathToString(macro) + PATHSEP;
}
diff --git a/src/App/Application.h b/src/App/Application.h
index e2a32adefe..2646737233 100644
--- a/src/App/Application.h
+++ b/src/App/Application.h
@@ -69,6 +69,10 @@ enum class MessageOption {
Throw, /**< Throw an exception. */
};
+struct DocumentCreateFlags {
+ bool createView {true};
+ bool temporary {false};
+};
/** The Application
* The root of the whole application
@@ -94,13 +98,13 @@ public:
* the user and stored in the App::Document::Name property.
*/
App::Document* newDocument(const char * Name=nullptr, const char * UserName=nullptr,
- bool createView=true, bool tempDoc=false);
+ DocumentCreateFlags CreateFlags=DocumentCreateFlags());
/// Closes the document \a name and removes it from the application.
bool closeDocument(const char* name);
/// find a unique document name
std::string getUniqueDocumentName(const char *Name, bool tempDoc=false) const;
/// Open an existing document from a file
- App::Document* openDocument(const char * FileName=nullptr, bool createView=true);
+ App::Document* openDocument(const char * FileName=nullptr, DocumentCreateFlags createFlags = DocumentCreateFlags{});
/** Open multiple documents
*
* @param filenames: input file names
@@ -122,7 +126,7 @@ public:
const std::vector *paths=nullptr,
const std::vector *labels=nullptr,
std::vector *errs=nullptr,
- bool createView = true);
+ DocumentCreateFlags createFlags = DocumentCreateFlags{});
/// Retrieve the active document
App::Document* getActiveDocument() const;
/// Retrieve a named document
@@ -409,6 +413,7 @@ public:
//@{
static std::string getHomePath();
static std::string getExecutableName();
+ static std::string getNameWithVersion();
/*!
Returns the temporary directory. By default, this is set to the
system's temporary directory but can be customized by the user.
@@ -486,7 +491,7 @@ protected:
/// open single document only
App::Document* openDocumentPrivate(const char * FileName, const char *propFileName,
- const char *label, bool isMainDoc, bool createView, std::vector &&objNames);
+ const char *label, bool isMainDoc, DocumentCreateFlags createFlags, std::vector &&objNames);
/// Helper class for App::Document to signal on close/abort transaction
class AppExport TransactionSignaller {
diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp
index 7303d7e56c..42d8942b33 100644
--- a/src/App/ApplicationPy.cpp
+++ b/src/App/ApplicationPy.cpp
@@ -149,12 +149,13 @@ PyMethodDef Application::Methods[] = {
{"openDocument",
reinterpret_cast(reinterpret_cast(Application::sOpenDocument)),
METH_VARARGS | METH_KEYWORDS,
- "openDocument(filepath,hidden=False) -> object\n"
+ "openDocument(filepath,hidden=False,temporary=False) -> object\n"
"Create a document and load the project file into the document.\n\n"
"filepath: file path to an existing file. If the file doesn't exist\n"
" or the file cannot be loaded an I/O exception is thrown.\n"
" In this case the document is kept alive.\n"
- "hidden: whether to hide document 3D view."},
+ "hidden: whether to hide document 3D view.\n"
+ "temporary: whether to hide document in the tree view."},
// {"saveDocument", (PyCFunction) Application::sSaveDocument, METH_VARARGS,
// "saveDocument(string) -- Save the document to a file."},
// {"saveDocumentAs", (PyCFunction) Application::sSaveDocumentAs, METH_VARARGS},
@@ -339,23 +340,30 @@ PyObject* Application::sOpenDocument(PyObject* /*self*/, PyObject* args, PyObjec
{
char* Name;
PyObject* hidden = Py_False;
- static const std::array kwlist {"name", "hidden", nullptr};
+ PyObject* temporary = Py_False;
+ static const std::array kwlist {"name", "hidden", "temporary", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args,
kwd,
- "et|O!",
+ "et|O!O!",
kwlist,
"utf-8",
&Name,
&PyBool_Type,
- &hidden)) {
+ &hidden,
+ &PyBool_Type,
+ &temporary)) {
return nullptr;
}
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
try {
+ DocumentCreateFlags createFlags;
+ createFlags.createView = !Base::asBoolean(hidden);
+ createFlags.temporary = Base::asBoolean(temporary);
+
// return new document
return (GetApplication()
- .openDocument(EncodedName.c_str(), !Base::asBoolean(hidden))
+ .openDocument(EncodedName.c_str(), createFlags)
->getPyObject());
}
catch (const Base::Exception& e) {
@@ -393,11 +401,13 @@ PyObject* Application::sNewDocument(PyObject* /*self*/, PyObject* args, PyObject
PY_TRY
{
+ DocumentCreateFlags createFlags;
+ createFlags.createView = !Base::asBoolean(hidden);
+ createFlags.temporary = Base::asBoolean(temp);
+
App::Document* doc = GetApplication().newDocument(docName,
usrName,
- !Base::asBoolean(hidden),
- Base::asBoolean(temp));
- PyMem_Free(docName);
+ createFlags);
PyMem_Free(usrName);
return doc->getPyObject();
}
@@ -1032,7 +1042,7 @@ PyObject* Application::sCheckLinkDepth(PyObject* /*self*/, PyObject* args)
PY_TRY
{
return Py::new_reference_to(
- Py::Int(GetApplication().checkLinkDepth(depth, MessageOption::Throw)));
+ Py::Long(GetApplication().checkLinkDepth(depth, MessageOption::Throw)));
}
PY_CATCH;
}
@@ -1122,7 +1132,7 @@ PyObject* Application::sSetActiveTransaction(PyObject* /*self*/, PyObject* args)
PY_TRY
{
- Py::Int ret(GetApplication().setActiveTransaction(name, Base::asBoolean(persist)));
+ Py::Long ret(GetApplication().setActiveTransaction(name, Base::asBoolean(persist)));
return Py::new_reference_to(ret);
}
PY_CATCH;
@@ -1143,7 +1153,7 @@ PyObject* Application::sGetActiveTransaction(PyObject* /*self*/, PyObject* args)
}
Py::Tuple ret(2);
ret.setItem(0, Py::String(name));
- ret.setItem(1, Py::Int(id));
+ ret.setItem(1, Py::Long(id));
return Py::new_reference_to(ret);
}
PY_CATCH;
diff --git a/src/App/ComplexGeoDataPy.xml b/src/App/ComplexGeoDataPy.xml
index 7b094cb3dd..00fb61f10b 100644
--- a/src/App/ComplexGeoDataPy.xml
+++ b/src/App/ComplexGeoDataPy.xml
@@ -117,7 +117,7 @@
Geometry Tag
-
+
@@ -129,7 +129,7 @@
Get the current element map size
-
+
diff --git a/src/App/ComplexGeoDataPyImp.cpp b/src/App/ComplexGeoDataPyImp.cpp
index 878876d9c4..768229a569 100644
--- a/src/App/ComplexGeoDataPyImp.cpp
+++ b/src/App/ComplexGeoDataPyImp.cpp
@@ -110,9 +110,9 @@ PyObject* ComplexGeoDataPy::getFacesFromSubElement(PyObject* args)
Py::List facet;
for (const auto& it : facets) {
Py::Tuple f(3);
- f.setItem(0, Py::Int(int(it.I1)));
- f.setItem(1, Py::Int(int(it.I2)));
- f.setItem(2, Py::Int(int(it.I3)));
+ f.setItem(0, Py::Long(int(it.I1)));
+ f.setItem(1, Py::Long(int(it.I2)));
+ f.setItem(2, Py::Long(int(it.I3)));
facet.append(f);
}
tuple.setItem(1, facet);
@@ -147,8 +147,8 @@ PyObject* ComplexGeoDataPy::getLinesFromSubElement(PyObject* args)
Py::List line;
for (const auto& it : lines) {
Py::Tuple l(2);
- l.setItem(0, Py::Int((int)it.I1));
- l.setItem(1, Py::Int((int)it.I2));
+ l.setItem(0, Py::Long((int)it.I1));
+ l.setItem(1, Py::Long((int)it.I2));
line.append(l);
}
tuple.setItem(1, line);
@@ -213,8 +213,8 @@ PyObject* ComplexGeoDataPy::getLines(PyObject* args)
Py::List line;
for (const auto& it : lines) {
Py::Tuple l(2);
- l.setItem(0, Py::Int((int)it.I1));
- l.setItem(1, Py::Int((int)it.I2));
+ l.setItem(0, Py::Long((int)it.I1));
+ l.setItem(1, Py::Long((int)it.I2));
line.append(l);
}
tuple.setItem(1, line);
@@ -247,9 +247,9 @@ PyObject* ComplexGeoDataPy::getFaces(PyObject* args)
Py::List facet;
for (const auto& it : facets) {
Py::Tuple f(3);
- f.setItem(0, Py::Int((int)it.I1));
- f.setItem(1, Py::Int((int)it.I2));
- f.setItem(2, Py::Int((int)it.I3));
+ f.setItem(0, Py::Long((int)it.I1));
+ f.setItem(1, Py::Long((int)it.I2));
+ f.setItem(2, Py::Long((int)it.I3));
facet.append(f);
}
tuple.setItem(1, facet);
@@ -509,9 +509,9 @@ Py::Dict ComplexGeoDataPy::getElementReverseMap() const
return ret;
}
-Py::Int ComplexGeoDataPy::getElementMapSize() const
+Py::Long ComplexGeoDataPy::getElementMapSize() const
{
- return Py::Int((long)getComplexGeoDataPtr()->getElementMapSize());
+ return Py::Long((long)getComplexGeoDataPtr()->getElementMapSize());
}
void ComplexGeoDataPy::setHasher(Py::Object obj)
@@ -575,12 +575,12 @@ Py::String ComplexGeoDataPy::getElementMapVersion() const
}
-Py::Int ComplexGeoDataPy::getTag() const
+Py::Long ComplexGeoDataPy::getTag() const
{
- return Py::Int(getComplexGeoDataPtr()->Tag);
+ return Py::Long(getComplexGeoDataPtr()->Tag);
}
-void ComplexGeoDataPy::setTag(Py::Int tag)
+void ComplexGeoDataPy::setTag(Py::Long tag)
{
getComplexGeoDataPtr()->Tag = tag;
}
diff --git a/src/App/Datums.cpp b/src/App/Datums.cpp
index 1d08929297..251f347111 100644
--- a/src/App/Datums.cpp
+++ b/src/App/Datums.cpp
@@ -156,7 +156,7 @@ App::DatumElement* LocalCoordinateSystem::getDatumElement(const char* role) cons
{
const auto& features = OriginFeatures.getValues();
auto featIt = std::find_if(features.begin(), features.end(), [role](App::DocumentObject* obj) {
- return obj->isDerivedFrom(App::DatumElement::getClassTypeId())
+ return obj->isDerivedFrom()
&& strcmp(static_cast(obj)->Role.getValue(), role) == 0;
});
if (featIt != features.end()) {
@@ -171,7 +171,7 @@ App::DatumElement* LocalCoordinateSystem::getDatumElement(const char* role) cons
App::Line* LocalCoordinateSystem::getAxis(const char* role) const
{
App::DatumElement* feat = getDatumElement(role);
- if (feat->isDerivedFrom(App::Line::getClassTypeId())) {
+ if (feat->isDerivedFrom()) {
return static_cast(feat);
}
std::stringstream err;
@@ -183,7 +183,7 @@ App::Line* LocalCoordinateSystem::getAxis(const char* role) const
App::Plane* LocalCoordinateSystem::getPlane(const char* role) const
{
App::DatumElement* feat = getDatumElement(role);
- if (feat->isDerivedFrom(App::Plane::getClassTypeId())) {
+ if (feat->isDerivedFrom()) {
return static_cast(feat);
}
std::stringstream err;
@@ -195,7 +195,7 @@ App::Plane* LocalCoordinateSystem::getPlane(const char* role) const
App::Point* LocalCoordinateSystem::getPoint(const char* role) const
{
App::DatumElement* feat = getDatumElement(role);
- if (feat->isDerivedFrom(App::Point::getClassTypeId())) {
+ if (feat->isDerivedFrom()) {
return static_cast(feat);
}
std::stringstream err;
@@ -262,7 +262,7 @@ DatumElement* LocalCoordinateSystem::createDatum(const SetupData& data)
std::string objName = doc->getUniqueObjectName(data.role);
App::DocumentObject* featureObj = doc->addObject(data.type.getName(), objName.c_str());
- assert(featureObj && featureObj->isDerivedFrom(App::DatumElement::getClassTypeId()));
+ assert(featureObj && featureObj->isDerivedFrom());
QByteArray byteArray = data.label.toUtf8();
featureObj->Label.setValue(byteArray.constData());
diff --git a/src/App/Document.cpp b/src/App/Document.cpp
index 6dc25c8fe3..9b583183c0 100644
--- a/src/App/Document.cpp
+++ b/src/App/Document.cpp
@@ -60,7 +60,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#ifndef _PreComp_
#include
#include
-#include
+#include
#endif
#include
@@ -131,7 +131,7 @@ using namespace zipios;
#define FC_LOGFEATUREUPDATE
#endif
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
namespace App
{
@@ -835,7 +835,7 @@ void Document::onChanged(const Property* prop)
void Document::onBeforeChangeProperty(const TransactionalObject* Who, const Property* What)
{
- if (Who->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
+ if (Who->isDerivedFrom()) {
signalBeforeChangeObject(*static_cast(Who), *What);
}
if (!d->rollback && !globalIsRelabeling) {
@@ -3544,7 +3544,7 @@ DocumentObject* Document::addObject(const char* sType,
const char* viewType,
bool isPartial)
{
- Base::Type type =
+ const Base::Type type =
Base::Type::getTypeIfDerivedFrom(sType, App::DocumentObject::getClassTypeId(), true);
if (type.isBad()) {
std::stringstream str;
@@ -3557,8 +3557,7 @@ DocumentObject* Document::addObject(const char* sType,
return nullptr;
}
- App::DocumentObject* pcObject = static_cast(typeInstance);
-
+ auto* pcObject = static_cast(typeInstance);
pcObject->setDocument(this);
// do no transactions if we do a rollback!
@@ -3571,15 +3570,8 @@ DocumentObject* Document::addObject(const char* sType,
}
// get Unique name
- string ObjectName;
-
- if (pObjectName && pObjectName[0] != '\0') {
- ObjectName = getUniqueObjectName(pObjectName);
- }
- else {
- ObjectName = getUniqueObjectName(sType);
- }
-
+ const bool hasName = pObjectName && pObjectName[0] != '\0';
+ const string ObjectName = getUniqueObjectName(hasName ? pObjectName : type.getName());
d->activeObject = pcObject;
@@ -4338,7 +4330,7 @@ std::vector Document::getObjectsOfType(const Base::Type& typeId
{
std::vector Objects;
for (auto it : d->objectArray) {
- if (it->getTypeId().isDerivedFrom(typeId)) {
+ if (it->isDerivedFrom(typeId)) {
Objects.push_back(it);
}
}
@@ -4376,7 +4368,7 @@ Document::findObjects(const Base::Type& typeId, const char* objname, const char*
std::vector Objects;
DocumentObject* found = nullptr;
for (auto it : d->objectArray) {
- if (it->getTypeId().isDerivedFrom(typeId)) {
+ if (it->isDerivedFrom(typeId)) {
found = it;
if (!rx_name.empty() && !boost::regex_search(it->getNameInDocument(), what, rx_name)) {
@@ -4398,7 +4390,7 @@ Document::findObjects(const Base::Type& typeId, const char* objname, const char*
int Document::countObjectsOfType(const Base::Type& typeId) const
{
return std::count_if(d->objectMap.begin(), d->objectMap.end(), [&](const auto& it) {
- return it.second->getTypeId().isDerivedFrom(typeId);
+ return it.second->isDerivedFrom(typeId);
});
}
diff --git a/src/App/Document.h b/src/App/Document.h
index b13b206bd0..cdabf8efce 100644
--- a/src/App/Document.h
+++ b/src/App/Document.h
@@ -268,6 +268,21 @@ public:
bool isNew = true,
const char* viewType = nullptr,
bool isPartial = false);
+ //@{
+ /** Add a feature of T type with sName (ASCII) to this document and set it active.
+ * Unicode names are set through the Label property.
+ * @param pObjectName if nonNULL use that name otherwise generate a new unique name based on the
+ * \a sType
+ * @param isNew if false don't call the \c DocumentObject::setupObject() callback (default
+ * is true)
+ * @param viewType override object's view provider name
+ * @param isPartial indicate if this object is meant to be partially loaded
+ */
+ template
+ T* addObject(const char* pObjectName = nullptr,
+ bool isNew = true,
+ const char* viewType = nullptr,
+ bool isPartial = false);
/** Add an array of features of the given types and names.
* Unicode names are set through the Label property.
* @param sType The type of created object
@@ -662,6 +677,12 @@ inline int Document::countObjectsOfType() const
return this->countObjectsOfType(T::getClassTypeId());
}
+template
+T* Document::addObject(const char* pObjectName, bool isNew, const char* viewType, bool isPartial)
+{
+ static_assert(std::is_base_of::value, "T must be derived from DocumentObject");
+ return static_cast(addObject(T::getClassName(), pObjectName, isNew, viewType, isPartial));
+}
} // namespace App
diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp
index bd2b3b395e..17f2b83ce8 100644
--- a/src/App/DocumentObject.cpp
+++ b/src/App/DocumentObject.cpp
@@ -759,7 +759,7 @@ bool DocumentObject::removeDynamicProperty(const char* name)
return false;
}
- if (prop->isDerivedFrom(PropertyLinkBase::getClassTypeId())) {
+ if (prop->isDerivedFrom()) {
clearOutListCache();
}
diff --git a/src/App/DocumentObjectExtension.cpp b/src/App/DocumentObjectExtension.cpp
index 85e3922839..c98e0d9f74 100644
--- a/src/App/DocumentObjectExtension.cpp
+++ b/src/App/DocumentObjectExtension.cpp
@@ -76,14 +76,14 @@ PyObject* DocumentObjectExtension::getExtensionPyObject()
const DocumentObject* DocumentObjectExtension::getExtendedObject() const
{
- assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId()));
+ assert(getExtendedContainer()->isDerivedFrom());
return static_cast(getExtendedContainer());
}
DocumentObject* DocumentObjectExtension::getExtendedObject()
{
- assert(getExtendedContainer()->isDerivedFrom(DocumentObject::getClassTypeId()));
+ assert(getExtendedContainer()->isDerivedFrom());
return static_cast(getExtendedContainer());
}
diff --git a/src/App/DocumentObjectPy.xml b/src/App/DocumentObjectPy.xml
index cb93c974db..ea63126b17 100644
--- a/src/App/DocumentObjectPy.xml
+++ b/src/App/DocumentObjectPy.xml
@@ -305,7 +305,7 @@ or None if the GUI is not up
The unique identifier (among its document) of this object
-
+
diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp
index c6e2e32b20..5ca4a9185b 100644
--- a/src/App/DocumentObjectPyImp.cpp
+++ b/src/App/DocumentObjectPyImp.cpp
@@ -898,9 +898,9 @@ int DocumentObjectPy::setCustomAttributes(const char*, PyObject*)
return 0;
}
-Py::Int DocumentObjectPy::getID() const
+Py::Long DocumentObjectPy::getID() const
{
- return Py::Int(getDocumentObjectPtr()->getID());
+ return Py::Long(getDocumentObjectPtr()->getID());
}
Py::Boolean DocumentObjectPy::getRemoving() const
diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp
index 78b8574302..0bbb616a52 100644
--- a/src/App/DocumentObserver.cpp
+++ b/src/App/DocumentObserver.cpp
@@ -177,7 +177,7 @@ void DocumentObjectT::operator=(const DocumentObject* obj)
void DocumentObjectT::operator=(const Property* prop)
{
if (!prop || !prop->hasName() || !prop->getContainer()
- || !prop->getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
+ || !prop->getContainer()->isDerivedFrom()) {
object.clear();
label.clear();
document.clear();
diff --git a/src/App/DocumentPy.xml b/src/App/DocumentPy.xml
index 2e929d7ac1..798994b3c8 100644
--- a/src/App/DocumentPy.xml
+++ b/src/App/DocumentPy.xml
@@ -136,15 +136,15 @@ viewType (String): override the view provider type directly, only effective when
Remove an object from the document
-
+
-copyObject(object, with_dependencies=False, return_all=False)
+copyObject(object, recursive=False, return_all=False)
Copy an object or objects from another document to this document.
object: can either a single object or sequence of objects
-with_dependencies: if True, all internal dependent objects are copied too.
-return_all: if True, return all copied objects, or else return only the copied
+recursive: if True, also recursively copies internal objects.
+return_all: if True, returns all copied objects, or else return only the copied
object corresponding to the input objects.
@@ -313,25 +313,25 @@ sort: whether to topologically sort the return list
The Undo mode of the Document (0 = no Undo, 1 = Undo/Redo)
-
+
The size of the Undo stack in byte
-
+
Number of possible Undos
-
+
Number of possible Redos
-
+
diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp
index c10db56c8c..1c7d8a03fe 100644
--- a/src/App/DocumentPyImp.cpp
+++ b/src/App/DocumentPyImp.cpp
@@ -388,7 +388,7 @@ PyObject* DocumentPy::addObject(PyObject* args, PyObject* kwd)
pyvp = Py::Object(view);
}
if (pyvp.isNone()) {
- pyvp = Py::Int(1);
+ pyvp = Py::Long(1);
}
// 'pyvp' is the python class with the implementation for ViewProvider
if (pyvp.hasAttr("__vobject__")) {
@@ -426,10 +426,21 @@ PyObject* DocumentPy::removeObject(PyObject* args)
}
}
-PyObject* DocumentPy::copyObject(PyObject* args)
+PyObject* DocumentPy::copyObject(PyObject* args, PyObject* kwd)
{
- PyObject *obj, *rec = Py_False, *retAll = Py_False;
- if (!PyArg_ParseTuple(args, "O|O!O!", &obj, &PyBool_Type, &rec, &PyBool_Type, &retAll)) {
+ PyObject* obj;
+ PyObject* rec = Py_False;
+ PyObject* retAll = Py_False;
+ static constexpr std::array kwlist {"object", "recursive", "return_all", nullptr};
+ if (!Base::Wrapped_ParseTupleAndKeywords(args,
+ kwd,
+ "O|O!O!",
+ kwlist,
+ &obj,
+ &PyBool_Type,
+ &rec,
+ &PyBool_Type,
+ &retAll)) {
return nullptr;
}
@@ -695,7 +706,7 @@ PyObject* DocumentPy::recompute(PyObject* args)
return nullptr;
}
- return Py::new_reference_to(Py::Int(objectCount));
+ return Py::new_reference_to(Py::Long(objectCount));
}
PY_CATCH;
}
@@ -890,30 +901,30 @@ Py::List DocumentPy::getRootObjectsIgnoreLinks() const
return res;
}
-Py::Int DocumentPy::getUndoMode() const
+Py::Long DocumentPy::getUndoMode() const
{
- return Py::Int(getDocumentPtr()->getUndoMode());
+ return Py::Long(getDocumentPtr()->getUndoMode());
}
-void DocumentPy::setUndoMode(Py::Int arg)
+void DocumentPy::setUndoMode(Py::Long arg)
{
getDocumentPtr()->setUndoMode(arg);
}
-Py::Int DocumentPy::getUndoRedoMemSize() const
+Py::Long DocumentPy::getUndoRedoMemSize() const
{
- return Py::Int((long)getDocumentPtr()->getUndoMemSize());
+ return Py::Long((long)getDocumentPtr()->getUndoMemSize());
}
-Py::Int DocumentPy::getUndoCount() const
+Py::Long DocumentPy::getUndoCount() const
{
- return Py::Int((long)getDocumentPtr()->getAvailableUndos());
+ return Py::Long((long)getDocumentPtr()->getAvailableUndos());
}
-Py::Int DocumentPy::getRedoCount() const
+Py::Long DocumentPy::getRedoCount() const
{
- return Py::Int((long)getDocumentPtr()->getAvailableRedos());
+ return Py::Long((long)getDocumentPtr()->getAvailableRedos());
}
Py::List DocumentPy::getUndoNames() const
diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp
index a6169b9697..596930a0bc 100644
--- a/src/App/Expression.cpp
+++ b/src/App/Expression.cpp
@@ -2016,7 +2016,7 @@ Py::Object FunctionExpression::evalAggregate(
}
for (auto &arg : args) {
- if (arg->isDerivedFrom(RangeExpression::getClassTypeId())) {
+ if (arg->isDerivedFrom()) {
Range range(static_cast(*arg).getRange());
do {
@@ -2159,7 +2159,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
switch (f) {
case LIST: {
- if (args.size() == 1 && args[0]->isDerivedFrom(RangeExpression::getClassTypeId()))
+ if (args.size() == 1 && args[0]->isDerivedFrom())
return args[0]->getPyValue();
Py::List list(args.size());
int i = 0;
@@ -2168,7 +2168,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
return list;
}
case TUPLE: {
- if (args.size() == 1 && args[0]->isDerivedFrom(RangeExpression::getClassTypeId()))
+ if (args.size() == 1 && args[0]->isDerivedFrom())
return Py::Tuple(args[0]->getPyValue());
Py::Tuple tuple(args.size());
int i = 0;
diff --git a/src/App/ExtensionContainer.h b/src/App/ExtensionContainer.h
index 0910125ca9..7972ba4975 100644
--- a/src/App/ExtensionContainer.h
+++ b/src/App/ExtensionContainer.h
@@ -239,7 +239,7 @@ private:
std::map _extensions;
};
-#define PROPERTY_HEADER_WITH_EXTENSIONS(_class_) PROPERTY_HEADER_WITH_OVERRIDE(_class)
+#define PROPERTY_HEADER_WITH_EXTENSIONS(_class_) PROPERTY_HEADER_WITH_OVERRIDE(_class_)
/// We make sure that the PropertyData of the container is not connected to the one of the extension
#define PROPERTY_SOURCE_WITH_EXTENSIONS(_class_, _parentclass_) \
diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp
index fdb7640821..c4188223c9 100644
--- a/src/App/FeaturePython.cpp
+++ b/src/App/FeaturePython.cpp
@@ -278,14 +278,14 @@ bool FeaturePythonImp::getSubObject(DocumentObject*& ret,
subname = "";
}
args.setItem(1, Py::String(subname));
- args.setItem(2, Py::Int(pyObj ? 2 : 1));
+ args.setItem(2, Py::Long(pyObj ? 2 : 1));
Base::MatrixPy* pyMat = new Base::MatrixPy(new Base::Matrix4D);
if (_mat) {
*pyMat->getMatrixPtr() = *_mat;
}
args.setItem(3, Py::asObject(pyMat));
args.setItem(4, Py::Boolean(transform));
- args.setItem(5, Py::Int(depth));
+ args.setItem(5, Py::Long(depth));
Py::Object res(Base::pyCall(py_getSubObject.ptr(), args.ptr()));
if (res.isNone()) {
@@ -343,7 +343,7 @@ bool FeaturePythonImp::getSubObjects(std::vector& ret, int reason)
try {
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
- args.setItem(1, Py::Int(reason));
+ args.setItem(1, Py::Long(reason));
Py::Object res(Base::pyCall(py_getSubObjects.ptr(), args.ptr()));
if (!res.isTrue()) {
return true;
@@ -390,7 +390,7 @@ bool FeaturePythonImp::getLinkedObject(DocumentObject*& ret,
}
args.setItem(2, Py::asObject(pyMat));
args.setItem(3, Py::Boolean(transform));
- args.setItem(4, Py::Int(depth));
+ args.setItem(4, Py::Long(depth));
Py::Object res(Base::pyCall(py_getLinkedObject.ptr(), args.ptr()));
if (!res.isTrue()) {
@@ -466,7 +466,7 @@ int FeaturePythonImp::isElementVisible(const char* element) const
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::String(element ? element : ""));
- return Py::Int(Base::pyCall(py_isElementVisible.ptr(), args.ptr()));
+ return Py::Long(Base::pyCall(py_isElementVisible.ptr(), args.ptr()));
}
catch (Py::Exception&) {
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
@@ -488,7 +488,7 @@ int FeaturePythonImp::setElementVisible(const char* element, bool visible)
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::String(element ? element : ""));
args.setItem(2, Py::Boolean(visible));
- return Py::Int(Base::pyCall(py_setElementVisible.ptr(), args.ptr()));
+ return Py::Long(Base::pyCall(py_setElementVisible.ptr(), args.ptr()));
}
catch (Py::Exception&) {
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
@@ -568,7 +568,7 @@ int FeaturePythonImp::canLoadPartial() const
try {
Py::Tuple args(1);
args.setItem(0, Py::Object(object->getPyObject(), true));
- Py::Int ret(Base::pyCall(py_canLoadPartial.ptr(), args.ptr()));
+ Py::Long ret(Base::pyCall(py_canLoadPartial.ptr(), args.ptr()));
return ret;
}
catch (Py::Exception&) {
diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp
index dc8808adf9..c7bc8252e3 100644
--- a/src/App/GeoFeatureGroupExtension.cpp
+++ b/src/App/GeoFeatureGroupExtension.cpp
@@ -55,7 +55,7 @@ GeoFeatureGroupExtension::~GeoFeatureGroupExtension() = default;
void GeoFeatureGroupExtension::initExtension(ExtensionContainer* obj)
{
- if (!obj->isDerivedFrom(App::GeoFeature::getClassTypeId())) {
+ if (!obj->isDerivedFrom()) {
throw Base::RuntimeError("GeoFeatureGroupExtension can only be applied to GeoFeatures");
}
@@ -88,7 +88,7 @@ DocumentObject* GeoFeatureGroupExtension::getGroupOfObject(const DocumentObject*
}
// we will find origins, but not origin features
- if (obj->isDerivedFrom(App::DatumElement::getClassTypeId())) {
+ if (obj->isDerivedFrom()) {
return OriginGroupExtension::getGroupOfObject(obj);
}
@@ -307,8 +307,8 @@ void GeoFeatureGroupExtension::getCSOutList(const App::DocumentObject* obj,
//we remove all links to origin features and origins, they belong to a CS too and can't be moved
result.erase(std::remove_if(result.begin(), result.end(), [](App::DocumentObject* obj)->bool {
- return (obj->isDerivedFrom(App::DatumElement::getClassTypeId()) ||
- obj->isDerivedFrom(App::Origin::getClassTypeId()));
+ return (obj->isDerivedFrom() ||
+ obj->isDerivedFrom());
}), result.end());
vec.insert(vec.end(), result.begin(), result.end());
@@ -483,7 +483,7 @@ bool GeoFeatureGroupExtension::isLinkValid(App::Property* prop)
}
// get the object that holds the property
- if (!prop->getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
+ if (!prop->getContainer()->isDerivedFrom()) {
return true; // this link comes not from a document object, scopes are meaningless
}
auto obj = static_cast(prop->getContainer());
diff --git a/src/App/Graphviz.cpp b/src/App/Graphviz.cpp
index 5a09a9e3ee..f2765da4b3 100644
--- a/src/App/Graphviz.cpp
+++ b/src/App/Graphviz.cpp
@@ -301,7 +301,7 @@ void Document::exportGraphviz(std::ostream& out) const
if (!sgraph) {
auto group = GeoFeatureGroupExtension::getGroupOfObject(docObj);
if (group) {
- if (docObj->isDerivedFrom(App::DatumElement::getClassTypeId())) {
+ if (docObj->isDerivedFrom()) {
sgraph = GraphList[group->getExtensionByType()
->Origin.getValue()];
}
@@ -311,7 +311,7 @@ void Document::exportGraphviz(std::ostream& out) const
}
}
if (!sgraph) {
- if (docObj->isDerivedFrom(DatumElement::getClassTypeId())) {
+ if (docObj->isDerivedFrom()) {
auto* lcs = static_cast(docObj)->getLCS();
if (lcs) {
sgraph = GraphList[lcs];
@@ -453,7 +453,7 @@ void Document::exportGraphviz(std::ostream& out) const
// ignore groups inside other groups, these will be processed in one of the next
// recursive calls. App::Origin now has the GeoFeatureGroupExtension but it
// should not move its group symbol outside its parent
- if (!objectIt->isDerivedFrom(Origin::getClassTypeId())
+ if (!objectIt->isDerivedFrom()
&& objectIt->hasExtension(
GeoFeatureGroupExtension::getExtensionClassTypeId())
&& GeoFeatureGroupExtension::getGroupOfObject(objectIt) == nullptr) {
@@ -571,7 +571,7 @@ void Document::exportGraphviz(std::ostream& out) const
// Add edges between document objects
for (const auto& It : d->objectMap) {
- if (omitGeoFeatureGroups && It.second->isDerivedFrom(Origin::getClassTypeId())) {
+ if (omitGeoFeatureGroups && It.second->isDerivedFrom()) {
continue;
}
diff --git a/src/App/GroupExtension.cpp b/src/App/GroupExtension.cpp
index 6e017b82f9..ed10599419 100644
--- a/src/App/GroupExtension.cpp
+++ b/src/App/GroupExtension.cpp
@@ -296,7 +296,7 @@ std::vector GroupExtension::getObjectsOfType(const Base::Type&
std::vector type;
const std::vector& grp = Group.getValues();
for (auto it : grp) {
- if (it->getTypeId().isDerivedFrom(typeId)) {
+ if (it->isDerivedFrom(typeId)) {
type.push_back(it);
}
}
@@ -309,7 +309,7 @@ int GroupExtension::countObjectsOfType(const Base::Type& typeId) const
int type = 0;
const std::vector& grp = Group.getValues();
for (auto it : grp) {
- if (it->getTypeId().isDerivedFrom(typeId)) {
+ if (it->isDerivedFrom(typeId)) {
type++;
}
}
diff --git a/src/App/GroupExtension.h b/src/App/GroupExtension.h
index 4130023d23..8fa14f3eed 100644
--- a/src/App/GroupExtension.h
+++ b/src/App/GroupExtension.h
@@ -51,6 +51,11 @@ public:
* append it to this group as well.
*/
virtual DocumentObject* addObject(const char* sType, const char* pObjectName);
+ /** Adds an object of \a T with \a pObjectName to the document this group belongs to and
+ * append it to this group as well.
+ */
+ template
+ T* addObject(const char* pObjectName);
/* Adds the object \a obj to this group. Returns all objects that have been added.
*/
virtual std::vector addObject(DocumentObject* obj);
@@ -151,6 +156,13 @@ private:
};
+template
+T* GroupExtension::addObject(const char* pObjectName)
+{
+ static_assert(std::is_base_of::value, "T must be derived from DocumentObject");
+ return static_cast(addObject(T::getClassName(), pObjectName));
+}
+
template
class GroupExtensionPythonT: public ExtensionT
{
diff --git a/src/App/Link.cpp b/src/App/Link.cpp
index c520d43a20..5703c39f00 100644
--- a/src/App/Link.cpp
+++ b/src/App/Link.cpp
@@ -409,7 +409,7 @@ App::DocumentObjectExecReturn* LinkBaseExtension::extensionExecute()
else {
const auto& elements = _getElementListValue();
for (int i = 0; i < _getElementCountValue(); ++i) {
- args.setItem(2, Py::Int(i));
+ args.setItem(2, Py::Long(i));
if (i < (int)elements.size()) {
args.setItem(3, Py::asObject(elements[i]->getPyObject()));
}
@@ -1167,7 +1167,7 @@ int LinkBaseExtension::extensionIsElementVisible(const char* element)
const DocumentObject* LinkBaseExtension::getContainer() const
{
auto ext = getExtendedContainer();
- if (!ext || !ext->isDerivedFrom(DocumentObject::getClassTypeId())) {
+ if (!ext || !ext->isDerivedFrom()) {
LINK_THROW(Base::RuntimeError, "Link: container not derived from document object");
}
return static_cast(ext);
@@ -1176,7 +1176,7 @@ const DocumentObject* LinkBaseExtension::getContainer() const
DocumentObject* LinkBaseExtension::getContainer()
{
auto ext = getExtendedContainer();
- if (!ext || !ext->isDerivedFrom(DocumentObject::getClassTypeId())) {
+ if (!ext || !ext->isDerivedFrom()) {
LINK_THROW(Base::RuntimeError, "Link: container not derived from document object");
}
return static_cast(ext);
diff --git a/src/App/LinkBaseExtensionPyImp.cpp b/src/App/LinkBaseExtensionPyImp.cpp
index 5cf44fea82..16b900fae5 100644
--- a/src/App/LinkBaseExtensionPyImp.cpp
+++ b/src/App/LinkBaseExtensionPyImp.cpp
@@ -258,7 +258,7 @@ PyObject* LinkBaseExtensionPy::setLink(PyObject* _args)
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next(pcObj, &pos, &key, &value)) {
- parseLink(ext, Py::Int(key), value);
+ parseLink(ext, Py::Long(key), value);
}
}
else if (PySequence_Check(pcObj)) {
diff --git a/src/App/Metadata.cpp b/src/App/Metadata.cpp
index 4e9df6f5fe..d91817624f 100644
--- a/src/App/Metadata.cpp
+++ b/src/App/Metadata.cpp
@@ -57,7 +57,7 @@ directly. If you did not intend to use a system-defined macro
#endif
using namespace App;
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
#ifndef XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_QUALIFIER
using namespace XERCES_CPP_NAMESPACE;
@@ -158,7 +158,7 @@ void Metadata::loadFromInputSource(const InputSource& source)
throw Base::XMLBaseException(
"Malformed package.xml document: Root group not found");
}
- auto formatVersion = XMLString::parseInt(_dom->getAttribute(XUTF8Str("format").unicodeForm()));
+ auto formatVersion = XMLString::parseInt(_dom->getAttribute(XUTF8StrLiteral("format").unicodeForm()));
switch (formatVersion) {
case 1:
parseVersion1(_dom);
@@ -246,7 +246,7 @@ std::string Metadata::classname() const
return _classname;
}
-boost::filesystem::path Metadata::subdirectory() const
+std::filesystem::path Metadata::subdirectory() const
{
return _subdirectory;
}
@@ -370,7 +370,7 @@ void Metadata::setClassname(const std::string& name)
_classname = name;
}
-void Metadata::setSubdirectory(const boost::filesystem::path& path)
+void Metadata::setSubdirectory(const std::filesystem::path& path)
{
_subdirectory = path;
}
@@ -475,7 +475,7 @@ void Metadata::removeTag(const std::string& tag)
_tag.erase(new_end, _tag.end());
}
-void Metadata::removeFile(const boost::filesystem::path& path)
+void Metadata::removeFile(const std::filesystem::path& path)
{
auto new_end = std::remove(_file.begin(), _file.end(), path);
_file.erase(new_end, _file.end());
@@ -560,10 +560,10 @@ void addAttribute(DOMElement* node, const std::string& key, const std::string& v
void addAttribute(DOMElement* node, const std::string& key, bool value)
{
if (value) {
- node->setAttribute(XUTF8Str(key.c_str()).unicodeForm(), XUTF8Str("True").unicodeForm());
+ node->setAttribute(XUTF8Str(key.c_str()).unicodeForm(), XUTF8StrLiteral("True").unicodeForm());
}
else {
- node->setAttribute(XUTF8Str(key.c_str()).unicodeForm(), XUTF8Str("False").unicodeForm());
+ node->setAttribute(XUTF8Str(key.c_str()).unicodeForm(), XUTF8StrLiteral("False").unicodeForm());
}
}
@@ -608,13 +608,13 @@ void addDependencyNode(DOMElement* root, const std::string& name, const Meta::De
void Metadata::write(const fs::path& file) const
{
DOMImplementation* impl =
- DOMImplementationRegistry::getDOMImplementation(XUTF8Str("Core LS").unicodeForm());
+ DOMImplementationRegistry::getDOMImplementation(XUTF8StrLiteral("Core LS").unicodeForm());
- DOMDocument* doc = impl->createDocument(nullptr, XUTF8Str("package").unicodeForm(), nullptr);
+ DOMDocument* doc = impl->createDocument(nullptr, XUTF8StrLiteral("package").unicodeForm(), nullptr);
DOMElement* root = doc->getDocumentElement();
- root->setAttribute(XUTF8Str("format").unicodeForm(), XUTF8Str("1").unicodeForm());
- root->setAttribute(XUTF8Str("xmlns").unicodeForm(),
- XUTF8Str("https://wiki.freecad.org/Package_Metadata").unicodeForm());
+ root->setAttribute(XUTF8StrLiteral("format").unicodeForm(), XUTF8StrLiteral("1").unicodeForm());
+ root->setAttribute(XUTF8StrLiteral("xmlns").unicodeForm(),
+ XUTF8StrLiteral("https://wiki.freecad.org/Package_Metadata").unicodeForm());
appendToElement(root);
@@ -852,7 +852,7 @@ void Metadata::appendToElement(DOMElement* root) const
if (!_content.empty()) {
auto doc = root->getOwnerDocument();
- DOMElement* contentRootElement = doc->createElement(XUTF8Str("content").unicodeForm());
+ DOMElement* contentRootElement = doc->createElement(XUTF8StrLiteral("content").unicodeForm());
root->appendChild(contentRootElement);
for (const auto& content : _content) {
DOMElement* contentElement =
@@ -982,7 +982,7 @@ Meta::Contact::Contact(const XERCES_CPP_NAMESPACE::DOMElement* elem)
if (!elem) {
return;
}
- auto emailAttribute = elem->getAttribute(XUTF8Str("email").unicodeForm());
+ auto emailAttribute = elem->getAttribute(XUTF8StrLiteral("email").unicodeForm());
name = StrXUTF8(elem->getTextContent()).str;
email = StrXUTF8(emailAttribute).str;
}
@@ -1004,7 +1004,7 @@ Meta::License::License(const XERCES_CPP_NAMESPACE::DOMElement* elem)
if (!elem) {
return;
}
- auto fileAttribute = elem->getAttribute(XUTF8Str("file").unicodeForm());
+ auto fileAttribute = elem->getAttribute(XUTF8StrLiteral("file").unicodeForm());
if (XMLString::stringLen(fileAttribute) > 0) {
file = fs::path(StrXUTF8(fileAttribute).str);
}
@@ -1033,7 +1033,7 @@ Meta::Url::Url(const XERCES_CPP_NAMESPACE::DOMElement* elem)
if (!elem) {
return;
}
- auto typeAttribute = StrXUTF8(elem->getAttribute(XUTF8Str("type").unicodeForm())).str;
+ auto typeAttribute = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("type").unicodeForm())).str;
if (typeAttribute.empty() || typeAttribute == "website") {
type = UrlType::website;
}
@@ -1057,7 +1057,7 @@ Meta::Url::Url(const XERCES_CPP_NAMESPACE::DOMElement* elem)
}
if (type == UrlType::repository) {
- branch = StrXUTF8(elem->getAttribute(XUTF8Str("branch").unicodeForm())).str;
+ branch = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("branch").unicodeForm())).str;
}
location = StrXUTF8(elem->getTextContent()).str;
}
@@ -1083,13 +1083,13 @@ App::Meta::Dependency::Dependency(std::string pkg)
Meta::Dependency::Dependency(const XERCES_CPP_NAMESPACE::DOMElement* elem)
{
- version_lt = StrXUTF8(elem->getAttribute(XUTF8Str("version_lt").unicodeForm())).str;
- version_lte = StrXUTF8(elem->getAttribute(XUTF8Str("version_lte").unicodeForm())).str;
- version_eq = StrXUTF8(elem->getAttribute(XUTF8Str("version_eq").unicodeForm())).str;
- version_gte = StrXUTF8(elem->getAttribute(XUTF8Str("version_gte").unicodeForm())).str;
- version_gt = StrXUTF8(elem->getAttribute(XUTF8Str("version_gt").unicodeForm())).str;
- condition = StrXUTF8(elem->getAttribute(XUTF8Str("condition").unicodeForm())).str;
- std::string opt_string = StrXUTF8(elem->getAttribute(XUTF8Str("optional").unicodeForm())).str;
+ version_lt = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("version_lt").unicodeForm())).str;
+ version_lte = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("version_lte").unicodeForm())).str;
+ version_eq = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("version_eq").unicodeForm())).str;
+ version_gte = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("version_gte").unicodeForm())).str;
+ version_gt = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("version_gt").unicodeForm())).str;
+ condition = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("condition").unicodeForm())).str;
+ std::string opt_string = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("optional").unicodeForm())).str;
if (opt_string == "true"
|| opt_string == "True") { // Support Python capitalization in this one case...
optional = true;
@@ -1097,7 +1097,7 @@ Meta::Dependency::Dependency(const XERCES_CPP_NAMESPACE::DOMElement* elem)
else {
optional = false;
}
- std::string type_string = StrXUTF8(elem->getAttribute(XUTF8Str("type").unicodeForm())).str;
+ std::string type_string = StrXUTF8(elem->getAttribute(XUTF8StrLiteral("type").unicodeForm())).str;
if (type_string == "automatic" || type_string.empty()) {
dependencyType = Meta::DependencyType::automatic;
}
diff --git a/src/App/Metadata.h b/src/App/Metadata.h
index 868315e638..271a112483 100644
--- a/src/App/Metadata.h
+++ b/src/App/Metadata.h
@@ -25,7 +25,7 @@
#include "FCConfig.h"
-#include
+#include
#include
Return the size of the hashes
-
+
@@ -58,7 +58,7 @@ base64: indicate if the input 'txt' is base64 encoded binary data
Data length exceed this threshold will be hashed before storing
-
+
diff --git a/src/App/StringIDPy.xml b/src/App/StringIDPy.xml
index de77d7c97a..acee95d628 100644
--- a/src/App/StringIDPy.xml
+++ b/src/App/StringIDPy.xml
@@ -24,7 +24,7 @@
Return the integer value of this ID
-
+
@@ -54,7 +54,7 @@
Geometry index. Only meaningful for geometry element name
-
+
private:
friend class StringID;
diff --git a/src/Base/BaseClass.h b/src/Base/BaseClass.h
index df658b6513..33d7ced2f2 100644
--- a/src/Base/BaseClass.h
+++ b/src/Base/BaseClass.h
@@ -156,16 +156,10 @@ public:
}
template
- bool is() const
- {
- return getTypeId() == T::getClassTypeId();
- }
+ bool is() const;
template
- bool isDerivedFrom() const
- {
- return getTypeId().isDerivedFrom(T::getClassTypeId());
- }
+ bool isDerivedFrom() const;
private:
static Type classTypeId; // NOLINT
@@ -187,6 +181,20 @@ public:
virtual ~BaseClass();
};
+template
+bool BaseClass::is() const
+{
+ static_assert(std::is_base_of::value, "T must be derived from Base::BaseClass");
+ return getTypeId() == T::getClassTypeId();
+}
+
+template
+bool BaseClass::isDerivedFrom() const
+{
+ static_assert(std::is_base_of::value, "T must be derived from Base::BaseClass");
+ return getTypeId().isDerivedFrom(T::getClassTypeId());
+}
+
/**
* Template that works just like dynamic_cast, but expects the argument to
* inherit from Base::BaseClass.
@@ -195,6 +203,8 @@ public:
template
T* freecad_dynamic_cast(Base::BaseClass* type)
{
+ static_assert(std::is_base_of::value, "T must be derived from Base::BaseClass");
+
if (type && type->isDerivedFrom(T::getClassTypeId())) {
return static_cast(type);
}
@@ -210,6 +220,8 @@ T* freecad_dynamic_cast(Base::BaseClass* type)
template
const T* freecad_dynamic_cast(const Base::BaseClass* type)
{
+ static_assert(std::is_base_of::value, "T must be derived from Base::BaseClass");
+
if (type && type->isDerivedFrom(T::getClassTypeId())) {
return static_cast(type);
}
diff --git a/src/Base/BoundBoxPy.xml b/src/Base/BoundBoxPy.xml
index 0af425be10..86e04940ba 100644
--- a/src/Base/BoundBoxPy.xml
+++ b/src/Base/BoundBoxPy.xml
@@ -64,7 +64,7 @@ max : Base.Vector, tuple
Invalidate the bounding box.
-
+
isValid() -> bool
@@ -90,9 +90,9 @@ z : float
Value to enlarge at z-direction.
-
+
- getPoint(index) ->Base.Vector
+ getPoint(index) -> Base.Vector
Get the point of the given index.
The index must be in the range of [0, 7].
@@ -100,7 +100,7 @@ The index must be in the range of [0, 7].
index : int
-
+
getEdge(index) -> tuple of Base.Vector
@@ -110,7 +110,7 @@ The index must be in the range of [0, 11].
index : int
-
+
closestPoint(point) -> Base.Vector
closestPoint(x, y, z) -> Base.Vector
diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp
index e5669ca658..d10a3c65b1 100644
--- a/src/Base/FileInfo.cpp
+++ b/src/Base/FileInfo.cpp
@@ -208,18 +208,18 @@ std::string FileInfo::getTempFileName(const char* FileName, const char* Path)
#endif
}
-boost::filesystem::path FileInfo::stringToPath(const std::string& str)
+std::filesystem::path FileInfo::stringToPath(const std::string& str)
{
#if defined(FC_OS_WIN32)
std::wstring_convert> converter;
- boost::filesystem::path path(converter.from_bytes(str));
+ std::filesystem::path path(converter.from_bytes(str));
#else
- boost::filesystem::path path(str);
+ std::filesystem::path path(str);
#endif
return path;
}
-std::string FileInfo::pathToString(const boost::filesystem::path& path)
+std::string FileInfo::pathToString(const std::filesystem::path& path)
{
#if defined(FC_OS_WIN32)
std::wstring_convert> converter;
@@ -583,14 +583,14 @@ bool FileInfo::createDirectory() const
bool FileInfo::createDirectories() const
{
try {
- boost::filesystem::path path(stringToPath(FileName));
- if (boost::filesystem::exists(path)) {
+ std::filesystem::path path(stringToPath(FileName));
+ if (std::filesystem::exists(path)) {
return true;
}
- boost::filesystem::create_directories(path);
+ std::filesystem::create_directories(path);
return true;
}
- catch (const boost::filesystem::filesystem_error&) {
+ catch (const std::filesystem::filesystem_error&) {
return false;
}
}
diff --git a/src/Base/FileInfo.h b/src/Base/FileInfo.h
index 502dec3f4a..7e0ddbb9a4 100644
--- a/src/Base/FileInfo.h
+++ b/src/Base/FileInfo.h
@@ -25,7 +25,7 @@
#ifndef BASE_FILEINFO_H
#define BASE_FILEINFO_H
-#include
+#include
#include
#include
#include
@@ -158,9 +158,9 @@ public:
/// Get the path to the dir which is considered to temp files
static const std::string& getTempPath();
/// Convert from filesystem path to string
- static std::string pathToString(const boost::filesystem::path& path);
+ static std::string pathToString(const std::filesystem::path& path);
/// Convert from string to filesystem path
- static boost::filesystem::path stringToPath(const std::string& str);
+ static std::filesystem::path stringToPath(const std::string& str);
//@}
private:
diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp
index 2bdc54ccff..41f592e4b8 100644
--- a/src/Base/Interpreter.cpp
+++ b/src/Base/Interpreter.cpp
@@ -557,7 +557,7 @@ const char* InterpreterSingleton::init(int argc, char* argv[])
PyRun_SimpleString(
"# Check for virtualenv, and activate if present.\n"
"# See "
- "https://virtualenv.pypa.io/en/latest/userguide/"
+ "https://virtualenv.pypa.io/en/latest/"
"#using-virtualenv-without-bin-python\n"
"import os\n"
"import sys\n"
diff --git a/src/Base/MatrixPy.xml b/src/Base/MatrixPy.xml
index cd70049b76..e3bd475120 100644
--- a/src/Base/MatrixPy.xml
+++ b/src/Base/MatrixPy.xml
@@ -99,7 +99,8 @@ tol : float
- decompose() -> Base.Matrix, Base.Matrix, Base.Matrix, Base.Matrix\n
+ decompose() -> Base.Matrix, Base.Matrix, Base.Matrix, Base.Matrix
+
Return a tuple of matrices representing shear, scale, rotation and move.
So that matrix = move * rotation * scale * shear.
diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp
index fbd21b4688..029f57af2c 100644
--- a/src/Base/MatrixPyImp.cpp
+++ b/src/Base/MatrixPyImp.cpp
@@ -212,7 +212,7 @@ PyObject* MatrixPy::number_power_handler(PyObject* self, PyObject* other, PyObje
Base::Matrix4D a = static_cast(self)->value();
- long b = Py::Int(other);
+ long b = Py::Long(other);
if (b == 0) {
return new MatrixPy(Matrix4D());
}
@@ -363,7 +363,7 @@ PyObject* MatrixPy::hasScale(PyObject* args)
ScaleType type = getMatrixPtr()->hasScale(tol);
Py::Module mod("FreeCAD");
return Py::new_reference_to(
- mod.callMemberFunction("ScaleType", Py::TupleN(Py::Int(static_cast(type)))));
+ mod.callMemberFunction("ScaleType", Py::TupleN(Py::Long(static_cast(type)))));
}
PyObject* MatrixPy::decompose(PyObject* args)
diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp
index b2308a7804..3e02aae6e6 100644
--- a/src/Base/Parameter.cpp
+++ b/src/Base/Parameter.cpp
@@ -362,8 +362,9 @@ ParameterGrp::CreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
const char* Type,
const char* Name)
{
- if (XMLString::compareString(Start->getNodeName(), XStr("FCParamGroup").unicodeForm()) != 0
- && XMLString::compareString(Start->getNodeName(), XStr("FCParameters").unicodeForm())
+ if (XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParamGroup").unicodeForm())
+ != 0
+ && XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParameters").unicodeForm())
!= 0) {
Base::Console().Warning("CreateElement: %s cannot have the element %s of type %s\n",
StrX(Start->getNodeName()).c_str(),
@@ -380,7 +381,7 @@ ParameterGrp::CreateElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* pDocument = Start->getOwnerDocument();
auto pcElem = pDocument->createElement(XStr(Type).unicodeForm());
- pcElem->setAttribute(XStr("Name").unicodeForm(), XStr(Name).unicodeForm());
+ pcElem->setAttribute(XStrLiteral("Name").unicodeForm(), XStr(Name).unicodeForm());
Start->appendChild(pcElem);
return pcElem;
@@ -488,9 +489,10 @@ std::vector> ParameterGrp::GetGroups()
DOMElement* pcTemp = FindElement(_pGroupNode, "FCParamGroup");
while (pcTemp) {
- Name =
- StrX(pcTemp->getAttributes()->getNamedItem(XStr("Name").unicodeForm())->getNodeValue())
- .c_str();
+ Name = StrX(pcTemp->getAttributes()
+ ->getNamedItem(XStrLiteral("Name").unicodeForm())
+ ->getNodeValue())
+ .c_str();
// already created?
if (!(rParamGrp = _GroupMap[Name]).isValid()) {
rParamGrp = Base::Reference(new ParameterGrp(pcTemp, Name.c_str(), this));
@@ -630,7 +632,7 @@ const char* ParameterGrp::GetAttribute(ParamType Type,
Value = GetASCII(Name, Default);
}
else if (Type != ParamType::FCGroup) {
- Value = StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str();
+ Value = StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str();
}
return Value.c_str();
}
@@ -654,7 +656,7 @@ ParameterGrp::GetAttributeMap(ParamType Type, const char* sFilter) const
while (pcTemp) {
Name = StrX(static_cast(pcTemp)
->getAttributes()
- ->getNamedItem(XStr("Name").unicodeForm())
+ ->getNamedItem(XStrLiteral("Name").unicodeForm())
->getNodeValue())
.c_str();
// check on filter condition
@@ -665,7 +667,7 @@ ParameterGrp::GetAttributeMap(ParamType Type, const char* sFilter) const
else {
res.emplace_back(Name,
StrX(static_cast(pcTemp)->getAttribute(
- XStr("Value").unicodeForm()))
+ XStrLiteral("Value").unicodeForm()))
.c_str());
}
}
@@ -731,7 +733,8 @@ bool ParameterGrp::GetBool(const char* Name, bool bPreset) const
}
// if yes check the value and return
- return (strcmp(StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str(), "1") == 0);
+ return (strcmp(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(), "1")
+ == 0);
}
void ParameterGrp::SetBool(const char* Name, bool bValue)
@@ -750,10 +753,11 @@ std::vector ParameterGrp::GetBools(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCBool");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
- if (strcmp(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(), "1") != 0) {
+ if (strcmp(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(), "1")
+ != 0) {
vrValues.push_back(false);
}
else {
@@ -777,10 +781,11 @@ std::vector> ParameterGrp::GetBoolMap(const char* s
DOMElement* pcTemp = FindElement(_pGroupNode, "FCBool");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
- if (strcmp(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(), "1") != 0) {
+ if (strcmp(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(), "1")
+ != 0) {
vrValues.emplace_back(Name, false);
}
else {
@@ -806,7 +811,7 @@ long ParameterGrp::GetInt(const char* Name, long lPreset) const
return lPreset;
}
// if yes check the value and return
- return atol(StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str());
+ return atol(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str());
}
void ParameterGrp::SetInt(const char* Name, long lValue)
@@ -826,11 +831,11 @@ std::vector ParameterGrp::GetInts(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCInt");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
vrValues.push_back(
- atol(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str()));
+ atol(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str()));
}
pcTemp = FindNextElement(pcTemp, "FCInt");
}
@@ -849,12 +854,12 @@ std::vector> ParameterGrp::GetIntMap(const char* sF
DOMElement* pcTemp = FindElement(_pGroupNode, "FCInt");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
vrValues.emplace_back(
Name,
- (atol(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str())));
+ (atol(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str())));
}
pcTemp = FindNextElement(pcTemp, "FCInt");
}
@@ -877,7 +882,9 @@ unsigned long ParameterGrp::GetUnsigned(const char* Name, unsigned long lPreset)
// if yes check the value and return
const int base = 10;
- return strtoul(StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str(), nullptr, base);
+ return strtoul(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
+ nullptr,
+ base);
}
void ParameterGrp::SetUnsigned(const char* Name, unsigned long lValue)
@@ -898,11 +905,11 @@ std::vector ParameterGrp::GetUnsigneds(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCUInt");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
vrValues.push_back(
- strtoul(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(),
+ strtoul(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
nullptr,
base));
}
@@ -925,12 +932,12 @@ ParameterGrp::GetUnsignedMap(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCUInt");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
vrValues.emplace_back(
Name,
- (strtoul(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(),
+ (strtoul(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str(),
nullptr,
base)));
}
@@ -953,7 +960,7 @@ double ParameterGrp::GetFloat(const char* Name, double dPreset) const
return dPreset;
}
// if yes check the value and return
- return atof(StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str());
+ return atof(StrX(pcElem->getAttribute(XStrLiteral("Value").unicodeForm())).c_str());
}
void ParameterGrp::SetFloat(const char* Name, double dValue)
@@ -974,11 +981,11 @@ std::vector ParameterGrp::GetFloats(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCFloat");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
vrValues.push_back(
- atof(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str()));
+ atof(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str()));
}
pcTemp = FindNextElement(pcTemp, "FCFloat");
}
@@ -997,12 +1004,12 @@ std::vector> ParameterGrp::GetFloatMap(const char
DOMElement* pcTemp = FindElement(_pGroupNode, "FCFloat");
while (pcTemp) {
- Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrX(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
vrValues.emplace_back(
Name,
- (atof(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str())));
+ (atof(StrX(pcTemp->getAttribute(XStrLiteral("Value").unicodeForm())).c_str())));
}
pcTemp = FindNextElement(pcTemp, "FCFloat");
}
@@ -1086,7 +1093,7 @@ std::vector ParameterGrp::GetASCIIs(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCText");
while (pcTemp) {
- Name = StrXUTF8(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrXUTF8(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
// retrieve the text element
@@ -1116,7 +1123,7 @@ ParameterGrp::GetASCIIMap(const char* sFilter) const
DOMElement* pcTemp = FindElement(_pGroupNode, "FCText");
while (pcTemp) {
- Name = StrXUTF8(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
+ Name = StrXUTF8(pcTemp->getAttribute(XStrLiteral("Name").unicodeForm())).c_str();
// check on filter condition
if (!sFilter || Name.find(sFilter) != std::string::npos) {
// retrieve the text element
@@ -1299,7 +1306,7 @@ bool ParameterGrp::RenameGrp(const char* OldName, const char* NewName)
// check if Element in group
DOMElement* pcElem = FindElement(_pGroupNode, "FCParamGroup", OldName);
if (pcElem) {
- pcElem->setAttribute(XStr("Name").unicodeForm(), XStr(NewName).unicodeForm());
+ pcElem->setAttribute(XStrLiteral("Name").unicodeForm(), XStr(NewName).unicodeForm());
}
_Notify(ParamType::FCGroup, NewName, OldName);
@@ -1349,7 +1356,7 @@ void ParameterGrp::Clear(bool notify)
if (type != ParamType::FCInvalid && type != ParamType::FCGroup) {
params.emplace_back(type,
StrX(child->getAttributes()
- ->getNamedItem(XStr("Name").unicodeForm())
+ ->getNamedItem(XStrLiteral("Name").unicodeForm())
->getNodeValue())
.c_str());
}
@@ -1387,8 +1394,9 @@ ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
const char* Type,
const char* Name) const
{
- if (XMLString::compareString(Start->getNodeName(), XStr("FCParamGroup").unicodeForm()) != 0
- && XMLString::compareString(Start->getNodeName(), XStr("FCParameters").unicodeForm())
+ if (XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParamGroup").unicodeForm())
+ != 0
+ && XMLString::compareString(Start->getNodeName(), XStrLiteral("FCParameters").unicodeForm())
!= 0) {
Base::Console().Warning("FindElement: %s cannot have the element %s of type %s\n",
StrX(Start->getNodeName()).c_str(),
@@ -1396,15 +1404,20 @@ ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* Start,
Type);
return nullptr;
}
+ const XStr xType(Type);
+ const XStr xName(Name);
for (DOMNode* clChild = Start->getFirstChild(); clChild != nullptr;
clChild = clChild->getNextSibling()) {
if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
// the right node Type
- if (!strcmp(Type, StrX(clChild->getNodeName()).c_str())) {
- if (clChild->getAttributes()->getLength() > 0) {
+ if (!XMLString::compareString(xType.unicodeForm(), clChild->getNodeName())) {
+ auto attrs = clChild->getAttributes();
+ if (attrs->getLength() > 0) {
if (Name) {
- DOMNode* attr = FindAttribute(clChild, "Name");
- if (attr && !strcmp(Name, StrX(attr->getNodeValue()).c_str())) {
+ DOMNode* attr = attrs->getNamedItem(XStrLiteral("Name").unicodeForm());
+ if (attr
+ && !XMLString::compareString(xName.unicodeForm(),
+ attr->getNodeValue())) {
return dynamic_cast(clChild);
}
}
@@ -1426,10 +1439,11 @@ ParameterGrp::FindNextElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* Prev, cons
return nullptr;
}
+ const XStr xType(Type);
while ((clChild = clChild->getNextSibling()) != nullptr) {
if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
// the right node Type
- if (!strcmp(Type, StrX(clChild->getNodeName()).c_str())) {
+ if (!XMLString::compareString(xType.unicodeForm(), clChild->getNodeName())) {
return dynamic_cast(clChild);
}
}
@@ -1479,7 +1493,7 @@ ParameterGrp::GetParameterNames(const char* sFilter) const
if (Type != ParamType::FCInvalid && Type != ParamType::FCGroup) {
if (clChild->getAttributes()->getLength() > 0) {
StrX name(clChild->getAttributes()
- ->getNamedItem(XStr("Name").unicodeForm())
+ ->getNamedItem(XStrLiteral("Name").unicodeForm())
->getNodeValue());
if (!sFilter || strstr(name.c_str(), sFilter)) {
res.emplace_back(Type, name.c_str());
@@ -1970,16 +1984,17 @@ void ParameterManager::CreateDocument()
{
// creating a document from screatch
DOMImplementation* impl =
- DOMImplementationRegistry::getDOMImplementation(XStr("Core").unicodeForm());
+ DOMImplementationRegistry::getDOMImplementation(XStrLiteral("Core").unicodeForm());
delete _pDocument;
- _pDocument = impl->createDocument(nullptr, // root element namespace URI.
- XStr("FCParameters").unicodeForm(), // root element name
- nullptr); // document type object (DTD).
+ _pDocument =
+ impl->createDocument(nullptr, // root element namespace URI.
+ XStrLiteral("FCParameters").unicodeForm(), // root element name
+ nullptr); // document type object (DTD).
// creating the node for the root group
DOMElement* rootElem = _pDocument->getDocumentElement();
- _pGroupNode = _pDocument->createElement(XStr("FCParamGroup").unicodeForm());
- _pGroupNode->setAttribute(XStr("Name").unicodeForm(), XStr("Root").unicodeForm());
+ _pGroupNode = _pDocument->createElement(XStrLiteral("FCParamGroup").unicodeForm());
+ _pGroupNode->setAttribute(XStrLiteral("Name").unicodeForm(), XStrLiteral("Root").unicodeForm());
rootElem->appendChild(_pGroupNode);
}
@@ -2090,14 +2105,15 @@ DOMPrintFilter::DOMPrintFilter(ShowType whatToShow)
DOMPrintFilter::FilterAction DOMPrintFilter::acceptNode(const DOMNode* node) const
{
- if (XMLString::compareString(node->getNodeName(), XStr("FCParameters").unicodeForm()) == 0) {
+ if (XMLString::compareString(node->getNodeName(), XStrLiteral("FCParameters").unicodeForm())
+ == 0) {
// This node is supposed to have a single FCParamGroup and two text nodes.
// Over time it can happen that the text nodes collect extra newlines.
const DOMNodeList* children = node->getChildNodes();
for (XMLSize_t i = 0; i < children->getLength(); i++) {
DOMNode* child = children->item(i);
if (child->getNodeType() == DOMNode::TEXT_NODE) {
- child->setNodeValue(XStr("\n").unicodeForm());
+ child->setNodeValue(XStrLiteral("\n").unicodeForm());
}
}
}
@@ -2110,7 +2126,7 @@ DOMPrintFilter::FilterAction DOMPrintFilter::acceptNode(const DOMNode* node) con
// there.
auto parent = node->getParentNode();
if (parent && XMLString::compareString(parent->getNodeName(),
- XStr("FCParamGroup").unicodeForm()) == 0) {
+ XStrLiteral("FCParamGroup").unicodeForm()) == 0) {
return DOMNodeFilter::FILTER_REJECT;
}
return DOMNodeFilter::FILTER_ACCEPT;
diff --git a/src/Base/Parameter.h b/src/Base/Parameter.h
index 92a9fcb7d4..3579b0d767 100644
--- a/src/Base/Parameter.h
+++ b/src/Base/Parameter.h
@@ -164,18 +164,64 @@ public:
};
static const char* TypeName(ParamType type);
static ParamType TypeValue(const char*);
+
+ /**
+ * Sets the value of an attribute.
+ *
+ * @param[in] Type The type of the attribute.
+ * @param[in] Name The name of the attribute.
+ * @param[in] Value The value to be set.
+ */
void SetAttribute(ParamType Type, const char* Name, const char* Value);
+
+ /**
+ * Removes an attribute.
+ *
+ * @param[in] Type The type of the attribute.
+ * @param[in] Name The name of the attribute.
+ */
void RemoveAttribute(ParamType Type, const char* Name);
+
+ /**
+ * Returns the value of the attribute.
+ *
+ * If the attribute can't be found, \n
+ * the fallback value is returned.
+ *
+ * @param[in] Type The type of the attribute.
+ * @param[in] Name The name of the attribute.
+ * @param[out] Value The value of attribute or the fallback value.
+ * @param[in] Default The fallback value.
+ */
const char*
GetAttribute(ParamType Type, const char* Name, std::string& Value, const char* Default) const;
+
+ /**
+ * Returns all attributes with the given type.
+ *
+ * Optionally filters them to only include attributes \n
+ * with names that contain a certain string.
+ *
+ * @param[in] Type The type of attributes to be returned
+ * @param[in] sFilter String that has to be present in the names of the attributes.
+ * @returns Vector of attribute name & value pairs.
+ */
std::vector>
GetAttributeMap(ParamType Type, const char* sFilter = nullptr) const;
- /** Return the type and name of all parameters with optional filter
- * @param sFilter only strings which name includes sFilter are put in the vector
- * @return std::vector of pair(type, name)
+
+
+ /**
+ * Returns all parameters.
+ *
+ * Optionally filters them to only include attributes \n
+ * with names that contain a certain string.
+ *
+ * @param[in] sFilter String that has to be present in the names of the attributes.
+ * @returns Vector of attribute type & name pairs.
*/
std::vector>
GetParameterNames(const char* sFilter = nullptr) const;
+
//@}
/** @name methods for bool handling */
diff --git a/src/Base/PersistencePy.xml b/src/Base/PersistencePy.xml
index 4638e43e01..d8ffbd55cf 100644
--- a/src/Base/PersistencePy.xml
+++ b/src/Base/PersistencePy.xml
@@ -26,7 +26,7 @@ Class to dump and restore the content of an object.
Memory size of the object in bytes.
-
+
diff --git a/src/Base/PersistencePyImp.cpp b/src/Base/PersistencePyImp.cpp
index 3c9f72d323..7e98b25631 100644
--- a/src/Base/PersistencePyImp.cpp
+++ b/src/Base/PersistencePyImp.cpp
@@ -52,9 +52,9 @@ Py::String PersistencePy::getContent() const
return {writer.getString()};
}
-Py::Int PersistencePy::getMemSize() const
+Py::Long PersistencePy::getMemSize() const
{
- return Py::Int((long)getPersistencePtr()->getMemSize());
+ return Py::Long((long)getPersistencePtr()->getMemSize());
}
PyObject* PersistencePy::dumpContent(PyObject* args, PyObject* kwds)
diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h
index c916703c93..18237d4604 100644
--- a/src/Base/PyObjectBase.h
+++ b/src/Base/PyObjectBase.h
@@ -163,18 +163,18 @@ namespace Base
{
-/** The PyObjectBase class, exports the class as a python type
+/** The PyObjectBase class, exports the class as a Python type
* PyObjectBase is the base class for all C++ classes which
- * need to get exported into the python namespace. This class is
+ * need to get exported into the Python namespace. This class is
* very important because nearly all important classes in FreeCAD
- * are visible in python for macro recording and automation purpose.
- * The class App::Document is a good expample for an exported class.
+ * are visible in Python for macro recording and automation purpose.
+ * The class App::Document is a good example for an exported class.
* There are some convenience macros to make it easier to inherit
- * from this class and defining new methods exported to python.
+ * from this class and defining new methods exported to Python.
* PYFUNCDEF_D defines a new exported method.
* PYFUNCIMP_D defines the implementation of the new exported method.
* In the implementation you can use Py_Return, Py_Error, Py_Try and Py_Assert.
- * PYMETHODEDEF makes the entry in the python method table.
+ * PYMETHODEDEF makes the entry in the Python method table.
* @see Document
* @see PYFUNCDEF_D
* @see PYFUNCIMP_D
diff --git a/src/Base/QuantityPy.xml b/src/Base/QuantityPy.xml
index 881b58a70b..0a874e8b3d 100644
--- a/src/Base/QuantityPy.xml
+++ b/src/Base/QuantityPy.xml
@@ -29,38 +29,36 @@ Quantity(string) -- arbitrary mixture of numbers and chars defining a Quantity
-
- toStr([decimals])
- returns a string representation rounded to number of decimals. If no decimals are specified then
- the internal precision is used
+ toStr([decimals])
+
+Returns a string representation rounded to number of decimals. If no decimals are specified then
+the internal precision is used
- returns a quantity with the translation factor and a string with the prevered unit
+ Returns a quantity with the translation factor and a string with the prevered unit
-
- returns a floating point value as the provided unit
+ Returns a floating point value as the provided unit
- Following parameters are allowed:
- getValueAs('m/s') # unit string to parse
- getValueAs(2.45,1) # translation value and unit signature
- getValueAs(FreeCAD.Units.Pascal) # predefined standard units
- getValueAs(Qantity('N/m^2')) # a quantity
- getValueAs(Unit(0,1,0,0,0,0,0,0)) # a unit
+Following parameters are allowed:
+getValueAs('m/s') # unit string to parse
+getValueAs(2.45,1) # translation value and unit signature
+getValueAs(FreeCAD.Units.Pascal) # predefined standard units
+getValueAs(Qantity('N/m^2')) # a quantity
+getValueAs(Unit(0,1,0,0,0,0,0,0)) # a unit
-
-Return the Integral closest to x, rounding half toward even.
+ Returns the Integral closest to x, rounding half toward even.
When an argument is passed, work like built-in round(x, ndigits).
diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp
index 5cf7514852..85078c38f6 100644
--- a/src/Base/QuantityPyImp.cpp
+++ b/src/Base/QuantityPyImp.cpp
@@ -641,9 +641,9 @@ Py::Dict QuantityPy::getFormat() const
QuantityFormat fmt = getQuantityPtr()->getFormat();
Py::Dict dict;
- dict.setItem("Precision", Py::Int(fmt.precision));
+ dict.setItem("Precision", Py::Long(fmt.precision));
dict.setItem("NumberFormat", Py::Char(fmt.toFormat()));
- dict.setItem("Denominator", Py::Int(fmt.denominator));
+ dict.setItem("Denominator", Py::Long(fmt.denominator));
return dict;
}
@@ -652,14 +652,14 @@ void QuantityPy::setFormat(Py::Dict arg)
QuantityFormat fmt = getQuantityPtr()->getFormat();
if (arg.hasKey("Precision")) {
- Py::Int prec(arg.getItem("Precision"));
+ Py::Long prec(arg.getItem("Precision"));
fmt.precision = static_cast(prec);
}
if (arg.hasKey("NumberFormat")) {
Py::Object item = arg.getItem("NumberFormat");
if (item.isNumeric()) {
- int format = static_cast(Py::Int(item));
+ int format = static_cast(Py::Long(item));
if (format < 0 || format > QuantityFormat::Scientific) {
throw Py::ValueError("Invalid format value");
}
@@ -681,7 +681,7 @@ void QuantityPy::setFormat(Py::Dict arg)
}
if (arg.hasKey("Denominator")) {
- Py::Int denom(arg.getItem("Denominator"));
+ Py::Long denom(arg.getItem("Denominator"));
int fracInch = static_cast(denom);
// check that the value is positive and a power of 2
if (fracInch <= 0) {
diff --git a/src/Base/RotationPy.xml b/src/Base/RotationPy.xml
index 53c8a3104a..9c86e4cfe0 100644
--- a/src/Base/RotationPy.xml
+++ b/src/Base/RotationPy.xml
@@ -88,7 +88,7 @@ coef : sequence of float
Sets the rotation to its inverse.
-
+
inverted() -> Base.Rotation
@@ -232,12 +232,11 @@ tol : float
-
- public:
- RotationPy(const Rotation & mat, PyTypeObject *T = &Type)
- :PyObjectBase(new Rotation(mat),T){}
- Rotation value() const
- { return *(getRotationPtr()); }
+ public:
+ RotationPy(const Rotation & mat, PyTypeObject *T = &Type)
+ :PyObjectBase(new Rotation(mat),T){}
+ Rotation value() const
+ { return *(getRotationPtr()); }
diff --git a/src/Base/Type.cpp b/src/Base/Type.cpp
index 51b2128c1e..f12c041aaf 100644
--- a/src/Base/Type.cpp
+++ b/src/Base/Type.cpp
@@ -59,7 +59,7 @@ map Type::typemap;
vector Type::typedata;
set Type::loadModuleSet;
-void* Type::createInstance()
+void* Type::createInstance() const
{
instantiationMethod method = typedata[index]->instMethod;
return method ? (*method)() : nullptr;
@@ -90,30 +90,33 @@ void* Type::createInstanceByName(const char* TypeName, bool bLoadModule)
void Type::importModule(const char* TypeName)
{
// cut out the module name
- string Mod = getModuleName(TypeName);
+ const string mod = getModuleName(TypeName);
+
// ignore base modules
- if (Mod != "App" && Mod != "Gui" && Mod != "Base") {
- // remember already loaded modules
- set::const_iterator pos = loadModuleSet.find(Mod);
- if (pos == loadModuleSet.end()) {
- Interpreter().loadModule(Mod.c_str());
-#ifdef FC_LOGLOADMODULE
- Console().Log("Act: Module %s loaded through class %s \n", Mod.c_str(), TypeName);
-#endif
- loadModuleSet.insert(Mod);
- }
+ if (mod == "App" || mod == "Gui" || mod == "Base") {
+ return;
}
+
+ // remember already loaded modules
+ const auto pos = loadModuleSet.find(mod);
+ if (pos != loadModuleSet.end()) {
+ return;
+ }
+
+ // lets load the module
+ Interpreter().loadModule(mod.c_str());
+#ifdef FC_LOGLOADMODULE
+ Console().Log("Act: Module %s loaded through class %s \n", Mod.c_str(), TypeName);
+#endif
+ loadModuleSet.insert(mod);
}
string Type::getModuleName(const char* ClassName)
{
- string temp(ClassName);
- std::string::size_type pos = temp.find_first_of("::");
+ string_view classNameView(ClassName);
+ auto pos = classNameView.find("::");
- if (pos != std::string::npos) {
- return {temp, 0, pos};
- }
- return {};
+ return pos != string_view::npos ? string(classNameView.substr(0, pos)) : string();
}
Type Type::badType()
diff --git a/src/Base/Type.h b/src/Base/Type.h
index 3f580724e2..fad31905db 100644
--- a/src/Base/Type.h
+++ b/src/Base/Type.h
@@ -88,7 +88,7 @@ public:
~Type() = default;
/// creates a instance of this type
- void* createInstance();
+ void* createInstance() const;
/// Checks whether this type can instantiate
bool canInstantiate() const;
/// creates a instance of the named type
diff --git a/src/Base/TypePy.xml b/src/Base/TypePy.xml
index 25e868a6ac..f1be79b63b 100644
--- a/src/Base/TypePy.xml
+++ b/src/Base/TypePy.xml
@@ -19,7 +19,7 @@ namespace Base {
This is the Type class
BaseTypePy class.
- This class provides functionality related to type management in the Base module. It's not intended for direct instantiation but for accessing type information and creating instances of various types. Instantiation is possible for classes that inherit from the Base::BaseClass class and are not abstract.
+This class provides functionality related to type management in the Base module. It's not intended for direct instantiation but for accessing type information and creating instances of various types. Instantiation is possible for classes that inherit from the Base::BaseClass class and are not abstract.
diff --git a/src/Base/Unit.cpp b/src/Base/Unit.cpp
index a3c2a12c87..45a53dedb1 100644
--- a/src/Base/Unit.cpp
+++ b/src/Base/Unit.cpp
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -587,7 +588,7 @@ std::string Unit::getString() const
std::string Unit::getTypeString() const
{
- static std::array, 55> unitSpecs {{
+ static std::array, 56> unitSpecs {{
{ Unit::Acceleration, "Acceleration" },
{ Unit::AmountOfSubstance, "AmountOfSubstance" },
{ Unit::Angle, "Angle" },
@@ -603,6 +604,7 @@ std::string Unit::getTypeString() const
{ Unit::ElectricalInductance, "ElectricalInductance" },
{ Unit::ElectricalResistance, "ElectricalResistance" },
{ Unit::ElectricCharge, "ElectricCharge" },
+ { Unit::SurfaceChargeDensity, "SurfaceChargeDensity" },
{ Unit::ElectricCurrent, "ElectricCurrent" },
{ Unit::ElectricPotential, "ElectricPotential" },
{ Unit::ElectromagneticPotential, "ElectromagneticPotential" },
@@ -681,6 +683,7 @@ const Unit Unit::ElectricalConductivity (-3, -1, 3, 2);
const Unit Unit::ElectricalInductance (2, 1, -2, -2);
const Unit Unit::ElectricalResistance (2, 1, -3, -2);
const Unit Unit::ElectricCharge (0, 0, 1, 1);
+const Unit Unit::SurfaceChargeDensity (-2, 0, 1, 1);
const Unit Unit::ElectricPotential (2, 1, -3, -1);
const Unit Unit::ElectromagneticPotential (1, 1, -2, -1);
const Unit Unit::Force (1, 1, -2);
diff --git a/src/Base/Unit.h b/src/Base/Unit.h
index 670cf67526..b47d5c26ae 100644
--- a/src/Base/Unit.h
+++ b/src/Base/Unit.h
@@ -110,6 +110,7 @@ public:
static const Unit ElectricCurrent;
static const Unit ElectricPotential;
static const Unit ElectricCharge;
+ static const Unit SurfaceChargeDensity;
static const Unit MagneticFieldStrength;
static const Unit MagneticFlux;
static const Unit MagneticFluxDensity;
diff --git a/src/Base/UnitPy.xml b/src/Base/UnitPy.xml
index 09ac932889..866b3536c8 100644
--- a/src/Base/UnitPy.xml
+++ b/src/Base/UnitPy.xml
@@ -15,16 +15,15 @@
FatherNamespace="Base">
-
- Unit
- defines a unit type, calculate and compare.
+ Unit
+defines a unit type, calculate and compare.
- The following constructors are supported:
- Unit() -- empty constructor
- Unit(i1,i2,i3,i4,i5,i6,i7,i8) -- unit signature
- Unit(Quantity) -- copy unit from Quantity
- Unit(Unit) -- copy constructor
- Unit(string) -- parse the string for units
+The following constructors are supported:
+Unit() -- empty constructor
+Unit(i1,i2,i3,i4,i5,i6,i7,i8) -- unit signature
+Unit(Quantity) -- copy unit from Quantity
+Unit(Unit) -- copy constructor
+Unit(string) -- parse the string for units
Unit
diff --git a/src/Base/UnitsSchemaInternal.cpp b/src/Base/UnitsSchemaInternal.cpp
index 63e543d205..1d67455bab 100644
--- a/src/Base/UnitsSchemaInternal.cpp
+++ b/src/Base/UnitsSchemaInternal.cpp
@@ -364,6 +364,10 @@ UnitsSchemaInternal::schemaTranslate(const Quantity& quant, double& factor, std:
unitString = "C";
factor = 1.0;
}
+ else if (unit == Unit::SurfaceChargeDensity) {
+ unitString = "C/m^2";
+ factor = 1e-6;
+ }
else if (unit == Unit::CurrentDensity) {
if (UnitValue <= 1e3) {
unitString = "A/m^2";
diff --git a/src/Base/UnitsSchemaMKS.cpp b/src/Base/UnitsSchemaMKS.cpp
index 98ef0545eb..241e3eba9b 100644
--- a/src/Base/UnitsSchemaMKS.cpp
+++ b/src/Base/UnitsSchemaMKS.cpp
@@ -312,6 +312,10 @@ UnitsSchemaMKS::schemaTranslate(const Quantity& quant, double& factor, std::stri
unitString = "C";
factor = 1.0;
}
+ else if (unit == Unit::SurfaceChargeDensity) {
+ unitString = "C/m^2";
+ factor = 1e-6;
+ }
else if (unit == Unit::CurrentDensity) {
if (UnitValue <= 1e3) {
unitString = "A/m^2";
diff --git a/src/Base/UnitsSchemaMeterDecimal.cpp b/src/Base/UnitsSchemaMeterDecimal.cpp
index e80bd7af7f..8d7337bdac 100644
--- a/src/Base/UnitsSchemaMeterDecimal.cpp
+++ b/src/Base/UnitsSchemaMeterDecimal.cpp
@@ -44,7 +44,7 @@ std::string UnitsSchemaMeterDecimal::schemaTranslate(const Base::Quantity& quant
std::string& unitString)
{
static std::array>, 7> unitSpecs {{
- {Unit::Length, {"m", 1e0}},
+ {Unit::Length, {"m", 1e3}},
{Unit::Area, {"m^2", 1e6}},
{Unit::Volume, {"m^3", 1e9}},
{Unit::Power, {"W", 1000000}},
diff --git a/src/Base/XMLTools.h b/src/Base/XMLTools.h
index 798b975d8c..cc17d1b336 100644
--- a/src/Base/XMLTools.h
+++ b/src/Base/XMLTools.h
@@ -174,6 +174,15 @@ inline XStr::~XStr()
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&fUnicodeForm);
}
+// Uses the compiler to create a cache of transcoded string literals so that each subsequent call
+// can re-use the data from the lambda's initial creation. Permits the same usage as
+// XStr("literal").unicodeForm()
+#define XStrLiteral(literal) \
+ ([]() -> const XStr& { \
+ static const XStr str {literal}; \
+ return str; \
+ }())
+
// -----------------------------------------------------------------------
// Getter methods
@@ -210,6 +219,14 @@ inline XUTF8Str::XUTF8Str(const char* const fromTranscode)
inline XUTF8Str::~XUTF8Str() = default;
+// Uses the compiler to create a cache of transcoded string literals so that each subsequent call
+// can re-use the data from the lambda's initial creation. Permits the same usage as
+// XStr("literal").unicodeForm()
+#define XUTF8StrLiteral(literal) \
+ ([]() -> const XUTF8Str& { \
+ static const XUTF8Str str {literal}; \
+ return str; \
+ }())
// -----------------------------------------------------------------------
// Getter methods
diff --git a/src/Ext/freecad/utils.py b/src/Ext/freecad/utils.py
index 01bb923e50..0230a2b0ad 100644
--- a/src/Ext/freecad/utils.py
+++ b/src/Ext/freecad/utils.py
@@ -31,7 +31,7 @@ import FreeCAD
def get_python_exe() -> str:
"""Find Python. In preference order
- A) The value of the PythonExecutableForPip user preference
+ A) The value of the BaseApp/Preferences/PythonConsole/ExternalPythonExecutable user preference
B) The executable located in the same bin directory as FreeCAD and called "python3"
C) The executable located in the same bin directory as FreeCAD and called "python"
D) The result of a shutil search for your system's "python3" executable
diff --git a/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp b/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp
index b244b59973..86237942bb 100644
--- a/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp
+++ b/src/Gui/3Dconnexion/navlib/NavlibPivot.cpp
@@ -43,7 +43,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -57,7 +57,7 @@ long NavlibInterface::GetSelectionTransform(navlib::matrix_t&) const
long NavlibInterface::GetIsSelectionEmpty(navlib::bool_t& empty) const
{
- empty = !Gui::SelectionSingleton::instance().hasSelection();
+ empty = !Gui::Selection().hasSelection();
return 0;
}
diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp
index ecf1c143fe..2c940ca0a7 100644
--- a/src/Gui/Action.cpp
+++ b/src/Gui/Action.cpp
@@ -46,7 +46,7 @@
#include "Action.h"
#include "BitmapFactory.h"
#include "Command.h"
-#include "DlgUndoRedo.h"
+#include "Dialogs/DlgUndoRedo.h"
#include "PreferencePages/DlgSettingsWorkbenchesImp.h"
#include "Document.h"
#include "EditorView.h"
@@ -331,10 +331,10 @@ QString Action::createToolTip(QString helpText,
helpText.resize(helpText.size() - shortcut.size());
}
if (!shortcut.isEmpty()) {
- shortcut = QString::fromLatin1(" (%1)").arg(shortcut);
+ shortcut = QStringLiteral(" (%1)").arg(shortcut);
}
- QString tooltip = QString::fromLatin1(
+ QString tooltip = QStringLiteral(
"%1%2
").arg(
text.toHtmlEscaped(), shortcut.toHtmlEscaped());
@@ -371,12 +371,11 @@ QString Action::createToolTip(QString helpText,
return tooltip + helpText + cmdName;
}
- tooltip += QString::fromLatin1(
- "");
+ tooltip += QStringLiteral("
");
// If the user supplied tooltip contains line break, we shall honour it.
if (helpText.indexOf(QLatin1Char('\n')) >= 0) {
- tooltip += helpText.toHtmlEscaped() + QString::fromLatin1("
") ;
+ tooltip += helpText.toHtmlEscaped() + QStringLiteral("
") ;
}
else {
// If not, try to end the non wrapping paragraph at some pre defined
@@ -385,7 +384,7 @@ QString Action::createToolTip(QString helpText,
QFontMetrics fm(font);
int width = QtTools::horizontalAdvance(fm, helpText);
if (width <= tipWidth) {
- tooltip += helpText.toHtmlEscaped() + QString::fromLatin1("") ;
+ tooltip += helpText.toHtmlEscaped() + QStringLiteral("") ;
}
else {
int index = tipWidth / width * helpText.size();
@@ -396,7 +395,7 @@ QString Action::createToolTip(QString helpText,
}
}
tooltip += helpText.left(index).toHtmlEscaped()
- + QString::fromLatin1("")
+ + QStringLiteral("")
+ helpText.right(helpText.size()-index).trimmed().toHtmlEscaped();
}
}
@@ -475,7 +474,7 @@ void ActionGroup::addTo(QWidget *widget)
widget->addAction(action());
QToolButton* tb = widget->findChildren().constLast();
tb->setPopupMode(QToolButton::MenuButtonPopup);
- tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton"));
+ tb->setObjectName(QStringLiteral("qt_toolbutton_menubutton"));
QList acts = groupAction()->actions();
auto menu = new QMenu(tb);
menu->addActions(acts);
@@ -692,7 +691,7 @@ void WorkbenchGroup::refreshWorkbenchList()
action->setToolTip(tip);
action->setStatusTip(tr("Select the '%1' workbench").arg(name));
if (index < 9) {
- action->setShortcut(QKeySequence(QString::fromUtf8("W,%1").arg(index + 1)));
+ action->setShortcut(QKeySequence(QStringLiteral("W,%1").arg(index + 1)));
}
if (wbName.toStdString() == activeWbName) {
action->setChecked(true);
@@ -850,10 +849,10 @@ void RecentFilesAction::appendFile(const QString& filename)
static QString numberToLabel(int number) {
if (number > 0 && number < 10) { // NOLINT: *-magic-numbers
- return QString::fromLatin1("&%1").arg(number);
+ return QStringLiteral("&%1").arg(number);
}
if (number == 10) { // NOLINT: *-magic-numbers
- return QString::fromLatin1("1&0");
+ return QStringLiteral("1&0");
}
// If we have a number greater than 10, we start using the alphabet.
// So 11 becomes 'A' and so on.
@@ -861,10 +860,10 @@ static QString numberToLabel(int number) {
constexpr char lettersEnd = lettersStart + ('Z' - 'A');
if (number >= lettersStart && number < lettersEnd) {
QChar letter = QChar::fromLatin1('A' + (number - lettersStart));
- return QString::fromLatin1("%1 (&%2)").arg(number).arg(letter);
+ return QStringLiteral("%1 (&%2)").arg(number).arg(letter);
}
// Not enough accelerators to cover this number.
- return QString::fromLatin1("%1").arg(number);
+ return QStringLiteral("%1").arg(number);
}
/**
@@ -879,7 +878,7 @@ void RecentFilesAction::setFiles(const QStringList& files)
for (int index = 0; index < numRecentFiles; index++) {
QString numberLabel = numberToLabel(index + 1);
QFileInfo fi(files[index]);
- recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(numberLabel).arg(fi.fileName()));
+ recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel).arg(fi.fileName()));
recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index]));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
@@ -977,7 +976,7 @@ void RecentFilesAction::save()
QList recentFiles = groupAction()->actions();
int num = std::min(count, recentFiles.count());
for (int index = 0; index < num; index++) {
- QString key = QString::fromLatin1("MRU%1").arg(index);
+ QString key = QStringLiteral("MRU%1").arg(index);
QString value = recentFiles[index]->toolTip();
if (value.isEmpty()) {
break;
@@ -1041,7 +1040,7 @@ void RecentMacrosAction::setFiles(const QStringList& files)
for (int index = 0; index < numRecentFiles; index++) {
QFileInfo fi(files[index]);
QString numberLabel = numberToLabel(index + 1);
- recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(numberLabel).arg(fi.completeBaseName()));
+ recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel).arg(fi.completeBaseName()));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
QString accel(tr("none"));
@@ -1192,7 +1191,7 @@ void RecentMacrosAction::save()
QList recentFiles = groupAction()->actions();
int num = std::min(count, recentFiles.count());
for (int index = 0; index < num; index++) {
- QString key = QString::fromLatin1("MRU%1").arg(index);
+ QString key = QStringLiteral("MRU%1").arg(index);
QString value = recentFiles[index]->toolTip();
if (value.isEmpty()) {
break;
diff --git a/src/Gui/ActiveObjectList.cpp b/src/Gui/ActiveObjectList.cpp
index 0fc064cdb6..1690e116d3 100644
--- a/src/Gui/ActiveObjectList.cpp
+++ b/src/Gui/ActiveObjectList.cpp
@@ -26,7 +26,7 @@
#include
#include
#include
-#include
+#include
#include
#include "ActiveObjectList.h"
diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp
index dec82e9aa0..5a13553bf4 100644
--- a/src/Gui/Application.cpp
+++ b/src/Gui/Application.cpp
@@ -2457,22 +2457,22 @@ QString Application::replaceVariablesInQss(QString qssText)
// convert them to hex.
// Note: the ulong contains alpha channels so 8 hex characters when we need 6 here.
- QString accentColor1 = QString::fromLatin1("#%1")
+ QString accentColor1 = QStringLiteral("#%1")
.arg(longAccentColor1, 8, 16, QLatin1Char('0'))
.toUpper()
.mid(0, 7);
- QString accentColor2 = QString::fromLatin1("#%1")
+ QString accentColor2 = QStringLiteral("#%1")
.arg(longAccentColor2, 8, 16, QLatin1Char('0'))
.toUpper()
.mid(0, 7);
- QString accentColor3 = QString::fromLatin1("#%1")
+ QString accentColor3 = QStringLiteral("#%1")
.arg(longAccentColor3, 8, 16, QLatin1Char('0'))
.toUpper()
.mid(0, 7);
- qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor1"), accentColor1);
- qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor2"), accentColor2);
- qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor3"), accentColor3);
+ qssText = qssText.replace(QStringLiteral("@ThemeAccentColor1"), accentColor1);
+ qssText = qssText.replace(QStringLiteral("@ThemeAccentColor2"), accentColor2);
+ qssText = qssText.replace(QStringLiteral("@ThemeAccentColor3"), accentColor3);
// Base::Console().Warning("%s\n", qssText.toStdString());
return qssText;
@@ -2562,7 +2562,9 @@ App::Document* Application::reopen(App::Document* doc)
}
for (auto& file : docs) {
- App::GetApplication().openDocument(file.c_str(), false);
+ App::DocumentCreateFlags createFlags;
+ createFlags.createView = false;
+ App::GetApplication().openDocument(file.c_str(), createFlags);
}
}
diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp
index 1db7e93df4..16dc543900 100644
--- a/src/Gui/ApplicationPy.cpp
+++ b/src/Gui/ApplicationPy.cpp
@@ -48,7 +48,7 @@
#include "ApplicationPy.h"
#include "BitmapFactory.h"
#include "Command.h"
-#include "DlgPreferencesImp.h"
+#include "Dialogs/DlgPreferencesImp.h"
#include "Document.h"
#include "DocumentObserverPython.h"
#include "DownloadManager.h"
@@ -773,10 +773,11 @@ PyObject* ApplicationPy::sExport(PyObject * /*self*/, PyObject *args)
view3d->viewAll();
}
QPrinter printer(QPrinter::ScreenResolution);
- // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/
+ // setPdfVersion sets the printed PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/
printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
+ printer.setCreator(QString::fromStdString(App::Application::getNameWithVersion()));
view->print(&printer);
}
}
diff --git a/src/Gui/AutoSaver.cpp b/src/Gui/AutoSaver.cpp
index 8ff9a9013f..576ebeedbb 100644
--- a/src/Gui/AutoSaver.cpp
+++ b/src/Gui/AutoSaver.cpp
@@ -146,7 +146,7 @@ void AutoSaver::saveDocument(const std::string& name, AutoSaveProperty& saver)
saver.dirName = dirName;
// Write recovery meta file
- QFile file(QString::fromLatin1("%1/fc_recovery_file.xml")
+ QFile file(QStringLiteral("%1/fc_recovery_file.xml")
.arg(QString::fromUtf8(doc->TransientDir.getValue())));
if (file.open(QFile::WriteOnly)) {
QTextStream str(&file);
@@ -293,13 +293,13 @@ bool RecoveryWriter::shouldWrite(const std::string& name, const Base::Persistenc
{
// Property files of a view provider can always be written because
// these are rather small files.
- if (object->isDerivedFrom(App::Property::getClassTypeId())) {
+ if (object->isDerivedFrom()) {
const auto* prop = static_cast(object);
const App::PropertyContainer* parent = prop->getContainer();
- if (parent && parent->isDerivedFrom(Gui::ViewProvider::getClassTypeId()))
+ if (parent && parent->isDerivedFrom())
return true;
}
- else if (object->isDerivedFrom(Gui::Document::getClassTypeId())) {
+ else if (object->isDerivedFrom()) {
return true;
}
@@ -333,7 +333,7 @@ public:
dirName = QString::fromUtf8(dir);
fileName = QString::fromUtf8(file);
- tmpName = QString::fromLatin1("%1.tmp%2").arg(fileName).arg(rand());
+ tmpName = QStringLiteral("%1.tmp%2").arg(fileName).arg(rand());
writer.putNextEntry(tmpName.toUtf8().constData());
}
~RecoveryRunnable() override
@@ -385,7 +385,7 @@ void RecoveryWriter::writeFiles()
}
// For properties a copy can be created and then this can be written to disk in a thread
- if (entry.Object->isDerivedFrom(App::Property::getClassTypeId())) {
+ if (entry.Object->isDerivedFrom()) {
const auto* prop = static_cast(entry.Object);
QThreadPool::globalInstance()->start(new RecoveryRunnable(getModes(), DirName.c_str(), entry.FileName.c_str(), prop));
}
diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp
index 1fd92ab83e..a51178fef3 100644
--- a/src/Gui/BitmapFactory.cpp
+++ b/src/Gui/BitmapFactory.cpp
@@ -75,8 +75,8 @@ BitmapFactoryInst& BitmapFactoryInst::instance()
}
_pcSingleton->addPath(path);
}
- _pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromStdString(App::Application::getHomePath())));
- _pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir())));
+ _pcSingleton->addPath(QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getHomePath())));
+ _pcSingleton->addPath(QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir())));
_pcSingleton->addPath(QLatin1String(":/icons/"));
_pcSingleton->addPath(QLatin1String(":/Icons/"));
}
@@ -124,22 +124,22 @@ void Gui::BitmapFactoryInst::configureUseIconTheme()
void BitmapFactoryInst::addPath(const QString& path)
{
- QDir::addSearchPath(QString::fromLatin1("icons"), path);
+ QDir::addSearchPath(QStringLiteral("icons"), path);
}
void BitmapFactoryInst::removePath(const QString& path)
{
- QStringList iconPaths = QDir::searchPaths(QString::fromLatin1("icons"));
+ QStringList iconPaths = QDir::searchPaths(QStringLiteral("icons"));
int pos = iconPaths.indexOf(path);
if (pos != -1) {
iconPaths.removeAt(pos);
- QDir::setSearchPaths(QString::fromLatin1("icons"), iconPaths);
+ QDir::setSearchPaths(QStringLiteral("icons"), iconPaths);
}
}
QStringList BitmapFactoryInst::getPaths() const
{
- return QDir::searchPaths(QString::fromLatin1("icons"));
+ return QDir::searchPaths(QStringLiteral("icons"));
}
QStringList BitmapFactoryInst::findIconFiles() const
@@ -147,9 +147,9 @@ QStringList BitmapFactoryInst::findIconFiles() const
QStringList files, filters;
QList formats = QImageReader::supportedImageFormats();
for (QList::iterator it = formats.begin(); it != formats.end(); ++it)
- filters << QString::fromLatin1("*.%1").arg(QString::fromLatin1(*it).toLower());
+ filters << QStringLiteral("*.%1").arg(QString::fromLatin1(*it).toLower());
- QStringList paths = QDir::searchPaths(QString::fromLatin1("icons"));
+ QStringList paths = QDir::searchPaths(QStringLiteral("icons"));
paths.removeDuplicates();
for (QStringList::Iterator pt = paths.begin(); pt != paths.end(); ++pt) {
QDir d(*pt);
@@ -252,11 +252,11 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const
QList formats = QImageReader::supportedImageFormats();
formats.prepend("SVG"); // check first for SVG to use special import mechanism
- QString fileName = QString::fromLatin1("icons:") + fn;
+ QString fileName = QStringLiteral("icons:") + fn;
if (!loadPixmap(fileName, icon)) {
// Go through supported file formats
for (QList::iterator fm = formats.begin(); fm != formats.end(); ++fm) {
- QString path = QString::fromLatin1("%1.%2").arg(fileName,
+ QString path = QStringLiteral("%1.%2").arg(fileName,
QString::fromLatin1((*fm).toLower().constData()));
if (loadPixmap(path, icon)) {
break;
@@ -286,7 +286,7 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size,
// try to find it in the 'icons' search paths
if (iconPath.isEmpty()) {
- QString fileName = QString::fromLatin1("icons:") + fn;
+ QString fileName = QStringLiteral("icons:") + fn;
QFileInfo fi(fileName);
if (fi.exists()) {
iconPath = fi.filePath();
@@ -328,8 +328,8 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, con
for ( const auto &colorToColor : colorMapping ) {
ulong fromColor = colorToColor.first;
ulong toColor = colorToColor.second;
- QString fromColorString = QString::fromLatin1(":#%1;").arg(fromColor, 6, 16, QChar::fromLatin1('0'));
- QString toColorString = QString::fromLatin1(":#%1;").arg(toColor, 6, 16, QChar::fromLatin1('0'));
+ QString fromColorString = QStringLiteral(":#%1;").arg(fromColor, 6, 16, QChar::fromLatin1('0'));
+ QString toColorString = QStringLiteral(":#%1;").arg(toColor, 6, 16, QChar::fromLatin1('0'));
stringContents = stringContents.replace(fromColorString, toColorString);
}
QByteArray contents = stringContents.toUtf8();
diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt
index 45053fa6b4..cb7fa1890e 100644
--- a/src/Gui/CMakeLists.txt
+++ b/src/Gui/CMakeLists.txt
@@ -19,14 +19,14 @@ IF(CMAKE_BUILD_TYPE)
add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}")
ENDIF(CMAKE_BUILD_TYPE)
-if (FREECAD_USE_3DCONNEXION_LEGACY)
+if (FREECAD_USE_3DCONNEXION_LEGACY AND (MSVC OR APPLE))
add_definitions(-D_USE_3DCONNEXION_SDK)
if(APPLE)
set(3DCONNEXION_LINKFLAGS "-F/Library/Frameworks -weak_framework 3DconnexionClient")
list(APPEND 3DCONNEXION_INCLUDE_DIR ${3DCONNEXIONCLIENT_FRAMEWORK}/Headers
${3DCONNEXIONCLIENT_FRAMEWORK}/Headers/3DconnexionClient )
endif(APPLE)
-endif(FREECAD_USE_3DCONNEXION_LEGACY)
+endif(FREECAD_USE_3DCONNEXION_LEGACY AND (MSVC OR APPLE))
if(FREECAD_USE_3DCONNEXION_NAVLIB AND (MSVC OR APPLE))
add_definitions(-DUSE_3DCONNEXION_NAVLIB)
@@ -48,6 +48,8 @@ include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Quarter
+ ${CMAKE_CURRENT_SOURCE_DIR}/PreferencePages
+ ${CMAKE_CURRENT_SOURCE_DIR}/Selection
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_BINARY_DIR}/..
@@ -138,7 +140,8 @@ if(${Qt5WinExtras_FOUND})
)
endif()
-IF(SPNAV_FOUND)
+IF(SPNAV_FOUND AND FREECAD_USE_3DCONNEXION_LEGACY)
+ add_definitions(-D_USE_3DCONNEXION_SDK)
if(SPNAV_USE_X11)
add_definitions(-DSPNAV_USE_X11)
if (FREECAD_QT_MAJOR_VERSION EQUAL 5 AND UNIX AND NOT APPLE)
@@ -186,7 +189,7 @@ IF(SPNAV_FOUND)
list(APPEND FreeCADGui_LIBS
${SPNAV_LIBRARIES}
)
-ENDIF(SPNAV_FOUND)
+ENDIF(SPNAV_FOUND AND FREECAD_USE_3DCONNEXION_LEGACY)
IF(OCULUS_FOUND)
add_definitions(-DOCULUS_FOUND)
@@ -254,12 +257,12 @@ generate_from_xml(ViewProviderDocumentObjectPy)
generate_from_xml(ViewProviderGeometryObjectPy)
generate_from_xml(ViewProviderExtensionPy)
generate_from_xml(WorkbenchPy)
-generate_from_xml(SelectionObjectPy)
+generate_from_xml(Selection/SelectionObjectPy)
generate_from_xml(LinkViewPy)
generate_from_xml(ViewProviderLinkPy)
generate_from_xml(AxisOriginPy)
generate_from_xml(CommandPy)
-generate_from_xml(NavigationStylePy)
+generate_from_xml(Navigation/NavigationStylePy)
generate_from_py(FreeCADGuiInit GuiInitScript.h)
@@ -271,7 +274,7 @@ SET(FreeCADGui_XML_SRCS
ViewProviderExtensionPy.xml
PythonWorkbenchPy.xml
WorkbenchPy.xml
- SelectionObjectPy.xml
+ Selection/SelectionObjectPy.xml
DocumentPy.xml
LinkViewPy.xml
ViewProviderLinkPy.xml
@@ -354,37 +357,37 @@ set_property(SOURCE GraphvizView.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURR
set_property(SOURCE GraphvizView.h APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView.cpp)
SET(Gui_UIC_SRCS
- AboutApplication.ui
+ Dialogs/AboutApplication.ui
Clipping.ui
DemoMode.ui
- DlgActions.ui
- DlgActivateWindow.ui
- DlgUnitsCalculator.ui
- DlgAuthorization.ui
- DlgChooseIcon.ui
- DlgCreateNewPreferencePack.ui
- DlgInputDialog.ui
- DlgKeyboard.ui
- DlgMacroExecute.ui
- DlgRunExternal.ui
- DlgMacroRecord.ui
- DlgMaterialProperties.ui
- DlgOnlineHelp.ui
- DlgParameter.ui
- DlgParameterFind.ui
- DlgPreferencePackManagement.ui
- DlgPreferences.ui
- DlgProjectInformation.ui
- DlgProjectUtility.ui
- DlgPropertyLink.ui
- DlgRevertToBackupConfig.ui
+ Dialogs/DlgActions.ui
+ Dialogs/DlgActivateWindow.ui
+ Dialogs/DlgUnitsCalculator.ui
+ Dialogs/DlgAuthorization.ui
+ Dialogs/DlgChooseIcon.ui
+ Dialogs/DlgCreateNewPreferencePack.ui
+ Dialogs/DlgInputDialog.ui
+ Dialogs/DlgKeyboard.ui
+ Dialogs/DlgMacroExecute.ui
+ Dialogs/DlgRunExternal.ui
+ Dialogs/DlgMacroRecord.ui
+ Dialogs/DlgMaterialProperties.ui
+ Dialogs/DlgOnlineHelp.ui
+ Dialogs/DlgParameter.ui
+ Dialogs/DlgParameterFind.ui
+ Dialogs/DlgPreferencePackManagement.ui
+ Dialogs/DlgPreferences.ui
+ Dialogs/DlgProjectInformation.ui
+ Dialogs/DlgProjectUtility.ui
+ Dialogs/DlgPropertyLink.ui
+ Dialogs/DlgRevertToBackupConfig.ui
PreferencePages/DlgSettings3DView.ui
PreferencePages/DlgSettingsCacheDirectory.ui
- DlgSettingsColorGradient.ui
+ Dialogs/DlgSettingsColorGradient.ui
PreferencePages/DlgSettingsDocument.ui
PreferencePages/DlgSettingsEditor.ui
PreferencePages/DlgSettingsGeneral.ui
- DlgSettingsImage.ui
+ Dialogs/DlgSettingsImage.ui
PreferencePages/DlgSettingsLightSources.ui
PreferencePages/DlgSettingsMacro.ui
PreferencePages/DlgSettingsNavigation.ui
@@ -395,15 +398,15 @@ SET(Gui_UIC_SRCS
PreferencePages/DlgSettingsUI.ui
PreferencePages/DlgSettingsViewColor.ui
PreferencePages/DlgSettingsWorkbenches.ui
- DlgCheckableMessageBox.ui
- DlgToolbars.ui
- DlgTreeWidget.ui
- DlgLocationAngle.ui
- DlgLocationPos.ui
+ Dialogs/DlgCheckableMessageBox.ui
+ Dialogs/DlgToolbars.ui
+ Dialogs/DlgTreeWidget.ui
+ Dialogs/DlgLocationAngle.ui
+ Dialogs/DlgLocationPos.ui
DocumentRecovery.ui
DownloadManager.ui
DownloadItem.ui
- DlgExpressionInput.ui
+ Dialogs/DlgExpressionInput.ui
MouseButtons.ui
SceneInspector.ui
InputVector.ui
@@ -415,14 +418,14 @@ SET(Gui_UIC_SRCS
TaskView/TaskImage.ui
TaskView/TaskSelectLinkProperty.ui
TaskElementColors.ui
- DlgObjectSelection.ui
- DlgAddProperty.ui
- DlgAddPropertyVarSet.ui
+ Dialogs/DlgObjectSelection.ui
+ Dialogs/DlgAddProperty.ui
+ Dialogs/DlgAddPropertyVarSet.ui
VectorListEditor.ui
)
if(FREECAD_USE_3DCONNEXION_LEGACY)
- list(APPEND Gui_UIC_SRCS DlgCustomizeSpNavSettings.ui)
+ list(APPEND Gui_UIC_SRCS Dialogs/DlgCustomizeSpNavSettings.ui)
endif(FREECAD_USE_3DCONNEXION_LEGACY)
set (FreeCAD_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Language/FreeCAD_translation.qrc)
@@ -475,28 +478,28 @@ SOURCE_GROUP("Command" FILES ${Command_SRCS})
SET(Dialog_CPP_SRCS
Clipping.cpp
DemoMode.cpp
- DlgAbout.cpp
- DlgActivateWindowImp.cpp
- DlgCreateNewPreferencePackImp.cpp
- DlgUnitsCalculatorImp.cpp
- DlgInputDialogImp.cpp
- DlgMacroExecuteImp.cpp
- DlgRunExternal.cpp
- DlgEditFileIncludePropertyExternal.cpp
- DlgMacroRecordImp.cpp
- DlgMaterialPropertiesImp.cpp
- DlgParameterImp.cpp
- DlgParameterFind.cpp
- DlgPreferencePackManagementImp.cpp
- DlgProjectInformationImp.cpp
- DlgProjectUtility.cpp
- DlgPropertyLink.cpp
- DlgRevertToBackupConfigImp.cpp
- DlgExpressionInput.cpp
+ Dialogs/DlgAbout.cpp
+ Dialogs/DlgActivateWindowImp.cpp
+ Dialogs/DlgCreateNewPreferencePackImp.cpp
+ Dialogs/DlgUnitsCalculatorImp.cpp
+ Dialogs/DlgInputDialogImp.cpp
+ Dialogs/DlgMacroExecuteImp.cpp
+ Dialogs/DlgRunExternal.cpp
+ Dialogs/DlgEditFileIncludePropertyExternal.cpp
+ Dialogs/DlgMacroRecordImp.cpp
+ Dialogs/DlgMaterialPropertiesImp.cpp
+ Dialogs/DlgParameterImp.cpp
+ Dialogs/DlgParameterFind.cpp
+ Dialogs/DlgPreferencePackManagementImp.cpp
+ Dialogs/DlgProjectInformationImp.cpp
+ Dialogs/DlgProjectUtility.cpp
+ Dialogs/DlgPropertyLink.cpp
+ Dialogs/DlgRevertToBackupConfigImp.cpp
+ Dialogs/DlgExpressionInput.cpp
TaskDlgRelocation.cpp
- DlgCheckableMessageBox.cpp
+ Dialogs/DlgCheckableMessageBox.cpp
TaskCSysDragger.cpp
- DlgUndoRedo.cpp
+ Dialogs/DlgUndoRedo.cpp
InputVector.cpp
Placement.cpp
PropertyPage.cpp
@@ -507,37 +510,37 @@ SET(Dialog_CPP_SRCS
DownloadManager.cpp
DocumentRecovery.cpp
TaskElementColors.cpp
- DlgObjectSelection.cpp
- DlgAddProperty.cpp
- DlgAddPropertyVarSet.cpp
+ Dialogs/DlgObjectSelection.cpp
+ Dialogs/DlgAddProperty.cpp
+ Dialogs/DlgAddPropertyVarSet.cpp
VectorListEditor.cpp
)
SET(Dialog_HPP_SRCS
Clipping.h
DemoMode.h
- DlgAbout.h
- DlgActivateWindowImp.h
- DlgCreateNewPreferencePackImp.h
- DlgUnitsCalculatorImp.h
- DlgInputDialogImp.h
- DlgMacroExecuteImp.h
- DlgRunExternal.h
- DlgEditFileIncludePropertyExternal.h
- DlgMacroRecordImp.h
- DlgMaterialPropertiesImp.h
- DlgParameterImp.h
- DlgParameterFind.h
- DlgPreferencePackManagementImp.h
- DlgProjectInformationImp.h
- DlgProjectUtility.h
- DlgPropertyLink.h
- DlgRevertToBackupConfigImp.h
- DlgCheckableMessageBox.h
- DlgExpressionInput.h
+ Dialogs/DlgAbout.h
+ Dialogs/DlgActivateWindowImp.h
+ Dialogs/DlgCreateNewPreferencePackImp.h
+ Dialogs/DlgUnitsCalculatorImp.h
+ Dialogs/DlgInputDialogImp.h
+ Dialogs/DlgMacroExecuteImp.h
+ Dialogs/DlgRunExternal.h
+ Dialogs/DlgEditFileIncludePropertyExternal.h
+ Dialogs/DlgMacroRecordImp.h
+ Dialogs/DlgMaterialPropertiesImp.h
+ Dialogs/DlgParameterImp.h
+ Dialogs/DlgParameterFind.h
+ Dialogs/DlgPreferencePackManagementImp.h
+ Dialogs/DlgProjectInformationImp.h
+ Dialogs/DlgProjectUtility.h
+ Dialogs/DlgPropertyLink.h
+ Dialogs/DlgRevertToBackupConfigImp.h
+ Dialogs/DlgCheckableMessageBox.h
+ Dialogs/DlgExpressionInput.h
TaskDlgRelocation.h
TaskCSysDragger.h
- DlgUndoRedo.h
+ Dialogs/DlgUndoRedo.h
InputVector.h
Placement.h
PropertyPage.h
@@ -548,40 +551,40 @@ SET(Dialog_HPP_SRCS
DownloadManager.h
DocumentRecovery.h
TaskElementColors.h
- DlgObjectSelection.h
- DlgAddProperty.h
- DlgAddPropertyVarSet.h
+ Dialogs/DlgObjectSelection.h
+ Dialogs/DlgAddProperty.h
+ Dialogs/DlgAddPropertyVarSet.h
VectorListEditor.h
)
SET(Dialog_SRCS
${Dialog_CPP_SRCS}
${Dialog_HPP_SRCS}
- AboutApplication.ui
+ Dialogs/AboutApplication.ui
Clipping.ui
DemoMode.ui
- DlgActivateWindow.ui
- DlgUnitsCalculator.ui
- DlgAuthorization.ui
- DlgInputDialog.ui
- DlgAddProperty.ui
- DlgLocationAngle.ui
- DlgLocationPos.ui
- DlgMacroExecute.ui
- DlgRunExternal.ui
- DlgMacroRecord.ui
- DlgMaterialProperties.ui
- DlgParameter.ui
- DlgParameterFind.ui
- DlgPreferencePackManagement.ui
- DlgProjectInformation.ui
- DlgProjectUtility.ui
- DlgPropertyLink.ui
- DlgRevertToBackupConfig.ui
- DlgCheckableMessageBox.ui
- DlgTreeWidget.ui
- DlgExpressionInput.ui
- DlgCreateNewPreferencePack.ui
+ Dialogs/DlgActivateWindow.ui
+ Dialogs/DlgUnitsCalculator.ui
+ Dialogs/DlgAuthorization.ui
+ Dialogs/DlgInputDialog.ui
+ Dialogs/DlgAddProperty.ui
+ Dialogs/DlgLocationAngle.ui
+ Dialogs/DlgLocationPos.ui
+ Dialogs/DlgMacroExecute.ui
+ Dialogs/DlgRunExternal.ui
+ Dialogs/DlgMacroRecord.ui
+ Dialogs/DlgMaterialProperties.ui
+ Dialogs/DlgParameter.ui
+ Dialogs/DlgParameterFind.ui
+ Dialogs/DlgPreferencePackManagement.ui
+ Dialogs/DlgProjectInformation.ui
+ Dialogs/DlgProjectUtility.ui
+ Dialogs/DlgPropertyLink.ui
+ Dialogs/DlgRevertToBackupConfig.ui
+ Dialogs/DlgCheckableMessageBox.ui
+ Dialogs/DlgTreeWidget.ui
+ Dialogs/DlgExpressionInput.ui
+ Dialogs/DlgCreateNewPreferencePack.ui
DownloadManager.ui
DownloadItem.ui
DocumentRecovery.ui
@@ -591,58 +594,58 @@ SET(Dialog_SRCS
SceneInspector.ui
TextureMapping.ui
TaskElementColors.ui
- DlgObjectSelection.ui
+ Dialogs/DlgObjectSelection.ui
VectorListEditor.ui
)
SOURCE_GROUP("Dialog" FILES ${Dialog_SRCS})
# The customize dialog sources
SET(Dialog_Customize_CPP_SRCS
- DlgActionsImp.cpp
- DlgCustomizeImp.cpp
- DlgKeyboardImp.cpp
- DlgToolbarsImp.cpp
- ListWidgetDragBugFix.cpp
+ Dialogs/DlgActionsImp.cpp
+ Dialogs/DlgCustomizeImp.cpp
+ Dialogs/DlgKeyboardImp.cpp
+ Dialogs/DlgToolbarsImp.cpp
+ PreferencePages/ListWidgetDragBugFix.cpp
)
SET(Dialog_Customize_HPP_SRCS
- DlgActionsImp.h
- DlgCustomizeImp.h
- DlgKeyboardImp.h
- DlgToolbarsImp.h
- ListWidgetDragBugFix.h
+ Dialogs/DlgActionsImp.h
+ Dialogs/DlgCustomizeImp.h
+ Dialogs/DlgKeyboardImp.h
+ Dialogs/DlgToolbarsImp.h
+ PreferencePages/ListWidgetDragBugFix.h
)
if(FREECAD_USE_3DCONNEXION_LEGACY)
- list(APPEND Dialog_Customize_CPP_SRCS DlgCustomizeSpaceball.cpp DlgCustomizeSpNavSettings.cpp)
- list(APPEND Dialog_Customize_HPP_SRCS DlgCustomizeSpaceball.h DlgCustomizeSpNavSettings.h)
+ list(APPEND Dialog_Customize_CPP_SRCS Dialogs/DlgCustomizeSpaceball.cpp Dialogs/DlgCustomizeSpNavSettings.cpp)
+ list(APPEND Dialog_Customize_HPP_SRCS Dialogs/DlgCustomizeSpaceball.h Dialogs/DlgCustomizeSpNavSettings.h)
endif(FREECAD_USE_3DCONNEXION_LEGACY)
SET(Dialog_Customize_SRCS
${Dialog_Customize_CPP_SRCS}
${Dialog_Customize_HPP_SRCS}
- DlgActions.ui
- DlgChooseIcon.ui
- DlgKeyboard.ui
- DlgToolbars.ui
+ Dialogs/DlgActions.ui
+ Dialogs/DlgChooseIcon.ui
+ Dialogs/DlgKeyboard.ui
+ Dialogs/DlgToolbars.ui
)
if(FREECAD_USE_3DCONNEXION_LEGACY)
- list(APPEND Dialog_Customize_SRCS DlgCustomizeSpNavSettings.ui)
+ list(APPEND Dialog_Customize_SRCS Dialogs/DlgCustomizeSpNavSettings.ui)
endif(FREECAD_USE_3DCONNEXION_LEGACY)
SOURCE_GROUP("Dialog\\Customize" FILES ${Dialog_Customize_SRCS})
# The settings dialog sources
SET(Dialog_Settings_CPP_SRCS
- DlgOnlineHelpImp.cpp
- DlgPreferencesImp.cpp
+ Dialogs/DlgOnlineHelpImp.cpp
+ Dialogs/DlgPreferencesImp.cpp
PreferencePages/DlgSettings3DViewImp.cpp
PreferencePages/DlgSettingsCacheDirectory.cpp
- DlgSettingsColorGradientImp.cpp
+ Dialogs/DlgSettingsColorGradientImp.cpp
PreferencePages/DlgSettingsDocumentImp.cpp
PreferencePages/DlgSettingsEditor.cpp
PreferencePages/DlgSettingsGeneral.cpp
- DlgSettingsImageImp.cpp
+ Dialogs/DlgSettingsImageImp.cpp
PreferencePages/DlgSettingsLightSources.cpp
PreferencePages/DlgSettingsMacroImp.cpp
PreferencePages/DlgSettingsNavigation.cpp
@@ -656,15 +659,15 @@ SET(Dialog_Settings_CPP_SRCS
PreferencePages/DlgSettingsAdvanced.cpp
)
SET(Dialog_Settings_HPP_SRCS
- DlgOnlineHelpImp.h
- DlgPreferencesImp.h
+ Dialogs/DlgOnlineHelpImp.h
+ Dialogs/DlgPreferencesImp.h
PreferencePages/DlgSettings3DViewImp.h
PreferencePages/DlgSettingsCacheDirectory.h
- DlgSettingsColorGradientImp.h
+ Dialogs/DlgSettingsColorGradientImp.h
PreferencePages/DlgSettingsDocumentImp.h
PreferencePages/DlgSettingsEditor.h
PreferencePages/DlgSettingsGeneral.h
- DlgSettingsImageImp.h
+ Dialogs/DlgSettingsImageImp.h
PreferencePages/DlgSettingsLightSources.h
PreferencePages/DlgSettingsMacroImp.h
PreferencePages/DlgSettingsNavigation.h
@@ -680,15 +683,15 @@ SET(Dialog_Settings_HPP_SRCS
SET(Dialog_Settings_SRCS
${Dialog_Settings_CPP_SRCS}
${Dialog_Settings_HPP_SRCS}
- DlgOnlineHelp.ui
- DlgPreferences.ui
+ Dialogs/DlgOnlineHelp.ui
+ Dialogs/DlgPreferences.ui
PreferencePages/DlgSettings3DView.ui
PreferencePages/DlgSettingsCacheDirectory.ui
- DlgSettingsColorGradient.ui
+ Dialogs/DlgSettingsColorGradient.ui
PreferencePages/DlgSettingsDocument.ui
PreferencePages/DlgSettingsEditor.ui
PreferencePages/DlgSettingsGeneral.ui
- DlgSettingsImage.ui
+ Dialogs/DlgSettingsImage.ui
PreferencePages/DlgSettingsLightSources.ui
PreferencePages/DlgSettingsMacro.ui
PreferencePages/DlgSettingsNavigation.ui
@@ -708,7 +711,7 @@ SET(Dock_Windows_CPP_SRCS
DockWindow.cpp
PropertyView.cpp
ReportView.cpp
- SelectionView.cpp
+ Selection/SelectionView.cpp
ToolBox.cpp
Tree.cpp
TreeView.cpp
@@ -723,7 +726,7 @@ SET(Dock_Windows_HPP_SRCS
DockWindow.h
PropertyView.h
ReportView.h
- SelectionView.h
+ Selection/SelectionView.h
ToolBox.h
Tree.h
TreeView.h
@@ -892,18 +895,6 @@ SET(View3D_CPP_SRCS
GLPainter.cpp
Multisample.cpp
MouseSelection.cpp
- NavigationStyle.cpp
- NavigationStylePyImp.cpp
- InventorNavigationStyle.cpp
- CADNavigationStyle.cpp
- RevitNavigationStyle.cpp
- BlenderNavigationStyle.cpp
- MayaGestureNavigationStyle.cpp
- OpenCascadeNavigationStyle.cpp
- OpenSCADNavigationStyle.cpp
- TinkerCADNavigationStyle.cpp
- TouchpadNavigationStyle.cpp
- GestureNavigationStyle.cpp
SplitView3DInventor.cpp
View.cpp
View3DInventor.cpp
@@ -915,8 +906,6 @@ SET(View3D_CPP_SRCS
View3DPy.cpp
View3DViewerPy.cpp
NaviCube.cpp
- NavigationAnimator.cpp
- NavigationAnimation.cpp
)
SET(View3D_SRCS
${View3D_CPP_SRCS}
@@ -926,9 +915,6 @@ SET(View3D_SRCS
GLPainter.h
Multisample.h
MouseSelection.h
- NavigationStyle.h
- NavigationStylePy.xml
- GestureNavigationStyle.h
SplitView3DInventor.h
View.h
View3DInventor.h
@@ -940,11 +926,35 @@ SET(View3D_SRCS
CoinRiftWidget.h
View3DViewerPy.h
NaviCube.h
- NavigationAnimator.h
- NavigationAnimation.h
)
SOURCE_GROUP("View3D" FILES ${View3D_SRCS})
+SET(Navigation_CPP_SRCS
+ Navigation/NavigationStyle.cpp
+ Navigation/NavigationStylePyImp.cpp
+ Navigation/InventorNavigationStyle.cpp
+ Navigation/CADNavigationStyle.cpp
+ Navigation/RevitNavigationStyle.cpp
+ Navigation/BlenderNavigationStyle.cpp
+ Navigation/MayaGestureNavigationStyle.cpp
+ Navigation/OpenCascadeNavigationStyle.cpp
+ Navigation/OpenSCADNavigationStyle.cpp
+ Navigation/TinkerCADNavigationStyle.cpp
+ Navigation/TouchpadNavigationStyle.cpp
+ Navigation/GestureNavigationStyle.cpp
+ Navigation/NavigationAnimator.cpp
+ Navigation/NavigationAnimation.cpp
+)
+SET(Navigation_SRCS
+ ${Navigation_CPP_SRCS}
+ Navigation/NavigationStyle.h
+ Navigation/NavigationStylePy.xml
+ Navigation/GestureNavigationStyle.h
+ Navigation/NavigationAnimator.h
+ Navigation/NavigationAnimation.h
+)
+SOURCE_GROUP("Navigation" FILES ${Navigation_SRCS})
+
#quarter sources
FILE(GLOB_RECURSE Quarter_CPP_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Quarter/*.cpp)
FILE(GLOB_RECURSE Quarter_H_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Quarter/*.h)
@@ -1069,10 +1079,10 @@ SET(Inventor_CPP_SRCS
SoFCInteractiveElement.cpp
SoFCOffscreenRenderer.cpp
SoQtOffscreenRendererPy.cpp
- SoFCSelection.cpp
- SoFCUnifiedSelection.cpp
- SoFCSelectionContext.cpp
- SoFCSelectionAction.cpp
+ Selection/SoFCSelection.cpp
+ Selection/SoFCUnifiedSelection.cpp
+ Selection/SoFCSelectionContext.cpp
+ Selection/SoFCSelectionAction.cpp
SoFCVectorizeSVGAction.cpp
SoFCVectorizeU3DAction.cpp
SoDevicePixelRatioElement.cpp
@@ -1101,10 +1111,10 @@ SET(Inventor_SRCS
SoFCInteractiveElement.h
SoFCOffscreenRenderer.h
SoQtOffscreenRendererPy.h
- SoFCSelection.h
- SoFCUnifiedSelection.h
- SoFCSelectionContext.h
- SoFCSelectionAction.h
+ Selection/SoFCSelection.h
+ Selection/SoFCUnifiedSelection.h
+ Selection/SoFCSelectionContext.h
+ Selection/SoFCSelectionAction.h
SoFCVectorizeSVGAction.h
SoFCVectorizeU3DAction.h
SoDevicePixelRatioElement.h
@@ -1136,6 +1146,9 @@ SET(Widget_CPP_SRCS
Widgets.cpp
Window.cpp
WorkbenchSelector.cpp
+ ElideLabel.cpp
+ ElideCheckBox.cpp
+ FontScaledSVG.cpp
)
SET(Widget_HPP_SRCS
FileDialog.h
@@ -1157,6 +1170,9 @@ SET(Widget_HPP_SRCS
Widgets.h
Window.h
WorkbenchSelector.h
+ ElideLabel.h
+ ElideCheckBox.h
+ FontScaledSVG.h
)
SET(Widget_SRCS
${Widget_CPP_SRCS}
@@ -1241,19 +1257,19 @@ SET(Workbench_SRCS
SOURCE_GROUP("Workbench" FILES ${Workbench_SRCS})
SET(Selection_SRCS
- SelectionObjectPyImp.cpp
- SelectionObject.h
- SelectionObject.cpp
- Selection.h
- Selection.cpp
- SelectionFilter.h
- SelectionFilter.cpp
- SelectionFilterPy.h
- SelectionFilterPy.cpp
- SelectionFilter.y
- SelectionFilter.l
- SelectionObserverPython.cpp
- SelectionObserverPython.h
+ Selection/SelectionObjectPyImp.cpp
+ Selection/SelectionObject.h
+ Selection/SelectionObject.cpp
+ Selection/Selection.h
+ Selection/Selection.cpp
+ Selection/SelectionFilter.h
+ Selection/SelectionFilter.cpp
+ Selection/SelectionFilterPy.h
+ Selection/SelectionFilterPy.cpp
+ Selection/SelectionFilter.y
+ Selection/SelectionFilter.l
+ Selection/SelectionObserverPython.cpp
+ Selection/SelectionObserverPython.h
)
SOURCE_GROUP("Selection" FILES ${Selection_SRCS})
@@ -1357,6 +1373,7 @@ SET(FreeCADGui_SRCS
${Resource_SRCS}
${Quarter_SRCS}
${View3D_SRCS}
+ ${Navigation_SRCS}
${Viewprovider_SRCS}
${Widget_SRCS}
${Params_SRCS}
@@ -1411,7 +1428,7 @@ if (EIGEN3_NO_DEPRECATED_COPY)
NaviCube.cpp
Inventor/SoAutoZoomTranslation.cpp
SoFCOffscreenRenderer.cpp
- SoFCSelectionAction.cpp
+ Selection/SoFCSelectionAction.cpp
SoFCCSysDragger.cpp
Quarter/QuarterWidget.cpp
View3DInventorViewer.cpp
diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp
index 750cd4fbf0..5fb02b32bc 100644
--- a/src/Gui/Command.cpp
+++ b/src/Gui/Command.cpp
@@ -50,7 +50,7 @@
#include "Application.h"
#include "BitmapFactory.h"
#include "Control.h"
-#include "DlgUndoRedo.h"
+#include "Dialogs/DlgUndoRedo.h"
#include "Document.h"
#include "frameobject.h"
#include "Macro.h"
@@ -251,7 +251,7 @@ bool Command::isViewOfType(Base::Type t) const
Gui::BaseView *v = d->getActiveView();
if (!v)
return false;
- if (v->getTypeId().isDerivedFrom(t))
+ if (v->isDerivedFrom(t))
return true;
else
return false;
@@ -1079,7 +1079,7 @@ Action * GroupCommand::createAction() {
for(auto &v : cmds) {
if(!v.first)
- pcAction->addAction(QString::fromLatin1(""))->setSeparator(true);
+ pcAction->addAction(QStringLiteral(""))->setSeparator(true);
else
v.first->addToGroup(pcAction);
}
@@ -1175,7 +1175,7 @@ void MacroCommand::activated(int iMsg)
d = QDir(QString::fromUtf8(cMacroPath.c_str()));
}
else {
- QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
+ QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro");
d = QDir(dirstr);
}
@@ -1560,7 +1560,7 @@ void PythonGroupCommand::activated(int iMsg)
if (cmd.hasAttr("Activated")) {
Py::Callable call(cmd.getAttr("Activated"));
Py::Tuple args(1);
- args.setItem(0, Py::Int(iMsg));
+ args.setItem(0, Py::Long(iMsg));
Py::Object ret = call.apply(args);
}
// If the command group doesn't implement the 'Activated' method then invoke the command directly
@@ -1640,7 +1640,7 @@ Action * PythonGroupCommand::createAction()
if (cmd.hasAttr("GetDefaultCommand")) {
Py::Callable call2(cmd.getAttr("GetDefaultCommand"));
- Py::Int def(call2.apply(args));
+ Py::Long def(call2.apply(args));
defaultId = static_cast(def);
}
diff --git a/src/Gui/Command.h b/src/Gui/Command.h
index b8f975eeca..661d1b1c75 100644
--- a/src/Gui/Command.h
+++ b/src/Gui/Command.h
@@ -1117,7 +1117,7 @@ protected: \
virtual bool isActive(void)\
{\
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();\
- return view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId());\
+ return view && view->isDerivedFrom();\
}\
private:\
X(const X&) = delete;\
diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp
index a61512d16c..6d9274b69a 100644
--- a/src/Gui/CommandDoc.cpp
+++ b/src/Gui/CommandDoc.cpp
@@ -55,13 +55,13 @@
#include "FileDialog.h"
#include "MainWindow.h"
#include "Selection.h"
-#include "DlgObjectSelection.h"
-#include "DlgProjectInformationImp.h"
-#include "DlgProjectUtility.h"
+#include "Dialogs/DlgObjectSelection.h"
+#include "Dialogs/DlgProjectInformationImp.h"
+#include "Dialogs/DlgProjectUtility.h"
#include "GraphvizView.h"
#include "ManualAlignment.h"
#include "MergeDocuments.h"
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "Placement.h"
#include "Transform.h"
#include "View3DInventor.h"
@@ -638,7 +638,7 @@ void StdCmdExportDependencyGraph::activated(int iMsg)
{
Q_UNUSED(iMsg);
App::Document* doc = App::GetApplication().getActiveDocument();
- QString format = QString::fromLatin1("%1 (*.gv)").arg(Gui::GraphvizView::tr("Graphviz format"));
+ QString format = QStringLiteral("%1 (*.gv)").arg(Gui::GraphvizView::tr("Graphviz format"));
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), Gui::GraphvizView::tr("Export graph"), QString(), format);
if (!fn.isEmpty()) {
QFile file(fn);
@@ -679,7 +679,7 @@ void StdCmdNew::activated(int iMsg)
{
Q_UNUSED(iMsg);
QString cmd;
- cmd = QString::fromLatin1("App.newDocument()");
+ cmd = QStringLiteral("App.newDocument()");
runCommand(Command::Doc,cmd.toUtf8());
doCommand(Command::Gui,"Gui.activeDocument().activeView().viewDefaultOrientation()");
@@ -1385,6 +1385,11 @@ void StdCmdDelete::activated(int iMsg)
bool autoDeletion = true;
for(auto &sel : sels) {
auto obj = sel.getObject();
+ if (obj == nullptr){
+ Base::Console().DeveloperWarning("StdCmdDelete::activated",
+ "App::DocumentObject pointer is nullptr\n");
+ continue;
+ }
for(auto parent : obj->getInList()) {
if(!Selection().isSelected(parent)) {
ViewProvider* vp = Application::Instance->getViewProvider(parent);
@@ -1396,7 +1401,7 @@ void StdCmdDelete::activated(int iMsg)
else
label = QLatin1String(parent->getNameInDocument());
if(parent->Label.getStrValue() != parent->getNameInDocument())
- label += QString::fromLatin1(" (%1)").arg(
+ label += QStringLiteral(" (%1)").arg(
QString::fromUtf8(parent->Label.getValue()));
affectedLabels.insert(label);
if(affectedLabels.size()>=10) {
@@ -1462,7 +1467,7 @@ void StdCmdDelete::activated(int iMsg)
e.ReportException();
} catch (...) {
QMessageBox::critical(getMainWindow(), QObject::tr("Delete failed"),
- QString::fromLatin1("Unknown error"));
+ QStringLiteral("Unknown error"));
}
commitCommand();
Gui::getMainWindow()->setUpdatesEnabled(true);
@@ -1728,7 +1733,7 @@ void StdCmdEdit::activated(int iMsg)
{
Q_UNUSED(iMsg);
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
- if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
+ if (view && view->isDerivedFrom()) {
Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer();
if (viewer->isEditingViewProvider()) {
doCommand(Command::Gui,"Gui.activeDocument().resetEdit()");
diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp
index 4f42511030..de54763b75 100644
--- a/src/Gui/CommandFeat.cpp
+++ b/src/Gui/CommandFeat.cpp
@@ -244,30 +244,30 @@ void StdCmdSendToPythonConsole::activated(int iMsg)
// clear variables from previous run, if any
QString cmd = QLatin1String("try:\n del(doc,lnk,obj,shp,sub,subs)\nexcept Exception:\n pass\n");
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
- cmd = QString::fromLatin1("doc = App.getDocument(\"%1\")").arg(docname);
+ cmd = QStringLiteral("doc = App.getDocument(\"%1\")").arg(docname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
//support links
if (obj->isDerivedFrom()) {
- cmd = QString::fromLatin1("lnk = doc.getObject(\"%1\")").arg(objname);
+ cmd = QStringLiteral("lnk = doc.getObject(\"%1\")").arg(objname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
- cmd = QString::fromLatin1("obj = lnk.getLinkedObject()");
+ cmd = QStringLiteral("obj = lnk.getLinkedObject()");
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
const auto link = static_cast(obj);
obj = link->getLinkedObject();
} else {
- cmd = QString::fromLatin1("obj = doc.getObject(\"%1\")").arg(objname);
+ cmd = QStringLiteral("obj = doc.getObject(\"%1\")").arg(objname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
}
if (obj->isDerivedFrom()) {
const auto geoObj = static_cast(obj);
const App::PropertyGeometry* geo = geoObj->getPropertyOfGeometry();
if (geo){
- cmd = QString::fromLatin1("shp = obj.") + QLatin1String(geo->getName()); //"Shape", "Mesh", "Points", etc.
+ cmd = QStringLiteral("shp = obj.") + QLatin1String(geo->getName()); //"Shape", "Mesh", "Points", etc.
Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1());
if (sels[0].hasSubNames()) {
std::vector subnames = sels[0].getSubNames();
QString subname = QString::fromLatin1(subnames[0].c_str());
- cmd = QString::fromLatin1("sub = obj.getSubObject(\"%1\")").arg(subname);
+ cmd = QStringLiteral("sub = obj.getSubObject(\"%1\")").arg(subname);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
if (subnames.size() > 1) {
std::ostringstream strm;
diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp
index 875f5b093b..eddb113e8a 100644
--- a/src/Gui/CommandLink.cpp
+++ b/src/Gui/CommandLink.cpp
@@ -413,7 +413,7 @@ static void linkConvert(bool unlink) {
continue;
}else{
auto name = doc->getUniqueObjectName("Link");
- auto link = static_cast(doc->addObject("App::Link",name.c_str()));
+ auto link = doc->addObject(name.c_str());
if(!link)
FC_THROWM(Base::RuntimeError,"Failed to create link");
link->setLink(-1,obj);
diff --git a/src/Gui/CommandMacro.cpp b/src/Gui/CommandMacro.cpp
index f192213ae8..ed022cde1a 100644
--- a/src/Gui/CommandMacro.cpp
+++ b/src/Gui/CommandMacro.cpp
@@ -29,8 +29,8 @@
#include "Action.h"
#include "Application.h"
#include "BitmapFactory.h"
-#include "DlgMacroExecuteImp.h"
-#include "DlgMacroRecordImp.h"
+#include "Dialogs/DlgMacroExecuteImp.h"
+#include "Dialogs/DlgMacroRecordImp.h"
#include "Macro.h"
#include "MainWindow.h"
#include "PythonDebugger.h"
diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp
index 57d6b9bac2..048b88bb1e 100644
--- a/src/Gui/CommandPyImp.cpp
+++ b/src/Gui/CommandPyImp.cpp
@@ -100,7 +100,7 @@ PyObject* CommandPy::listByShortcut(PyObject *args)
for (Command* c : cmds) {
Action* action = c->getAction();
if (action) {
- QString spc = QString::fromLatin1(" ");
+ QString spc = QStringLiteral(" ");
if (Base::asBoolean(bIsRegularExp)) {
QRegularExpression re(QString::fromLatin1(shortcut_to_find), QRegularExpression::CaseInsensitiveOption);
if (!re.isValid()) {
diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp
index 67536d6d62..d48a784e63 100644
--- a/src/Gui/CommandStd.cpp
+++ b/src/Gui/CommandStd.cpp
@@ -42,11 +42,11 @@
#include "Action.h"
#include "BitmapFactory.h"
#include "Command.h"
-#include "DlgAbout.h"
-#include "DlgCustomizeImp.h"
-#include "DlgParameterImp.h"
-#include "DlgPreferencesImp.h"
-#include "DlgUnitsCalculatorImp.h"
+#include "Dialogs/DlgAbout.h"
+#include "Dialogs/DlgCustomizeImp.h"
+#include "Dialogs/DlgParameterImp.h"
+#include "Dialogs/DlgPreferencesImp.h"
+#include "Dialogs/DlgUnitsCalculatorImp.h"
#include "GuiConsole.h"
#include "MainWindow.h"
#include "OnlineDocumentation.h"
@@ -358,7 +358,7 @@ void StdCmdRestartInSafeMode::activated(int iMsg)
{
QStringList args = QApplication::arguments();
args.pop_front();
- auto const safeModeArgument = QString::fromLatin1("--safe-mode");
+ auto const safeModeArgument = QStringLiteral("--safe-mode");
if (!args.contains(safeModeArgument)) {
args.append(safeModeArgument);
}
@@ -534,7 +534,7 @@ StdCmdOnlineHelp::StdCmdOnlineHelp()
void StdCmdOnlineHelp::activated(int iMsg)
{
Q_UNUSED(iMsg);
- Gui::getMainWindow()->showDocumentation(QString::fromLatin1("Online_Help_Startpage"));
+ Gui::getMainWindow()->showDocumentation(QStringLiteral("Online_Help_Startpage"));
}
//===========================================================================
@@ -885,8 +885,8 @@ Gui::Action * StdCmdUserEditMode::createAction()
QAction* act = pcAction->addAction(QString());
auto modeName = QString::fromStdString(uem.second.first).remove(QChar::fromLatin1('&'));
act->setCheckable(true);
- act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QString::fromLatin1("Std_UserEditMode")+modeName)));
- act->setObjectName(QString::fromLatin1("Std_UserEditMode")+modeName);
+ act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QStringLiteral("Std_UserEditMode")+modeName)));
+ act->setObjectName(QStringLiteral("Std_UserEditMode")+modeName);
act->setWhatsThis(QString::fromLatin1(getWhatsThis()));
act->setToolTip(QString::fromStdString(uem.second.second));
diff --git a/src/Gui/CommandTest.cpp b/src/Gui/CommandTest.cpp
index 0a86fa47a7..00f3888803 100644
--- a/src/Gui/CommandTest.cpp
+++ b/src/Gui/CommandTest.cpp
@@ -70,8 +70,8 @@ void Std_TestQM::activated(int iMsg)
{
Q_UNUSED(iMsg);
QStringList files = QFileDialog::getOpenFileNames(getMainWindow(),
- QString::fromLatin1("Test translation"), QString(),
- QString::fromLatin1("Translation (*.qm)"));
+ QStringLiteral("Test translation"), QString(),
+ QStringLiteral("Translation (*.qm)"));
if (!files.empty()) {
Translator::instance()->activateLanguage("English");
QList i18n = qApp->findChildren();
diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp
index 672c4862c6..04fe6742ae 100644
--- a/src/Gui/CommandView.cpp
+++ b/src/Gui/CommandView.cpp
@@ -61,14 +61,14 @@
#include "Control.h"
#include "Clipping.h"
#include "DemoMode.h"
-#include "DlgSettingsImageImp.h"
+#include "Dialogs/DlgSettingsImageImp.h"
#include "Document.h"
#include "FileDialog.h"
#include "ImageView.h"
#include "Inventor/SoAxisCrossKit.h"
#include "Macro.h"
#include "MainWindow.h"
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "OverlayParams.h"
#include "OverlayManager.h"
#include "SceneInspector.h"
@@ -339,19 +339,19 @@ Action * StdCmdFreezeViews::createAction()
saveView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* loadView = pcAction->addAction(QObject::tr("&Load views..."));
loadView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
- pcAction->addAction(QString::fromLatin1(""))->setSeparator(true);
+ pcAction->addAction(QStringLiteral(""))->setSeparator(true);
freezeView = pcAction->addAction(QObject::tr("F&reeze view"));
freezeView->setShortcut(QString::fromLatin1(getAccel()));
freezeView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
clearView = pcAction->addAction(QObject::tr("&Clear views"));
clearView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
- separator = pcAction->addAction(QString::fromLatin1(""));
+ separator = pcAction->addAction(QStringLiteral(""));
separator->setSeparator(true);
offset = pcAction->actions().count();
// allow up to 50 views
for (int i=0; iaddAction(QString::fromLatin1(""))->setVisible(false);
+ pcAction->addAction(QStringLiteral(""))->setVisible(false);
return pcAction;
}
@@ -394,7 +394,7 @@ void StdCmdFreezeViews::activated(int iMsg)
(*it)->setToolTip(QString::fromLatin1(ppReturn));
(*it)->setVisible(true);
if (index < 10) {
- (*it)->setShortcut(QKeySequence(QString::fromLatin1("CTRL+%1").arg(index)));
+ (*it)->setShortcut(QKeySequence(QStringLiteral("CTRL+%1").arg(index)));
}
break;
}
@@ -410,7 +410,7 @@ void StdCmdFreezeViews::activated(int iMsg)
// Activate a view
QList acts = pcAction->actions();
QString data = acts[iMsg]->toolTip();
- QString send = QString::fromLatin1("SetCamera %1").arg(data);
+ QString send = QStringLiteral("SetCamera %1").arg(data);
getGuiApplication()->sendMsgToActiveView(send.toLatin1());
}
}
@@ -419,7 +419,7 @@ void StdCmdFreezeViews::onSaveViews()
{
// Save the views to an XML file
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save frozen views"),
- QString(), QString::fromLatin1("%1 (*.cam)").arg(QObject::tr("Frozen views")));
+ QString(), QStringLiteral("%1 (*.cam)").arg(QObject::tr("Frozen views")));
if (fn.isEmpty())
return;
QFile file(fn);
@@ -440,11 +440,11 @@ void StdCmdFreezeViews::onSaveViews()
// remove the first line because it's a comment like '#Inventor V2.1 ascii'
QString viewPos;
if (!data.isEmpty()) {
- QStringList lines = data.split(QString::fromLatin1("\n"));
+ QStringList lines = data.split(QStringLiteral("\n"));
if (lines.size() > 1) {
lines.pop_front();
}
- viewPos = lines.join(QString::fromLatin1(" "));
+ viewPos = lines.join(QStringLiteral(" "));
}
str << " \n";
@@ -469,7 +469,7 @@ void StdCmdFreezeViews::onRestoreViews()
// Restore the views from an XML file
QString fn = FileDialog::getOpenFileName(getMainWindow(), QObject::tr("Restore frozen views"),
- QString(), QString::fromLatin1("%1 (*.cam)").arg(QObject::tr("Frozen views")));
+ QString(), QStringLiteral("%1 (*.cam)").arg(QObject::tr("Frozen views")));
if (fn.isEmpty())
return;
QFile file(fn);
@@ -500,19 +500,19 @@ void StdCmdFreezeViews::onRestoreViews()
}
bool ok;
- int scheme = root.attribute(QString::fromLatin1("SchemaVersion")).toInt(&ok);
+ int scheme = root.attribute(QStringLiteral("SchemaVersion")).toInt(&ok);
if (!ok)
return;
// SchemeVersion "1"
if (scheme == 1) {
// read the views, ignore the attribute 'Count'
- QDomElement child = root.firstChildElement(QString::fromLatin1("Views"));
- QDomElement views = child.firstChildElement(QString::fromLatin1("Camera"));
+ QDomElement child = root.firstChildElement(QStringLiteral("Views"));
+ QDomElement views = child.firstChildElement(QStringLiteral("Camera"));
QStringList cameras;
while (!views.isNull()) {
- QString setting = views.attribute(QString::fromLatin1("settings"));
+ QString setting = views.attribute(QStringLiteral("settings"));
cameras << setting;
- views = views.nextSiblingElement(QString::fromLatin1("Camera"));
+ views = views.nextSiblingElement(QStringLiteral("Camera"));
}
// use this rather than the attribute 'Count' because it could be
@@ -533,7 +533,7 @@ void StdCmdFreezeViews::onRestoreViews()
acts[i+offset]->setToolTip(setting);
acts[i+offset]->setVisible(true);
if (i < 9) {
- acts[i+offset]->setShortcut(QKeySequence(QString::fromLatin1("CTRL+%1").arg(i+1)));
+ acts[i+offset]->setShortcut(QKeySequence(QStringLiteral("CTRL+%1").arg(i+1)));
}
}
@@ -668,44 +668,44 @@ Gui::Action * StdCmdDrawStyle::createAction()
a0->setCheckable(true);
a0->setIcon(BitmapFactory().iconFromTheme("DrawStyleAsIs"));
a0->setChecked(true);
- a0->setObjectName(QString::fromLatin1("Std_DrawStyleAsIs"));
- a0->setShortcut(QKeySequence(QString::fromUtf8("V,1")));
+ a0->setObjectName(QStringLiteral("Std_DrawStyleAsIs"));
+ a0->setShortcut(QKeySequence(QStringLiteral("V,1")));
a0->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* a1 = pcAction->addAction(QString());
a1->setCheckable(true);
a1->setIcon(BitmapFactory().iconFromTheme("DrawStylePoints"));
- a1->setObjectName(QString::fromLatin1("Std_DrawStylePoints"));
- a1->setShortcut(QKeySequence(QString::fromUtf8("V,2")));
+ a1->setObjectName(QStringLiteral("Std_DrawStylePoints"));
+ a1->setShortcut(QKeySequence(QStringLiteral("V,2")));
a1->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* a2 = pcAction->addAction(QString());
a2->setCheckable(true);
a2->setIcon(BitmapFactory().iconFromTheme("DrawStyleWireFrame"));
- a2->setObjectName(QString::fromLatin1("Std_DrawStyleWireframe"));
- a2->setShortcut(QKeySequence(QString::fromUtf8("V,3")));
+ a2->setObjectName(QStringLiteral("Std_DrawStyleWireframe"));
+ a2->setShortcut(QKeySequence(QStringLiteral("V,3")));
a2->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* a3 = pcAction->addAction(QString());
a3->setCheckable(true);
a3->setIcon(BitmapFactory().iconFromTheme("DrawStyleHiddenLine"));
- a3->setObjectName(QString::fromLatin1("Std_DrawStyleHiddenLine"));
- a3->setShortcut(QKeySequence(QString::fromUtf8("V,4")));
+ a3->setObjectName(QStringLiteral("Std_DrawStyleHiddenLine"));
+ a3->setShortcut(QKeySequence(QStringLiteral("V,4")));
a3->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* a4 = pcAction->addAction(QString());
a4->setCheckable(true);
a4->setIcon(BitmapFactory().iconFromTheme("DrawStyleNoShading"));
- a4->setObjectName(QString::fromLatin1("Std_DrawStyleNoShading"));
- a4->setShortcut(QKeySequence(QString::fromUtf8("V,5")));
+ a4->setObjectName(QStringLiteral("Std_DrawStyleNoShading"));
+ a4->setShortcut(QKeySequence(QStringLiteral("V,5")));
a4->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* a5 = pcAction->addAction(QString());
a5->setCheckable(true);
a5->setIcon(BitmapFactory().iconFromTheme("DrawStyleShaded"));
- a5->setObjectName(QString::fromLatin1("Std_DrawStyleShaded"));
- a5->setShortcut(QKeySequence(QString::fromUtf8("V,6")));
+ a5->setObjectName(QStringLiteral("Std_DrawStyleShaded"));
+ a5->setShortcut(QKeySequence(QStringLiteral("V,6")));
a5->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* a6 = pcAction->addAction(QString());
a6->setCheckable(true);
a6->setIcon(BitmapFactory().iconFromTheme("DrawStyleFlatLines"));
- a6->setObjectName(QString::fromLatin1("Std_DrawStyleFlatLines"));
- a6->setShortcut(QKeySequence(QString::fromUtf8("V,7")));
+ a6->setObjectName(QStringLiteral("Std_DrawStyleFlatLines"));
+ a6->setShortcut(QKeySequence(QStringLiteral("V,7")));
a6->setWhatsThis(QString::fromLatin1(getWhatsThis()));
pcAction->setIcon(a0->icon());
@@ -931,7 +931,7 @@ void StdCmdToggleTransparency::activated(int iMsg)
App::Document* doc = obj->getDocument();
Gui::ViewProvider* view = Application::Instance->getDocument(doc)->getViewProvider(obj);
App::Property* prop = view->getPropertyByName("Transparency");
- if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
+ if (prop && prop->isDerivedFrom()) {
// To prevent toggling the tip of a PD body (see #11353), we check if the parent has a
// Tip prop.
const std::vector parents = obj->getInList();
@@ -942,7 +942,7 @@ void StdCmdToggleTransparency::activated(int iMsg)
if (parentProp) {
// Make sure it has a transparency prop too
parentProp = parentView->getPropertyByName("Transparency");
- if (parentProp && parentProp->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
+ if (parentProp && parentProp->isDerivedFrom()) {
view = parentView;
}
}
@@ -967,7 +967,7 @@ void StdCmdToggleTransparency::activated(int iMsg)
bool oneTransparent = false;
for (auto* view : viewsToToggle) {
App::Property* prop = view->getPropertyByName("Transparency");
- if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
+ if (prop && prop->isDerivedFrom()) {
auto* transparencyProp = dynamic_cast(prop);
int transparency = transparencyProp->getValue();
if (transparency != 0) {
@@ -984,7 +984,7 @@ void StdCmdToggleTransparency::activated(int iMsg)
for (auto* view : viewsToToggle) {
App::Property* prop = view->getPropertyByName("Transparency");
- if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
+ if (prop && prop->isDerivedFrom()) {
auto* transparencyProp = dynamic_cast(prop);
transparencyProp->setValue(transparency);
}
@@ -1033,7 +1033,7 @@ void StdCmdToggleSelectability::activated(int iMsg)
for (const auto & ft : sel) {
ViewProvider *pr = pcDoc->getViewProviderByName(ft->getNameInDocument());
- if (pr && pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){
+ if (pr && pr->isDerivedFrom()){
if (static_cast(pr)->Selectable.getValue())
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=False"
, doc->getName(), ft->getNameInDocument());
@@ -1959,7 +1959,7 @@ void StdViewScreenShot::activated(int iMsg)
QStringList filter;
QString selFilter;
for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
- filter << QString::fromLatin1("%1 %2 (*.%3)").arg((*it).toUpper(),
+ filter << QStringLiteral("%1 %2 (*.%3)").arg((*it).toUpper(),
QObject::tr("files"), (*it).toLower());
if (ext == *it)
selFilter = filter.last();
@@ -2121,8 +2121,8 @@ void StdViewLoadImage::activated(int iMsg)
QFileDialog dialog(Gui::getMainWindow());
dialog.setWindowTitle(QObject::tr("Choose an image file to open"));
dialog.setMimeTypeFilters(mimeTypeFilters);
- dialog.selectMimeTypeFilter(QString::fromLatin1("image/png"));
- dialog.setDefaultSuffix(QString::fromLatin1("png"));
+ dialog.selectMimeTypeFilter(QStringLiteral("image/png"));
+ dialog.setDefaultSuffix(QStringLiteral("png"));
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setOption(QFileDialog::DontUseNativeDialog);
@@ -2187,7 +2187,7 @@ void StdCmdToggleNavigation::activated(int iMsg)
{
Q_UNUSED(iMsg);
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
- if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
+ if (view && view->isDerivedFrom()) {
Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer();
SbBool toggle = viewer->isRedirectedToSceneGraph();
viewer->setRedirectToSceneGraph(!toggle);
@@ -2203,7 +2203,7 @@ bool StdCmdToggleNavigation::isActive()
if (Gui::Control().activeDialog())
return false;
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
- if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
+ if (view && view->isDerivedFrom()) {
Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer();
return viewer->isEditing() && viewer->isRedirectToSceneGraphEnabled();
}
@@ -3203,7 +3203,7 @@ void StdCmdTextureMapping::activated(int iMsg)
bool StdCmdTextureMapping::isActive()
{
Gui::MDIView* view = getMainWindow()->activeWindow();
- return view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())
+ return view && view->isDerivedFrom()
&& (!(Gui::Control().activeDialog()));
}
diff --git a/src/Gui/CommandWindow.cpp b/src/Gui/CommandWindow.cpp
index c8ee5c24ed..b4e925aee5 100644
--- a/src/Gui/CommandWindow.cpp
+++ b/src/Gui/CommandWindow.cpp
@@ -34,7 +34,7 @@
#include "MainWindow.h"
#include "View.h"
#include "Document.h"
-#include "DlgActivateWindowImp.h"
+#include "Dialogs/DlgActivateWindowImp.h"
#include "DockWindowManager.h"
#include "ToolBarManager.h"
diff --git a/src/Gui/DAGView/DAGFilter.cpp b/src/Gui/DAGView/DAGFilter.cpp
index 57bc3915af..e331d52d2e 100644
--- a/src/Gui/DAGView/DAGFilter.cpp
+++ b/src/Gui/DAGView/DAGFilter.cpp
@@ -31,7 +31,7 @@
using namespace Gui;
using namespace DAG;
-FilterBase::FilterBase() : name(QString::fromLatin1("empty name"))
+FilterBase::FilterBase() : name(QStringLiteral("empty name"))
{
}
diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp
index 2db0d5fea4..9dc8a902a9 100644
--- a/src/Gui/DAGView/DAGModel.cpp
+++ b/src/Gui/DAGView/DAGModel.cpp
@@ -47,7 +47,7 @@
#include
#include
#include
-#include
+#include
#include
#include "DAGModel.h"
@@ -315,7 +315,7 @@ void Model::slotChangeObject(const ViewProviderDocumentObject &VPDObjectIn, cons
text->setPlainText(QString::fromUtf8(record.DObject->Label.getValue()));
}
}
- else if (propertyIn.isDerivedFrom(App::PropertyLinkBase::getClassTypeId()))
+ else if (propertyIn.isDerivedFrom())
{
if (hasRecord(&VPDObjectIn, *graphLink))
{
diff --git a/src/Gui/DAGView/DAGView.h b/src/Gui/DAGView/DAGView.h
index 9b9ccd75e9..23fc7b4677 100644
--- a/src/Gui/DAGView/DAGView.h
+++ b/src/Gui/DAGView/DAGView.h
@@ -29,7 +29,7 @@
#include
#include
-#include
+#include
#include "DAGModel.h"
diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp
index 861e1bf86f..e253246b3d 100644
--- a/src/Gui/DemoMode.cpp
+++ b/src/Gui/DemoMode.cpp
@@ -143,12 +143,8 @@ void DemoMode::hideEvent(QHideEvent*)
Gui::View3DInventor* DemoMode::activeView() const
{
- Document* doc = Application::Instance->activeDocument();
- if (doc) {
- MDIView* view = doc->getActiveView();
- if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
- return static_cast(view);
- }
+ if (Document* doc = Application::Instance->activeDocument()) {
+ return Base::freecad_dynamic_cast(doc->getActiveView());
}
return nullptr;
diff --git a/src/Gui/AboutApplication.ui b/src/Gui/Dialogs/AboutApplication.ui
similarity index 99%
rename from src/Gui/AboutApplication.ui
rename to src/Gui/Dialogs/AboutApplication.ui
index 61787e56c1..d8b4daa7fd 100644
--- a/src/Gui/AboutApplication.ui
+++ b/src/Gui/Dialogs/AboutApplication.ui
@@ -33,7 +33,7 @@
- :/icons/freecadsplash.png
+ :/icons/freecadsplash.png
Qt::AlignCenter
@@ -398,7 +398,7 @@ p, li { white-space: pre-wrap; }
-
+
diff --git a/src/Gui/DlgAbout.cpp b/src/Gui/Dialogs/DlgAbout.cpp
similarity index 83%
rename from src/Gui/DlgAbout.cpp
rename to src/Gui/Dialogs/DlgAbout.cpp
index 74ec04eaee..8a1808333f 100644
--- a/src/Gui/DlgAbout.cpp
+++ b/src/Gui/Dialogs/DlgAbout.cpp
@@ -45,21 +45,22 @@
#include
#include
#include
+#include
#include
-#include
+#include
#include
#include
#include "BitmapFactory.h"
-#include "DlgAbout.h"
+#include "Dialogs/DlgAbout.h"
#include "MainWindow.h"
#include "SplashScreen.h"
#include "ui_AboutApplication.h"
using namespace Gui;
using namespace Gui::Dialog;
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
static QString prettyProductInfoWrapper()
{
@@ -67,7 +68,7 @@ static QString prettyProductInfoWrapper()
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
#ifdef FC_OS_MACOSX
auto macosVersionFile =
- QString::fromUtf8("/System/Library/CoreServices/.SystemVersionPlatform.plist");
+ QStringLiteral("/System/Library/CoreServices/.SystemVersionPlatform.plist");
auto fi = QFileInfo(macosVersionFile);
if (fi.exists() && fi.isReadable()) {
auto plistFile = QFile(macosVersionFile);
@@ -77,10 +78,10 @@ static QString prettyProductInfoWrapper()
if (line.contains("ProductUserVisibleVersion")) {
auto nextLine = plistFile.readLine();
if (nextLine.contains("")) {
- QRegularExpression re(QString::fromUtf8("\\s*(.*)"));
+ QRegularExpression re(QStringLiteral("\\s*(.*)"));
auto matches = re.match(QString::fromUtf8(nextLine));
if (matches.hasMatch()) {
- productName = QString::fromUtf8("macOS ") + matches.captured(1);
+ productName = QStringLiteral("macOS ") + matches.captured(1);
break;
}
}
@@ -91,22 +92,22 @@ static QString prettyProductInfoWrapper()
#endif
#ifdef FC_OS_WIN64
QSettings regKey {
- QString::fromUtf8("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
+ QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
QSettings::NativeFormat};
- if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
- auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
+ if (regKey.contains(QStringLiteral("CurrentBuildNumber"))) {
+ auto buildNumber = regKey.value(QStringLiteral("CurrentBuildNumber")).toInt();
if (buildNumber > 0) {
if (buildNumber < 9200) {
- productName = QString::fromUtf8("Windows 7 build %1").arg(buildNumber);
+ productName = QStringLiteral("Windows 7 build %1").arg(buildNumber);
}
else if (buildNumber < 10240) {
- productName = QString::fromUtf8("Windows 8 build %1").arg(buildNumber);
+ productName = QStringLiteral("Windows 8 build %1").arg(buildNumber);
}
else if (buildNumber < 22000) {
- productName = QString::fromUtf8("Windows 10 build %1").arg(buildNumber);
+ productName = QStringLiteral("Windows 10 build %1").arg(buildNumber);
}
else {
- productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber);
+ productName = QStringLiteral("Windows 11 build %1").arg(buildNumber);
}
}
}
@@ -210,7 +211,7 @@ QPixmap AboutDialog::aboutImage() const
{
// See if we have a custom About screen image set
QPixmap about_image;
- QFileInfo fi(QString::fromLatin1("images:about_image.png"));
+ QFileInfo fi(QStringLiteral("images:about_image.png"));
if (fi.isFile() && fi.exists()) {
about_image.load(fi.filePath(), "PNG");
}
@@ -250,7 +251,7 @@ void AboutDialog::setupLabels()
#endif
// avoid overriding user set style sheet
if (qApp->styleSheet().isEmpty()) {
- setStyleSheet(QString::fromLatin1("Gui--Dialog--AboutDialog QLabel {font-size: %1pt;}")
+ setStyleSheet(QStringLiteral("Gui--Dialog--AboutDialog QLabel {font-size: %1pt;}")
.arg(fontSize));
}
@@ -271,41 +272,41 @@ void AboutDialog::setupLabels()
// gets replaced to "FreeCAD", for example
QString author = ui->labelAuthor->text();
- author.replace(QString::fromLatin1("Unknown Application"), exeName);
- author.replace(QString::fromLatin1("(c) Unknown Author"), banner);
+ author.replace(QStringLiteral("Unknown Application"), exeName);
+ author.replace(QStringLiteral("(c) Unknown Author"), banner);
ui->labelAuthor->setText(author);
ui->labelAuthor->setUrl(mturl);
if (qApp->styleSheet().isEmpty()) {
- ui->labelAuthor->setStyleSheet(QString::fromLatin1(
+ ui->labelAuthor->setStyleSheet(QStringLiteral(
"Gui--UrlLabel {color: #0000FF;text-decoration: underline;font-weight: 600;}"));
}
QString version = ui->labelBuildVersion->text();
- version.replace(QString::fromLatin1("Unknown"),
- QString::fromLatin1("%1.%2.%3%4").arg(major, minor, point, suffix));
+ version.replace(QStringLiteral("Unknown"),
+ QStringLiteral("%1.%2.%3%4").arg(major, minor, point, suffix));
ui->labelBuildVersion->setText(version);
QString revision = ui->labelBuildRevision->text();
- revision.replace(QString::fromLatin1("Unknown"), build);
+ revision.replace(QStringLiteral("Unknown"), build);
ui->labelBuildRevision->setText(revision);
QString date = ui->labelBuildDate->text();
- date.replace(QString::fromLatin1("Unknown"), disda);
+ date.replace(QStringLiteral("Unknown"), disda);
ui->labelBuildDate->setText(date);
QString os = ui->labelBuildOS->text();
- os.replace(QString::fromLatin1("Unknown"), prettyProductInfoWrapper());
+ os.replace(QStringLiteral("Unknown"), prettyProductInfoWrapper());
ui->labelBuildOS->setText(os);
QString architecture = ui->labelBuildRunArchitecture->text();
if (QSysInfo::buildCpuArchitecture() == QSysInfo::currentCpuArchitecture()) {
- architecture.replace(QString::fromLatin1("Unknown"), QSysInfo::buildCpuArchitecture());
+ architecture.replace(QStringLiteral("Unknown"), QSysInfo::buildCpuArchitecture());
}
else {
architecture.replace(
- QString::fromLatin1("Unknown"),
- QString::fromLatin1("%1 (running on: %2)")
+ QStringLiteral("Unknown"),
+ QStringLiteral("%1 (running on: %2)")
.arg(QSysInfo::buildCpuArchitecture(), QSysInfo::currentCpuArchitecture()));
}
ui->labelBuildRunArchitecture->setText(architecture);
@@ -314,7 +315,7 @@ void AboutDialog::setupLabels()
it = config.find("BuildRevisionBranch");
if (it != config.end()) {
QString branch = ui->labelBuildBranch->text();
- branch.replace(QString::fromLatin1("Unknown"), QString::fromStdString(it->second));
+ branch.replace(QStringLiteral("Unknown"), QString::fromStdString(it->second));
ui->labelBuildBranch->setText(branch);
}
else {
@@ -327,7 +328,7 @@ void AboutDialog::setupLabels()
if (it != config.end()) {
QString hash = ui->labelBuildHash->text();
hash.replace(
- QString::fromLatin1("Unknown"),
+ QStringLiteral("Unknown"),
QString::fromStdString(it->second).left(7)); // Use the 7-char abbreviated hash
ui->labelBuildHash->setText(hash);
if (auto url_itr = config.find("BuildRepositoryURL"); url_itr != config.end()) {
@@ -337,15 +338,15 @@ void AboutDialog::setupLabels()
url = url.left(space); // Strip off the branch information to get just the repo
}
- if (url == QString::fromUtf8("Unknown")) {
- url = QString::fromUtf8("https://github.com/FreeCAD/FreeCAD"); // Just take a guess
+ if (url == QStringLiteral("Unknown")) {
+ url = QStringLiteral("https://github.com/FreeCAD/FreeCAD"); // Just take a guess
}
// This may only create valid URLs for Github, but some other hosts use the same format
// so give it a shot...
- auto https = url.replace(QString::fromUtf8("git://"), QString::fromUtf8("https://"));
- https.replace(QString::fromUtf8(".git"), QString::fromUtf8(""));
- ui->labelBuildHash->setUrl(https + QString::fromUtf8("/commit/")
+ auto https = url.replace(QStringLiteral("git://"), QStringLiteral("https://"));
+ https.replace(QStringLiteral(".git"), QStringLiteral(""));
+ ui->labelBuildHash->setUrl(https + QStringLiteral("/commit/")
+ QString::fromStdString(it->second));
}
}
@@ -365,26 +366,26 @@ void AboutDialog::showCredits()
}
auto tab_credits = new QWidget();
- tab_credits->setObjectName(QString::fromLatin1("tab_credits"));
+ tab_credits->setObjectName(QStringLiteral("tab_credits"));
ui->tabWidget->addTab(tab_credits, tr("Credits"));
auto hlayout = new QVBoxLayout(tab_credits);
auto textField = new QTextBrowser(tab_credits);
textField->setOpenExternalLinks(true);
hlayout->addWidget(textField);
- QString creditsHTML = QString::fromLatin1("");
+ QString creditsHTML = QStringLiteral("
");
//: Header for bgbsww
creditsHTML +=
tr("This version of FreeCAD is dedicated to the memory of Brad McLean, aka bgbsww.");
//: Header for the Credits tab of the About screen
- creditsHTML += QString::fromLatin1("
");
+ creditsHTML += QStringLiteral("");
creditsHTML += tr("Credits");
- creditsHTML += QString::fromLatin1("
");
+ creditsHTML += QStringLiteral("
");
creditsHTML += tr("FreeCAD would not be possible without the contributions of");
- creditsHTML += QString::fromLatin1(":
");
+ creditsHTML += QStringLiteral(":");
//: Header for the list of individual people in the Credits list.
creditsHTML += tr("Individuals");
- creditsHTML += QString::fromLatin1("
");
+ creditsHTML += QStringLiteral("
");
QTextStream stream(&creditsFile);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@@ -393,37 +394,37 @@ void AboutDialog::showCredits()
QString line;
while (stream.readLineInto(&line)) {
if (!line.isEmpty()) {
- if (line == QString::fromLatin1("Firms")) {
- creditsHTML += QString::fromLatin1("
");
+ if (line == QStringLiteral("Firms")) {
+ creditsHTML += QStringLiteral("");
//: Header for the list of companies/organizations in the Credits list.
creditsHTML += tr("Organizations");
- creditsHTML += QString::fromLatin1("
");
+ creditsHTML += QStringLiteral("
");
}
else {
- creditsHTML += QString::fromLatin1("- ") + line + QString::fromLatin1("
");
+ creditsHTML += QStringLiteral("- ") + line + QStringLiteral("
");
}
}
}
- creditsHTML += QString::fromLatin1("
");
+ creditsHTML += QStringLiteral("");
textField->setHtml(creditsHTML);
}
void AboutDialog::showLicenseInformation()
{
- QString licenseFileURL = QString::fromLatin1("%1/LICENSE.html")
+ QString licenseFileURL = QStringLiteral("%1/LICENSE.html")
.arg(QString::fromStdString(App::Application::getHelpDir()));
QFile licenseFile(licenseFileURL);
if (licenseFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString licenseHTML = QString::fromUtf8(licenseFile.readAll());
const auto placeholder =
- QString::fromUtf8("");
+ QStringLiteral("");
licenseHTML.replace(placeholder, getAdditionalLicenseInformation());
ui->tabWidget->removeTab(1); // Hide the license placeholder widget
auto tab_license = new QWidget();
- tab_license->setObjectName(QString::fromLatin1("tab_license"));
+ tab_license->setObjectName(QStringLiteral("tab_license"));
ui->tabWidget->addTab(tab_license, tr("License"));
auto hlayout = new QVBoxLayout(tab_license);
auto textField = new QTextBrowser(tab_license);
@@ -437,7 +438,7 @@ void AboutDialog::showLicenseInformation()
QString info(QLatin1String("SUCH DAMAGES.
"));
info += getAdditionalLicenseInformation();
QString lictext = ui->textBrowserLicense->toHtml();
- lictext.replace(QString::fromLatin1("SUCH DAMAGES.
"), info);
+ lictext.replace(QStringLiteral("SUCH DAMAGES.
"), info);
ui->textBrowserLicense->setHtml(lictext);
}
}
@@ -449,7 +450,7 @@ QString AboutDialog::getAdditionalLicenseInformation() const
// and add an
tag at the end to nicely separate license blocks
QString info;
#ifdef _USE_3DCONNEXION_SDK
- info += QString::fromUtf8(
+ info += QStringLiteral(
"3D Mouse Support
"
"Development tools and related technology provided under license from 3Dconnexion.
"
"Copyright © 1992–2012 3Dconnexion. All rights reserved.
"
@@ -461,7 +462,7 @@ QString AboutDialog::getAdditionalLicenseInformation() const
void AboutDialog::showLibraryInformation()
{
auto tab_library = new QWidget();
- tab_library->setObjectName(QString::fromLatin1("tab_library"));
+ tab_library->setObjectName(QStringLiteral("tab_library"));
ui->tabWidget->addTab(tab_library, tr("Libraries"));
auto hlayout = new QVBoxLayout(tab_library);
auto textField = new QTextBrowser(tab_library);
@@ -469,7 +470,7 @@ void AboutDialog::showLibraryInformation()
textField->setOpenLinks(false);
hlayout->addWidget(textField);
- QString baseurl = QString::fromLatin1("file:///%1/ThirdPartyLibraries.html")
+ QString baseurl = QStringLiteral("file:///%1/ThirdPartyLibraries.html")
.arg(QString::fromStdString(App::Application::getHelpDir()));
textField->setSource(QUrl(baseurl));
@@ -484,7 +485,7 @@ void AboutDialog::showCollectionInformation()
}
auto tab_collection = new QWidget();
- tab_collection->setObjectName(QString::fromLatin1("tab_collection"));
+ tab_collection->setObjectName(QStringLiteral("tab_collection"));
ui->tabWidget->addTab(tab_collection, tr("Collection"));
auto hlayout = new QVBoxLayout(tab_collection);
auto textField = new QTextBrowser(tab_collection);
@@ -503,7 +504,7 @@ void AboutDialog::showPrivacyPolicy()
}
auto text = QString::fromUtf8(policyFile.readAll());
auto tabPrivacyPolicy = new QWidget();
- tabPrivacyPolicy->setObjectName(QString::fromLatin1("tabPrivacyPolicy"));
+ tabPrivacyPolicy->setObjectName(QStringLiteral("tabPrivacyPolicy"));
ui->tabWidget->addTab(tabPrivacyPolicy, tr("Privacy Policy"));
auto hLayout = new QVBoxLayout(tabPrivacyPolicy);
auto textField = new QTextBrowser(tabPrivacyPolicy);
@@ -527,7 +528,7 @@ void AboutDialog::linkActivated(const QUrl& link)
QString fragment = link.fragment();
if (fragment.startsWith(QLatin1String("_Toc"))) {
QString prefix = fragment.mid(4);
- title = QString::fromLatin1("%1 %2").arg(prefix, title);
+ title = QStringLiteral("%1 %2").arg(prefix, title);
}
licenseView->setWindowTitle(title);
getMainWindow()->addWindow(licenseView);
@@ -547,8 +548,8 @@ void AboutDialog::addModuleInfo(QTextStream& str, const QString& modPath, bool&
str << " * " << (mod.isDir() ? QDir(modPath).dirName() : mod.fileName());
try {
auto metadataFile =
- boost::filesystem::path(mod.absoluteFilePath().toStdString()) / "package.xml";
- if (boost::filesystem::exists(metadataFile)) {
+ std::filesystem::path(mod.absoluteFilePath().toStdString()) / "package.xml";
+ if (std::filesystem::exists(metadataFile)) {
App::Metadata metadata(metadataFile);
if (metadata.version() != App::Meta::Version()) {
str << QLatin1String(" ") + QString::fromStdString(metadata.version().str());
@@ -560,7 +561,7 @@ void AboutDialog::addModuleInfo(QTextStream& str, const QString& modPath, bool&
QChar::fromLatin1(' '));
str << " (Malformed metadata: " << what << ")";
}
- QFileInfo disablingFile(mod.absoluteFilePath(), QString::fromLatin1("ADDON_DISABLED"));
+ QFileInfo disablingFile(mod.absoluteFilePath(), QStringLiteral("ADDON_DISABLED"));
if (disablingFile.exists()) {
str << " (Disabled)";
}
@@ -652,6 +653,28 @@ void AboutDialog::copyToClipboard()
str << "Qt " << QT_VERSION_STR << ", ";
str << "Coin " << COIN_VERSION << ", ";
str << "Vtk " << fcVtkVersion << ", ";
+
+ const char* cmd = "import ifcopenshell\n"
+ "version = ifcopenshell.version";
+ PyObject * ifcopenshellVer = nullptr;
+
+ try {
+ ifcopenshellVer = Base::Interpreter().getValue(cmd, "version");
+ }
+ catch (const Base::Exception& e) {
+ Base::Console().Log("%s (safe to ignore, unless using the BIM workbench and IFC).\n", e.what());
+ }
+
+ if (ifcopenshellVer) {
+ const char* ifcopenshellVerAsStr = PyUnicode_AsUTF8(ifcopenshellVer);
+
+ if (ifcopenshellVerAsStr) {
+ str << "IfcOpenShell " << ifcopenshellVerAsStr << ", ";
+ Py_DECREF(ifcopenshellVerAsStr);
+ }
+ Py_DECREF(ifcopenshellVer);
+ }
+
#if defined(HAVE_OCC_VERSION)
str << "OCC " << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE
#ifdef OCC_VERSION_DEVELOPMENT
@@ -709,6 +732,13 @@ void AboutDialog::copyToClipboard()
str << "Stylesheet/Theme/QtStyle: " << QString::fromStdString(styleSheet) << "/"
<< QString::fromStdString(theme) << "/" << QString::fromStdString(style) << "\n";
+ // Add DPI information
+ str << "Logical/physical DPI: "
+ << QApplication::primaryScreen()->logicalDotsPerInch()
+ << "/"
+ << QApplication::primaryScreen()->physicalDotsPerInch()
+ << "\n";
+
// Add installed module information:
auto modDir = fs::path(App::Application::getUserAppDataDir()) / "Mod";
bool firstMod = true;
diff --git a/src/Gui/DlgAbout.h b/src/Gui/Dialogs/DlgAbout.h
similarity index 100%
rename from src/Gui/DlgAbout.h
rename to src/Gui/Dialogs/DlgAbout.h
diff --git a/src/Gui/DlgActions.ui b/src/Gui/Dialogs/DlgActions.ui
similarity index 100%
rename from src/Gui/DlgActions.ui
rename to src/Gui/Dialogs/DlgActions.ui
diff --git a/src/Gui/DlgActionsImp.cpp b/src/Gui/Dialogs/DlgActionsImp.cpp
similarity index 96%
rename from src/Gui/DlgActionsImp.cpp
rename to src/Gui/Dialogs/DlgActionsImp.cpp
index a1c72702e5..42ec839db5 100644
--- a/src/Gui/DlgActionsImp.cpp
+++ b/src/Gui/Dialogs/DlgActionsImp.cpp
@@ -33,7 +33,7 @@
#include
#endif
-#include "DlgActionsImp.h"
+#include "Dialogs/DlgActionsImp.h"
#include "ui_DlgActions.h"
#include "Action.h"
#include "Application.h"
@@ -73,7 +73,7 @@ DlgCustomActionsImp::DlgCustomActionsImp(QWidget* parent)
}
QString systemMacroDirStr =
- QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
+ QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro");
d = QDir(systemMacroDirStr, QLatin1String("*.FCMacro *.py"));
if (d.exists()) {
for (unsigned int i = 0; i < d.count(); i++) {
@@ -483,7 +483,7 @@ void IconDialog::onAddIconPath()
QStringList filters;
QList formats = QImageReader::supportedImageFormats();
for (const auto& format : formats) {
- filters << QString::fromLatin1("*.%1").arg(
+ filters << QStringLiteral("*.%1").arg(
QString::fromLatin1(format).toLower());
}
QDir d(path);
diff --git a/src/Gui/DlgActionsImp.h b/src/Gui/Dialogs/DlgActionsImp.h
similarity index 100%
rename from src/Gui/DlgActionsImp.h
rename to src/Gui/Dialogs/DlgActionsImp.h
diff --git a/src/Gui/DlgActivateWindow.ui b/src/Gui/Dialogs/DlgActivateWindow.ui
similarity index 100%
rename from src/Gui/DlgActivateWindow.ui
rename to src/Gui/Dialogs/DlgActivateWindow.ui
diff --git a/src/Gui/DlgActivateWindowImp.cpp b/src/Gui/Dialogs/DlgActivateWindowImp.cpp
similarity index 96%
rename from src/Gui/DlgActivateWindowImp.cpp
rename to src/Gui/Dialogs/DlgActivateWindowImp.cpp
index 1a7abd4829..8449fe9069 100644
--- a/src/Gui/DlgActivateWindowImp.cpp
+++ b/src/Gui/Dialogs/DlgActivateWindowImp.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "DlgActivateWindowImp.h"
+#include "Dialogs/DlgActivateWindowImp.h"
#include "ui_DlgActivateWindow.h"
#include "MainWindow.h"
#include "MDIView.h"
diff --git a/src/Gui/DlgActivateWindowImp.h b/src/Gui/Dialogs/DlgActivateWindowImp.h
similarity index 100%
rename from src/Gui/DlgActivateWindowImp.h
rename to src/Gui/Dialogs/DlgActivateWindowImp.h
diff --git a/src/Gui/DlgAddProperty.cpp b/src/Gui/Dialogs/DlgAddProperty.cpp
similarity index 97%
rename from src/Gui/DlgAddProperty.cpp
rename to src/Gui/Dialogs/DlgAddProperty.cpp
index 1454fec98a..f307dbf8bd 100644
--- a/src/Gui/DlgAddProperty.cpp
+++ b/src/Gui/Dialogs/DlgAddProperty.cpp
@@ -31,7 +31,7 @@
#include
#include
-#include "DlgAddProperty.h"
+#include "Dialogs/DlgAddProperty.h"
#include "ui_DlgAddProperty.h"
#include "MainWindow.h"
#include "ViewProviderDocumentObject.h"
diff --git a/src/Gui/DlgAddProperty.h b/src/Gui/Dialogs/DlgAddProperty.h
similarity index 100%
rename from src/Gui/DlgAddProperty.h
rename to src/Gui/Dialogs/DlgAddProperty.h
diff --git a/src/Gui/DlgAddProperty.ui b/src/Gui/Dialogs/DlgAddProperty.ui
similarity index 100%
rename from src/Gui/DlgAddProperty.ui
rename to src/Gui/Dialogs/DlgAddProperty.ui
diff --git a/src/Gui/DlgAddPropertyVarSet.cpp b/src/Gui/Dialogs/DlgAddPropertyVarSet.cpp
similarity index 98%
rename from src/Gui/DlgAddPropertyVarSet.cpp
rename to src/Gui/Dialogs/DlgAddPropertyVarSet.cpp
index adbd4a3504..312666ded2 100644
--- a/src/Gui/DlgAddPropertyVarSet.cpp
+++ b/src/Gui/Dialogs/DlgAddPropertyVarSet.cpp
@@ -34,7 +34,7 @@
#include
#include
-#include "DlgAddPropertyVarSet.h"
+#include "Dialogs/DlgAddPropertyVarSet.h"
#include "ui_DlgAddPropertyVarSet.h"
#include "MainWindow.h"
#include "ViewProviderVarSet.h"
@@ -69,7 +69,7 @@ DlgAddPropertyVarSet::~DlgAddPropertyVarSet() = default;
void DlgAddPropertyVarSet::initializeGroup()
{
- comboBoxGroup.setObjectName(QString::fromUtf8("comboBoxGroup"));
+ comboBoxGroup.setObjectName(QStringLiteral("comboBoxGroup"));
comboBoxGroup.setInsertPolicy(QComboBox::InsertAtTop);
comboBoxGroup.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
auto formLayout = qobject_cast(layout());
@@ -253,7 +253,7 @@ void DlgAddPropertyVarSet::addEditor(PropertyEditor::PropertyItem* propertyItem,
}));
propertyItem->setEditorData(editor.get(), QVariant());
editor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- editor->setObjectName(QString::fromUtf8("editor"));
+ editor->setObjectName(QStringLiteral("editor"));
auto formLayout = qobject_cast(layout());
formLayout->setWidget(3, QFormLayout::FieldRole, editor.get());
@@ -433,7 +433,7 @@ void DlgAddPropertyVarSet::checkGroup() {
critical(QObject::tr("Invalid name"),
QObject::tr("The group name must only contain alpha numericals,\n"
"underscore, and must not start with a digit."));
- comboBoxGroup.setEditText(QString::fromUtf8("Base"));
+ comboBoxGroup.setEditText(QStringLiteral("Base"));
throw CreatePropertyException("Invalid name");
}
}
diff --git a/src/Gui/DlgAddPropertyVarSet.h b/src/Gui/Dialogs/DlgAddPropertyVarSet.h
similarity index 100%
rename from src/Gui/DlgAddPropertyVarSet.h
rename to src/Gui/Dialogs/DlgAddPropertyVarSet.h
diff --git a/src/Gui/DlgAddPropertyVarSet.ui b/src/Gui/Dialogs/DlgAddPropertyVarSet.ui
similarity index 100%
rename from src/Gui/DlgAddPropertyVarSet.ui
rename to src/Gui/Dialogs/DlgAddPropertyVarSet.ui
diff --git a/src/Gui/DlgAuthorization.ui b/src/Gui/Dialogs/DlgAuthorization.ui
similarity index 100%
rename from src/Gui/DlgAuthorization.ui
rename to src/Gui/Dialogs/DlgAuthorization.ui
diff --git a/src/Gui/DlgCheckableMessageBox.cpp b/src/Gui/Dialogs/DlgCheckableMessageBox.cpp
similarity index 98%
rename from src/Gui/DlgCheckableMessageBox.cpp
rename to src/Gui/Dialogs/DlgCheckableMessageBox.cpp
index 815281ec2b..c326c739aa 100644
--- a/src/Gui/DlgCheckableMessageBox.cpp
+++ b/src/Gui/Dialogs/DlgCheckableMessageBox.cpp
@@ -35,7 +35,7 @@
#include
-#include "DlgCheckableMessageBox.h"
+#include "Dialogs/DlgCheckableMessageBox.h"
#include "ui_DlgCheckableMessageBox.h"
#include "MainWindow.h"
@@ -44,7 +44,7 @@ namespace Gui {
namespace Dialog {
QByteArray toParamEntry(QString name)
{
- name.replace(QString::fromLatin1(" "), QString::fromLatin1("_"));
+ name.replace(QStringLiteral(" "), QStringLiteral("_"));
return name.toLatin1();
}
diff --git a/src/Gui/DlgCheckableMessageBox.h b/src/Gui/Dialogs/DlgCheckableMessageBox.h
similarity index 98%
rename from src/Gui/DlgCheckableMessageBox.h
rename to src/Gui/Dialogs/DlgCheckableMessageBox.h
index da268fb99a..443bf54ba7 100644
--- a/src/Gui/DlgCheckableMessageBox.h
+++ b/src/Gui/Dialogs/DlgCheckableMessageBox.h
@@ -104,11 +104,11 @@ public:
/// It shows a dialog with header and message provided and a checkbox in check state with the message provided.
/// It uses a parameter in path "User parameter:BaseApp/CheckMessages" derived from the header test, defaulting to false,
/// to store the status of the checkbox, when the user exits the modal dialog.
- static void showMessage(const QString& header, const QString& message, bool check = false, const QString& checkText = QString::fromLatin1("Don't show me again"));
+ static void showMessage(const QString& header, const QString& message, bool check = false, const QString& checkText = QStringLiteral("Don't show me again"));
/// Same as showMessage above, but it checks the specific preference path and parameter provided, defaulting to entryDefault value if the parameter is not present.
static void showMessage(const QString& header, const QString& message, const QString& prefPath, const QString& paramEntry, bool entryDefault = false,
- bool check = false, const QString& checkText = QString::fromLatin1("Don't show me again"));
+ bool check = false, const QString& checkText = QStringLiteral("Don't show me again"));
private Q_SLOTS:
void slotClicked(QAbstractButton *b);
diff --git a/src/Gui/DlgCheckableMessageBox.ui b/src/Gui/Dialogs/DlgCheckableMessageBox.ui
similarity index 100%
rename from src/Gui/DlgCheckableMessageBox.ui
rename to src/Gui/Dialogs/DlgCheckableMessageBox.ui
diff --git a/src/Gui/DlgChooseIcon.ui b/src/Gui/Dialogs/DlgChooseIcon.ui
similarity index 100%
rename from src/Gui/DlgChooseIcon.ui
rename to src/Gui/Dialogs/DlgChooseIcon.ui
diff --git a/src/Gui/DlgCreateNewPreferencePack.ui b/src/Gui/Dialogs/DlgCreateNewPreferencePack.ui
similarity index 100%
rename from src/Gui/DlgCreateNewPreferencePack.ui
rename to src/Gui/Dialogs/DlgCreateNewPreferencePack.ui
diff --git a/src/Gui/DlgCreateNewPreferencePackImp.cpp b/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp
similarity index 98%
rename from src/Gui/DlgCreateNewPreferencePackImp.cpp
rename to src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp
index 5f0656ea38..a811b78e49 100644
--- a/src/Gui/DlgCreateNewPreferencePackImp.cpp
+++ b/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp
@@ -29,7 +29,7 @@
# include
#endif
-#include "DlgCreateNewPreferencePackImp.h"
+#include "Dialogs/DlgCreateNewPreferencePackImp.h"
#include "ui_DlgCreateNewPreferencePack.h"
#include "FileDialog.h"
@@ -49,7 +49,7 @@ DlgCreateNewPreferencePackImp::DlgCreateNewPreferencePackImp(QWidget* parent)
{
ui->setupUi(this);
- QRegularExpression validNames(QString::fromUtf8(R"([^/\\?%*:|"<>]+)"));
+ QRegularExpression validNames(QStringLiteral(R"([^/\\?%*:|"<>]+)"));
_nameValidator.setRegularExpression(validNames);
ui->lineEdit->setValidator(&_nameValidator);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
diff --git a/src/Gui/DlgCreateNewPreferencePackImp.h b/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.h
similarity index 100%
rename from src/Gui/DlgCreateNewPreferencePackImp.h
rename to src/Gui/Dialogs/DlgCreateNewPreferencePackImp.h
diff --git a/src/Gui/DlgCustomizeImp.cpp b/src/Gui/Dialogs/DlgCustomizeImp.cpp
similarity index 94%
rename from src/Gui/DlgCustomizeImp.cpp
rename to src/Gui/Dialogs/DlgCustomizeImp.cpp
index c1109d25c5..e35382ecb6 100644
--- a/src/Gui/DlgCustomizeImp.cpp
+++ b/src/Gui/Dialogs/DlgCustomizeImp.cpp
@@ -29,7 +29,7 @@
# include
#endif
-#include "DlgCustomizeImp.h"
+#include "Dialogs/DlgCustomizeImp.h"
#include "MainWindow.h"
#include "WidgetFactory.h"
@@ -79,7 +79,7 @@ DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WindowFlags fl)
customLayout->addLayout( layout, 1, 0 );
tabWidget = new QTabWidget( this );
- tabWidget->setObjectName(QString::fromLatin1("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp
+ tabWidget->setObjectName(QStringLiteral("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp
// make sure that pages are ready to create
GetWidgetFactorySupplier();
diff --git a/src/Gui/DlgCustomizeImp.h b/src/Gui/Dialogs/DlgCustomizeImp.h
similarity index 100%
rename from src/Gui/DlgCustomizeImp.h
rename to src/Gui/Dialogs/DlgCustomizeImp.h
diff --git a/src/Gui/DlgCustomizeSpNavSettings.cpp b/src/Gui/Dialogs/DlgCustomizeSpNavSettings.cpp
similarity index 99%
rename from src/Gui/DlgCustomizeSpNavSettings.cpp
rename to src/Gui/Dialogs/DlgCustomizeSpNavSettings.cpp
index 3840d0b20e..8ee96ead45 100644
--- a/src/Gui/DlgCustomizeSpNavSettings.cpp
+++ b/src/Gui/Dialogs/DlgCustomizeSpNavSettings.cpp
@@ -22,7 +22,7 @@
#include "PreCompiled.h"
-#include "DlgCustomizeSpNavSettings.h"
+#include "Dialogs/DlgCustomizeSpNavSettings.h"
#include "ui_DlgCustomizeSpNavSettings.h"
#include "Application.h"
#include "GuiApplicationNativeEventAware.h"
diff --git a/src/Gui/DlgCustomizeSpNavSettings.h b/src/Gui/Dialogs/DlgCustomizeSpNavSettings.h
similarity index 100%
rename from src/Gui/DlgCustomizeSpNavSettings.h
rename to src/Gui/Dialogs/DlgCustomizeSpNavSettings.h
diff --git a/src/Gui/DlgCustomizeSpNavSettings.ui b/src/Gui/Dialogs/DlgCustomizeSpNavSettings.ui
similarity index 96%
rename from src/Gui/DlgCustomizeSpNavSettings.ui
rename to src/Gui/Dialogs/DlgCustomizeSpNavSettings.ui
index 6784470029..06665c5de3 100644
--- a/src/Gui/DlgCustomizeSpNavSettings.ui
+++ b/src/Gui/Dialogs/DlgCustomizeSpNavSettings.ui
@@ -140,7 +140,7 @@
- :/icons/SpNav-PanLR
+ :/icons/SpNav-PanLR
@@ -150,7 +150,7 @@
- :/icons/SpNav-PanUD
+ :/icons/SpNav-PanUD
@@ -160,7 +160,7 @@
- :/icons/SpNav-Zoom
+ :/icons/SpNav-Zoom
@@ -170,7 +170,7 @@
- :/icons/SpNav-Tilt
+ :/icons/SpNav-Tilt
@@ -180,7 +180,7 @@
- :/icons/SpNav-Roll
+ :/icons/SpNav-Roll
@@ -190,7 +190,7 @@
- :/icons/SpNav-Spin
+ :/icons/SpNav-Spin
@@ -528,7 +528,7 @@
-
+
diff --git a/src/Gui/DlgCustomizeSpaceball.cpp b/src/Gui/Dialogs/DlgCustomizeSpaceball.cpp
similarity index 99%
rename from src/Gui/DlgCustomizeSpaceball.cpp
rename to src/Gui/Dialogs/DlgCustomizeSpaceball.cpp
index aa4a00cca6..5336840d02 100644
--- a/src/Gui/DlgCustomizeSpaceball.cpp
+++ b/src/Gui/Dialogs/DlgCustomizeSpaceball.cpp
@@ -39,7 +39,7 @@
#include "Base/Console.h"
#include "Command.h"
-#include "DlgCustomizeSpaceball.h"
+#include "Dialogs/DlgCustomizeSpaceball.h"
#include "Application.h"
#include "BitmapFactory.h"
#include "GuiApplicationNativeEventAware.h"
@@ -282,7 +282,7 @@ QString ButtonModel::getLabel(const int &number) const
GetGroup(numberString.toLatin1())->
GetASCII("Description",""));
if (desc.length())
- desc = QString::fromUtf8(" \"") + desc + QString::fromUtf8("\"");
+ desc = QStringLiteral(" \"") + desc + QStringLiteral("\"");
return tr("Button %1").arg(number + 1) + desc;
} else
return tr("Out Of Range");
@@ -492,7 +492,7 @@ CommandNode* CommandModel::nodeFromIndex(const QModelIndex &index) const
void CommandModel::goAddMacro(const QByteArray ¯oName)
{
- QModelIndexList indexList(this->match(this->index(0,0), Qt::UserRole, QVariant(QString::fromLatin1("Macros")),
+ QModelIndexList indexList(this->match(this->index(0,0), Qt::UserRole, QVariant(QStringLiteral("Macros")),
1, Qt::MatchWrap | Qt::MatchRecursive));
QModelIndex macrosIndex;
if (indexList.empty())
@@ -500,7 +500,7 @@ void CommandModel::goAddMacro(const QByteArray ¯oName)
//this is the first macro and we have to add the Macros item.
//figure out where to insert it. Should be in the command groups now.
QStringList groups = orderedGroups();
- int location(groups.indexOf(QString::fromLatin1("Macros")));
+ int location(groups.indexOf(QStringLiteral("Macros")));
if (location == -1)
location = groups.size();
//add row
diff --git a/src/Gui/DlgCustomizeSpaceball.h b/src/Gui/Dialogs/DlgCustomizeSpaceball.h
similarity index 100%
rename from src/Gui/DlgCustomizeSpaceball.h
rename to src/Gui/Dialogs/DlgCustomizeSpaceball.h
diff --git a/src/Gui/DlgEditFileIncludePropertyExternal.cpp b/src/Gui/Dialogs/DlgEditFileIncludePropertyExternal.cpp
similarity index 95%
rename from src/Gui/DlgEditFileIncludePropertyExternal.cpp
rename to src/Gui/Dialogs/DlgEditFileIncludePropertyExternal.cpp
index f273a21611..803372e5b2 100644
--- a/src/Gui/DlgEditFileIncludePropertyExternal.cpp
+++ b/src/Gui/Dialogs/DlgEditFileIncludePropertyExternal.cpp
@@ -22,7 +22,7 @@
#include "PreCompiled.h"
-#include "DlgEditFileIncludePropertyExternal.h"
+#include "Dialogs/DlgEditFileIncludePropertyExternal.h"
#include "Application.h"
#include "FileDialog.h"
diff --git a/src/Gui/DlgEditFileIncludePropertyExternal.h b/src/Gui/Dialogs/DlgEditFileIncludePropertyExternal.h
similarity index 96%
rename from src/Gui/DlgEditFileIncludePropertyExternal.h
rename to src/Gui/Dialogs/DlgEditFileIncludePropertyExternal.h
index 9826c4c047..d31101ce5b 100644
--- a/src/Gui/DlgEditFileIncludePropertyExternal.h
+++ b/src/Gui/Dialogs/DlgEditFileIncludePropertyExternal.h
@@ -24,7 +24,7 @@
#ifndef GUI_DIALOG_DlgEditFileIncludePropertyExternal_H
#define GUI_DIALOG_DlgEditFileIncludePropertyExternal_H
-#include "DlgRunExternal.h"
+#include "Dialogs/DlgRunExternal.h"
#include
namespace Gui {
diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/Dialogs/DlgExpressionInput.cpp
similarity index 99%
rename from src/Gui/DlgExpressionInput.cpp
rename to src/Gui/Dialogs/DlgExpressionInput.cpp
index 61798c8fa4..98e279af6a 100644
--- a/src/Gui/DlgExpressionInput.cpp
+++ b/src/Gui/Dialogs/DlgExpressionInput.cpp
@@ -37,7 +37,7 @@
#include
#include
-#include "DlgExpressionInput.h"
+#include "Dialogs/DlgExpressionInput.h"
#include "ui_DlgExpressionInput.h"
#include "Application.h"
#include "Command.h"
diff --git a/src/Gui/DlgExpressionInput.h b/src/Gui/Dialogs/DlgExpressionInput.h
similarity index 100%
rename from src/Gui/DlgExpressionInput.h
rename to src/Gui/Dialogs/DlgExpressionInput.h
diff --git a/src/Gui/DlgExpressionInput.ui b/src/Gui/Dialogs/DlgExpressionInput.ui
similarity index 100%
rename from src/Gui/DlgExpressionInput.ui
rename to src/Gui/Dialogs/DlgExpressionInput.ui
diff --git a/src/Gui/DlgInputDialog.ui b/src/Gui/Dialogs/DlgInputDialog.ui
similarity index 100%
rename from src/Gui/DlgInputDialog.ui
rename to src/Gui/Dialogs/DlgInputDialog.ui
diff --git a/src/Gui/DlgInputDialogImp.cpp b/src/Gui/Dialogs/DlgInputDialogImp.cpp
similarity index 95%
rename from src/Gui/DlgInputDialogImp.cpp
rename to src/Gui/Dialogs/DlgInputDialogImp.cpp
index 5f70de8a6c..b386dd0151 100644
--- a/src/Gui/DlgInputDialogImp.cpp
+++ b/src/Gui/Dialogs/DlgInputDialogImp.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "DlgInputDialogImp.h"
+#include "Dialogs/DlgInputDialogImp.h"
#include "ui_DlgInputDialog.h"
#include "SpinBox.h"
diff --git a/src/Gui/DlgInputDialogImp.h b/src/Gui/Dialogs/DlgInputDialogImp.h
similarity index 100%
rename from src/Gui/DlgInputDialogImp.h
rename to src/Gui/Dialogs/DlgInputDialogImp.h
diff --git a/src/Gui/DlgKeyboard.ui b/src/Gui/Dialogs/DlgKeyboard.ui
similarity index 100%
rename from src/Gui/DlgKeyboard.ui
rename to src/Gui/Dialogs/DlgKeyboard.ui
diff --git a/src/Gui/DlgKeyboardImp.cpp b/src/Gui/Dialogs/DlgKeyboardImp.cpp
similarity index 97%
rename from src/Gui/DlgKeyboardImp.cpp
rename to src/Gui/Dialogs/DlgKeyboardImp.cpp
index fe703f5a44..6a90b7950c 100644
--- a/src/Gui/DlgKeyboardImp.cpp
+++ b/src/Gui/Dialogs/DlgKeyboardImp.cpp
@@ -34,7 +34,7 @@
#include
#include
-#include "DlgKeyboardImp.h"
+#include "Dialogs/DlgKeyboardImp.h"
#include "ui_DlgKeyboard.h"
#include "Action.h"
#include "Application.h"
diff --git a/src/Gui/DlgKeyboardImp.h b/src/Gui/Dialogs/DlgKeyboardImp.h
similarity index 97%
rename from src/Gui/DlgKeyboardImp.h
rename to src/Gui/Dialogs/DlgKeyboardImp.h
index a52a67282a..1cdc954439 100644
--- a/src/Gui/DlgKeyboardImp.h
+++ b/src/Gui/Dialogs/DlgKeyboardImp.h
@@ -24,7 +24,7 @@
#ifndef GUI_DIALOG_DLGKEYBOARD_IMP_H
#define GUI_DIALOG_DLGKEYBOARD_IMP_H
-#include
+#include
#include
#include
#include
diff --git a/src/Gui/DlgLocationAngle.ui b/src/Gui/Dialogs/DlgLocationAngle.ui
similarity index 100%
rename from src/Gui/DlgLocationAngle.ui
rename to src/Gui/Dialogs/DlgLocationAngle.ui
diff --git a/src/Gui/DlgLocationPos.ui b/src/Gui/Dialogs/DlgLocationPos.ui
similarity index 100%
rename from src/Gui/DlgLocationPos.ui
rename to src/Gui/Dialogs/DlgLocationPos.ui
diff --git a/src/Gui/DlgMacroExecute.ui b/src/Gui/Dialogs/DlgMacroExecute.ui
similarity index 100%
rename from src/Gui/DlgMacroExecute.ui
rename to src/Gui/Dialogs/DlgMacroExecute.ui
diff --git a/src/Gui/DlgMacroExecuteImp.cpp b/src/Gui/Dialogs/DlgMacroExecuteImp.cpp
similarity index 93%
rename from src/Gui/DlgMacroExecuteImp.cpp
rename to src/Gui/Dialogs/DlgMacroExecuteImp.cpp
index 24ac9e982d..4822c6df75 100644
--- a/src/Gui/DlgMacroExecuteImp.cpp
+++ b/src/Gui/Dialogs/DlgMacroExecuteImp.cpp
@@ -34,13 +34,13 @@
#include
#include
-#include "DlgMacroExecuteImp.h"
+#include "Dialogs/DlgMacroExecuteImp.h"
#include "ui_DlgMacroExecute.h"
#include "Application.h"
#include "BitmapFactory.h"
#include "Command.h"
-#include "DlgCustomizeImp.h"
-#include "DlgToolbarsImp.h"
+#include "Dialogs/DlgCustomizeImp.h"
+#include "Dialogs/DlgToolbarsImp.h"
#include "Document.h"
#include "EditorView.h"
#include "Macro.h"
@@ -265,7 +265,7 @@ void DlgMacroExecuteImp::fillUpList()
fillUpListForDir(this->macroPath, false);
QString dirstr =
- QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
+ QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro");
fillUpListForDir(dirstr, true);
auto& config = App::Application::Config();
@@ -432,7 +432,7 @@ void DlgMacroExecuteImp::onEditButtonClicked()
auto mitem = static_cast(item);
QDir dir(mitem->dirPath);
- QString file = QString::fromLatin1("%1/%2").arg(dir.absolutePath(), item->text(0));
+ QString file = QStringLiteral("%1/%2").arg(dir.absolutePath(), item->text(0));
auto editor = new PythonEditor();
editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python"));
auto edit = new PythonEditorView(editor, getMainWindow());
@@ -445,7 +445,7 @@ void DlgMacroExecuteImp::onEditButtonClicked()
if (mitem->systemWide) {
editor->setReadOnly(true);
QString shownName;
- shownName = QString::fromLatin1("%1[*] - [%2]").arg(item->text(0), tr("Read-only"));
+ shownName = QStringLiteral("%1[*] - [%2]").arg(item->text(0), tr("Read-only"));
edit->setWindowTitle(shownName);
}
close();
@@ -505,7 +505,7 @@ void DlgMacroExecuteImp::onCreateButtonClicked()
auto edit = new PythonEditorView(editor, getMainWindow());
edit->open(fi.absoluteFilePath());
getMainWindow()->appendRecentMacro(fi.absoluteFilePath());
- edit->setWindowTitle(QString::fromLatin1("%1[*]").arg(fn));
+ edit->setWindowTitle(QStringLiteral("%1[*]").arg(fn));
edit->resize(400, 300);
getMainWindow()->addWindow(edit);
close();
@@ -569,6 +569,7 @@ void DlgMacroExecuteImp::onToolbarButtonClicked()
QAbstractButton* doNotShowAgainButton =
msgBox.addButton(tr("Do not show again"), QMessageBox::YesRole);
msgBox.setText(tr("Guided Walkthrough"));
+ msgBox.setObjectName(QStringLiteral("macroGuideWalkthrough"));
msgBox.setInformativeText(tr("This will guide you in setting up this macro in a custom \
global toolbar. Instructions will be in red text inside the dialog.\n\
\n\
@@ -626,14 +627,14 @@ Note: your changes will be applied when you next switch workbenches\n"));
/** title is normally "Customize" **/
dlg.setWindowTitle(tr("Walkthrough, dialog 1 of 2"));
- tabWidget = dlg.findChild(QString::fromLatin1("Gui__Dialog__TabWidget"));
+ tabWidget = dlg.findChild(QStringLiteral("Gui__Dialog__TabWidget"));
if (!tabWidget) {
std::cerr << "Toolbar walkthrough error: Unable to find tabwidget" << std::endl;
return;
}
auto setupCustomMacrosPage =
- tabWidget->findChild(QString::fromLatin1("Gui__Dialog__DlgCustomActions"));
+ tabWidget->findChild(QStringLiteral("Gui__Dialog__DlgCustomActions"));
if (!setupCustomMacrosPage) {
std::cerr << "Toolbar walkthrough error: Unable to find setupCustomMacrosPage"
<< std::endl;
@@ -642,7 +643,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
tabWidget->setCurrentWidget(setupCustomMacrosPage);
auto groupBox7 =
- setupCustomMacrosPage->findChild(QString::fromLatin1("GroupBox7"));
+ setupCustomMacrosPage->findChild(QStringLiteral("GroupBox7"));
if (!groupBox7) {
Base::Console().Warning("Toolbar walkthrough: Unable to find groupBox7\n");
// just warn when not a fatal error
@@ -651,20 +652,20 @@ Note: your changes will be applied when you next switch workbenches\n"));
/** normally the groupbox title is "Setup Custom Macros", but we change it here **/
groupBox7->setTitle(tr("Walkthrough instructions: Fill in missing fields (optional) "
"then click Add, then Close"));
- groupBox7->setStyleSheet(QString::fromLatin1("QGroupBox::title {color:red}"));
+ groupBox7->setStyleSheet(QStringLiteral("QGroupBox::title {color:red}"));
}
auto buttonAddAction =
- setupCustomMacrosPage->findChild(QString::fromLatin1("buttonAddAction"));
+ setupCustomMacrosPage->findChild(QStringLiteral("buttonAddAction"));
if (!buttonAddAction) {
Base::Console().Warning("Toolbar walkthrough: Unable to find buttonAddAction\n");
}
else {
- buttonAddAction->setStyleSheet(QString::fromLatin1("color:red"));
+ buttonAddAction->setStyleSheet(QStringLiteral("color:red"));
}
auto macroListBox =
- setupCustomMacrosPage->findChild(QString::fromLatin1("actionMacros"));
+ setupCustomMacrosPage->findChild(QStringLiteral("actionMacros"));
if (!macroListBox) {
Base::Console().Warning("Toolbar walkthrough: Unable to find actionMacros combo box\n");
}
@@ -675,7 +676,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
}
auto menuText =
- setupCustomMacrosPage->findChild(QString::fromLatin1("actionMenu"));
+ setupCustomMacrosPage->findChild(QStringLiteral("actionMenu"));
if (!menuText) {
Base::Console().Warning("Toolbar walkthrough: Unable to find actionMenu menuText\n");
}
@@ -693,7 +694,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
: tr("Walkthrough, dialog 2 of 2"));
tabWidget = nullptr;
- tabWidget = dlg.findChild(QString::fromLatin1("Gui__Dialog__TabWidget"));
+ tabWidget = dlg.findChild(QStringLiteral("Gui__Dialog__TabWidget"));
if (!tabWidget) {
std::cerr << "Toolbar walkthrough: Unable to find tabWidget Gui__Dialog__TabWidget"
<< std::endl;
@@ -701,7 +702,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
}
auto setupToolbarPage = tabWidget->findChild(
- QString::fromLatin1("Gui__Dialog__DlgCustomToolbars"));
+ QStringLiteral("Gui__Dialog__DlgCustomToolbars"));
if (!setupToolbarPage) {
std::cerr
<< "Toolbar walkthrough: Unable to find setupToolbarPage Gui__Dialog__DlgCustomToolbars"
@@ -711,12 +712,12 @@ Note: your changes will be applied when you next switch workbenches\n"));
tabWidget->setCurrentWidget(setupToolbarPage);
auto moveActionRightButton =
- setupToolbarPage->findChild(QString::fromLatin1("moveActionRightButton"));
+ setupToolbarPage->findChild(QStringLiteral("moveActionRightButton"));
if (!moveActionRightButton) {
Base::Console().Warning("Toolbar walkthrough: Unable to find moveActionRightButton\n");
}
else {
- moveActionRightButton->setStyleSheet(QString::fromLatin1("background-color: red"));
+ moveActionRightButton->setStyleSheet(QStringLiteral("background-color: red"));
}
/** tailor instructions depending on whether user already has custom toolbar created
* if not, they need to click New button to create one first
@@ -725,14 +726,14 @@ Note: your changes will be applied when you next switch workbenches\n"));
QString instructions2 =
tr("Walkthrough instructions: Select macro from list, then click right arrow button (->), then Close.");
auto workbenchBox =
- setupToolbarPage->findChild(QString::fromLatin1("workbenchBox"));
+ setupToolbarPage->findChild(QStringLiteral("workbenchBox"));
if (!workbenchBox) {
Base::Console().Warning("Toolbar walkthrough: Unable to find workbenchBox\n");
}
else {
/** find the Global workbench and select it for the user **/
- int globalIdx = workbenchBox->findData(QString::fromLatin1("Global"));
+ int globalIdx = workbenchBox->findData(QStringLiteral("Global"));
if (globalIdx != -1) {
workbenchBox->setCurrentIndex(globalIdx);
setupToolbarPage->activateWorkbenchBox(globalIdx);
@@ -743,12 +744,12 @@ Note: your changes will be applied when you next switch workbenches\n"));
if (!hasCustomToolbar) {
auto newButton =
- setupToolbarPage->findChild(QString::fromLatin1("newButton"));
+ setupToolbarPage->findChild(QStringLiteral("newButton"));
if (!newButton) {
Base::Console().Warning("Toolbar walkthrough: Unable to find newButton\n");
}
else {
- newButton->setStyleSheet(QString::fromLatin1("color:red"));
+ newButton->setStyleSheet(QStringLiteral("color:red"));
instructions2 = tr("Walkthrough instructions: Click New, select macro, then right arrow (->) "
"button, then Close.");
}
@@ -757,17 +758,17 @@ Note: your changes will be applied when you next switch workbenches\n"));
/** "label" normally says "Note: the changes become active the next time you load the
* appropriate workbench" **/
- auto label = setupToolbarPage->findChild(QString::fromLatin1("label"));
+ auto label = setupToolbarPage->findChild(QStringLiteral("label"));
if (!label) {
Base::Console().Warning("Toolbar walkthrough: Unable to find label\n");
}
else {
label->setText(instructions2);
- label->setStyleSheet(QString::fromLatin1("color:red"));
+ label->setStyleSheet(QStringLiteral("color:red"));
}
/** find Macros category and select it for the user **/
- auto categoryBox = setupToolbarPage->findChild(QString::fromLatin1("categoryBox"));
+ auto categoryBox = setupToolbarPage->findChild(QStringLiteral("categoryBox"));
if (!categoryBox) {
Base::Console().Warning("Toolbar walkthrough: Unable to find categoryBox\n");
}
@@ -783,7 +784,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
/** expand custom toolbar items **/
auto toolbarTreeWidget =
- setupToolbarPage->findChild(QString::fromLatin1("toolbarTreeWidget"));
+ setupToolbarPage->findChild(QStringLiteral("toolbarTreeWidget"));
if (!toolbarTreeWidget) {
Base::Console().Warning("Toolbar walkthrough: Unable to find toolbarTreeWidget\n");
}
@@ -796,7 +797,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
**/
QTimer::singleShot(500, [=]() {
auto commandTreeWidget =
- setupToolbarPage->findChild(QString::fromLatin1("commandTreeWidget"));
+ setupToolbarPage->findChild(QStringLiteral("commandTreeWidget"));
if (!commandTreeWidget) {
Base::Console().Warning("Toolbar walkthrough: Unable to find commandTreeWidget\n");
}
diff --git a/src/Gui/DlgMacroExecuteImp.h b/src/Gui/Dialogs/DlgMacroExecuteImp.h
similarity index 100%
rename from src/Gui/DlgMacroExecuteImp.h
rename to src/Gui/Dialogs/DlgMacroExecuteImp.h
diff --git a/src/Gui/DlgMacroRecord.ui b/src/Gui/Dialogs/DlgMacroRecord.ui
similarity index 100%
rename from src/Gui/DlgMacroRecord.ui
rename to src/Gui/Dialogs/DlgMacroRecord.ui
diff --git a/src/Gui/DlgMacroRecordImp.cpp b/src/Gui/Dialogs/DlgMacroRecordImp.cpp
similarity index 96%
rename from src/Gui/DlgMacroRecordImp.cpp
rename to src/Gui/Dialogs/DlgMacroRecordImp.cpp
index 9e0f6b3d1b..01ae153a2b 100644
--- a/src/Gui/DlgMacroRecordImp.cpp
+++ b/src/Gui/Dialogs/DlgMacroRecordImp.cpp
@@ -28,7 +28,7 @@
#include
#endif
-#include "DlgMacroRecordImp.h"
+#include "Dialogs/DlgMacroRecordImp.h"
#include "ui_DlgMacroRecord.h"
#include "Application.h"
#include "FileDialog.h"
diff --git a/src/Gui/DlgMacroRecordImp.h b/src/Gui/Dialogs/DlgMacroRecordImp.h
similarity index 100%
rename from src/Gui/DlgMacroRecordImp.h
rename to src/Gui/Dialogs/DlgMacroRecordImp.h
diff --git a/src/Gui/DlgMaterialProperties.ui b/src/Gui/Dialogs/DlgMaterialProperties.ui
similarity index 100%
rename from src/Gui/DlgMaterialProperties.ui
rename to src/Gui/Dialogs/DlgMaterialProperties.ui
diff --git a/src/Gui/DlgMaterialPropertiesImp.cpp b/src/Gui/Dialogs/DlgMaterialPropertiesImp.cpp
similarity index 96%
rename from src/Gui/DlgMaterialPropertiesImp.cpp
rename to src/Gui/Dialogs/DlgMaterialPropertiesImp.cpp
index 77defe6836..a121928968 100644
--- a/src/Gui/DlgMaterialPropertiesImp.cpp
+++ b/src/Gui/Dialogs/DlgMaterialPropertiesImp.cpp
@@ -24,7 +24,7 @@
#include
-#include "DlgMaterialPropertiesImp.h"
+#include "Dialogs/DlgMaterialPropertiesImp.h"
#include "ui_DlgMaterialProperties.h"
#include "ViewProvider.h"
diff --git a/src/Gui/DlgMaterialPropertiesImp.h b/src/Gui/Dialogs/DlgMaterialPropertiesImp.h
similarity index 100%
rename from src/Gui/DlgMaterialPropertiesImp.h
rename to src/Gui/Dialogs/DlgMaterialPropertiesImp.h
diff --git a/src/Gui/DlgObjectSelection.cpp b/src/Gui/Dialogs/DlgObjectSelection.cpp
similarity index 99%
rename from src/Gui/DlgObjectSelection.cpp
rename to src/Gui/Dialogs/DlgObjectSelection.cpp
index 1392ab3b47..89869fc7f8 100644
--- a/src/Gui/DlgObjectSelection.cpp
+++ b/src/Gui/Dialogs/DlgObjectSelection.cpp
@@ -30,7 +30,7 @@
#include
#include
-#include "DlgObjectSelection.h"
+#include "Dialogs/DlgObjectSelection.h"
#include "ui_DlgObjectSelection.h"
#include "Application.h"
#include "MainWindow.h"
diff --git a/src/Gui/DlgObjectSelection.h b/src/Gui/Dialogs/DlgObjectSelection.h
similarity index 100%
rename from src/Gui/DlgObjectSelection.h
rename to src/Gui/Dialogs/DlgObjectSelection.h
diff --git a/src/Gui/DlgObjectSelection.ui b/src/Gui/Dialogs/DlgObjectSelection.ui
similarity index 100%
rename from src/Gui/DlgObjectSelection.ui
rename to src/Gui/Dialogs/DlgObjectSelection.ui
diff --git a/src/Gui/DlgOnlineHelp.ui b/src/Gui/Dialogs/DlgOnlineHelp.ui
similarity index 100%
rename from src/Gui/DlgOnlineHelp.ui
rename to src/Gui/Dialogs/DlgOnlineHelp.ui
diff --git a/src/Gui/DlgOnlineHelpImp.cpp b/src/Gui/Dialogs/DlgOnlineHelpImp.cpp
similarity index 92%
rename from src/Gui/DlgOnlineHelpImp.cpp
rename to src/Gui/Dialogs/DlgOnlineHelpImp.cpp
index a16cf2ec1e..94f0808b98 100644
--- a/src/Gui/DlgOnlineHelpImp.cpp
+++ b/src/Gui/Dialogs/DlgOnlineHelpImp.cpp
@@ -28,7 +28,7 @@
#include
-#include "DlgOnlineHelpImp.h"
+#include "Dialogs/DlgOnlineHelpImp.h"
#include "ui_DlgOnlineHelp.h"
@@ -49,7 +49,7 @@ DlgOnlineHelpImp::DlgOnlineHelpImp( QWidget* parent )
{
ui->setupUi(this);
- ui->prefStartPage->setFilter(QString::fromLatin1("%1 (*.html *.htm)").arg(tr("HTML files")));
+ ui->prefStartPage->setFilter(QStringLiteral("%1 (*.html *.htm)").arg(tr("HTML files")));
if (ui->prefStartPage->fileName().isEmpty()) {
ui->prefStartPage->setFileName(getStartpage());
}
@@ -69,7 +69,7 @@ DlgOnlineHelpImp::~DlgOnlineHelpImp() = default;
QString DlgOnlineHelpImp::getStartpage()
{
QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str()));
- return docdir.absoluteFilePath(QString::fromUtf8("Start_Page.html"));
+ return docdir.absoluteFilePath(QStringLiteral("Start_Page.html"));
}
void DlgOnlineHelpImp::saveSettings()
diff --git a/src/Gui/DlgOnlineHelpImp.h b/src/Gui/Dialogs/DlgOnlineHelpImp.h
similarity index 100%
rename from src/Gui/DlgOnlineHelpImp.h
rename to src/Gui/Dialogs/DlgOnlineHelpImp.h
diff --git a/src/Gui/DlgParameter.ui b/src/Gui/Dialogs/DlgParameter.ui
similarity index 100%
rename from src/Gui/DlgParameter.ui
rename to src/Gui/Dialogs/DlgParameter.ui
diff --git a/src/Gui/DlgParameterFind.cpp b/src/Gui/Dialogs/DlgParameterFind.cpp
similarity index 99%
rename from src/Gui/DlgParameterFind.cpp
rename to src/Gui/Dialogs/DlgParameterFind.cpp
index 9ec5c46dbf..1fb2dcdc8c 100644
--- a/src/Gui/DlgParameterFind.cpp
+++ b/src/Gui/Dialogs/DlgParameterFind.cpp
@@ -26,9 +26,9 @@
#include
#endif
-#include "DlgParameterFind.h"
+#include "Dialogs/DlgParameterFind.h"
#include "ui_DlgParameterFind.h"
-#include "DlgParameterImp.h"
+#include "Dialogs/DlgParameterImp.h"
using namespace Gui::Dialog;
diff --git a/src/Gui/DlgParameterFind.h b/src/Gui/Dialogs/DlgParameterFind.h
similarity index 100%
rename from src/Gui/DlgParameterFind.h
rename to src/Gui/Dialogs/DlgParameterFind.h
diff --git a/src/Gui/DlgParameterFind.ui b/src/Gui/Dialogs/DlgParameterFind.ui
similarity index 100%
rename from src/Gui/DlgParameterFind.ui
rename to src/Gui/Dialogs/DlgParameterFind.ui
diff --git a/src/Gui/DlgParameterImp.cpp b/src/Gui/Dialogs/DlgParameterImp.cpp
similarity index 95%
rename from src/Gui/DlgParameterImp.cpp
rename to src/Gui/Dialogs/DlgParameterImp.cpp
index 51cc3e861f..c33cfd1aa2 100644
--- a/src/Gui/DlgParameterImp.cpp
+++ b/src/Gui/Dialogs/DlgParameterImp.cpp
@@ -36,11 +36,11 @@
#include
#include
-#include "DlgParameterImp.h"
+#include "Dialogs/DlgParameterImp.h"
#include "ui_DlgParameter.h"
#include "BitmapFactory.h"
-#include "DlgParameterFind.h"
-#include "DlgInputDialogImp.h"
+#include "Dialogs/DlgParameterFind.h"
+#include "Dialogs/DlgInputDialogImp.h"
#include "FileDialog.h"
#include "SpinBox.h"
@@ -224,7 +224,7 @@ void DlgParameterImp::onFindGroupTtextChanged(const QString& SearchStr)
}
else {
// Set red background to indicate no matching
- QString styleSheet = QString::fromLatin1(" QLineEdit {\n"
+ QString styleSheet = QStringLiteral(" QLineEdit {\n"
" background-color: rgb(221,144,161);\n"
" }\n");
ui->findGroupLE->setStyleSheet(styleSheet);
@@ -610,7 +610,7 @@ void ParameterGroup::onExportToFile()
QString file = FileDialog::getSaveFileName(this,
tr("Export parameter to file"),
QString(),
- QString::fromLatin1("XML (*.FCParam)"));
+ QStringLiteral("XML (*.FCParam)"));
if (!file.isEmpty()) {
QTreeWidgetItem* item = currentItem();
if (item && item->isSelected()) {
@@ -626,7 +626,7 @@ void ParameterGroup::onImportFromFile()
QString file = FileDialog::getOpenFileName(this,
tr("Import parameter from file"),
QString(),
- QString::fromLatin1("XML (*.FCParam)"));
+ QStringLiteral("XML (*.FCParam)"));
if (!file.isEmpty()) {
QTreeWidgetItem* item = currentItem();
if (item && item->isSelected()) {
@@ -989,7 +989,7 @@ void ParameterValue::onCreateBoolItem()
}
QStringList list;
- list << QString::fromLatin1("true") << QString::fromLatin1("false");
+ list << QStringLiteral("true") << QStringLiteral("false");
QString val = QInputDialog::getItem(this,
QObject::tr("New boolean item"),
QObject::tr("Choose an item:"),
@@ -1138,7 +1138,7 @@ ParameterText::ParameterText(QTreeWidget* parent,
{
setIcon(0, BitmapFactory().iconFromTheme("Param_Text"));
setText(0, label);
- setText(1, QString::fromLatin1("Text"));
+ setText(1, QStringLiteral("Text"));
setText(2, QString::fromUtf8(value));
}
@@ -1187,8 +1187,8 @@ ParameterInt::ParameterInt(QTreeWidget* parent,
{
setIcon(0, BitmapFactory().iconFromTheme("Param_Int"));
setText(0, label);
- setText(1, QString::fromLatin1("Integer"));
- setText(2, QString::fromLatin1("%1").arg(value));
+ setText(1, QStringLiteral("Integer"));
+ setText(2, QStringLiteral("%1").arg(value));
}
ParameterInt::~ParameterInt() = default;
@@ -1206,7 +1206,7 @@ void ParameterInt::changeValue()
&ok,
Qt::MSWindowsFixedSizeDialogHint);
if (ok) {
- setText(2, QString::fromLatin1("%1").arg(num));
+ setText(2, QStringLiteral("%1").arg(num));
_hcGrp->SetInt(text(0).toLatin1(), (long)num);
}
}
@@ -1238,8 +1238,8 @@ ParameterUInt::ParameterUInt(QTreeWidget* parent,
{
setIcon(0, BitmapFactory().iconFromTheme("Param_UInt"));
setText(0, label);
- setText(1, QString::fromLatin1("Unsigned"));
- setText(2, QString::fromLatin1("%1").arg(value));
+ setText(1, QStringLiteral("Unsigned"));
+ setText(2, QStringLiteral("%1").arg(value));
}
ParameterUInt::~ParameterUInt() = default;
@@ -1260,7 +1260,7 @@ void ParameterUInt::changeValue()
unsigned long num = value.toULong(&ok);
if (ok) {
- setText(2, QString::fromLatin1("%1").arg(num));
+ setText(2, QStringLiteral("%1").arg(num));
_hcGrp->SetUnsigned(text(0).toLatin1(), (unsigned long)num);
}
}
@@ -1293,8 +1293,8 @@ ParameterFloat::ParameterFloat(QTreeWidget* parent,
{
setIcon(0, BitmapFactory().iconFromTheme("Param_Float"));
setText(0, label);
- setText(1, QString::fromLatin1("Float"));
- setText(2, QString::fromLatin1("%1").arg(value));
+ setText(1, QStringLiteral("Float"));
+ setText(2, QStringLiteral("%1").arg(value));
}
ParameterFloat::~ParameterFloat() = default;
@@ -1312,7 +1312,7 @@ void ParameterFloat::changeValue()
&ok,
Qt::MSWindowsFixedSizeDialogHint);
if (ok) {
- setText(2, QString::fromLatin1("%1").arg(num));
+ setText(2, QStringLiteral("%1").arg(num));
_hcGrp->SetFloat(text(0).toLatin1(), num);
}
}
@@ -1344,7 +1344,7 @@ ParameterBool::ParameterBool(QTreeWidget* parent,
{
setIcon(0, BitmapFactory().iconFromTheme("Param_Bool"));
setText(0, label);
- setText(1, QString::fromLatin1("Boolean"));
+ setText(1, QStringLiteral("Boolean"));
setText(2, QString::fromLatin1((value ? "true" : "false")));
}
@@ -1354,7 +1354,7 @@ void ParameterBool::changeValue()
{
bool ok;
QStringList list;
- list << QString::fromLatin1("true") << QString::fromLatin1("false");
+ list << QStringLiteral("true") << QStringLiteral("false");
int pos = (text(2) == list[0] ? 0 : 1);
QString txt = QInputDialog::getItem(treeWidget(),
diff --git a/src/Gui/DlgParameterImp.h b/src/Gui/Dialogs/DlgParameterImp.h
similarity index 100%
rename from src/Gui/DlgParameterImp.h
rename to src/Gui/Dialogs/DlgParameterImp.h
diff --git a/src/Gui/DlgPreferencePackManagement.ui b/src/Gui/Dialogs/DlgPreferencePackManagement.ui
similarity index 100%
rename from src/Gui/DlgPreferencePackManagement.ui
rename to src/Gui/Dialogs/DlgPreferencePackManagement.ui
diff --git a/src/Gui/DlgPreferencePackManagementImp.cpp b/src/Gui/Dialogs/DlgPreferencePackManagementImp.cpp
similarity index 99%
rename from src/Gui/DlgPreferencePackManagementImp.cpp
rename to src/Gui/Dialogs/DlgPreferencePackManagementImp.cpp
index 437f6105ba..e310ce0708 100644
--- a/src/Gui/DlgPreferencePackManagementImp.cpp
+++ b/src/Gui/Dialogs/DlgPreferencePackManagementImp.cpp
@@ -25,7 +25,7 @@
# include
#endif
-#include "DlgPreferencePackManagementImp.h"
+#include "Dialogs/DlgPreferencePackManagementImp.h"
#include "ui_DlgPreferencePackManagement.h"
#include "Application.h"
#include "Command.h"
@@ -33,7 +33,7 @@
using namespace Gui::Dialog;
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
/* TRANSLATOR Gui::Dialog::DlgPreferencePackManagementImp */
diff --git a/src/Gui/DlgPreferencePackManagementImp.h b/src/Gui/Dialogs/DlgPreferencePackManagementImp.h
similarity index 98%
rename from src/Gui/DlgPreferencePackManagementImp.h
rename to src/Gui/Dialogs/DlgPreferencePackManagementImp.h
index f4a41bdb03..49bd8c7d4d 100644
--- a/src/Gui/DlgPreferencePackManagementImp.h
+++ b/src/Gui/Dialogs/DlgPreferencePackManagementImp.h
@@ -26,7 +26,7 @@
#include
#include
-#include
+#include
#include
diff --git a/src/Gui/DlgPreferences.ui b/src/Gui/Dialogs/DlgPreferences.ui
similarity index 100%
rename from src/Gui/DlgPreferences.ui
rename to src/Gui/Dialogs/DlgPreferences.ui
diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/Dialogs/DlgPreferencesImp.cpp
similarity index 96%
rename from src/Gui/DlgPreferencesImp.cpp
rename to src/Gui/Dialogs/DlgPreferencesImp.cpp
index c4e2c95eb6..23d968e365 100644
--- a/src/Gui/DlgPreferencesImp.cpp
+++ b/src/Gui/Dialogs/DlgPreferencesImp.cpp
@@ -47,7 +47,7 @@
#include
#include
-#include "DlgPreferencesImp.h"
+#include "Dialogs/DlgPreferencesImp.h"
#include "ui_DlgPreferences.h"
#include "BitmapFactory.h"
#include "MainWindow.h"
diff --git a/src/Gui/DlgPreferencesImp.h b/src/Gui/Dialogs/DlgPreferencesImp.h
similarity index 100%
rename from src/Gui/DlgPreferencesImp.h
rename to src/Gui/Dialogs/DlgPreferencesImp.h
diff --git a/src/Gui/DlgProjectInformation.ui b/src/Gui/Dialogs/DlgProjectInformation.ui
similarity index 100%
rename from src/Gui/DlgProjectInformation.ui
rename to src/Gui/Dialogs/DlgProjectInformation.ui
diff --git a/src/Gui/DlgProjectInformationImp.cpp b/src/Gui/Dialogs/DlgProjectInformationImp.cpp
similarity index 97%
rename from src/Gui/DlgProjectInformationImp.cpp
rename to src/Gui/Dialogs/DlgProjectInformationImp.cpp
index 7505fb2ed4..7909f1612e 100644
--- a/src/Gui/DlgProjectInformationImp.cpp
+++ b/src/Gui/Dialogs/DlgProjectInformationImp.cpp
@@ -32,7 +32,7 @@
#include
#include
-#include "DlgProjectInformationImp.h"
+#include "Dialogs/DlgProjectInformationImp.h"
#include "ui_DlgProjectInformation.h"
#include "MainWindow.h"
diff --git a/src/Gui/DlgProjectInformationImp.h b/src/Gui/Dialogs/DlgProjectInformationImp.h
similarity index 100%
rename from src/Gui/DlgProjectInformationImp.h
rename to src/Gui/Dialogs/DlgProjectInformationImp.h
diff --git a/src/Gui/DlgProjectUtility.cpp b/src/Gui/Dialogs/DlgProjectUtility.cpp
similarity index 93%
rename from src/Gui/DlgProjectUtility.cpp
rename to src/Gui/Dialogs/DlgProjectUtility.cpp
index 75de3e8fe1..eb340dbf1d 100644
--- a/src/Gui/DlgProjectUtility.cpp
+++ b/src/Gui/Dialogs/DlgProjectUtility.cpp
@@ -29,7 +29,7 @@
#include
-#include "DlgProjectUtility.h"
+#include "Dialogs/DlgProjectUtility.h"
#include "ui_DlgProjectUtility.h"
#include "Application.h"
#include "Command.h"
@@ -47,7 +47,7 @@ DlgProjectUtility::DlgProjectUtility(QWidget* parent, Qt::WindowFlags fl)
ui->setupUi(this);
connect(ui->extractButton, &QPushButton::clicked, this, &DlgProjectUtility::extractButton);
connect(ui->createButton, &QPushButton::clicked, this, &DlgProjectUtility::createButton);
- ui->extractSource->setFilter(QString::fromLatin1("%1 (*.FCStd)").arg(tr("Project file")));
+ ui->extractSource->setFilter(QStringLiteral("%1 (*.FCStd)").arg(tr("Project file")));
}
/**
@@ -85,7 +85,7 @@ void DlgProjectUtility::createButton()
return;
}
- dest = QDir(dest).absoluteFilePath(QString::fromUtf8("project.fcstd"));
+ dest = QDir(dest).absoluteFilePath(QStringLiteral("project.fcstd"));
bool openFile = ui->checkLoadProject->isChecked();
tryCreateArchive(source, dest, openFile);
diff --git a/src/Gui/DlgProjectUtility.h b/src/Gui/Dialogs/DlgProjectUtility.h
similarity index 100%
rename from src/Gui/DlgProjectUtility.h
rename to src/Gui/Dialogs/DlgProjectUtility.h
diff --git a/src/Gui/DlgProjectUtility.ui b/src/Gui/Dialogs/DlgProjectUtility.ui
similarity index 100%
rename from src/Gui/DlgProjectUtility.ui
rename to src/Gui/Dialogs/DlgProjectUtility.ui
diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/Dialogs/DlgPropertyLink.cpp
similarity index 97%
rename from src/Gui/DlgPropertyLink.cpp
rename to src/Gui/Dialogs/DlgPropertyLink.cpp
index 869d541670..0417c688da 100644
--- a/src/Gui/DlgPropertyLink.cpp
+++ b/src/Gui/Dialogs/DlgPropertyLink.cpp
@@ -36,7 +36,7 @@
#include
#include
-#include "DlgPropertyLink.h"
+#include "Dialogs/DlgPropertyLink.h"
#include "ui_DlgPropertyLink.h"
#include "Application.h"
#include "Document.h"
@@ -173,16 +173,16 @@ DlgPropertyLink::formatObject(App::Document* ownerDoc, App::DocumentObject* obj,
if (obj->Label.getStrValue() == obj->getNameInDocument()) {
return QLatin1String(objName);
}
- return QString::fromLatin1("%1 (%2)").arg(QLatin1String(objName),
+ return QStringLiteral("%1 (%2)").arg(QLatin1String(objName),
QString::fromUtf8(obj->Label.getValue()));
}
auto sobj = obj->getSubObject(sub);
if (!sobj || sobj->Label.getStrValue() == sobj->getNameInDocument()) {
- return QString::fromLatin1("%1.%2").arg(QLatin1String(objName), QString::fromUtf8(sub));
+ return QStringLiteral("%1.%2").arg(QLatin1String(objName), QString::fromUtf8(sub));
}
- return QString::fromLatin1("%1.%2 (%3)")
+ return QStringLiteral("%1.%2 (%3)")
.arg(QLatin1String(objName),
QString::fromUtf8(sub),
QString::fromUtf8(sobj->Label.getValue()));
@@ -226,7 +226,7 @@ QString DlgPropertyLink::formatLinks(App::Document* ownerDoc, QList 3 ? " ..." : ""));
@@ -239,7 +239,7 @@ QString DlgPropertyLink::formatLinks(App::Document* ownerDoc, QList 3 ? " ..." : ""));
}
@@ -289,15 +289,15 @@ void DlgPropertyLink::init(const App::DocumentObjectT& prop, bool tryFilter)
std::vector docs;
singleSelect = false;
- if (propLink->isDerivedFrom(App::PropertyXLinkSub::getClassTypeId())
- || propLink->isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) {
+ if (propLink->isDerivedFrom()
+ || propLink->isDerivedFrom()) {
allowSubObject = true;
singleParent = true;
}
- else if (propLink->isDerivedFrom(App::PropertyLink::getClassTypeId())) {
+ else if (propLink->isDerivedFrom()) {
singleSelect = true;
}
- else if (propLink->isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())) {
+ else if (propLink->isDerivedFrom()) {
allowSubObject = true;
}
@@ -310,8 +310,8 @@ void DlgPropertyLink::init(const App::DocumentObjectT& prop, bool tryFilter)
}
bool isLinkList = false;
- if (propLink->isDerivedFrom(App::PropertyXLinkList::getClassTypeId())
- || propLink->isDerivedFrom(App::PropertyLinkList::getClassTypeId())) {
+ if (propLink->isDerivedFrom()
+ || propLink->isDerivedFrom()) {
isLinkList = true;
allowSubObject = false;
}
diff --git a/src/Gui/DlgPropertyLink.h b/src/Gui/Dialogs/DlgPropertyLink.h
similarity index 100%
rename from src/Gui/DlgPropertyLink.h
rename to src/Gui/Dialogs/DlgPropertyLink.h
diff --git a/src/Gui/DlgPropertyLink.ui b/src/Gui/Dialogs/DlgPropertyLink.ui
similarity index 100%
rename from src/Gui/DlgPropertyLink.ui
rename to src/Gui/Dialogs/DlgPropertyLink.ui
diff --git a/src/Gui/DlgRevertToBackupConfig.ui b/src/Gui/Dialogs/DlgRevertToBackupConfig.ui
similarity index 100%
rename from src/Gui/DlgRevertToBackupConfig.ui
rename to src/Gui/Dialogs/DlgRevertToBackupConfig.ui
diff --git a/src/Gui/DlgRevertToBackupConfigImp.cpp b/src/Gui/Dialogs/DlgRevertToBackupConfigImp.cpp
similarity index 88%
rename from src/Gui/DlgRevertToBackupConfigImp.cpp
rename to src/Gui/Dialogs/DlgRevertToBackupConfigImp.cpp
index 2910fbea26..5f9df07c99 100644
--- a/src/Gui/DlgRevertToBackupConfigImp.cpp
+++ b/src/Gui/Dialogs/DlgRevertToBackupConfigImp.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "DlgRevertToBackupConfigImp.h"
+#include "Dialogs/DlgRevertToBackupConfigImp.h"
#include "ui_DlgRevertToBackupConfig.h"
#include "Application.h"
#include "PreferencePackManager.h"
@@ -34,7 +34,7 @@
using namespace Gui;
using namespace Gui::Dialog;
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
/* TRANSLATOR Gui::Dialog::DlgRevertToBackupConfigImp */
@@ -71,12 +71,22 @@ void DlgRevertToBackupConfigImp::changeEvent(QEvent *e)
}
}
+// FIXME: Replace with more accurate C++20 solution once its usable: https://stackoverflow.com/a/68593141
+template
+static std::time_t to_time_t(TP tp)
+{
+ using namespace std::chrono;
+ auto sctp = time_point_cast(tp - TP::clock::now()
+ + system_clock::now());
+ return system_clock::to_time_t(sctp);
+}
+
void DlgRevertToBackupConfigImp::showEvent(QShowEvent* event)
{
ui->listWidget->clear();
const auto& backups = Application::Instance->prefPackManager()->configBackups();
for (const auto& backup : backups) {
- auto modification_date = QDateTime::fromSecsSinceEpoch(fs::last_write_time(backup));
+ auto modification_date = QDateTime::fromSecsSinceEpoch(to_time_t(fs::last_write_time(backup)));
auto item = new QListWidgetItem(QLocale().toString(modification_date));
item->setData(Qt::UserRole, QString::fromStdString(backup.string()));
ui->listWidget->addItem(item);
diff --git a/src/Gui/DlgRevertToBackupConfigImp.h b/src/Gui/Dialogs/DlgRevertToBackupConfigImp.h
similarity index 100%
rename from src/Gui/DlgRevertToBackupConfigImp.h
rename to src/Gui/Dialogs/DlgRevertToBackupConfigImp.h
diff --git a/src/Gui/DlgRunExternal.cpp b/src/Gui/Dialogs/DlgRunExternal.cpp
similarity index 96%
rename from src/Gui/DlgRunExternal.cpp
rename to src/Gui/Dialogs/DlgRunExternal.cpp
index 0bcdfe6bf5..2d82690a20 100644
--- a/src/Gui/DlgRunExternal.cpp
+++ b/src/Gui/Dialogs/DlgRunExternal.cpp
@@ -25,7 +25,7 @@
#include
#endif
-#include "DlgRunExternal.h"
+#include "Dialogs/DlgRunExternal.h"
#include "ui_DlgRunExternal.h"
#include "FileDialog.h"
diff --git a/src/Gui/DlgRunExternal.h b/src/Gui/Dialogs/DlgRunExternal.h
similarity index 100%
rename from src/Gui/DlgRunExternal.h
rename to src/Gui/Dialogs/DlgRunExternal.h
diff --git a/src/Gui/DlgRunExternal.ui b/src/Gui/Dialogs/DlgRunExternal.ui
similarity index 100%
rename from src/Gui/DlgRunExternal.ui
rename to src/Gui/Dialogs/DlgRunExternal.ui
diff --git a/src/Gui/DlgSettingsColorGradient.ui b/src/Gui/Dialogs/DlgSettingsColorGradient.ui
similarity index 100%
rename from src/Gui/DlgSettingsColorGradient.ui
rename to src/Gui/Dialogs/DlgSettingsColorGradient.ui
diff --git a/src/Gui/DlgSettingsColorGradientImp.cpp b/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp
similarity index 96%
rename from src/Gui/DlgSettingsColorGradientImp.cpp
rename to src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp
index 5979f363f2..23f3a4856e 100644
--- a/src/Gui/DlgSettingsColorGradientImp.cpp
+++ b/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp
@@ -31,7 +31,7 @@
#include
#endif
-#include "DlgSettingsColorGradientImp.h"
+#include "Dialogs/DlgSettingsColorGradientImp.h"
#include "ui_DlgSettingsColorGradient.h"
#include "SpinBox.h"
#include "Tools.h"
@@ -69,7 +69,7 @@ DlgSettingsColorGradientImp::DlgSettingsColorGradientImp(const App::ColorGradien
// assure that the LineEdit is as wide to contain numbers with 4 digits and 6 decimals
QFontMetrics fm(ui->floatLineEditMax->font());
ui->floatLineEditMax->setMinimumWidth(
- QtTools::horizontalAdvance(fm, QString::fromLatin1("-8000.000000")));
+ QtTools::horizontalAdvance(fm, QStringLiteral("-8000.000000")));
setColorModelNames(cg.getColorModelNames());
setProfile(cg.getProfile());
diff --git a/src/Gui/DlgSettingsColorGradientImp.h b/src/Gui/Dialogs/DlgSettingsColorGradientImp.h
similarity index 100%
rename from src/Gui/DlgSettingsColorGradientImp.h
rename to src/Gui/Dialogs/DlgSettingsColorGradientImp.h
diff --git a/src/Gui/DlgSettingsImage.ui b/src/Gui/Dialogs/DlgSettingsImage.ui
similarity index 100%
rename from src/Gui/DlgSettingsImage.ui
rename to src/Gui/Dialogs/DlgSettingsImage.ui
diff --git a/src/Gui/DlgSettingsImageImp.cpp b/src/Gui/Dialogs/DlgSettingsImageImp.cpp
similarity index 96%
rename from src/Gui/DlgSettingsImageImp.cpp
rename to src/Gui/Dialogs/DlgSettingsImageImp.cpp
index 659c34f9b1..85692b9246 100644
--- a/src/Gui/DlgSettingsImageImp.cpp
+++ b/src/Gui/Dialogs/DlgSettingsImageImp.cpp
@@ -26,7 +26,7 @@
#include
#endif
-#include "DlgSettingsImageImp.h"
+#include "Dialogs/DlgSettingsImageImp.h"
#include "ui_DlgSettingsImage.h"
diff --git a/src/Gui/DlgSettingsImageImp.h b/src/Gui/Dialogs/DlgSettingsImageImp.h
similarity index 100%
rename from src/Gui/DlgSettingsImageImp.h
rename to src/Gui/Dialogs/DlgSettingsImageImp.h
diff --git a/src/Gui/DlgToolbars.ui b/src/Gui/Dialogs/DlgToolbars.ui
similarity index 97%
rename from src/Gui/DlgToolbars.ui
rename to src/Gui/Dialogs/DlgToolbars.ui
index 910985b748..0a4700fbc3 100644
--- a/src/Gui/DlgToolbars.ui
+++ b/src/Gui/Dialogs/DlgToolbars.ui
@@ -113,7 +113,7 @@
-
+
:/icons/button_right.svg:/icons/button_right.svg
@@ -139,7 +139,7 @@
-
+
:/icons/button_left.svg:/icons/button_left.svg
@@ -171,7 +171,7 @@
-
+
:/icons/button_up.svg:/icons/button_up.svg
@@ -197,7 +197,7 @@
-
+
:/icons/button_down.svg:/icons/button_down.svg
@@ -352,7 +352,7 @@
deleteButton
-
+
diff --git a/src/Gui/DlgToolbarsImp.cpp b/src/Gui/Dialogs/DlgToolbarsImp.cpp
similarity index 96%
rename from src/Gui/DlgToolbarsImp.cpp
rename to src/Gui/Dialogs/DlgToolbarsImp.cpp
index b317d4c9e8..33edb6d115 100644
--- a/src/Gui/DlgToolbarsImp.cpp
+++ b/src/Gui/Dialogs/DlgToolbarsImp.cpp
@@ -30,8 +30,8 @@
#include
#endif
-#include "DlgToolbarsImp.h"
-#include "DlgKeyboardImp.h"
+#include "Dialogs/DlgToolbarsImp.h"
+#include "Dialogs/DlgKeyboardImp.h"
#include "ui_DlgToolbars.h"
#include "Application.h"
#include "BitmapFactory.h"
@@ -84,7 +84,7 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent)
workbenches.sort();
int index = 1;
ui->workbenchBox->addItem(QApplication::windowIcon(), tr("Global"));
- ui->workbenchBox->setItemData(0, QVariant(QString::fromLatin1("Global")), Qt::UserRole);
+ ui->workbenchBox->setItemData(0, QVariant(QStringLiteral("Global")), Qt::UserRole);
for (const auto& workbench : workbenches) {
QPixmap px = Application::Instance->workbenchIcon(workbench);
QString mt = Application::Instance->workbenchMenuText(workbench);
@@ -265,7 +265,7 @@ void DlgCustomToolbars::exportCustomToolbars(const QByteArray& workbench)
CommandManager& rMgr = Application::Instance->commandManager();
for (int i = 0; i < ui->toolbarTreeWidget->topLevelItemCount(); i++) {
QTreeWidgetItem* toplevel = ui->toolbarTreeWidget->topLevelItem(i);
- QString groupName = QString::fromLatin1("Custom_%1").arg(i + 1);
+ QString groupName = QStringLiteral("Custom_%1").arg(i + 1);
QByteArray toolbarName = toplevel->text(0).toUtf8();
ParameterGrp::handle hToolGrp = hGrp->GetGroup(groupName.toLatin1());
hToolGrp->SetASCII("Name", toolbarName.constData());
@@ -439,7 +439,7 @@ void DlgCustomToolbars::onNewButtonClicked()
{
bool ok;
QString text =
- QString::fromLatin1("Custom%1").arg(ui->toolbarTreeWidget->topLevelItemCount() + 1);
+ QStringLiteral("Custom%1").arg(ui->toolbarTreeWidget->topLevelItemCount() + 1);
text = QInputDialog::getText(this,
tr("New toolbar"),
tr("Toolbar name:"),
@@ -678,7 +678,7 @@ void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList
QMenu* menu = tb->menu();
if (!menu) {
tb->setPopupMode(QToolButton::MenuButtonPopup);
- tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton"));
+ tb->setObjectName(QStringLiteral("qt_toolbutton_menubutton"));
auto menu = new QMenu(tb);
menu->addActions(group);
tb->setMenu(menu);
diff --git a/src/Gui/DlgToolbarsImp.h b/src/Gui/Dialogs/DlgToolbarsImp.h
similarity index 100%
rename from src/Gui/DlgToolbarsImp.h
rename to src/Gui/Dialogs/DlgToolbarsImp.h
diff --git a/src/Gui/DlgTreeWidget.ui b/src/Gui/Dialogs/DlgTreeWidget.ui
similarity index 100%
rename from src/Gui/DlgTreeWidget.ui
rename to src/Gui/Dialogs/DlgTreeWidget.ui
diff --git a/src/Gui/DlgUndoRedo.cpp b/src/Gui/Dialogs/DlgUndoRedo.cpp
similarity index 96%
rename from src/Gui/DlgUndoRedo.cpp
rename to src/Gui/Dialogs/DlgUndoRedo.cpp
index 64190bcc13..439c0a1532 100644
--- a/src/Gui/DlgUndoRedo.cpp
+++ b/src/Gui/Dialogs/DlgUndoRedo.cpp
@@ -27,7 +27,7 @@
#include
#endif
-#include "DlgUndoRedo.h"
+#include "Dialogs/DlgUndoRedo.h"
#include "Application.h"
#include "MainWindow.h"
#include "MDIView.h"
diff --git a/src/Gui/DlgUndoRedo.h b/src/Gui/Dialogs/DlgUndoRedo.h
similarity index 100%
rename from src/Gui/DlgUndoRedo.h
rename to src/Gui/Dialogs/DlgUndoRedo.h
diff --git a/src/Gui/DlgUnitsCalculator.ui b/src/Gui/Dialogs/DlgUnitsCalculator.ui
similarity index 100%
rename from src/Gui/DlgUnitsCalculator.ui
rename to src/Gui/Dialogs/DlgUnitsCalculator.ui
diff --git a/src/Gui/DlgUnitsCalculatorImp.cpp b/src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp
similarity index 94%
rename from src/Gui/DlgUnitsCalculatorImp.cpp
rename to src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp
index c1a0276c72..f63e080e2e 100644
--- a/src/Gui/DlgUnitsCalculatorImp.cpp
+++ b/src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp
@@ -28,7 +28,7 @@
#include
#endif
-#include "DlgUnitsCalculatorImp.h"
+#include "Dialogs/DlgUnitsCalculatorImp.h"
#include "ui_DlgUnitsCalculator.h"
#include
@@ -51,7 +51,7 @@ DlgUnitsCalculator::DlgUnitsCalculator(QWidget* parent, Qt::WindowFlags fl)
ui->setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);
- ui->comboBoxScheme->addItem(QString::fromLatin1("Preference system"), static_cast(-1));
+ ui->comboBoxScheme->addItem(QStringLiteral("Preference system"), static_cast(-1));
int num = static_cast(Base::UnitSystem::NumUnitSystemTypes);
for (int i = 0; i < num; i++) {
QString item = Base::UnitsApi::getDescription(static_cast(i));
@@ -83,8 +83,8 @@ DlgUnitsCalculator::DlgUnitsCalculator(QWidget* parent, Qt::WindowFlags fl)
ui->ValueInput->setParamGrpPath(QByteArray("User parameter:BaseApp/History/UnitsCalculator"));
// set a default that also illustrates how the dialog works
- ui->ValueInput->setText(QString::fromLatin1("1 cm"));
- ui->UnitInput->setText(QString::fromLatin1("in"));
+ ui->ValueInput->setText(QStringLiteral("1 cm"));
+ ui->UnitInput->setText(QStringLiteral("in"));
units << Base::Unit::Acceleration << Base::Unit::AmountOfSubstance << Base::Unit::Angle
<< Base::Unit::Area << Base::Unit::Density << Base::Unit::CurrentDensity
@@ -137,10 +137,10 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
// first check the unit, if it is invalid, getTypeString() outputs an empty string
// explicitly check for "ee" like in "eeV" because this would trigger an exception in Base::Unit
// since it expects then a scientific notation number like "1e3"
- if ((ui->UnitInput->text().mid(0, 2) == QString::fromLatin1("ee"))
+ if ((ui->UnitInput->text().mid(0, 2) == QStringLiteral("ee"))
|| Base::Unit(ui->UnitInput->text().toStdString()).getTypeString().empty()) {
ui->ValueOutput->setText(
- QString::fromLatin1("%1 %2").arg(tr("unknown unit:"), ui->UnitInput->text()));
+ QStringLiteral("%1 %2").arg(tr("unknown unit:"), ui->UnitInput->text()));
ui->pushButton_Copy->setEnabled(false);
}
else { // the unit is valid
@@ -167,7 +167,7 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
val = QLocale().toString(value, 'f', Base::UnitsApi::getDecimals());
}
// create the output string
- QString out = QString::fromLatin1("%1 %2").arg(val, ui->UnitInput->text());
+ QString out = QStringLiteral("%1 %2").arg(val, ui->UnitInput->text());
ui->ValueOutput->setText(out);
ui->pushButton_Copy->setEnabled(true);
}
@@ -191,7 +191,7 @@ void DlgUnitsCalculator::copy()
void DlgUnitsCalculator::returnPressed()
{
if (ui->pushButton_Copy->isEnabled()) {
- ui->textEdit->append(ui->ValueInput->text() + QString::fromLatin1(" = ")
+ ui->textEdit->append(ui->ValueInput->text() + QStringLiteral(" = ")
+ ui->ValueOutput->text());
ui->ValueInput->pushToHistory();
}
diff --git a/src/Gui/DlgUnitsCalculatorImp.h b/src/Gui/Dialogs/DlgUnitsCalculatorImp.h
similarity index 100%
rename from src/Gui/DlgUnitsCalculatorImp.h
rename to src/Gui/Dialogs/DlgUnitsCalculatorImp.h
diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp
index 00a800cffd..432214d4de 100644
--- a/src/Gui/Document.cpp
+++ b/src/Gui/Document.cpp
@@ -695,7 +695,7 @@ void Document::_resetEdit()
// the editing object gets deleted inside the above call to
// 'finishEditing()', which will trigger our slotDeletedObject(), which
// nullifies _editViewProvider.
- if (d->_editViewProvider && d->_editViewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
+ if (d->_editViewProvider && d->_editViewProvider->isDerivedFrom()) {
auto vpd = static_cast(d->_editViewProvider);
vpd->getDocument()->signalResetEdit(*vpd);
}
@@ -823,7 +823,7 @@ std::vector Document::getViewProvidersOfType(const Base::Type& ty
std::vector Objects;
for (std::map::const_iterator it =
d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it ) {
- if (it->second->getTypeId().isDerivedFrom(typeId))
+ if (it->second->isDerivedFrom(typeId))
Objects.push_back(it->second);
}
return Objects;
@@ -993,7 +993,7 @@ void Document::slotDeletedObject(const App::DocumentObject& Obj)
handleChildren3D(viewProvider,true);
- if (viewProvider && viewProvider->getTypeId().isDerivedFrom
+ if (viewProvider && viewProvider->isDerivedFrom
(ViewProviderDocumentObject::getClassTypeId())) {
// go through the views
for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) {
@@ -1034,7 +1034,7 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop
if(d->_editingViewer
&& d->_editingObject
&& d->_editViewProviderParent
- && (Prop.isDerivedFrom(App::PropertyPlacement::getClassTypeId())
+ && (Prop.isDerivedFrom()
// Issue ID 0004230 : getName() can return null in which case strstr() crashes
|| (Prop.getName() && strstr(Prop.getName(),"Scale")))
&& d->_editObjs.count(&Obj))
@@ -1063,7 +1063,7 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop
handleChildren3D(viewProvider);
- if (viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
+ if (viewProvider->isDerivedFrom())
signalChangedObject(static_cast(*viewProvider), Prop);
}
@@ -1079,7 +1079,7 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop
void Document::slotRelabelObject(const App::DocumentObject& Obj)
{
ViewProvider* viewProvider = getViewProvider(&Obj);
- if (viewProvider && viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
+ if (viewProvider && viewProvider->isDerivedFrom()) {
signalRelabelObject(*(static_cast(viewProvider)));
}
}
@@ -1087,7 +1087,7 @@ void Document::slotRelabelObject(const App::DocumentObject& Obj)
void Document::slotTransactionAppend(const App::DocumentObject& obj, App::Transaction* transaction)
{
ViewProvider* viewProvider = getViewProvider(&obj);
- if (viewProvider && viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
+ if (viewProvider && viewProvider->isDerivedFrom()) {
transaction->addObjectDel(viewProvider);
}
}
@@ -1116,7 +1116,7 @@ void Document::slotTransactionRemove(const App::DocumentObject& obj, App::Transa
void Document::slotActivatedObject(const App::DocumentObject& Obj)
{
ViewProvider* viewProvider = getViewProvider(&Obj);
- if (viewProvider && viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
+ if (viewProvider && viewProvider->isDerivedFrom()) {
signalActivatedObject(*(static_cast(viewProvider)));
}
}
@@ -1298,7 +1298,7 @@ static bool checkCanonicalPath(const std::map &docs)
auto docName = [](App::Document *doc) -> QString {
if (doc->Label.getStrValue() == doc->getName())
return QString::fromLatin1(doc->getName());
- return QString::fromLatin1("%1 (%2)").arg(QString::fromUtf8(doc->Label.getValue()),
+ return QStringLiteral("%1 (%2)").arg(QString::fromUtf8(doc->Label.getValue()),
QString::fromLatin1(doc->getName()));
};
int count = 0;
@@ -1458,7 +1458,7 @@ bool Document::saveAs()
}
QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe),
name,
- QString::fromLatin1("%1 %2 (*.FCStd)").arg(exe, QObject::tr("Document")));
+ QStringLiteral("%1 %2 (*.FCStd)").arg(exe, QObject::tr("Document")));
if (!fn.isEmpty()) {
QFileInfo fi;
@@ -1544,7 +1544,7 @@ void Document::saveAll()
catch (const Base::Exception& e) {
QMessageBox::critical(getMainWindow(),
QObject::tr("Failed to save document") +
- QString::fromLatin1(": %1").arg(QString::fromUtf8(doc->getName())),
+ QStringLiteral(": %1").arg(QString::fromUtf8(doc->getName())),
QString::fromLatin1(e.what()));
break;
}
@@ -1749,7 +1749,7 @@ void Document::slotFinishRestoreDocument(const App::Document& doc)
App::DocumentObject* act = doc.getActiveObject();
if (act) {
ViewProvider* viewProvider = getViewProvider(act);
- if (viewProvider && viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
+ if (viewProvider && viewProvider->isDerivedFrom()) {
signalActivatedObject(*(static_cast(viewProvider)));
}
}
@@ -2029,7 +2029,7 @@ MDIView *Document::createView(const Base::Type& typeId)
view3D->getViewer()->removeViewProvider(getViewProvider(obj));
const char* name = getDocument()->Label.getValue();
- QString title = QString::fromLatin1("%1 : %2[*]")
+ QString title = QStringLiteral("%1 : %2[*]")
.arg(QString::fromUtf8(name)).arg(d->_iWinCount++);
view3D->setWindowTitle(title);
@@ -2260,7 +2260,7 @@ bool Document::canClose (bool checkModify, bool checkLink)
getActiveView(),
QObject::tr("Document not saved"),
QObject::tr("The document%1 could not be saved. Do you want to cancel closing it?")
- .arg(docName?(QString::fromUtf8(" ")+QString::fromUtf8(docName)):QString()),
+ .arg(docName?(QStringLiteral(" ")+QString::fromUtf8(docName)):QString()),
QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Discard);
if (ret == QMessageBox::Discard)
@@ -2389,7 +2389,7 @@ MDIView* Document::getActiveView() const
// hidden page has view but not in the list. By right, the view will
// self delete, but not the case for TechDraw, especially during
// document restore.
- if(windows.contains(*rit) || (*rit)->isDerivedFrom(View3DInventor::getClassTypeId()))
+ if(windows.contains(*rit) || (*rit)->isDerivedFrom())
return *rit;
}
return nullptr;
@@ -2434,7 +2434,7 @@ MDIView *Document::setActiveView(const ViewProviderDocumentObject* vp, Base::Typ
if (!view || (!typeId.isBad() && !view->isDerivedFrom(typeId))) {
view = nullptr;
for (auto *v : d->baseViews) {
- if (v->isDerivedFrom(MDIView::getClassTypeId()) &&
+ if (v->isDerivedFrom() &&
(typeId.isBad() || v->isDerivedFrom(typeId))) {
view = static_cast(v);
break;
@@ -2593,7 +2593,7 @@ bool Document::checkTransactionID(bool undo, int iSteps) {
str << " " << doc->getName() << "\n";
}
int ret = QMessageBox::warning(getMainWindow(), undo ? QObject::tr("Undo") : QObject::tr("Redo"),
- QString::fromLatin1("%1,\n%2%3").arg(
+ QStringLiteral("%1,\n%2%3").arg(
QObject::tr("There are grouped transactions in the following documents with "
"other preceding transactions"),
QString::fromStdString(str.str()),
diff --git a/src/Gui/DocumentModel.cpp b/src/Gui/DocumentModel.cpp
index c8d58d0006..fc04ef65aa 100644
--- a/src/Gui/DocumentModel.cpp
+++ b/src/Gui/DocumentModel.cpp
@@ -575,15 +575,10 @@ const Document* DocumentModel::getDocument(const QModelIndex& index) const
bool DocumentModel::isPropertyLink(const App::Property& prop) const
{
- if (prop.isDerivedFrom(App::PropertyLink::getClassTypeId()))
- return true;
- if (prop.isDerivedFrom(App::PropertyLinkSub::getClassTypeId()))
- return true;
- if (prop.isDerivedFrom(App::PropertyLinkList::getClassTypeId()))
- return true;
- if (prop.isDerivedFrom(App::PropertyLinkSubList::getClassTypeId()))
- return true;
- return false;
+ return prop.isDerivedFrom()
+ || prop.isDerivedFrom()
+ || prop.isDerivedFrom()
+ || prop.isDerivedFrom();
}
std::vector
diff --git a/src/Gui/DocumentPy.xml b/src/Gui/DocumentPy.xml
index da3a79186c..2823a7acc4 100644
--- a/src/Gui/DocumentPy.xml
+++ b/src/Gui/DocumentPy.xml
@@ -15,106 +15,106 @@
- show(objName) -> None
+ show(objName) -> None
-Show an object.
+Show an object.
-objName : str
+objName : str
Name of the `Gui.ViewProvider` to show.
- hide(objName) -> None
+ hide(objName) -> None
-Hide an object.
+Hide an object.
-objName : str
+objName : str
Name of the `Gui.ViewProvider` to hide.
- setPos(objName, matrix) -> None
+ setPos(objName, matrix) -> None
-Set the position of an object.
+Set the position of an object.
-objName : str
- Name of the `Gui.ViewProvider`.
+objName : str
+ Name of the `Gui.ViewProvider`.
-matrix : Base.Matrix
+matrix : Base.Matrix
Transformation to apply on the object.
- setEdit(obj, mod=0, subName) -> bool
+ setEdit(obj, mod=0, subName) -> bool
-Set an object in edit mode.
+Set an object in edit mode.
-obj : str, App.DocumentObject, Gui.ViewPrivider
+obj : str, App.DocumentObject, Gui.ViewPrivider
Object to set in edit mode.
-mod : int
+mod : int
Edit mode.
-subName : str
+subName : str
Subelement name. Optional.
- getInEdit() -> Gui.ViewProviderDocumentObject or None
+ getInEdit() -> Gui.ViewProviderDocumentObject or None
Returns the current object in edit mode or None if there is no such object.
- resetEdit() -> None
+ resetEdit() -> None
End the current editing.
- addAnnotation(annoName, fileName, modName) -> None
+ addAnnotation(annoName, fileName, modName) -> None
-Add an Inventor object from a file.
+Add an Inventor object from a file.
-annoName : str
+annoName : str
Annotation name.
-fileName : str
+fileName : str
File name.
-modName : str
+modName : str
Display mode name. Optional.
- update() -> None
+ update() -> None
Update the view representations of all objects.
- getObject(objName) -> object or None
+ getObject(objName) -> object or None
-Return the object with the given name. If no one exists, return None.
+Return the object with the given name. If no one exists, return None.
-ObjName : str
+ObjName : str
Object name.
- activeObject() -> object or None
+ activeObject() -> object or None
The active object of the document. Deprecated, use ActiveObject.
- activeView() -> object or None
+ activeView() -> object or None
The active view of the document. Deprecated, use ActiveView.
@@ -131,76 +131,76 @@ type : str
- mdiViewsOfType(type) -> list of MDIView
+ mdiViewsOfType(type) -> list of MDIView
-Return a list of mdi views of a given type.
+Return a list of mdi views of a given type.
-type : str
+type : str
Type name.
- save() -> bool
+ save() -> bool
Attempts to save the document
- saveAs() -> bool
+ saveAs() -> bool
Attempts to save the document under a new name
- sendMsgToViews(msg) -> None
+ sendMsgToViews(msg) -> None
-Send a message to all views of the document.
+Send a message to all views of the document.
msg : str
- mergeProject(fileName) -> None
+ mergeProject(fileName) -> None
-Merges this document with another project file.
+Merges this document with another project file.
-fileName : str
+fileName : str
File name.
- toggleTreeItem(obj, mod=0, subName) -> None
+ toggleTreeItem(obj, mod=0, subName) -> None
-Change TreeItem of a document object.
+Change TreeItem of a document object.
obj : App.DocumentObject
-mod : int
+mod : int
Item mode.
0: Toggle, 1: Collapse, 2: Expand, 3: Expand path.
-subName : str
+subName : str
Subelement name. Optional.
- scrollToTreeItem(obj) -> None
+ scrollToTreeItem(obj) -> None
-Scroll the tree view to the item of a view object.
+Scroll the tree view to the item of a view object.
obj : Gui.ViewProviderDocumentObject
- toggleInSceneGraph(obj) -> None
+ toggleInSceneGraph(obj) -> None
-Add or remove view object from scene graph of all views depending
-on its canAddToSceneGraph().
+Add or remove view object from scene graph of all views depending
+on its canAddToSceneGraph().
obj : Gui.ViewProvider
@@ -233,7 +233,7 @@ obj : Gui.ViewProvider
Current edit mode. Only meaningful when there is a current object in edit.
-
+
diff --git a/src/Gui/DocumentPyImp.cpp b/src/Gui/DocumentPyImp.cpp
index ed89f6c7e2..d982541749 100644
--- a/src/Gui/DocumentPyImp.cpp
+++ b/src/Gui/DocumentPyImp.cpp
@@ -494,7 +494,7 @@ Py::Object DocumentPy::getInEditInfo() const {
return Py::None();
return Py::TupleN(Py::Object(vp->getObject()->getPyObject(),true),
- Py::String(subname),Py::String(subelement),Py::Int(mode));
+ Py::String(subname),Py::String(subelement),Py::Long(mode));
}
void DocumentPy::setInEditInfo(Py::Object arg)
@@ -509,12 +509,12 @@ void DocumentPy::setInEditInfo(Py::Object arg)
pyobj)->getViewProviderDocumentObjectPtr(),subname);
}
-Py::Int DocumentPy::getEditMode() const
+Py::Long DocumentPy::getEditMode() const
{
int mode = -1;
getDocumentPtr()->getInEdit(nullptr,nullptr,&mode);
- return Py::Int(mode);
+ return Py::Long(mode);
}
Py::Boolean DocumentPy::getTransacting() const
diff --git a/src/Gui/DocumentRecovery.cpp b/src/Gui/DocumentRecovery.cpp
index c839a42481..e4ae5a94b0 100644
--- a/src/Gui/DocumentRecovery.cpp
+++ b/src/Gui/DocumentRecovery.cpp
@@ -52,7 +52,7 @@
#include
#include
#include
-#include
+#include
#include
#include
@@ -212,7 +212,7 @@ QString DocumentRecovery::createProjectFile(const QString& documentXml)
{
QString source = documentXml;
QFileInfo fi(source);
- QString dest = fi.dir().absoluteFilePath(QString::fromLatin1("fc_recovery_file.fcstd"));
+ QString dest = fi.dir().absoluteFilePath(QStringLiteral("fc_recovery_file.fcstd"));
std::stringstream str;
str << doctools << "\n";
@@ -412,16 +412,16 @@ DocumentRecoveryPrivate::Info DocumentRecoveryPrivate::getRecoveryInfo(const QFi
if (doc_dir.exists(QLatin1String("fc_recovery_file.xml"))) {
XmlConfig cfg = readXmlFile(info.xmlFile);
- if (cfg.contains(QString::fromLatin1("Label"))) {
- info.label = cfg[QString::fromLatin1("Label")];
+ if (cfg.contains(QStringLiteral("Label"))) {
+ info.label = cfg[QStringLiteral("Label")];
}
- if (cfg.contains(QString::fromLatin1("FileName"))) {
- info.fileName = cfg[QString::fromLatin1("FileName")];
+ if (cfg.contains(QStringLiteral("FileName"))) {
+ info.fileName = cfg[QStringLiteral("FileName")];
}
- if (cfg.contains(QString::fromLatin1("Status"))) {
- QString status = cfg[QString::fromLatin1("Status")];
+ if (cfg.contains(QStringLiteral("Status"))) {
+ QString status = cfg[QStringLiteral("Status")];
if (status == QLatin1String("Deprecated"))
info.status = DocumentRecoveryPrivate::Overage;
else if (status == QLatin1String("Success"))
@@ -474,9 +474,9 @@ DocumentRecoveryPrivate::XmlConfig DocumentRecoveryPrivate::readXmlFile(const QS
file.close();
QVector filter;
- filter << QString::fromLatin1("Label");
- filter << QString::fromLatin1("FileName");
- filter << QString::fromLatin1("Status");
+ filter << QStringLiteral("Label");
+ filter << QStringLiteral("FileName");
+ filter << QStringLiteral("Status");
QDomElement child;
if (!root.isNull()) {
@@ -590,7 +590,7 @@ void DocumentRecoveryFinder::checkDocumentDirs(QDir& tmp, const QList
}
else {
int countDeletedDocs = 0;
- QString recovery_files = QString::fromLatin1("fc_recovery_files");
+ QString recovery_files = QStringLiteral("fc_recovery_files");
for (QList::const_iterator it = dirs.cbegin(); it != dirs.cend(); ++it) {
QDir doc_dir(it->absoluteFilePath());
doc_dir.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries);
@@ -646,7 +646,7 @@ bool DocumentRecoveryFinder::showRecoveryDialogIfNeeded()
void DocumentRecoveryHandler::checkForPreviousCrashes(const std::function&, const QString&)> & callableFunc) const
{
QDir tmp = QString::fromUtf8(App::Application::getUserCachePath().c_str());
- tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
+ tmp.setNameFilters(QStringList() << QStringLiteral("*.lock"));
tmp.setFilter(QDir::Files);
QString exeName = QString::fromStdString(App::Application::getExecutableName());
diff --git a/src/Gui/DownloadItem.cpp b/src/Gui/DownloadItem.cpp
index 8831de1868..1ef9e9d0ed 100644
--- a/src/Gui/DownloadItem.cpp
+++ b/src/Gui/DownloadItem.cpp
@@ -45,7 +45,7 @@
#include "DownloadManager.h"
#include "FileDialog.h"
#include "MainWindow.h"
-#include "ui_DlgAuthorization.h"
+#include "Dialogs/ui_DlgAuthorization.h"
#include "Tools.h"
#include
diff --git a/src/Gui/EditableDatumLabel.cpp b/src/Gui/EditableDatumLabel.cpp
index bca2b209b2..5fa800935e 100644
--- a/src/Gui/EditableDatumLabel.cpp
+++ b/src/Gui/EditableDatumLabel.cpp
@@ -27,6 +27,7 @@
# include
# include
# include
+# include
#endif // _PreComp_
#include
@@ -60,13 +61,17 @@ EditableDatumLabel::EditableDatumLabel(View3DInventorViewer* view,
, function(Function::Positioning)
{
// NOLINTBEGIN
- root = new SoAnnotation;
+ root = new SoSwitch;
root->ref();
- root->renderCaching = SoSeparator::OFF;
+
+ annotation = new SoAnnotation;
+ annotation->ref();
+ annotation->renderCaching = SoSeparator::OFF;
+ root->addChild(annotation);
transform = new SoTransform();
transform->ref();
- root->addChild(transform);
+ annotation->addChild(transform);
label = new SoDatumLabel();
label->ref();
@@ -82,16 +87,19 @@ EditableDatumLabel::EditableDatumLabel(View3DInventorViewer* view,
if (autoDistance) {
setLabelRecommendedDistance();
}
- root->addChild(label);
+ annotation->addChild(label);
setPlacement(plc);
// NOLINTEND
+
+ static_cast(viewer->getSceneGraph())->addChild(root); // NOLINT
}
EditableDatumLabel::~EditableDatumLabel()
{
deactivate();
transform->unref();
+ annotation->unref();
root->unref();
label->unref();
}
@@ -102,7 +110,7 @@ void EditableDatumLabel::activate()
return;
}
- static_cast(viewer->getSceneGraph())->addChild(root); // NOLINT
+ root->whichChild = 0;
//track camera movements to update spinbox position.
auto info = new NodeData{ this };
@@ -129,9 +137,7 @@ void EditableDatumLabel::deactivate()
cameraSensor = nullptr;
}
- if (viewer) {
- static_cast(viewer->getSceneGraph())->removeChild(root); // NOLINT
- }
+ root->whichChild = SO_SWITCH_NONE;
}
void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj, bool visibleToMouse)
diff --git a/src/Gui/EditableDatumLabel.h b/src/Gui/EditableDatumLabel.h
index 80d6bffe06..ea224ff31a 100644
--- a/src/Gui/EditableDatumLabel.h
+++ b/src/Gui/EditableDatumLabel.h
@@ -34,6 +34,8 @@
class SoNodeSensor;
class SoTransform;
+class SoAnnotation;
+class SoSwitch;
namespace Gui {
@@ -97,7 +99,8 @@ private:
SbVec3f getTextCenterPoint() const;
private:
- SoSeparator* root;
+ SoSwitch* root;
+ SoAnnotation* annotation;
SoTransform* transform;
QPointer viewer;
QuantitySpinBox* spinBox;
diff --git a/src/Gui/EditorView.cpp b/src/Gui/EditorView.cpp
index 0f7e94fb67..f0ac94567a 100644
--- a/src/Gui/EditorView.cpp
+++ b/src/Gui/EditorView.cpp
@@ -370,7 +370,7 @@ bool EditorView::saveAs()
this,
QObject::tr("Save Macro"),
QString(),
- QString::fromLatin1("%1 (*.FCMacro);;Python (*.py)").arg(tr("FreeCAD macro")));
+ QStringLiteral("%1 (*.FCMacro);;Python (*.py)").arg(tr("FreeCAD macro")));
if (fn.isEmpty()) {
return false;
}
@@ -503,7 +503,7 @@ void EditorView::printPdf()
FileDialog::getSaveFileName(this,
tr("Export PDF"),
QString(),
- QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file")));
+ QStringLiteral("%1 (*.pdf)").arg(tr("PDF file")));
if (!filename.isEmpty()) {
QPrinter printer(QPrinter::ScreenResolution);
// setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under:
@@ -511,6 +511,7 @@ void EditorView::printPdf()
printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
+ printer.setCreator(QString::fromStdString(App::Application::getNameWithVersion()));
d->textEdit->document()->print(&printer);
}
}
@@ -540,7 +541,7 @@ void EditorView::setCurrentFileName(const QString& fileName)
shownName = tr("untitled[*]");
}
else {
- shownName = QString::fromLatin1("%1[*]").arg(name);
+ shownName = QStringLiteral("%1[*]").arg(name);
}
shownName += tr(" - Editor");
setWindowTitle(shownName);
@@ -893,7 +894,7 @@ void SearchBar::findText(bool skip, bool next, const QString& str)
QString styleSheet;
if (!found) {
- styleSheet = QString::fromLatin1(" QLineEdit {\n"
+ styleSheet = QStringLiteral(" QLineEdit {\n"
" background-color: rgb(221,144,161);\n"
" }\n");
}
diff --git a/src/Gui/ElideCheckBox.cpp b/src/Gui/ElideCheckBox.cpp
new file mode 100644
index 0000000000..8ca88b0d2e
--- /dev/null
+++ b/src/Gui/ElideCheckBox.cpp
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/****************************************************************************
+ * *
+ * Copyright (c) 2025 Alfredo Monclus *
+ * *
+ * This file is part of FreeCAD. *
+ * *
+ * FreeCAD is free software: you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 2.1 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * FreeCAD is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with FreeCAD. If not, see *
+ * . *
+ * *
+ ***************************************************************************/
+
+// This custom widget adds the missing ellipsize functionality in QT5
+
+#include "PreCompiled.h"
+
+#include "ElideCheckBox.h"
+
+namespace Gui {
+
+const int CheckboxSpacing = 18;
+
+ElideCheckBox::ElideCheckBox(QWidget *parent)
+ : QCheckBox(parent) {
+}
+
+void ElideCheckBox::paintEvent(QPaintEvent *event) {
+ Q_UNUSED(event);
+ QStyleOptionButton option;
+ option.initFrom(this);
+ option.state = (isChecked() ? QStyle::State_On : QStyle::State_Off) |
+ (isEnabled() ? QStyle::State_Enabled : QStyle::State_ReadOnly);
+
+ QPainter painter(this);
+ style()->drawControl(QStyle::CE_CheckBox, &option, &painter, this);
+
+ QRect textRect = option.rect;
+ textRect.setX(textRect.x() + CheckboxSpacing);
+
+ constexpr int padding = 4;
+ QFontMetrics fm(font());
+ QString elidedText = fm.elidedText(text(), Qt::ElideRight, textRect.width() - padding);
+
+ painter.setPen(palette().color(QPalette::WindowText));
+ painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, elidedText);
+}
+
+QSize ElideCheckBox::sizeHint() const {
+ QFontMetrics fm(font());
+ int width = fm.horizontalAdvance(this->text()) + CheckboxSpacing;
+ int height = fm.height();
+ return {width, height};
+}
+
+QSize ElideCheckBox::minimumSizeHint() const {
+ QFontMetrics fm(font());
+ QString minimumText = QStringLiteral("A...");
+ int width = fm.horizontalAdvance(minimumText) + CheckboxSpacing;
+ int height = fm.height();
+ return {width, height};
+}
+
+} // namespace Gui
+
+#include "moc_ElideCheckBox.cpp" // NOLINT
diff --git a/src/Gui/ElideCheckBox.h b/src/Gui/ElideCheckBox.h
new file mode 100644
index 0000000000..ce93133b53
--- /dev/null
+++ b/src/Gui/ElideCheckBox.h
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/****************************************************************************
+ * *
+ * Copyright (c) 2025 Alfredo Monclus *
+ * *
+ * This file is part of FreeCAD. *
+ * *
+ * FreeCAD is free software: you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 2.1 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * FreeCAD is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with FreeCAD. If not, see *
+ * . *
+ * *
+ ***************************************************************************/
+
+// This custom widget adds the missing ellipsize functionality in QT5
+
+#ifndef ELIDECHECKBOX_H
+#define ELIDECHECKBOX_H
+
+#ifndef _PreComp_
+#include
+#include
+#include
+#include
+#endif
+
+#include
+
+namespace Gui {
+
+class GuiExport ElideCheckBox : public QCheckBox {
+ Q_OBJECT
+
+public:
+ explicit ElideCheckBox(QWidget *parent = nullptr);
+ ~ElideCheckBox() override = default;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
+};
+
+} // namespace Gui
+
+#endif // ELIDECHECKBOX_H
+
diff --git a/src/Gui/ElideLabel.cpp b/src/Gui/ElideLabel.cpp
new file mode 100644
index 0000000000..10d7294522
--- /dev/null
+++ b/src/Gui/ElideLabel.cpp
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/****************************************************************************
+ * *
+ * Copyright (c) 2025 Alfredo Monclus *
+ * *
+ * This file is part of FreeCAD. *
+ * *
+ * FreeCAD is free software: you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 2.1 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * FreeCAD is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with FreeCAD. If not, see *
+ * . *
+ * *
+ ***************************************************************************/
+
+// This custom widget adds the missing ellipsize functionality in QT5
+
+#include "PreCompiled.h"
+
+#include "ElideLabel.h"
+
+namespace Gui {
+
+ElideLabel::ElideLabel(QWidget *parent)
+ : QLabel(parent) {
+}
+
+void ElideLabel::paintEvent(QPaintEvent *event) {
+ Q_UNUSED(event);
+ QPainter painter(this);
+ painter.setPen(palette().color(QPalette::WindowText));
+ painter.setFont(font());
+
+ constexpr int padding = 4;
+ QFontMetrics fm(painter.fontMetrics());
+
+ int availableWidth = width() - padding * 2;
+ if (availableWidth < 0) {
+ return;
+ }
+
+ QString elidedText = fm.elidedText(text(), Qt::ElideRight, availableWidth);
+
+ QRect textRect = rect().adjusted(padding, 0, -padding, 0);
+ painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, elidedText);
+}
+
+QSize ElideLabel::sizeHint() const {
+ QFontMetrics fm(font());
+ int width = fm.horizontalAdvance(this->text());
+ int height = fm.height();
+ return {width, height};
+}
+
+QSize ElideLabel::minimumSizeHint() const {
+ QFontMetrics fm(font());
+ QString minimumText = QStringLiteral("A...");
+ int width = fm.horizontalAdvance(minimumText);
+ int height = fm.height();
+ return {width, height};
+}
+
+} // namespace Gui
+
+#include "moc_ElideLabel.cpp" // NOLINT
diff --git a/src/Gui/ElideLabel.h b/src/Gui/ElideLabel.h
new file mode 100644
index 0000000000..7191d52f57
--- /dev/null
+++ b/src/Gui/ElideLabel.h
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/****************************************************************************
+ * *
+ * Copyright (c) 2025 Alfredo Monclus *
+ * *
+ * This file is part of FreeCAD. *
+ * *
+ * FreeCAD is free software: you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 2.1 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * FreeCAD is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with FreeCAD. If not, see *
+ * . *
+ * *
+ ***************************************************************************/
+
+// This custom widget adds the missing ellipsize functionality in QT5
+
+#ifndef ELIDELABEL_H
+#define ELIDELABEL_H
+
+#ifndef _PreComp_
+#include
+#include
+#include
+#endif
+
+#include
+
+namespace Gui {
+
+class GuiExport ElideLabel : public QLabel {
+ Q_OBJECT
+
+public:
+ explicit ElideLabel(QWidget *parent = nullptr);
+ ~ElideLabel() override = default;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
+};
+
+} // namespace Gui
+
+#endif // ELIDELABEL_H
diff --git a/src/Gui/ExpressionBinding.cpp b/src/Gui/ExpressionBinding.cpp
index d6d8972ef8..b5163cb443 100644
--- a/src/Gui/ExpressionBinding.cpp
+++ b/src/Gui/ExpressionBinding.cpp
@@ -281,7 +281,7 @@ ExpressionWidget::ExpressionWidget() = default;
QPixmap ExpressionWidget::getIcon(const char* name, const QSize& size) const
{
- QString key = QString::fromLatin1("%1_%2x%3")
+ QString key = QStringLiteral("%1_%2x%3")
.arg(QString::fromLatin1(name))
.arg(size.width())
.arg(size.height());
@@ -308,8 +308,8 @@ void ExpressionWidget::makeLabel(QLineEdit* le)
iconLabel->setCursor(Qt::ArrowCursor);
QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight));
iconLabel->setPixmap(pixmap);
- iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2));
+ iconLabel->setStyleSheet(QStringLiteral("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2));
iconLabel->hide();
iconLabel->setExpressionText(QString());
- le->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth));
+ le->setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth));
}
diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp
index 978f825dd1..353672461a 100644
--- a/src/Gui/FileDialog.cpp
+++ b/src/Gui/FileDialog.cpp
@@ -118,7 +118,7 @@ QList FileDialog::fetchSidebarUrls()
bool FileDialog::hasSuffix(const QString& ext) const
{
- QRegularExpression rx(QString::fromLatin1("\\*.(%1)\\W").arg(ext), QRegularExpression::CaseInsensitiveOption);
+ QRegularExpression rx(QStringLiteral("\\*.(%1)\\W").arg(ext), QRegularExpression::CaseInsensitiveOption);
QStringList filters = nameFilters();
for (const auto & str : filters) {
if (rx.match(str).hasMatch()) {
@@ -142,9 +142,9 @@ void FileDialog::accept()
// #0001928: do not add a suffix if a file with suffix is entered
// #0002209: make sure that the entered suffix is part of one of the filters
if (!ext.isEmpty() && (suffix.isEmpty() || !hasSuffix(suffix))) {
- file = QString::fromLatin1("%1.%2").arg(file, ext);
+ file = QStringLiteral("%1.%2").arg(file, ext);
// That's the built-in line edit
- auto fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit"));
+ auto fileNameEdit = this->findChild(QStringLiteral("fileNameEdit"));
if (fileNameEdit)
fileNameEdit->setText(file);
}
@@ -514,10 +514,10 @@ void FileOptionsDialog::accept()
if (ext.isEmpty())
setDefaultSuffix(suf);
else if (ext.toLower() != suf.toLower()) {
- fn = QString::fromLatin1("%1.%2").arg(fn, suf);
+ fn = QStringLiteral("%1.%2").arg(fn, suf);
selectFile(fn);
// That's the built-in line edit (fixes Debian bug #811200)
- auto fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit"));
+ auto fileNameEdit = this->findChild(QStringLiteral("fileNameEdit"));
if (fileNameEdit)
fileNameEdit->setText(fn);
}
@@ -617,7 +617,7 @@ QIcon FileIconProvider::icon(const QFileInfo & info) const
auto urlToThumbnail = [](const QString& filename) {
QString hash = QString::fromLatin1(QCryptographicHash::hash(filename.toUtf8(), QCryptographicHash::Md5).toHex());
QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
- return QString::fromLatin1("%1/thumbnails/normal/%2.png").arg(cache, hash);
+ return QStringLiteral("%1/thumbnails/normal/%2.png").arg(cache, hash);
};
auto iconFromFile = [](const QString& filename) {
@@ -627,7 +627,7 @@ QIcon FileIconProvider::icon(const QFileInfo & info) const
return icon;
}
- return QIcon(QString::fromLatin1(":/icons/freecad-doc.png"));
+ return QIcon(QStringLiteral(":/icons/freecad-doc.png"));
};
if (info.suffix().toLower() == QLatin1String("fcstd")) {
@@ -637,7 +637,7 @@ QIcon FileIconProvider::icon(const QFileInfo & info) const
return iconFromFile(thumb);
}
else if (info.suffix().toLower().startsWith(QLatin1String("fcstd"))) {
- QIcon icon(QString::fromLatin1(":/icons/freecad-doc.png"));
+ QIcon icon(QStringLiteral(":/icons/freecad-doc.png"));
QIcon darkIcon;
int w = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize);
darkIcon.addPixmap(icon.pixmap(w, w, QIcon::Disabled, QIcon::Off), QIcon::Normal, QIcon::Off);
@@ -673,7 +673,7 @@ FileChooser::FileChooser ( QWidget * parent )
completer = new QCompleter ( this );
completer->setMaxVisibleItems( 12 );
fs_model = new QFileSystemModel( completer );
- fs_model->setRootPath(QString::fromUtf8(""));
+ fs_model->setRootPath(QStringLiteral(""));
completer->setModel( fs_model );
lineEdit->setCompleter( completer );
@@ -884,7 +884,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types
module = module.left(match.capturedStart());
}
- button->setText(QString::fromLatin1("%1 (%2)").arg(filter, module));
+ button->setText(QStringLiteral("%1 (%2)").arg(filter, module));
button->setObjectName(it.value());
gridLayout1->addWidget(button, index, 0, 1, 1);
group->addButton(button, index);
@@ -902,7 +902,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types
hboxLayout->addItem(spacerItem1);
buttonBox = new QDialogButtonBox(this);
- buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
+ buttonBox->setObjectName(QStringLiteral("buttonBox"));
buttonBox->setStandardButtons(QDialogButtonBox::Open | QDialogButtonBox::Cancel);
buttonBox->button(QDialogButtonBox::Open)->setEnabled(false);
diff --git a/src/Gui/FontScaledSVG.cpp b/src/Gui/FontScaledSVG.cpp
new file mode 100644
index 0000000000..89c02e3b21
--- /dev/null
+++ b/src/Gui/FontScaledSVG.cpp
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/****************************************************************************
+ * *
+ * Copyright (c) 2025 Alfredo Monclus *
+ * *
+ * This file is part of FreeCAD. *
+ * *
+ * FreeCAD is free software: you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 2.1 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * FreeCAD is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with FreeCAD. If not, see *
+ * . *
+ * *
+ ***************************************************************************/
+
+// This custom widget scales an svg according to fonts
+
+#include "PreCompiled.h"
+
+#include "FontScaledSVG.h"
+
+namespace Gui {
+
+FontScaledSVG::FontScaledSVG(QWidget *parent)
+ : QWidget(parent), m_svgRenderer(new QSvgRenderer(this)) {
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+}
+
+void FontScaledSVG::setSvg(const QString &svgPath) {
+ if (m_svgRenderer->load(svgPath)) {
+ updateScaledSize();
+ update();
+ }
+}
+
+void FontScaledSVG::paintEvent(QPaintEvent *event) {
+ Q_UNUSED(event);
+ QPainter painter(this);
+
+ if (m_svgRenderer->isValid()) {
+ QRect targetRect(0, 0, width(), height());
+ m_svgRenderer->render(&painter, targetRect);
+ }
+}
+
+void FontScaledSVG::resizeEvent(QResizeEvent *event) {
+ Q_UNUSED(event);
+ updateScaledSize();
+}
+
+void FontScaledSVG::updateScaledSize() {
+ QSize baseSize = m_svgRenderer->defaultSize();
+
+ QFontMetrics metrics(font());
+ qreal spacing = metrics.lineSpacing();
+ constexpr int baseFactor = 18;
+ qreal scalingFactor = spacing / baseFactor;
+
+ QSize targetSize = baseSize * scalingFactor;
+ setFixedSize(targetSize);
+}
+
+} // namespace Gui
+
+#include "moc_FontScaledSVG.cpp" // NOLINT
diff --git a/src/Gui/FontScaledSVG.h b/src/Gui/FontScaledSVG.h
new file mode 100644
index 0000000000..ffdc3e666b
--- /dev/null
+++ b/src/Gui/FontScaledSVG.h
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/****************************************************************************
+ * *
+ * Copyright (c) 2025 Alfredo Monclus *
+ * *
+ * This file is part of FreeCAD. *
+ * *
+ * FreeCAD is free software: you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation, either version 2.1 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * FreeCAD is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with FreeCAD. If not, see *
+ * . *
+ * *
+ ***************************************************************************/
+
+// This custom widget scales an svg according to fonts
+
+#ifndef FONTSCALEDSVG_H
+#define FONTSCALEDSVG_H
+
+#ifndef _PreComp_
+#include
+#include
+#include
+#include
+#endif
+
+#include
+
+namespace Gui {
+
+class GuiExport FontScaledSVG : public QWidget {
+ Q_OBJECT
+
+public:
+ explicit FontScaledSVG(QWidget *parent = nullptr);
+ void setSvg(const QString &svgPath);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+
+private:
+ QSvgRenderer *m_svgRenderer;
+
+ void updateScaledSize();
+};
+
+} // namespace Gui
+
+#endif // FONTSCALEDSVG_H
diff --git a/src/Gui/GraphvizView.cpp b/src/Gui/GraphvizView.cpp
index fa51ccdf5b..f7acbc3e99 100644
--- a/src/Gui/GraphvizView.cpp
+++ b/src/Gui/GraphvizView.cpp
@@ -285,15 +285,15 @@ void GraphvizView::updateSvgItem(const App::Document &doc)
args << QLatin1String("-Granksep=2") << QLatin1String("-Goutputorder=edgesfirst")
<< QLatin1String("-Gsplines=ortho") << QLatin1String("-Tsvg");
flatArgs << QLatin1String("-c2 -l2");
- auto dot = QString::fromLatin1("dot");
- auto unflatten = QString::fromLatin1("unflatten");
+ auto dot = QStringLiteral("dot");
+ auto unflatten = QStringLiteral("unflatten");
auto path = QString::fromUtf8(hGrp->GetASCII("Graphviz").c_str());
bool pathChanged = false;
QDir dir;
if (!path.isEmpty()) {
dir = QDir(path);
- dot = dir.filePath(QString::fromLatin1("dot"));
- unflatten = dir.filePath(QString::fromLatin1("unflatten"));
+ dot = dir.filePath(QStringLiteral("dot"));
+ unflatten = dir.filePath(QStringLiteral("unflatten"));
}
dotProc->setEnvironment(QProcess::systemEnvironment());
flatProc->setEnvironment(QProcess::systemEnvironment());
@@ -305,7 +305,7 @@ void GraphvizView::updateSvgItem(const App::Document &doc)
if (!dotProc->waitForStarted()) {
int ret = QMessageBox::warning(Gui::getMainWindow(),
tr("Graphviz not found"),
- QString::fromLatin1("%1 "
+ QStringLiteral("%1 "
"%2"
"%3
")
.arg(tr("Graphviz couldn't be found on your system."),
@@ -324,8 +324,8 @@ void GraphvizView::updateSvgItem(const App::Document &doc)
}
else {
dir = QDir(path);
- dot = dir.filePath(QString::fromLatin1("dot"));
- unflatten = dir.filePath(QString::fromLatin1("unflatten"));
+ dot = dir.filePath(QStringLiteral("dot"));
+ unflatten = dir.filePath(QStringLiteral("unflatten"));
pathChanged = true;
}
}
@@ -391,7 +391,7 @@ QByteArray GraphvizView::exportGraph(const QString& format)
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Paths");
QProcess dotProc, flatProc;
QStringList args, flatArgs;
- args << QString::fromLatin1("-T%1").arg(format);
+ args << QStringLiteral("-T%1").arg(format);
flatArgs << QLatin1String("-c2 -l2");
#ifdef FC_OS_LINUX
@@ -401,11 +401,11 @@ QByteArray GraphvizView::exportGraph(const QString& format)
#endif
#ifdef FC_OS_WIN32
- QString exe = QString::fromLatin1("\"%1/dot\"").arg(path);
- QString unflatten = QString::fromLatin1("\"%1/unflatten\"").arg(path);
+ QString exe = QStringLiteral("\"%1/dot\"").arg(path);
+ QString unflatten = QStringLiteral("\"%1/unflatten\"").arg(path);
#else
- QString exe = QString::fromLatin1("%1/dot").arg(path);
- QString unflatten = QString::fromLatin1("%1/unflatten").arg(path);
+ QString exe = QStringLiteral("%1/dot").arg(path);
+ QString unflatten = QStringLiteral("%1/unflatten").arg(path);
#endif
dotProc.setEnvironment(QProcess::systemEnvironment());
@@ -442,13 +442,13 @@ bool GraphvizView::onMsg(const char* pMsg, const char**)
{
if (strcmp("Save",pMsg) == 0 || strcmp("SaveAs",pMsg) == 0) {
QList< QPair > formatMap;
- formatMap << qMakePair(QString::fromLatin1("%1 (*.gv)").arg(tr("Graphviz format")), QString::fromLatin1("gv"));
- formatMap << qMakePair(QString::fromLatin1("%1 (*.png)").arg(tr("PNG format")), QString::fromLatin1("png"));
- formatMap << qMakePair(QString::fromLatin1("%1 (*.bmp)").arg(tr("Bitmap format")), QString::fromLatin1("bmp"));
- formatMap << qMakePair(QString::fromLatin1("%1 (*.gif)").arg(tr("GIF format")), QString::fromLatin1("gif"));
- formatMap << qMakePair(QString::fromLatin1("%1 (*.jpg)").arg(tr("JPG format")), QString::fromLatin1("jpg"));
- formatMap << qMakePair(QString::fromLatin1("%1 (*.svg)").arg(tr("SVG format")), QString::fromLatin1("svg"));
- formatMap << qMakePair(QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format")), QString::fromLatin1("pdf"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.gv)").arg(tr("Graphviz format")), QStringLiteral("gv"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.png)").arg(tr("PNG format")), QStringLiteral("png"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.bmp)").arg(tr("Bitmap format")), QStringLiteral("bmp"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.gif)").arg(tr("GIF format")), QStringLiteral("gif"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.jpg)").arg(tr("JPG format")), QStringLiteral("jpg"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.svg)").arg(tr("SVG format")), QStringLiteral("svg"));
+ formatMap << qMakePair(QStringLiteral("%1 (*.pdf)").arg(tr("PDF format")), QStringLiteral("pdf"));
QStringList filter;
for (const auto & it : std::as_const(formatMap)) {
@@ -523,7 +523,7 @@ void GraphvizView::print(QPrinter* printer)
QPainter p(printer);
QRect rect = printer->pageLayout().paintRectPixels(printer->resolution());
view->scene()->render(&p, rect);
- //QByteArray buffer = exportGraph(QString::fromLatin1("svg"));
+ //QByteArray buffer = exportGraph(QStringLiteral("svg"));
//QSvgRenderer svg(buffer);
//svg.render(&p, rect);
p.end();
@@ -543,7 +543,7 @@ void GraphvizView::print()
void GraphvizView::printPdf()
{
QStringList filter;
- filter << QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format"));
+ filter << QStringLiteral("%1 (*.pdf)").arg(tr("PDF format"));
QString selectedFilter;
QString fn = Gui::FileDialog::getSaveFileName(this, tr("Export graph"), QString(), filter.join(QLatin1String(";;")), &selectedFilter);
diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp
index 2383e93a20..42e8ded33c 100644
--- a/src/Gui/GuiApplicationNativeEventAware.cpp
+++ b/src/Gui/GuiApplicationNativeEventAware.cpp
@@ -59,7 +59,11 @@ Gui::GUIApplicationNativeEventAware::~GUIApplicationNativeEventAware() = default
void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
{
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
- nativeEvent->initSpaceball(window);
+ ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath(
+ "User parameter:BaseApp/Preferences/View");
+ if (nativeEvent && hViewGrp->GetBool("LegacySpaceMouseDevices", false)) {
+ nativeEvent->initSpaceball(window);
+ }
#else
Q_UNUSED(window);
#endif
diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp
index 642b16a58a..0d432566a9 100644
--- a/src/Gui/InputField.cpp
+++ b/src/Gui/InputField.cpp
@@ -88,11 +88,11 @@ InputField::InputField(QWidget * parent)
iconLabel->setCursor(Qt::ArrowCursor);
QPixmap pixmap = getValidationIcon(":/icons/button_valid.svg", QSize(sizeHint().height(),sizeHint().height()));
iconLabel->setPixmap(pixmap);
- iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; }"));
+ iconLabel->setStyleSheet(QStringLiteral("QLabel { border: none; padding: 0px; }"));
iconLabel->hide();
connect(this, &QLineEdit::textChanged, this, &InputField::updateIconLabel);
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
- setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1));
+ setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1));
QSize msz = minimumSizeHint();
setMinimumSize(qMax(msz.width(), iconLabel->sizeHint().height() + frameWidth * 2 + 2),
qMax(msz.height(), iconLabel->sizeHint().height() + frameWidth * 2 + 2));
@@ -143,7 +143,7 @@ bool InputField::apply()
QPixmap InputField::getValidationIcon(const char* name, const QSize& size) const
{
- QString key = QString::fromLatin1("%1_%2x%3")
+ QString key = QStringLiteral("%1_%2x%3")
.arg(QString::fromLatin1(name))
.arg(size.width())
.arg(size.height());
@@ -192,7 +192,7 @@ void InputField::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *editMenu = createStandardContextMenu();
editMenu->setTitle(tr("Edit"));
- auto menu = new QMenu(QString::fromLatin1("InputFieldContextmenu"));
+ auto menu = new QMenu(QStringLiteral("InputFieldContextmenu"));
menu->addMenu(editMenu);
menu->addSeparator();
@@ -274,7 +274,7 @@ void InputField::newInput(const QString & text)
if(!actUnit.isEmpty() && !res.getUnit().isEmpty() && actUnit != res.getUnit()){
QPixmap pixmap = getValidationIcon(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height()));
iconLabel->setPixmap(pixmap);
- Q_EMIT parseError(QString::fromLatin1("Wrong unit"));
+ Q_EMIT parseError(QStringLiteral("Wrong unit"));
validInput = false;
return;
}
@@ -474,7 +474,7 @@ QString InputField::rawText() const
std::string unit;
double value = actQuantity.getValue();
actQuantity.getUserString(factor, unit);
- return QString::fromLatin1("%1 %2").arg(value / factor).arg(QString::fromStdString(unit));
+ return QStringLiteral("%1 %2").arg(value / factor).arg(QString::fromStdString(unit));
}
/// expects the string in C locale and internally converts it into the OS-specific locale
@@ -595,7 +595,7 @@ void InputField::setHistorySize(int i)
void InputField::selectNumber()
{
- QString expr = QString::fromLatin1("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)")
+ QString expr = QStringLiteral("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)")
.arg(locale().negativeSign())
.arg(locale().positiveSign())
.arg(locale().groupSeparator())
@@ -676,7 +676,7 @@ void InputField::keyPressEvent(QKeyEvent *event)
double dFactor;
std::string unitStr;
actQuantity.getUserString(dFactor, unitStr);
- this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
+ this->setText(QStringLiteral("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
event->accept();
}
@@ -702,7 +702,7 @@ void InputField::wheelEvent (QWheelEvent * event)
std::string unitStr;
actQuantity.getUserString(dFactor, unitStr);
- this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
+ this->setText(QStringLiteral("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
selectNumber();
event->accept();
}
diff --git a/src/Gui/InputVector.cpp b/src/Gui/InputVector.cpp
index 9220a23df2..141583b994 100644
--- a/src/Gui/InputVector.cpp
+++ b/src/Gui/InputVector.cpp
@@ -158,7 +158,7 @@ void LocationWidget::setDirection(const Base::Vector3d& dir)
}
// add a new item before the very last item
- QString display = QString::fromLatin1("(%1,%2,%3)")
+ QString display = QStringLiteral("(%1,%2,%3)")
.arg(dir.x)
.arg(dir.y)
.arg(dir.z);
diff --git a/src/Gui/InputVector.h b/src/Gui/InputVector.h
index 89dc54c3fc..17419500c7 100644
--- a/src/Gui/InputVector.h
+++ b/src/Gui/InputVector.h
@@ -204,7 +204,7 @@ private:
}
// add a new item before the very last item
- QString display = QString::fromLatin1("(%1,%2,%3)")
+ QString display = QStringLiteral("(%1,%2,%3)")
.arg(dir.x)
.arg(dir.y)
.arg(dir.z);
@@ -322,7 +322,7 @@ public:
}
// add a new item before the very last item
- QString display = QString::fromLatin1("(%1,%2,%3)")
+ QString display = QStringLiteral("(%1,%2,%3)")
.arg(dir.x)
.arg(dir.y)
.arg(dir.z);
@@ -503,7 +503,7 @@ public:
}
// add a new item before the very last item
- QString display = QString::fromLatin1("(%1,%2,%3)")
+ QString display = QStringLiteral("(%1,%2,%3)")
.arg(dir.x)
.arg(dir.y)
.arg(dir.z);
diff --git a/src/Gui/Inventor/SoAxisCrossKit.cpp b/src/Gui/Inventor/SoAxisCrossKit.cpp
index e894ff1ae2..ec95db0f03 100644
--- a/src/Gui/Inventor/SoAxisCrossKit.cpp
+++ b/src/Gui/Inventor/SoAxisCrossKit.cpp
@@ -29,6 +29,8 @@
# include
# endif
+#include
+
# include
# include
# include
@@ -50,6 +52,9 @@
# include
#endif
+#include
+#include
+
#include "SoAxisCrossKit.h"
#include "SoDevicePixelRatioElement.h"
@@ -218,12 +223,28 @@ SoAxisCrossKit::createAxes()
set("xAxis.appearance.drawStyle", "lineWidth 1");
set("yAxis.appearance.drawStyle", "lineWidth 1");
set("zAxis.appearance.drawStyle", "lineWidth 1");
- set("xAxis.appearance.material", "diffuseColor 0.5 0.125 0.125");
- set("xHead.appearance.material", "diffuseColor 0.5 0.125 0.125");
- set("yAxis.appearance.material", "diffuseColor 0.125 0.5 0.125");
- set("yHead.appearance.material", "diffuseColor 0.125 0.5 0.125");
- set("zAxis.appearance.material", "diffuseColor 0.125 0.125 0.5");
- set("zHead.appearance.material", "diffuseColor 0.125 0.125 0.5");
+
+ unsigned long colorLong;
+ App::Color color;
+ std::stringstream parameterstring;
+
+ colorLong = Gui::ViewParams::instance()->getAxisXColor();
+ color = App::Color(static_cast(colorLong));
+ parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
+ set("xAxis.appearance.material", parameterstring.str().c_str());
+ set("xHead.appearance.material", parameterstring.str().c_str());
+
+ colorLong = Gui::ViewParams::instance()->getAxisYColor();
+ color = App::Color(static_cast(colorLong));
+ parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
+ set("yAxis.appearance.material", parameterstring.str().c_str());
+ set("yHead.appearance.material", parameterstring.str().c_str());
+
+ colorLong = Gui::ViewParams::instance()->getAxisZColor();
+ color = App::Color(static_cast(colorLong));
+ parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
+ set("zAxis.appearance.material", parameterstring.str().c_str());
+ set("zHead.appearance.material", parameterstring.str().c_str());
// Make unpickable
set("xAxis.pickStyle", "style UNPICKABLE");
diff --git a/src/Gui/Language/Translator.cpp b/src/Gui/Language/Translator.cpp
index cbe8422492..cdfd257a4c 100644
--- a/src/Gui/Language/Translator.cpp
+++ b/src/Gui/Language/Translator.cpp
@@ -182,7 +182,7 @@ Translator::Translator()
auto entries = hGrp->GetASCII("AdditionalLanguageDomainEntries", "");
// The format of the entries is "Language Name 1"="code1";"Language Name 2"="code2";...
// Example: "Romanian"="ro";"Polish"="pl";
- QRegularExpression matchingRE(QString::fromUtf8("\"(.*[^\\s]+.*)\"\\s*=\\s*\"([^\\s]+)\";?"));
+ QRegularExpression matchingRE(QStringLiteral("\"(.*[^\\s]+.*)\"\\s*=\\s*\"([^\\s]+)\";?"));
auto matches = matchingRE.globalMatch(QString::fromStdString(entries));
while (matches.hasNext()) {
QRegularExpressionMatch match = matches.next();
@@ -223,7 +223,7 @@ TStringMap Translator::supportedLocales() const
for (const auto& domainMap : d->mapLanguageTopLevelDomain) {
for (const auto& directoryName : std::as_const(d->paths)) {
QDir dir(directoryName);
- QString filter = QString::fromLatin1("*_%1.qm").arg(QString::fromStdString(domainMap.second));
+ QString filter = QStringLiteral("*_%1.qm").arg(QString::fromStdString(domainMap.second));
QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name);
if (!fileNames.isEmpty()) {
d->mapSupportedLocales[domainMap.first] = domainMap.second;
@@ -309,7 +309,7 @@ void Translator::addPath(const QString& path)
void Translator::installQMFiles(const QDir& dir, const char* locale)
{
- QString filter = QString::fromLatin1("*_%1.qm").arg(QLatin1String(locale));
+ QString filter = QStringLiteral("*_%1.qm").arg(QLatin1String(locale));
QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name);
for (const auto &it : fileNames){
bool ok=false;
diff --git a/src/Gui/LinkViewPy.xml b/src/Gui/LinkViewPy.xml
index 9341090f85..cf00ba3eac 100644
--- a/src/Gui/LinkViewPy.xml
+++ b/src/Gui/LinkViewPy.xml
@@ -154,7 +154,7 @@ Return a tuple(path,detail) for the coin3D SoPath and SoDetail of the element
Set the element size to create an array of linked object
-
+
diff --git a/src/Gui/LinkViewPyImp.cpp b/src/Gui/LinkViewPyImp.cpp
index c7cccdd198..efc738216f 100644
--- a/src/Gui/LinkViewPyImp.cpp
+++ b/src/Gui/LinkViewPyImp.cpp
@@ -83,7 +83,7 @@ PyObject* LinkViewPy::setMaterial(PyObject *args) {
Py_ssize_t pos = 0;
std::map materials;
while(PyDict_Next(pyObj, &pos, &key, &value)) {
- Py::Int idx(key);
+ Py::Long idx(key);
if(value == Py_None)
materials[(int)idx] = nullptr;
else if(!PyObject_TypeCheck(value,&App::MaterialPy::Type)) {
@@ -135,7 +135,7 @@ PyObject* LinkViewPy::setTransform(PyObject *args) {
Py_ssize_t pos = 0;
std::map mat;
while(PyDict_Next(pyObj, &pos, &key, &value)) {
- Py::Int idx(key);
+ Py::Long idx(key);
if(!PyObject_TypeCheck(value,&Base::MatrixPy::Type)) {
PyErr_SetString(PyExc_TypeError, "exepcting a type of Matrix");
return nullptr;
@@ -384,11 +384,11 @@ PyObject* LinkViewPy::getChildren(PyObject *args) {
return Py::new_reference_to(ret);
}
-Py::Int LinkViewPy::getCount() const {
- return Py::Int(getLinkViewPtr()->getSize());
+Py::Long LinkViewPy::getCount() const {
+ return Py::Long(getLinkViewPtr()->getSize());
}
-void LinkViewPy::setCount(Py::Int count) {
+void LinkViewPy::setCount(Py::Long count) {
try {
getLinkViewPtr()->setSize((int)count);
} catch (const Base::Exception& e) {
diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp
index 3b3554664f..5568d3a429 100644
--- a/src/Gui/MDIView.cpp
+++ b/src/Gui/MDIView.cpp
@@ -39,6 +39,7 @@
#include
#include
+#include
#include "MDIView.h"
#include "MDIViewPy.h"
@@ -168,7 +169,7 @@ void MDIView::onRelabel(Gui::Document *pDoc)
}
else {
cap = QString::fromUtf8(pDoc->getDocument()->Label.getValue());
- cap = QString::fromLatin1("%1[*]").arg(cap);
+ cap = QStringLiteral("%1[*]").arg(cap);
setWindowTitle(cap);
}
}
@@ -257,13 +258,14 @@ void MDIView::print()
void MDIView::printPdf()
{
QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(),
- QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file")));
+ QStringLiteral("%1 (*.pdf)").arg(tr("PDF file")));
if (!filename.isEmpty()) {
QPrinter printer(QPrinter::ScreenResolution);
// setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/
printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
+ printer.setCreator(QString::fromStdString(App::Application::getNameWithVersion()));
print(&printer);
}
}
diff --git a/src/Gui/Macro.cpp b/src/Gui/Macro.cpp
index 32549ca763..7428cccbc3 100644
--- a/src/Gui/Macro.cpp
+++ b/src/Gui/Macro.cpp
@@ -84,7 +84,7 @@ bool MacroFile::commit()
str.setCodec("UTF-8");
#endif
QStringList import;
- import << QString::fromLatin1("import FreeCAD");
+ import << QStringLiteral("import FreeCAD");
QStringList body;
for (const auto& it : std::as_const(this->macroInProgress)) {
@@ -99,14 +99,14 @@ bool MacroFile::commit()
}
QString header;
- header += QString::fromLatin1("# -*- coding: utf-8 -*-\n\n");
- header += QString::fromLatin1("# Macro Begin: ");
+ header += QStringLiteral("# -*- coding: utf-8 -*-\n\n");
+ header += QStringLiteral("# Macro Begin: ");
header += this->macroName;
- header += QString::fromLatin1(" +++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ header += QStringLiteral(" +++++++++++++++++++++++++++++++++++++++++++++++++\n");
- QString footer = QString::fromLatin1("# Macro End: ");
+ QString footer = QStringLiteral("# Macro End: ");
footer += this->macroName;
- footer += QString::fromLatin1(" +++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ footer += QStringLiteral(" +++++++++++++++++++++++++++++++++++++++++++++++++\n");
// write the data to the text file
str << header;
@@ -329,7 +329,7 @@ void MacroManager::addToOutput(LineType type, const char* line)
void MacroManager::setModule(const char* sModule)
{
if (macroFile.isOpen() && sModule && *sModule != '\0') {
- macroFile.append(QString::fromLatin1("import %1").arg(QString::fromLatin1(sModule)));
+ macroFile.append(QStringLiteral("import %1").arg(QString::fromLatin1(sModule)));
}
}
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 6c1b1a7fa6..a315a2209a 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -114,7 +114,7 @@
#include "SpaceballEvent.h"
#include "View3DInventor.h"
#include "View3DInventorViewer.h"
-#include "DlgObjectSelection.h"
+#include "Dialogs/DlgObjectSelection.h"
#include
FC_LOG_LEVEL_INIT("MainWindow",false,true,true)
@@ -366,7 +366,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
tab->setTabsClosable(true);
// The tabs might be very wide
tab->setExpanding(false);
- tab->setObjectName(QString::fromLatin1("mdiAreaTabBar"));
+ tab->setObjectName(QStringLiteral("mdiAreaTabBar"));
}
d->mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
d->mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@@ -377,7 +377,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
d->mdiArea->setBackground(QBrush(QColor(160,160,160)));
setCentralWidget(d->mdiArea);
- statusBar()->setObjectName(QString::fromLatin1("statusBar"));
+ statusBar()->setObjectName(QStringLiteral("statusBar"));
connect(statusBar(), &QStatusBar::messageChanged, this, &MainWindow::statusMessageChanged);
// labels and progressbar
@@ -401,24 +401,24 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
if(notificationAreaEnabled) {
NotificationArea* notificationArea = new NotificationArea(statusBar());
- notificationArea->setObjectName(QString::fromLatin1("notificationArea"));
+ notificationArea->setObjectName(QStringLiteral("notificationArea"));
notificationArea->setStyleSheet(QStringLiteral("text-align:left;"));
statusBar()->addPermanentWidget(notificationArea);
}
// clears the action label
d->actionTimer = new QTimer( this );
- d->actionTimer->setObjectName(QString::fromLatin1("actionTimer"));
+ d->actionTimer->setObjectName(QStringLiteral("actionTimer"));
connect(d->actionTimer, &QTimer::timeout, d->actionLabel, &QLabel::clear);
// clear status type
d->statusTimer = new QTimer( this );
- d->statusTimer->setObjectName(QString::fromLatin1("statusTimer"));
+ d->statusTimer->setObjectName(QStringLiteral("statusTimer"));
connect(d->statusTimer, &QTimer::timeout, this, &MainWindow::clearStatus);
// update gui timer
d->activityTimer = new QTimer(this);
- d->activityTimer->setObjectName(QString::fromLatin1("activityTimer"));
+ d->activityTimer->setObjectName(QStringLiteral("activityTimer"));
connect(d->activityTimer, &QTimer::timeout, this, &MainWindow::_updateActions);
d->activityTimer->setSingleShot(false);
d->activityTimer->start(150);
@@ -784,6 +784,7 @@ void MainWindow::closeActiveWindow ()
int MainWindow::confirmSave(const char *docName, QWidget *parent, bool addCheckbox) {
QMessageBox box(parent?parent:this);
+ box.setObjectName(QStringLiteral("confirmSave"));
box.setIcon(QMessageBox::Question);
box.setWindowFlags(box.windowFlags() | Qt::WindowStaysOnTopHint);
box.setWindowTitle(QObject::tr("Unsaved document"));
@@ -798,7 +799,7 @@ int MainWindow::confirmSave(const char *docName, QWidget *parent, bool addCheckb
box.setDefaultButton(QMessageBox::Save);
box.setEscapeButton(QMessageBox::Cancel);
- QCheckBox checkBox(QObject::tr("Apply answer to all"));
+ QCheckBox checkBox(QObject::tr("Apply to all"));
ParameterGrp::handle hGrp;
if(addCheckbox) {
hGrp = App::GetApplication().GetUserParameter().
@@ -1316,16 +1317,16 @@ void MainWindow::onWindowsMenuAboutToShow()
QAction* action = actions.at(index);
QString text;
QString title = child->windowTitle();
- int lastIndex = title.lastIndexOf(QString::fromLatin1("[*]"));
+ int lastIndex = title.lastIndexOf(QStringLiteral("[*]"));
if (lastIndex > 0) {
title = title.left(lastIndex);
if (child->isWindowModified())
- title = QString::fromLatin1("%1*").arg(title);
+ title = QStringLiteral("%1*").arg(title);
}
if (index < 9)
- text = QString::fromLatin1("&%1 %2").arg(index+1).arg(title);
+ text = QStringLiteral("&%1 %2").arg(index+1).arg(title);
else
- text = QString::fromLatin1("%1 %2").arg(index+1).arg(title);
+ text = QStringLiteral("%1 %2").arg(index+1).arg(title);
action->setText(text);
action->setVisible(true);
action->setChecked(child == active);
@@ -1590,7 +1591,7 @@ void MainWindow::delayedStartup()
void MainWindow::appendRecentFile(const QString& filename)
{
auto recent = this->findChild
- (QString::fromLatin1("recentFiles"));
+ (QStringLiteral("recentFiles"));
if (recent) {
recent->appendFile(filename);
}
@@ -1599,7 +1600,7 @@ void MainWindow::appendRecentFile(const QString& filename)
void MainWindow::appendRecentMacro(const QString& filename)
{
auto recent = this->findChild
- (QString::fromLatin1("recentMacros"));
+ (QStringLiteral("recentMacros"));
if (recent) {
recent->appendFile(filename);
}
@@ -1766,6 +1767,8 @@ void MainWindow::loadWindowSettings()
statusBar()->setVisible(showStatusBar);
+ setAttribute(Qt::WA_AlwaysShowToolTips);
+
ToolBarManager::getInstance()->restoreState();
std::clog << "Toolbars restored" << std::endl;
@@ -2152,7 +2155,7 @@ void MainWindow::changeEvent(QEvent *e)
void MainWindow::clearStatus() {
d->currentStatusType = 100;
- statusBar()->setStyleSheet(QString::fromLatin1("#statusBar{}"));
+ statusBar()->setStyleSheet(QStringLiteral("#statusBar{}"));
}
void MainWindow::statusMessageChanged() {
@@ -2211,7 +2214,7 @@ void MainWindow::showStatus(int type, const QString& message)
statusBar()->setStyleSheet(d->status->wrn);
break;
case MainWindow::Pane:
- statusBar()->setStyleSheet(QString::fromLatin1("#statusBar{}"));
+ statusBar()->setStyleSheet(QStringLiteral("#statusBar{}"));
break;
default:
statusBar()->setStyleSheet(d->status->msg);
@@ -2303,23 +2306,18 @@ void MainWindow::setWindowTitle(const QString& string)
if (showVersion) {
// set main window title with FreeCAD Version
- auto config = App::Application::Config();
- QString major = QString::fromUtf8(config["BuildVersionMajor"].c_str());
- QString minor = QString::fromUtf8(config["BuildVersionMinor"].c_str());
- QString point = QString::fromUtf8(config["BuildVersionPoint"].c_str());
- QString suffix = QString::fromUtf8(config["BuildVersionSuffix"].c_str());
- title = QString::fromUtf8("%1 %2.%3.%4%5").arg(appname, major, minor, point, suffix);
+ title = QString::fromStdString(App::Application::getNameWithVersion());
}
else {
title = appname;
}
if (SafeMode::SafeModeEnabled()) {
- title = QString::fromUtf8("%1 (%2)").arg(title, tr("Safe Mode"));
+ title = QStringLiteral("%1 (%2)").arg(title, tr("Safe Mode"));
}
if (!string.isEmpty()) {
- title = QString::fromUtf8("[*] %1 - %2").arg(string, title);
+ title = QStringLiteral("[*] %1 - %2").arg(string, title);
}
QMainWindow::setWindowTitle(title);
@@ -2330,9 +2328,9 @@ void MainWindow::setWindowTitle(const QString& string)
StatusBarObserver::StatusBarObserver()
: WindowParameter("OutputWindow")
{
- msg = QString::fromLatin1("#statusBar{color: #000000}"); // black
- wrn = QString::fromLatin1("#statusBar{color: #ffaa00}"); // orange
- err = QString::fromLatin1("#statusBar{color: #ff0000}"); // red
+ msg = QStringLiteral("#statusBar{color: #000000}"); // black
+ wrn = QStringLiteral("#statusBar{color: #ffaa00}"); // orange
+ err = QStringLiteral("#statusBar{color: #ff0000}"); // red
Base::Console().AttachObserver(this);
getWindowParameter()->Attach(this);
getWindowParameter()->NotifyAll();
@@ -2347,7 +2345,7 @@ void MainWindow::setWindowTitle(const QString& string)
void StatusBarObserver::OnChange(Base::Subject & rCaller, const char* sReason)
{
ParameterGrp& rclGrp = ((ParameterGrp&)rCaller);
- auto format = QString::fromLatin1("#statusBar{color: %1}");
+ auto format = QStringLiteral("#statusBar{color: %1}");
if (strcmp(sReason, "colorText") == 0) {
unsigned long col = rclGrp.GetUnsigned(sReason);
this->msg = format.arg(App::Color::fromPackedRGB(col).name());
diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp
index 82a6bb0f94..419acfd717 100644
--- a/src/Gui/ManualAlignment.cpp
+++ b/src/Gui/ManualAlignment.cpp
@@ -51,7 +51,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -136,7 +136,7 @@ void AlignmentGroup::setRandomColor()
float r = /*(float)rand()/(float)RAND_MAX*/0.0f;
float g = (float)rand()/(float)RAND_MAX;
float b = (float)rand()/(float)RAND_MAX;
- if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) {
+ if ((*it)->isDerivedFrom()) {
SoSearchAction searchAction;
searchAction.setType(SoMaterial::getClassTypeId());
searchAction.setInterest(SoSearchAction::FIRST);
@@ -239,7 +239,7 @@ Base::BoundBox3d AlignmentGroup::getBoundingBox() const
Base::BoundBox3d box;
std::vector::const_iterator it;
for (it = this->_views.begin(); it != this->_views.end(); ++it) {
- if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) {
+ if ((*it)->isDerivedFrom()) {
auto geo = (*it)->getObject();
const App::PropertyComplexGeoData* prop = geo->getPropertyOfGeometry();
if (prop)
diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp
index 354cbabf8f..db95032839 100644
--- a/src/Gui/NaviCube.cpp
+++ b/src/Gui/NaviCube.cpp
@@ -56,6 +56,7 @@
#include "MainWindow.h"
#include "View3DInventorViewer.h"
#include "View3DInventor.h"
+#include "ViewParams.h"
using namespace Eigen;
@@ -179,6 +180,10 @@ public:
float m_InactiveOpacity = 0.5;
SbVec2s m_PosOffset = SbVec2s(0,0);
+ App::Color m_xColor;
+ App::Color m_yColor;
+ App::Color m_zColor;
+
bool m_Prepared = false;
static vector m_commands;
bool m_Draggable = false;
@@ -212,6 +217,7 @@ int NaviCube::getNaviCubeSize()
NaviCube::NaviCube(Gui::View3DInventorViewer* viewer) {
m_NaviCubeImplementation = new NaviCubeImplementation(viewer);
+ updateColors();
}
NaviCube::~NaviCube() {
@@ -828,13 +834,16 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode, float opacity)
a, a, a // 0
};
glVertexPointer(3, GL_FLOAT, 0, pointData);
- glColor4f(1, 0, 0, opacity);
+
+ glColor4f(m_xColor.r, m_xColor.g, m_xColor.b, opacity);
glDrawArrays(GL_LINES, 0, 2);
glDrawArrays(GL_POINTS, 0, 2);
- glColor4f(0, 1, 0, opacity);
+
+ glColor4f(m_yColor.r, m_yColor.g, m_yColor.b, opacity);
glDrawArrays(GL_LINES, 2, 2);
glDrawArrays(GL_POINTS, 2, 2);
- glColor4f(0, 0, 1, opacity);
+
+ glColor4f(m_zColor.r, m_zColor.g, m_zColor.b, opacity);
glDrawArrays(GL_LINES, 4, 2);
glDrawArrays(GL_POINTS, 4, 2);
}
@@ -1167,6 +1176,18 @@ QString NaviCubeImplementation::str(const char* str) {
return QString::fromLatin1(str);
}
+void NaviCube::updateColors()
+{
+ unsigned long colorLong;
+
+ colorLong = Gui::ViewParams::instance()->getAxisXColor();
+ m_NaviCubeImplementation->m_xColor = App::Color(static_cast(colorLong));
+ colorLong = Gui::ViewParams::instance()->getAxisYColor();
+ m_NaviCubeImplementation->m_yColor = App::Color(static_cast(colorLong));
+ colorLong = Gui::ViewParams::instance()->getAxisZColor();
+ m_NaviCubeImplementation->m_zColor = App::Color(static_cast(colorLong));
+}
+
void NaviCube::setNaviCubeCommands(const std::vector& cmd)
{
NaviCubeImplementation::m_commands = cmd;
@@ -1192,7 +1213,7 @@ void NaviCubeDraggableCmd::activated(int iMsg)
bool NaviCubeDraggableCmd::isActive()
{
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
- if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
+ if (view && view->isDerivedFrom()) {
bool check = _pcAction->isChecked();
auto view = qobject_cast(getMainWindow()->activeWindow());
bool mode = view->getViewer()->getNaviCube()->isDraggable();
diff --git a/src/Gui/NaviCube.h b/src/Gui/NaviCube.h
index 8802e192de..f9412011f6 100644
--- a/src/Gui/NaviCube.h
+++ b/src/Gui/NaviCube.h
@@ -51,6 +51,7 @@ public:
void setCorner(Corner);
void setOffset(int x, int y);
bool isDraggable();
+ void updateColors();
void setDraggable(bool draggable);
void setSize(int size);
void setChamfer(float size);
diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/Navigation/BlenderNavigationStyle.cpp
similarity index 99%
rename from src/Gui/BlenderNavigationStyle.cpp
rename to src/Gui/Navigation/BlenderNavigationStyle.cpp
index 6988b34caa..3bc606585a 100644
--- a/src/Gui/BlenderNavigationStyle.cpp
+++ b/src/Gui/Navigation/BlenderNavigationStyle.cpp
@@ -27,7 +27,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/Navigation/CADNavigationStyle.cpp
similarity index 99%
rename from src/Gui/CADNavigationStyle.cpp
rename to src/Gui/Navigation/CADNavigationStyle.cpp
index b5d9dbb632..301d80907e 100644
--- a/src/Gui/CADNavigationStyle.cpp
+++ b/src/Gui/Navigation/CADNavigationStyle.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/GestureNavigationStyle-state-machine-diagram.docx b/src/Gui/Navigation/GestureNavigationStyle-state-machine-diagram.docx
similarity index 100%
rename from src/Gui/GestureNavigationStyle-state-machine-diagram.docx
rename to src/Gui/Navigation/GestureNavigationStyle-state-machine-diagram.docx
diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/Navigation/GestureNavigationStyle.cpp
similarity index 100%
rename from src/Gui/GestureNavigationStyle.cpp
rename to src/Gui/Navigation/GestureNavigationStyle.cpp
diff --git a/src/Gui/GestureNavigationStyle.h b/src/Gui/Navigation/GestureNavigationStyle.h
similarity index 99%
rename from src/Gui/GestureNavigationStyle.h
rename to src/Gui/Navigation/GestureNavigationStyle.h
index 3b8886799b..a8fa4e6d0a 100644
--- a/src/Gui/GestureNavigationStyle.h
+++ b/src/Gui/Navigation/GestureNavigationStyle.h
@@ -23,7 +23,7 @@
#ifndef GESTURENAVIGATIONSTYLE2_H
#define GESTURENAVIGATIONSTYLE2_H
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include
#include
diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/Navigation/InventorNavigationStyle.cpp
similarity index 99%
rename from src/Gui/InventorNavigationStyle.cpp
rename to src/Gui/Navigation/InventorNavigationStyle.cpp
index 9acf9f6255..e8bb21d176 100644
--- a/src/Gui/InventorNavigationStyle.cpp
+++ b/src/Gui/Navigation/InventorNavigationStyle.cpp
@@ -28,7 +28,7 @@
#endif
#include "Inventor/SoMouseWheelEvent.h"
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/MayaGestureNavigationStyle.cpp b/src/Gui/Navigation/MayaGestureNavigationStyle.cpp
similarity index 99%
rename from src/Gui/MayaGestureNavigationStyle.cpp
rename to src/Gui/Navigation/MayaGestureNavigationStyle.cpp
index 645f1067b9..9d7e31ebf5 100644
--- a/src/Gui/MayaGestureNavigationStyle.cpp
+++ b/src/Gui/Navigation/MayaGestureNavigationStyle.cpp
@@ -63,7 +63,7 @@
#include
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "SoTouchEvents.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/NavigationAnimation.cpp b/src/Gui/Navigation/NavigationAnimation.cpp
similarity index 100%
rename from src/Gui/NavigationAnimation.cpp
rename to src/Gui/Navigation/NavigationAnimation.cpp
diff --git a/src/Gui/NavigationAnimation.h b/src/Gui/Navigation/NavigationAnimation.h
similarity index 98%
rename from src/Gui/NavigationAnimation.h
rename to src/Gui/Navigation/NavigationAnimation.h
index 1308a8e95e..d14e8a366a 100644
--- a/src/Gui/NavigationAnimation.h
+++ b/src/Gui/Navigation/NavigationAnimation.h
@@ -24,7 +24,7 @@
#ifndef GUI_NAVIGATIONANIMATION_H
#define GUI_NAVIGATIONANIMATION_H
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include
#include
#include
diff --git a/src/Gui/NavigationAnimator.cpp b/src/Gui/Navigation/NavigationAnimator.cpp
similarity index 100%
rename from src/Gui/NavigationAnimator.cpp
rename to src/Gui/Navigation/NavigationAnimator.cpp
diff --git a/src/Gui/NavigationAnimator.h b/src/Gui/Navigation/NavigationAnimator.h
similarity index 98%
rename from src/Gui/NavigationAnimator.h
rename to src/Gui/Navigation/NavigationAnimator.h
index 8b206acd71..0d0f6e953f 100644
--- a/src/Gui/NavigationAnimator.h
+++ b/src/Gui/Navigation/NavigationAnimator.h
@@ -24,7 +24,7 @@
#ifndef GUI_NAVIGATIONANIMATOR_H
#define GUI_NAVIGATIONANIMATOR_H
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include
#include
diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/Navigation/NavigationStyle.cpp
similarity index 99%
rename from src/Gui/NavigationStyle.cpp
rename to src/Gui/Navigation/NavigationStyle.cpp
index 9316c1ac8d..32f9939e3c 100644
--- a/src/Gui/NavigationStyle.cpp
+++ b/src/Gui/Navigation/NavigationStyle.cpp
@@ -42,14 +42,14 @@
#include
#include
-#include "NavigationStyle.h"
-#include "NavigationStylePy.h"
+#include "Navigation/NavigationStyle.h"
+#include "Navigation/NavigationStylePy.h"
#include "Application.h"
#include "Inventor/SoMouseWheelEvent.h"
#include "MenuManager.h"
#include "MouseSelection.h"
-#include "NavigationAnimator.h"
-#include "NavigationAnimation.h"
+#include "Navigation/NavigationAnimator.h"
+#include "Navigation/NavigationAnimation.h"
#include "View3DInventorViewer.h"
using namespace Gui;
diff --git a/src/Gui/NavigationStyle.h b/src/Gui/Navigation/NavigationStyle.h
similarity index 100%
rename from src/Gui/NavigationStyle.h
rename to src/Gui/Navigation/NavigationStyle.h
diff --git a/src/Gui/NavigationStylePy.xml b/src/Gui/Navigation/NavigationStylePy.xml
similarity index 90%
rename from src/Gui/NavigationStylePy.xml
rename to src/Gui/Navigation/NavigationStylePy.xml
index 7506701f88..314eda00ee 100644
--- a/src/Gui/NavigationStylePy.xml
+++ b/src/Gui/Navigation/NavigationStylePy.xml
@@ -5,7 +5,7 @@
Name="NavigationStylePy"
Twin="NavigationStyle"
TwinPointer="NavigationStyle"
- Include="Gui/NavigationStyle.h"
+ Include="Gui/Navigation/NavigationStyle.h"
Namespace="Gui"
FatherInclude="Base/BaseClassPy.h"
FatherNamespace="Base">
diff --git a/src/Gui/NavigationStylePyImp.cpp b/src/Gui/Navigation/NavigationStylePyImp.cpp
similarity index 94%
rename from src/Gui/NavigationStylePyImp.cpp
rename to src/Gui/Navigation/NavigationStylePyImp.cpp
index df0f1c573c..c8cb1859ac 100644
--- a/src/Gui/NavigationStylePyImp.cpp
+++ b/src/Gui/Navigation/NavigationStylePyImp.cpp
@@ -22,8 +22,8 @@
#include "PreCompiled.h"
// inclusion of the generated files (generated out of NavigationStylePy.xml)
-#include "NavigationStylePy.h"
-#include "NavigationStylePy.cpp"
+#include "Navigation/NavigationStylePy.h"
+#include "Navigation/NavigationStylePy.cpp"
using namespace Gui;
diff --git a/src/Gui/OpenCascadeNavigationStyle.cpp b/src/Gui/Navigation/OpenCascadeNavigationStyle.cpp
similarity index 99%
rename from src/Gui/OpenCascadeNavigationStyle.cpp
rename to src/Gui/Navigation/OpenCascadeNavigationStyle.cpp
index ddb6613069..0100f2c7c0 100644
--- a/src/Gui/OpenCascadeNavigationStyle.cpp
+++ b/src/Gui/Navigation/OpenCascadeNavigationStyle.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/OpenSCADNavigationStyle.cpp b/src/Gui/Navigation/OpenSCADNavigationStyle.cpp
similarity index 99%
rename from src/Gui/OpenSCADNavigationStyle.cpp
rename to src/Gui/Navigation/OpenSCADNavigationStyle.cpp
index 263e8f0f85..3603df95a6 100644
--- a/src/Gui/OpenSCADNavigationStyle.cpp
+++ b/src/Gui/Navigation/OpenSCADNavigationStyle.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/RevitNavigationStyle.cpp b/src/Gui/Navigation/RevitNavigationStyle.cpp
similarity index 99%
rename from src/Gui/RevitNavigationStyle.cpp
rename to src/Gui/Navigation/RevitNavigationStyle.cpp
index af4e9b114e..7efc1bf436 100644
--- a/src/Gui/RevitNavigationStyle.cpp
+++ b/src/Gui/Navigation/RevitNavigationStyle.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/TinkerCADNavigationStyle.cpp b/src/Gui/Navigation/TinkerCADNavigationStyle.cpp
similarity index 99%
rename from src/Gui/TinkerCADNavigationStyle.cpp
rename to src/Gui/Navigation/TinkerCADNavigationStyle.cpp
index e7ca54f6c0..2935e2037f 100644
--- a/src/Gui/TinkerCADNavigationStyle.cpp
+++ b/src/Gui/Navigation/TinkerCADNavigationStyle.cpp
@@ -26,7 +26,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/Navigation/TouchpadNavigationStyle.cpp
similarity index 99%
rename from src/Gui/TouchpadNavigationStyle.cpp
rename to src/Gui/Navigation/TouchpadNavigationStyle.cpp
index 6efa6dc9a3..9300b4619e 100644
--- a/src/Gui/TouchpadNavigationStyle.cpp
+++ b/src/Gui/Navigation/TouchpadNavigationStyle.cpp
@@ -25,7 +25,7 @@
# include
#endif
-#include "NavigationStyle.h"
+#include "Navigation/NavigationStyle.h"
#include "View3DInventorViewer.h"
diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp
index 8b71ff0951..989f1856fd 100644
--- a/src/Gui/NetworkRetriever.cpp
+++ b/src/Gui/NetworkRetriever.cpp
@@ -39,7 +39,7 @@
#include "BitmapFactory.h"
#include "FileDialog.h"
#include "MainWindow.h"
-#include "ui_DlgAuthorization.h"
+#include "Dialogs/ui_DlgAuthorization.h"
using namespace Gui;
@@ -241,15 +241,15 @@ bool NetworkRetriever::startDownload( const QString& startUrl )
if ( !d->proxy.isEmpty() )
{
QStringList env = wget->environment();
- env << QString::fromLatin1("http_proxy=%1").arg(d->proxy);
- env << QString::fromLatin1("ftp_proxy=%1").arg(d->proxy);
+ env << QStringLiteral("http_proxy=%1").arg(d->proxy);
+ env << QStringLiteral("ftp_proxy=%1").arg(d->proxy);
wget->setEnvironment(env);
}
else
{
QStringList env = wget->environment();
- env.removeAll(QString::fromLatin1("http_proxy=%1").arg(d->proxy));
- env.removeAll(QString::fromLatin1("ftp_proxy=%1").arg(d->proxy));
+ env.removeAll(QStringLiteral("http_proxy=%1").arg(d->proxy));
+ env.removeAll(QStringLiteral("ftp_proxy=%1").arg(d->proxy));
wget->setEnvironment(env);
}
@@ -278,43 +278,43 @@ bool NetworkRetriever::startDownload( const QString& startUrl )
{
if ( !d->user.isEmpty() )
{
- wgetArguments << QString::fromLatin1("--proxy-user=%1").arg( d->user );
+ wgetArguments << QStringLiteral("--proxy-user=%1").arg( d->user );
if ( !d->passwd.isEmpty() )
{
- wgetArguments << QString::fromLatin1("--proxy-passwd=%1").arg( d->passwd );
+ wgetArguments << QStringLiteral("--proxy-passwd=%1").arg( d->passwd );
}
}
}
// output file
if ( !d->outputFile.isEmpty() )
- wgetArguments << QString::fromLatin1("--output-document=%1").arg( d->outputFile );
+ wgetArguments << QStringLiteral("--output-document=%1").arg( d->outputFile );
// timestamping enabled -> update newer files only
if ( d->timeStamp )
- wgetArguments << QString::fromLatin1("-N");
+ wgetArguments << QStringLiteral("-N");
// get all needed image files
if ( d->img )
- wgetArguments << QString::fromLatin1("-p");
+ wgetArguments << QStringLiteral("-p");
// follow relative links only
if ( d->folRel )
- wgetArguments<< QString::fromLatin1("-L");
+ wgetArguments<< QStringLiteral("-L");
if ( d->recurse )
{
- wgetArguments << QString::fromLatin1("-r");
- wgetArguments << QString::fromLatin1("--level=%1").arg( d->level );
+ wgetArguments << QStringLiteral("-r");
+ wgetArguments << QStringLiteral("--level=%1").arg( d->level );
}
if ( d->nop )
- wgetArguments << QString::fromLatin1("-np");
+ wgetArguments << QStringLiteral("-np");
// convert absolute links in to relative
if ( d->convert )
- wgetArguments << QString::fromLatin1("-k");
+ wgetArguments << QStringLiteral("-k");
// number of tries
- wgetArguments << QString::fromLatin1("--tries=%1").arg( d->tries );
+ wgetArguments << QStringLiteral("--tries=%1").arg( d->tries );
// use HTML file extension
if ( d->html )
- wgetArguments << QString::fromLatin1("-E");
+ wgetArguments << QStringLiteral("-E");
// start URL
wgetArguments << startUrl;
@@ -327,10 +327,10 @@ bool NetworkRetriever::startDownload( const QString& startUrl )
QDir::setCurrent(d->dir);
}
- wget->start(QString::fromLatin1("wget"), wgetArguments);
+ wget->start(QStringLiteral("wget"), wgetArguments);
QDir::setCurrent( cwd );
#else
- wget->start(QString::fromLatin1("wget"), wgetArguments);
+ wget->start(QStringLiteral("wget"), wgetArguments);
#endif
return wget->state() == QProcess::Running;
@@ -374,7 +374,7 @@ void NetworkRetriever::wgetFinished(int exitCode, QProcess::ExitStatus status)
bool NetworkRetriever::testWget()
{
QProcess proc;
- proc.setProgram(QString::fromLatin1("wget"));
+ proc.setProgram(QStringLiteral("wget"));
proc.start();
bool ok = proc.state() == QProcess::Running;
proc.kill();
@@ -484,7 +484,7 @@ void StdCmdDownloadOnlineHelp::activated(int iMsg)
// set output directory
QString path = QString::fromStdString(App::Application::getHomePath());
- path += QString::fromLatin1("/doc/");
+ path += QStringLiteral("/doc/");
ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/OnlineHelp");
path = QString::fromUtf8(hURLGrp->GetASCII( "DownloadLocation", path.toLatin1() ).c_str());
diff --git a/src/Gui/NotificationArea.cpp b/src/Gui/NotificationArea.cpp
index edade8d749..0925013a70 100644
--- a/src/Gui/NotificationArea.cpp
+++ b/src/Gui/NotificationArea.cpp
@@ -1134,7 +1134,7 @@ void NotificationArea::showInNotificationArea()
// We update the message with the most recent up to maxOpenNotifications
QString msgw =
- QString::fromLatin1(
+ QStringLiteral(
" \
\
\
@@ -1149,7 +1149,7 @@ void NotificationArea::showInNotificationArea()
if (currentlynotifying > pImp->maxOpenNotifications) {
msgw +=
- QString::fromLatin1(
+ QStringLiteral(
" \
\
 | \
@@ -1187,7 +1187,7 @@ void NotificationArea::showInNotificationArea()
convertFromPlainText(item->getMessage(), Qt::WhiteSpaceMode::WhiteSpaceNormal);
msgw +=
- QString::fromLatin1(
+ QStringLiteral(
" \
\
 | \
@@ -1233,7 +1233,7 @@ void NotificationArea::showInNotificationArea()
i++;
}
- msgw += QString::fromLatin1("
");
+ msgw += QStringLiteral("");
NotificationBox::Options options = NotificationBox::Options::RestrictAreaToReference;
diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp
index 9c101ac1f0..e35486ebf3 100644
--- a/src/Gui/OnlineDocumentation.cpp
+++ b/src/Gui/OnlineDocumentation.cpp
@@ -169,7 +169,7 @@ QByteArray PythonOnlineHelp::loadHelpPage(const QString& filename) const
QByteArray PythonOnlineHelp::fileNotFound() const
{
const int pageNotFound = 404;
- QString contentType = QString::fromLatin1(
+ QString contentType = QStringLiteral(
"text/html\r\n"
"\r\n"
"Error"
@@ -189,11 +189,11 @@ QByteArray PythonOnlineHelp::fileNotFound() const
""
"\r\n");
- QString header = QString::fromLatin1("content-type: %1\r\n").arg(contentType);
+ QString header = QStringLiteral("content-type: %1\r\n").arg(contentType);
QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n"));
QString httpResponseHeader =
- http.arg(pageNotFound).arg(QString::fromLatin1("File not found"), header);
+ http.arg(pageNotFound).arg(QStringLiteral("File not found"), header);
QByteArray res = httpResponseHeader.toLatin1();
return res;
@@ -203,7 +203,7 @@ QByteArray PythonOnlineHelp::loadFailed(const QString& error) const
{
const int pageNotFound = 404;
QString contentType =
- QString::fromLatin1(
+ QStringLiteral(
"text/html\r\n"
"\r\n"
"Error"
@@ -222,11 +222,11 @@ QByteArray PythonOnlineHelp::loadFailed(const QString& error) const
"\r\n")
.arg(error);
- QString header = QString::fromLatin1("content-type: %1\r\n").arg(contentType);
+ QString header = QStringLiteral("content-type: %1\r\n").arg(contentType);
QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n"));
QString httpResponseHeader =
- http.arg(pageNotFound).arg(QString::fromLatin1("File not found"), header);
+ http.arg(pageNotFound).arg(QStringLiteral("File not found"), header);
QByteArray res = httpResponseHeader.toLatin1();
return res;
diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp
index 307727c363..5e63bb3558 100644
--- a/src/Gui/Placement.cpp
+++ b/src/Gui/Placement.cpp
@@ -42,7 +42,7 @@
#include
#include
#include
-#include
+#include
#include
#include
@@ -338,7 +338,7 @@ void PlacementHandler::applyPlacement(const App::DocumentObject* obj, const QStr
QString PlacementHandler::getIncrementalPlacement(const App::DocumentObject* obj, const QString& data) const
{
- return QString::fromLatin1(
+ return QStringLiteral(
R"(App.getDocument("%1").%2.%3=%4.multiply(App.getDocument("%1").%2.%3))")
.arg(QString::fromLatin1(obj->getDocument()->getName()),
QString::fromLatin1(obj->getNameInDocument()),
@@ -348,7 +348,7 @@ QString PlacementHandler::getIncrementalPlacement(const App::DocumentObject* obj
QString PlacementHandler::getSimplePlacement(const App::DocumentObject* obj, const QString& data) const
{
- return QString::fromLatin1(
+ return QStringLiteral(
"App.getDocument(\"%1\").%2.%3=%4")
.arg(QString::fromLatin1(obj->getDocument()->getName()),
QString::fromLatin1(obj->getNameInDocument()),
@@ -1036,7 +1036,7 @@ QString Placement::getPlacementFromEulerAngles() const
Base::Vector3d pos = getPositionData();
Base::Vector3d ypr = getAnglesData();
Base::Vector3d cnt = getCenterData();
- return QString::fromLatin1(
+ return QStringLiteral(
"App.Placement(App.Vector(%1,%2,%3), App.Rotation(%4,%5,%6), App.Vector(%7,%8,%9))")
.arg(pos.x)
.arg(pos.y)
@@ -1055,7 +1055,7 @@ QString Placement::getPlacementFromAxisWithAngle() const
Base::Vector3d cnt = getCenterData();
Base::Vector3d dir = getDirection();
double angle = ui->angle->value().getValue();
- return QString::fromLatin1(
+ return QStringLiteral(
"App.Placement(App.Vector(%1,%2,%3), App.Rotation(App.Vector(%4,%5,%6),%7), App.Vector(%8,%9,%10))")
.arg(pos.x)
.arg(pos.y)
diff --git a/src/Gui/Placement.h b/src/Gui/Placement.h
index bf6af51282..89d80d3b80 100644
--- a/src/Gui/Placement.h
+++ b/src/Gui/Placement.h
@@ -25,7 +25,7 @@
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Gui/PrefWidgets.cpp b/src/Gui/PrefWidgets.cpp
index 445392c041..abd41dda7c 100644
--- a/src/Gui/PrefWidgets.cpp
+++ b/src/Gui/PrefWidgets.cpp
@@ -169,6 +169,15 @@ void PrefWidget::failedToRestore(const QString& name) const
PrefSpinBox::PrefSpinBox ( QWidget * parent )
: QSpinBox(parent), PrefWidget()
{
+ setFocusPolicy(Qt::FocusPolicy::StrongFocus);
+}
+
+void PrefSpinBox::wheelEvent(QWheelEvent *event)
+{
+ if (hasFocus())
+ QSpinBox::wheelEvent(event);
+ else
+ event->ignore();
}
PrefSpinBox::~PrefSpinBox() = default;
@@ -201,6 +210,15 @@ void PrefSpinBox::savePreferences()
PrefDoubleSpinBox::PrefDoubleSpinBox ( QWidget * parent )
: QDoubleSpinBox(parent), PrefWidget()
{
+ setFocusPolicy(Qt::FocusPolicy::StrongFocus);
+}
+
+void PrefDoubleSpinBox::wheelEvent(QWheelEvent *event)
+{
+ if (hasFocus())
+ QDoubleSpinBox::wheelEvent(event);
+ else
+ event->ignore();
}
PrefDoubleSpinBox::~PrefDoubleSpinBox() = default;
@@ -332,6 +350,15 @@ void PrefFileChooser::savePreferences()
PrefComboBox::PrefComboBox ( QWidget * parent )
: QComboBox(parent), PrefWidget()
{
+ setFocusPolicy(Qt::FocusPolicy::StrongFocus);
+}
+
+void PrefComboBox::wheelEvent(QWheelEvent *event)
+{
+ if (hasFocus())
+ QComboBox::wheelEvent(event);
+ else
+ event->ignore();
}
PrefComboBox::~PrefComboBox() = default;
@@ -566,6 +593,15 @@ void PrefColorButton::savePreferences()
PrefUnitSpinBox::PrefUnitSpinBox ( QWidget * parent )
: QuantitySpinBox(parent), PrefWidget()
{
+ setFocusPolicy(Qt::FocusPolicy::StrongFocus);
+}
+
+void PrefUnitSpinBox::wheelEvent(QWheelEvent *event)
+{
+ if (hasFocus())
+ QuantitySpinBox::wheelEvent(event);
+ else
+ event->ignore();
}
PrefUnitSpinBox::~PrefUnitSpinBox() = default;
@@ -662,6 +698,7 @@ PrefQuantitySpinBox::PrefQuantitySpinBox (QWidget * parent)
: QuantitySpinBox(parent)
, d_ptr(new PrefQuantitySpinBoxPrivate())
{
+ setFocusPolicy(Qt::FocusPolicy::StrongFocus);
}
PrefQuantitySpinBox::~PrefQuantitySpinBox() = default;
@@ -672,7 +709,7 @@ void PrefQuantitySpinBox::contextMenuEvent(QContextMenuEvent *event)
QMenu *editMenu = lineEdit()->createStandardContextMenu();
editMenu->setTitle(tr("Edit"));
- std::unique_ptr menu(new QMenu(QString::fromLatin1("PrefQuantitySpinBox")));
+ std::unique_ptr menu(new QMenu(QStringLiteral("PrefQuantitySpinBox")));
menu->addMenu(editMenu);
menu->addSeparator();
@@ -708,6 +745,14 @@ void PrefQuantitySpinBox::contextMenuEvent(QContextMenuEvent *event)
}
}
+void PrefQuantitySpinBox::wheelEvent(QWheelEvent *event)
+{
+ if (hasFocus())
+ QuantitySpinBox::wheelEvent(event);
+ else
+ event->ignore();
+}
+
void PrefQuantitySpinBox::restorePreferences()
{
Q_D(PrefQuantitySpinBox);
diff --git a/src/Gui/PrefWidgets.h b/src/Gui/PrefWidgets.h
index d1f1b5ede3..c805f7d063 100644
--- a/src/Gui/PrefWidgets.h
+++ b/src/Gui/PrefWidgets.h
@@ -123,6 +123,7 @@ public:
~PrefSpinBox() override;
protected:
+ void wheelEvent(QWheelEvent *event) override;
// restore from/save to parameters
void restorePreferences() override;
void savePreferences() override;
@@ -143,6 +144,7 @@ public:
~PrefDoubleSpinBox() override;
protected:
+ void wheelEvent(QWheelEvent *event) override;
// restore from/save to parameters
void restorePreferences() override;
void savePreferences() override;
@@ -236,6 +238,7 @@ public:
~PrefComboBox() override;
protected:
+ void wheelEvent(QWheelEvent *event) override;
// restore from/save to parameters
void restorePreferences() override;
void savePreferences() override;
@@ -351,6 +354,7 @@ public:
~PrefUnitSpinBox() override;
protected:
+ void wheelEvent(QWheelEvent *event) override;
// restore from/save to parameters
void restorePreferences() override;
void savePreferences() override;
@@ -391,6 +395,7 @@ public:
protected:
void contextMenuEvent(QContextMenuEvent * event) override;
+ void wheelEvent(QWheelEvent *event) override;
// restore from/save to parameters
void restorePreferences() override;
void savePreferences() override;
diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp
index d443926d8b..56581e9a4d 100644
--- a/src/Gui/PreferencePackManager.cpp
+++ b/src/Gui/PreferencePackManager.cpp
@@ -29,7 +29,7 @@
# include
#endif
-#include
+#include
#include
#include
@@ -48,15 +48,15 @@
using namespace Gui;
using namespace xercesc;
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
-static boost::filesystem::path getSavedPrefPacksPath()
+static std::filesystem::path getSavedPrefPacksPath()
{
return fs::path(Base::FileInfo::stringToPath(App::Application::getUserAppDataDir()))
/ "SavedPreferencePacks";
}
-static boost::filesystem::path getResourcePrefPacksPath()
+static std::filesystem::path getResourcePrefPacksPath()
{
return fs::path(Base::FileInfo::stringToPath(App::Application::getResourceDir())) / "Gui"
/ "PreferencePacks";
@@ -69,17 +69,17 @@ PreferencePack::PreferencePack(const fs::path& path, const App::Metadata& metada
throw std::runtime_error{ "Cannot access " + path.string() };
}
- auto qssPaths = QDir::searchPaths(QString::fromUtf8("qss"));
- auto cssPaths = QDir::searchPaths(QString::fromUtf8("css"));
- auto overlayPaths = QDir::searchPaths(QString::fromUtf8("overlay"));
+ auto qssPaths = QDir::searchPaths(QStringLiteral("qss"));
+ auto cssPaths = QDir::searchPaths(QStringLiteral("css"));
+ auto overlayPaths = QDir::searchPaths(QStringLiteral("overlay"));
qssPaths.append(QString::fromStdString(Base::FileInfo::pathToString(_path)));
cssPaths.append(QString::fromStdString(Base::FileInfo::pathToString(_path)));
overlayPaths.append(QString::fromStdString(Base::FileInfo::pathToString(_path) + "/overlay"));
- QDir::setSearchPaths(QString::fromUtf8("qss"), qssPaths);
- QDir::setSearchPaths(QString::fromUtf8("css"), cssPaths);
- QDir::setSearchPaths(QString::fromUtf8("overlay"), overlayPaths);
+ QDir::setSearchPaths(QStringLiteral("qss"), qssPaths);
+ QDir::setSearchPaths(QStringLiteral("css"), cssPaths);
+ QDir::setSearchPaths(QStringLiteral("overlay"), overlayPaths);
}
std::string PreferencePack::name() const
@@ -228,29 +228,25 @@ void Gui::PreferencePackManager::AddPackToMetadata(const std::string &packName)
}
void Gui::PreferencePackManager::importConfig(const std::string& packName,
- const boost::filesystem::path& path)
+ const std::filesystem::path& path)
{
AddPackToMetadata(packName);
auto savedPreferencePacksDirectory = getSavedPreferencePacksPath();
auto cfgFilename = savedPreferencePacksDirectory / packName / (packName + ".cfg");
-#if BOOST_VERSION >= 107400
fs::copy_file(path, cfgFilename, fs::copy_options::overwrite_existing);
-#else
- fs::copy_file(path, cfgFilename, fs::copy_option::overwrite_if_exists);
-#endif
rescan();
}
// TODO(Shvedov): Is this suitable place for this method? It is more generic,
// and maybe more suitable place at Application?
-std::vector Gui::PreferencePackManager::modPaths() const
+std::vector Gui::PreferencePackManager::modPaths() const
{
auto userModPath = fs::path(Base::FileInfo::stringToPath(App::Application::getUserAppDataDir())) / "Mod";
auto& config = App::Application::Config();
auto additionalModules = config.find("AdditionalModulePaths");
- std::vector result;
+ std::vector result;
if (additionalModules != config.end()) {
boost::split(result,
@@ -262,12 +258,12 @@ std::vector Gui::PreferencePackManager::modPaths() cons
return result;
}
-boost::filesystem::path Gui::PreferencePackManager::getSavedPreferencePacksPath() const
+std::filesystem::path Gui::PreferencePackManager::getSavedPreferencePacksPath() const
{
return getSavedPrefPacksPath();
}
-boost::filesystem::path Gui::PreferencePackManager::getResourcePreferencePacksPath() const
+std::filesystem::path Gui::PreferencePackManager::getResourcePreferencePacksPath() const
{
return getResourcePrefPacksPath();
}
@@ -309,7 +305,7 @@ void Gui::PreferencePackManager::FindPreferencePacksInPackage(const fs::path &mo
}
}
-void PreferencePackManager::TryFindPreferencePacksInPackage(const boost::filesystem::path& mod)
+void PreferencePackManager::TryFindPreferencePacksInPackage(const std::filesystem::path& mod)
{
auto packageMetadataFile = mod / "package.xml";
static const auto modDirectory = fs::path(Base::FileInfo::stringToPath(App::Application::getUserAppDataDir())) / "Mod" / "SavedPreferencePacks";
@@ -625,6 +621,16 @@ void Gui::PreferencePackManager::BackupCurrentConfig() const
App::GetApplication().GetUserParameter().SaveDocument(Base::FileInfo::pathToString(filename).c_str());
}
+// FIXME: Replace with more accurate C++20 solution once its usable: https://stackoverflow.com/a/68593141
+template
+static std::time_t to_time_t(TP tp)
+{
+ using namespace std::chrono;
+ auto sctp = time_point_cast(tp - TP::clock::now()
+ + system_clock::now());
+ return system_clock::to_time_t(sctp);
+}
+
void Gui::PreferencePackManager::DeleteOldBackups() const
{
constexpr auto oneWeek = 60.0 * 60.0 * 24.0 * 7.0;
@@ -632,7 +638,7 @@ void Gui::PreferencePackManager::DeleteOldBackups() const
auto backupDirectory = getSavedPreferencePacksPath() / "Backups";
if (fs::exists(backupDirectory) && fs::is_directory(backupDirectory)) {
for (const auto& backup : fs::directory_iterator(backupDirectory)) {
- if (std::difftime(now, fs::last_write_time(backup)) > oneWeek) {
+ if (std::difftime(now, to_time_t(fs::last_write_time(backup))) > oneWeek) {
try {
fs::remove(backup);
}
@@ -642,9 +648,10 @@ void Gui::PreferencePackManager::DeleteOldBackups() const
}
}
-std::vector Gui::PreferencePackManager::configBackups() const
+// FIXME: Replace with more accurate C++20 solution once its usable: https://stackoverflow.com/a/68593141
+std::vector Gui::PreferencePackManager::configBackups() const
{
- std::vector results;
+ std::vector results;
auto backupDirectory = getSavedPreferencePacksPath() / "Backups";
if (fs::exists(backupDirectory) && fs::is_directory(backupDirectory)) {
for (const auto& backup : fs::directory_iterator(backupDirectory)) {
diff --git a/src/Gui/PreferencePackManager.h b/src/Gui/PreferencePackManager.h
index bb87917447..5250b3407b 100644
--- a/src/Gui/PreferencePackManager.h
+++ b/src/Gui/PreferencePackManager.h
@@ -44,7 +44,7 @@ namespace Gui {
* \param path A path to a mod directory that contains a preferencePack
* \param metadata The metadata from the package.xml file describing this preferencePack
*/
- PreferencePack(const boost::filesystem::path& path, const App::Metadata& metadata);
+ PreferencePack(const std::filesystem::path& path, const App::Metadata& metadata);
~PreferencePack() = default;
@@ -68,7 +68,7 @@ namespace Gui {
void applyConfigChanges() const;
- boost::filesystem::path _path;
+ std::filesystem::path _path;
App::Metadata _metadata;
};
@@ -168,7 +168,7 @@ namespace Gui {
struct TemplateFile {
std::string group; // Generally the Add-On/Mod/Package name
std::string name;
- boost::filesystem::path path;
+ std::filesystem::path path;
};
/**
@@ -184,37 +184,37 @@ namespace Gui {
/**
* Get a list of all available config file backups. Backups are currently stored for one week.
*/
- std::vector configBackups() const;
+ std::vector configBackups() const;
/**
* Import an existing config file as a preference pack with a given name.
*/
- void importConfig(const std::string &packName, const boost::filesystem::path &path);
+ void importConfig(const std::string &packName, const std::filesystem::path &path);
/**
* Get a list of all mod directories.
*/
- std::vector modPaths() const;
+ std::vector modPaths() const;
/**
* Get the path to the saved preference packs.
*/
- boost::filesystem::path getSavedPreferencePacksPath() const;
+ std::filesystem::path getSavedPreferencePacksPath() const;
/**
* Get the path to the preference packs of the resource directory.
*/
- boost::filesystem::path getResourcePreferencePacksPath() const;
+ std::filesystem::path getResourcePreferencePacksPath() const;
/**
* Collect all preference packs of a directory.
*/
- std::vector getPacksFromDirectory(const boost::filesystem::path& path) const;
+ std::vector getPacksFromDirectory(const std::filesystem::path& path) const;
private:
- void FindPreferencePacksInPackage(const boost::filesystem::path& mod);
- void TryFindPreferencePacksInPackage(const boost::filesystem::path& mod);
+ void FindPreferencePacksInPackage(const std::filesystem::path& mod);
+ void TryFindPreferencePacksInPackage(const std::filesystem::path& mod);
void BackupCurrentConfig() const;
@@ -222,7 +222,7 @@ namespace Gui {
void AddPackToMetadata(const std::string &packName) const;
- std::vector _preferencePackPaths;
+ std::vector _preferencePackPaths;
std::vector _templateFiles;
std::map _preferencePacks;
mutable std::mutex _mutex;
diff --git a/src/Gui/PreferencePackTemplates/View.cfg b/src/Gui/PreferencePackTemplates/View.cfg
index a7357e70cb..8c2392fb2c 100644
--- a/src/Gui/PreferencePackTemplates/View.cfg
+++ b/src/Gui/PreferencePackTemplates/View.cfg
@@ -14,6 +14,9 @@
+
+
+
diff --git a/src/Gui/PreferencePacks/FreeCAD Classic/FreeCAD Classic.cfg b/src/Gui/PreferencePacks/FreeCAD Classic/FreeCAD Classic.cfg
index f1b0e88734..d70940da22 100644
--- a/src/Gui/PreferencePacks/FreeCAD Classic/FreeCAD Classic.cfg
+++ b/src/Gui/PreferencePacks/FreeCAD Classic/FreeCAD Classic.cfg
@@ -71,6 +71,12 @@
+
+ #feff9e
+ #000000
+ #000000
+ #000000
+
@@ -125,6 +131,7 @@