diff --git a/Clients/ParaView/Testing/XML/PythonDefaultSaveState.xml b/Clients/ParaView/Testing/XML/PythonDefaultSaveState.xml
new file mode 100644
index 0000000000000000000000000000000000000000..619c7617d9c9ff5cd4c1dd2ae6c904351319e4ca
--- /dev/null
+++ b/Clients/ParaView/Testing/XML/PythonDefaultSaveState.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Clients/ParaView/Testing/XML/test.python.cmake b/Clients/ParaView/Testing/XML/test.python.cmake
index f4c8eae0c9e4901723902db77727f1a46370301d..4a4dc17c0d38e64cff3f523fcb73833b6f1401ed 100644
--- a/Clients/ParaView/Testing/XML/test.python.cmake
+++ b/Clients/ParaView/Testing/XML/test.python.cmake
@@ -6,6 +6,7 @@ list(APPEND TESTS_WITHOUT_BASELINES
MacroEditor.xml
MultipleNumberOfComponents.xml
ProgrammableSourcePythonEditorLink.xml
+ PythonDefaultSaveState.xml
PythonEditorTab.xml
PythonResetSessionMacro.xml
SpreadSheetNullArrayName.xml # needs programmable filter
diff --git a/Qt/ApplicationComponents/pqAutoSaveBehavior.cxx b/Qt/ApplicationComponents/pqAutoSaveBehavior.cxx
index 3a5bfd404e89cf2006bc3474088c4db4b8452c03..8fbeef76fd1395ef382ee504a69ba5900227304c 100644
--- a/Qt/ApplicationComponents/pqAutoSaveBehavior.cxx
+++ b/Qt/ApplicationComponents/pqAutoSaveBehavior.cxx
@@ -76,19 +76,6 @@ void pqAutoSaveBehavior::setAutoSaveSetting(bool enable)
settings->alertSettingsModified();
}
-//-----------------------------------------------------------------------------
-QString pqAutoSaveBehavior::formatToExtension(StateFormat format)
-{
- switch (format)
- {
- case StateFormat::Python:
- return "py";
- case StateFormat::PVSM:
- default:
- return "pvsm";
- }
-}
-
//-----------------------------------------------------------------------------
void pqAutoSaveBehavior::updateConnections()
{
@@ -145,12 +132,15 @@ QString pqAutoSaveBehavior::getBakStatePath()
}
//-----------------------------------------------------------------------------
-pqAutoSaveBehavior::StateFormat pqAutoSaveBehavior::getStateFormat()
+pqApplicationCore::StateFileFormat pqAutoSaveBehavior::getStateFormat()
{
pqSettings* settings = pqApplicationCore::instance()->settings();
- int value = settings->value(::AUTOSAVE_FORMAT_KEY, static_cast(StateFormat::PVSM)).toInt();
+ int value =
+ settings
+ ->value(::AUTOSAVE_FORMAT_KEY, static_cast(pqApplicationCore::StateFileFormat::PVSM))
+ .toInt();
- return StateFormat(value);
+ return pqApplicationCore::StateFileFormat(value);
}
//-----------------------------------------------------------------------------
@@ -164,8 +154,8 @@ QString pqAutoSaveBehavior::getStatePath(bool bak)
state = state.arg("bak.%1");
}
- StateFormat format = pqAutoSaveBehavior::getStateFormat();
- QString stateExtension = pqAutoSaveBehavior::formatToExtension(format);
+ pqApplicationCore::StateFileFormat format = pqAutoSaveBehavior::getStateFormat();
+ QString stateExtension = pqApplicationCore::stateFileFormatToExtension(format);
state = state.arg(stateExtension);
return state;
}
@@ -208,8 +198,8 @@ void pqAutoSaveBehavior::saveState()
QFile::copy(newState, bakState);
}
- StateFormat format = pqAutoSaveBehavior::getStateFormat();
- if (format == StateFormat::Python)
+ pqApplicationCore::StateFileFormat format = pqAutoSaveBehavior::getStateFormat();
+ if (format == pqApplicationCore::StateFileFormat::Python)
{
vtkSmartPointer options;
options.TakeReference(pqSaveStateReaction::createPythonStateOptions(false));
diff --git a/Qt/ApplicationComponents/pqAutoSaveBehavior.h b/Qt/ApplicationComponents/pqAutoSaveBehavior.h
index 9be7b3005247bf70cb1dbd2c111f53070f2740f5..db87ee4b504e0913e0badfccd2bb0bc030178a23 100644
--- a/Qt/ApplicationComponents/pqAutoSaveBehavior.h
+++ b/Qt/ApplicationComponents/pqAutoSaveBehavior.h
@@ -10,6 +10,7 @@
#include
#include "pqUndoStack.h"
+#include "vtkSMSessionProxyManager.h"
/**
* @ingroup Behaviors
@@ -34,12 +35,6 @@ public:
pqAutoSaveBehavior(QObject* parent = nullptr);
~pqAutoSaveBehavior() override;
- enum class StateFormat : unsigned int
- {
- PVSM = 0,
- Python = 1
- };
-
public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
/**
* Saves the state.
@@ -57,13 +52,6 @@ public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
*/
static QDir getStateDirectory();
- /**
- * Return the extension for the given format
- * See StateFormat.
- * Default to pvsm
- */
- static QString formatToExtension(StateFormat format);
-
/**
* Return true if the AutoSave settings is enabled.
*/
@@ -78,7 +66,7 @@ public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
* Return the file format for the statefile, as defined in the settings.
* Default to StateFormat::PVSM.
*/
- static StateFormat getStateFormat();
+ static pqApplicationCore::StateFileFormat getStateFormat();
private Q_SLOTS:
/**
diff --git a/Qt/ApplicationComponents/pqSaveStateReaction.cxx b/Qt/ApplicationComponents/pqSaveStateReaction.cxx
index fe18244a82951e087ffa1fb00aa48be74662e142..8a9fe49d2429fbc7803016804d968778451eeaad 100644
--- a/Qt/ApplicationComponents/pqSaveStateReaction.cxx
+++ b/Qt/ApplicationComponents/pqSaveStateReaction.cxx
@@ -9,6 +9,7 @@
#include "pqFileDialog.h"
#include "pqProxyWidgetDialog.h"
#include "pqServer.h"
+#include "pqSettings.h"
#include "pqStandardRecentlyUsedResourceLoaderImplementation.h"
#include "pqUndoStack.h"
#include "vtkNew.h"
@@ -25,6 +26,11 @@
#include
+namespace
+{
+static const QString DEFAULT_SAVE_STATE_FORMAT_KEY = "GeneralSettings.DefaultSaveStateFormat";
+};
+
//-----------------------------------------------------------------------------
pqSaveStateReaction::pqSaveStateReaction(QAction* parentObject)
: Superclass(parentObject)
@@ -53,10 +59,27 @@ bool pqSaveStateReaction::saveState()
//-----------------------------------------------------------------------------
bool pqSaveStateReaction::saveState(pqServer* server)
{
- QString fileExt = tr("ParaView state file") + QString(" (*.pvsm);;");
+ pqSettings* settings = pqApplicationCore::instance()->settings();
+ unsigned int value = settings->value(::DEFAULT_SAVE_STATE_FORMAT_KEY, 0).toInt();
+ pqApplicationCore::StateFileFormat format = pqApplicationCore::StateFileFormat(value);
+
+ const QString pvsmExt = tr("ParaView state file") + QString(" (*.pvsm);;");
+ QString pyExt;
+
#if VTK_MODULE_ENABLE_ParaView_pqPython
- fileExt += tr("Python state file") + QString(" (*.py);;");
+ pyExt += tr("Python state file") + QString(" (*.py);;");
#endif
+
+ QString fileExt;
+ // Order matters as first argument is default
+ if (format == pqApplicationCore::StateFileFormat::PVSM)
+ {
+ fileExt = pvsmExt + pyExt;
+ }
+ else
+ {
+ fileExt = pyExt + pvsmExt;
+ }
fileExt += tr("All Files") + QString(" (*)");
pqFileDialog fileDialog(
diff --git a/Qt/ApplicationComponents/pqTraceReaction.cxx b/Qt/ApplicationComponents/pqTraceReaction.cxx
index e93b4edaba9f5368cf62405f453d1f690871b340..7807492f27f8368fa85c9e8bcbdaeea21ab063cc 100644
--- a/Qt/ApplicationComponents/pqTraceReaction.cxx
+++ b/Qt/ApplicationComponents/pqTraceReaction.cxx
@@ -101,7 +101,7 @@ void pqTraceReaction::start()
}
this->AutoSavePythonEnabled = pqAutoSaveBehavior::autoSaveSettingEnabled() &&
- pqAutoSaveBehavior::getStateFormat() == pqAutoSaveBehavior::StateFormat::Python;
+ pqAutoSaveBehavior::getStateFormat() == pqApplicationCore::StateFileFormat::Python;
if (this->AutoSavePythonEnabled)
{
auto userAnswer = QMessageBox::warning(pqCoreUtilities::mainWidget(),
diff --git a/Qt/Core/pqApplicationCore.cxx b/Qt/Core/pqApplicationCore.cxx
index c8e2f6ac6ccc730a0327f40296ea76a7aef1ec2b..5b7a47173e5d274809f14e945d35dfc7581f2c71 100644
--- a/Qt/Core/pqApplicationCore.cxx
+++ b/Qt/Core/pqApplicationCore.cxx
@@ -303,6 +303,19 @@ QObject* pqApplicationCore::manager(const QString& function)
return nullptr;
}
+//-----------------------------------------------------------------------------
+QString pqApplicationCore::stateFileFormatToExtension(pqApplicationCore::StateFileFormat format)
+{
+ switch (format)
+ {
+ case pqApplicationCore::StateFileFormat::Python:
+ return "py";
+ case pqApplicationCore::StateFileFormat::PVSM:
+ default:
+ return "pvsm";
+ }
+}
+
//-----------------------------------------------------------------------------
bool pqApplicationCore::saveState(const QString& filename, vtkTypeUInt32 location)
{
diff --git a/Qt/Core/pqApplicationCore.h b/Qt/Core/pqApplicationCore.h
index 120af1aea275dd012928226bc30eda0857745551..81e169bd2650a5e71a559b6ad4cca7e6af7754f1 100644
--- a/Qt/Core/pqApplicationCore.h
+++ b/Qt/Core/pqApplicationCore.h
@@ -215,6 +215,22 @@ public:
*/
void clearSettings();
+ /**
+ * Enum to capture possible Save State file formats.
+ */
+ enum class StateFileFormat : unsigned int
+ {
+ PVSM = 0,
+ Python = 1
+ };
+
+ /**
+ * Return the extension for the given format
+ * See StateFileFormat.
+ * Default to pvsm
+ */
+ static QString stateFileFormatToExtension(pqApplicationCore::StateFileFormat format);
+
/**
* Save the ServerManager state to a XML element.
*/
diff --git a/Remoting/Settings/Resources/utilities_settings.xml b/Remoting/Settings/Resources/utilities_settings.xml
index 5fb86cff759d9af64be6bef88e072e408886ca11..0c6a8e3bffabd4d2b1c7fdd17ac47e2097a67fc6 100644
--- a/Remoting/Settings/Resources/utilities_settings.xml
+++ b/Remoting/Settings/Resources/utilities_settings.xml
@@ -34,6 +34,23 @@
+
+
+ Set the default save state format.
+ `pvsm` is the standard xml-based statefile. `py` is the Python version.
+
+
+
+
+
+
+
+
+
+