Add option to export to pdf without asking user

This commit is contained in:
Magne Sjaastad 2022-04-21 11:24:11 +02:00
parent 73f5c793e8
commit b6f7dd931e
3 changed files with 26 additions and 2 deletions

View File

@ -81,6 +81,9 @@ RiaPreferencesSystem::RiaPreferencesSystem()
CAF_PDM_InitField( &m_showProgressBar, "showProgressBar", true, "Show Progress Bar" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showProgressBar );
CAF_PDM_InitField( &m_showPdfExportDialog, "showPdfExportDialog", true, "Show PDF Export Dialog" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showPdfExportDialog );
CAF_PDM_InitField( &m_gtestFilter, "gtestFilter", QString(), "Unit Test Filter (gtest)" );
CAF_PDM_InitField( &m_eclipseReaderMode,
@ -195,6 +198,14 @@ bool RiaPreferencesSystem::showProgressBar() const
return m_showProgressBar();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesSystem::showPdfExportDialog() const
{
return m_showPdfExportDialog();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -227,6 +238,7 @@ void RiaPreferencesSystem::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd
uiOrdering.add( &m_includeFractureDebugInfoFile );
uiOrdering.add( &m_holoLensExportFolder );
uiOrdering.add( &m_showProgressBar );
uiOrdering.add( &m_showPdfExportDialog );
}
//--------------------------------------------------------------------------------------------------

View File

@ -53,6 +53,7 @@ public:
bool show3dInformation() const;
QString gtestFilter() const;
bool showProgressBar() const;
bool showPdfExportDialog() const;
EclipseTextFileReaderMode eclipseTextFileReaderMode() const;
@ -77,6 +78,7 @@ private:
caf::PdmField<bool> m_includeFractureDebugInfoFile;
caf::PdmField<QString> m_holoLensExportFolder;
caf::PdmField<bool> m_showPdfExportDialog;
caf::PdmField<bool> m_showProgressBar;
caf::PdmField<QString> m_gtestFilter;

View File

@ -21,6 +21,7 @@
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaPreferencesSystem.h"
#include "RicSnapshotFilenameGenerator.h"
#include "RicSnapshotViewToFileFeature.h"
@ -58,13 +59,22 @@ void RicSnapshotViewToPdfFeature::onActionTriggered( bool isChecked )
return;
}
RimPlotWindow* plotWindow = dynamic_cast<RimPlotWindow*>( viewWindow );
auto* plotWindow = dynamic_cast<RimPlotWindow*>( viewWindow );
if ( plotWindow )
{
QString fileExtension = "pdf";
QString defaultFileName = RicSnapshotFilenameGenerator::generateSnapshotFileName( viewWindow );
QString fileName = RicSnapshotViewToFileFeature::generateSaveFileName( defaultFileName, true, fileExtension );
QString fileName;
if ( RiaPreferencesSystem::current()->showPdfExportDialog() )
{
fileName = RicSnapshotViewToFileFeature::generateSaveFileName( defaultFileName, true, fileExtension );
}
else
{
fileName = defaultFileName + ".pdf";
}
if ( !fileName.isEmpty() )
{
if ( plotWindow && fileName.endsWith( "PDF", Qt::CaseInsensitive ) )