From 17623afd0e8202cf8b11f0954268d8715778b2d0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Nov 2020 14:37:46 +0100 Subject: [PATCH] #6799 Preferences : Clean white-space when using path to python/octave --- .../Application/RiaPreferences.cpp | 32 ++++++++++++++----- ApplicationCode/Application/RiaPreferences.h | 12 ++++--- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 2546913479..1c8ef4b40e 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -125,9 +125,9 @@ RiaPreferences::RiaPreferences( void ) CAF_PDM_InitField( &scriptEditorExecutable, "scriptEditorExecutable", defaultTextEditor, "Script Editor", "", "", "" ); scriptEditorExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &octaveExecutable, "octaveExecutable", QString( "octave" ), "Octave Executable Location", "", "", "" ); - octaveExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - octaveExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + CAF_PDM_InitField( &m_octaveExecutable, "octaveExecutable", QString( "octave" ), "Octave Executable Location", "", "", "" ); + m_octaveExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_octaveExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); CAF_PDM_InitField( &octaveShowHeaderInfoWhenExecutingScripts, "octaveShowHeaderInfoWhenExecutingScripts", @@ -138,9 +138,9 @@ RiaPreferences::RiaPreferences( void ) "" ); octaveShowHeaderInfoWhenExecutingScripts.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - CAF_PDM_InitField( &pythonExecutable, "pythonExecutable", QString( "python" ), "Python Executable Location", "", "", "" ); - pythonExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); - pythonExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + CAF_PDM_InitField( &m_pythonExecutable, "pythonExecutable", QString( "python" ), "Python Executable Location", "", "", "" ); + m_pythonExecutable.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_pythonExecutable.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); CAF_PDM_InitField( &showPythonDebugInfo, "pythonDebugInfo", false, "Show Python Debug Info", "", "", "" ); CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address", "", "", "" ); @@ -555,7 +555,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& else if ( uiConfigName == RiaPreferences::tabNameScripting() ) { caf::PdmUiGroup* octaveGroup = uiOrdering.addNewGroup( "Octave" ); - octaveGroup->add( &octaveExecutable ); + octaveGroup->add( &m_octaveExecutable ); octaveGroup->add( &octaveShowHeaderInfoWhenExecutingScripts ); #ifdef ENABLE_GRPC @@ -563,7 +563,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& pythonGroup->add( &enableGrpcServer ); pythonGroup->add( &showPythonDebugInfo ); pythonGroup->add( &defaultGrpcPortNumber ); - pythonGroup->add( &pythonExecutable ); + pythonGroup->add( &m_pythonExecutable ); #endif caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup( "Script files" ); scriptGroup->add( &scriptDirectories ); @@ -1104,6 +1104,22 @@ bool RiaPreferences::showGridBox() const return m_showGridBox(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferences::pythonExecutable() const +{ + return m_pythonExecutable().trimmed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferences::octaveExecutable() const +{ + return m_octaveExecutable().trimmed(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index c84d840f0a..4ac34795de 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -130,17 +130,17 @@ public: bool showInfoBox() const; bool showGridBox() const; + // Script paths + QString pythonExecutable() const; + QString octaveExecutable() const; + public: // Pdm Fields caf::PdmField enableGrpcServer; caf::PdmField defaultGrpcPortNumber; caf::PdmField scriptDirectories; caf::PdmField scriptEditorExecutable; - - caf::PdmField octaveExecutable; caf::PdmField octaveShowHeaderInfoWhenExecutingScripts; - - caf::PdmField pythonExecutable; caf::PdmField showPythonDebugInfo; caf::PdmField ssihubAddress; @@ -228,6 +228,10 @@ private: caf::PdmField m_searchPlotTemplateFoldersRecursively; caf::PdmField m_defaultPlotTemplate; + // Script paths + caf::PdmField m_octaveExecutable; + caf::PdmField m_pythonExecutable; + // Surface Import caf::PdmField m_surfaceImportResamplingDistance;