7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 06:16:56 +00:00

Fix color theme load logic in jobs

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19754
This commit is contained in:
Jon Evans 2025-01-27 19:00:35 -05:00
parent e417b209a0
commit 8a7bf78b38
4 changed files with 25 additions and 12 deletions

View File

@ -113,7 +113,7 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aEditFrame, wxWindow* aParent,
{
SetTitle( aJob->GetSettingsDialogTitle() );
PCB_PLOTTER::PlotJobToPlotOpts( m_plotOpts, m_job );
PCB_PLOTTER::PlotJobToPlotOpts( m_plotOpts, m_job, m_messagesPanel->Reporter() );
m_messagesPanel->Hide();
m_browseButton->Hide();

View File

@ -325,7 +325,8 @@ LSEQ PCB_PLOTTER::getPlotSequence( PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllL
}
void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT* aJob )
void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT* aJob,
REPORTER& aReporter )
{
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER )
{
@ -408,15 +409,26 @@ void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT
break;
}
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
wxString theme = aJob->m_colorTheme;
// Theme may be empty when running from a job in GUI context, so use the GUI settings.
if( theme.IsEmpty() )
theme = wxT( "pcbnew" );
{
PCBNEW_SETTINGS* pcbSettings = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
theme = pcbSettings->m_ColorTheme;
}
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( theme );
aOpts.SetColorSettings( mgr.GetColorSettings( cfg->m_ColorTheme ) );
COLOR_SETTINGS* colors = mgr.GetColorSettings( aJob->m_colorTheme );
if( colors->GetFilename() != theme )
{
aReporter.Report( wxString::Format(
wxT( "Color theme '%s' not found, will use theme from PCB Editor settings.\n" ),
theme ),
RPT_SEVERITY_WARNING );
}
aOpts.SetColorSettings( colors );
aOpts.SetOutputDirectory( aJob->GetConfiguredOutputPath() );
}
}

View File

@ -70,7 +70,8 @@ public:
/**
* Translate a JOB to PCB_PLOT_PARAMS
*/
static void PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT* aJob );
static void PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT* aJob,
REPORTER& aReporter );
protected:
BOARD* m_board;
@ -83,4 +84,4 @@ private:
*/
LSEQ getPlotSequence( PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllLayersSeq );
};
};

View File

@ -740,7 +740,7 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
brd->SynchronizeProperties();
PCB_PLOT_PARAMS plotOpts;
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aSvgJob );
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aSvgJob, *m_reporter );
PCB_PLOTTER plotter( brd, m_reporter, plotOpts );
@ -813,7 +813,7 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
}
PCB_PLOT_PARAMS plotOpts;
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aDxfJob );
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aDxfJob, *m_reporter);
PCB_PLOTTER plotter( brd, m_reporter, plotOpts );
@ -873,7 +873,7 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
}
PCB_PLOT_PARAMS plotOpts;
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aPdfJob );
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aPdfJob, *m_reporter );
int returnCode = CLI::EXIT_CODES::OK;