7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-02 00:26:45 +00:00

Added a button to open output directory in plot dialog

Shows a bitmap button next to the output location string, allowing the user to quickly view the generated file location

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17659
This commit is contained in:
IkomaSo 2024-10-27 23:33:24 +00:00 committed by Seth Hillbrand
parent 26094762ee
commit f5765bac7f
13 changed files with 210 additions and 4 deletions

View File

@ -84,6 +84,7 @@ void BuildBitmapInfo( std::unordered_map<BITMAPS, std::vector<BITMAP_INFO>>& aBi
aBitmapInfoCache[BITMAPS::small_edit].emplace_back( BITMAPS::small_edit, wxT( "small_edit_16.png" ), 16, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_folder].emplace_back( BITMAPS::small_folder, wxT( "small_folder_16.png" ), 16, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_library].emplace_back( BITMAPS::small_library, wxT( "small_library_16.png" ), 16, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_new_window].emplace_back( BITMAPS::small_new_window, wxT( "small_new_window_16.png" ), 16, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_plus].emplace_back( BITMAPS::small_plus, wxT( "small_plus_16.png" ), 16, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_refresh].emplace_back( BITMAPS::small_refresh, wxT( "small_refresh_16.png" ), 16, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_sort_desc].emplace_back( BITMAPS::small_sort_desc, wxT( "small_sort_desc_16.png" ), 16, wxT( "light" ) );
@ -166,6 +167,7 @@ void BuildBitmapInfo( std::unordered_map<BITMAPS, std::vector<BITMAP_INFO>>& aBi
aBitmapInfoCache[BITMAPS::small_edit].emplace_back( BITMAPS::small_edit, wxT( "small_edit_dark_16.png" ), 16, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_folder].emplace_back( BITMAPS::small_folder, wxT( "small_folder_dark_16.png" ), 16, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_library].emplace_back( BITMAPS::small_library, wxT( "small_library_dark_16.png" ), 16, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_new_window].emplace_back( BITMAPS::small_new_window, wxT( "small_new_window_dark_16.png" ), 16, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_plus].emplace_back( BITMAPS::small_plus, wxT( "small_plus_dark_16.png" ), 16, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_refresh].emplace_back( BITMAPS::small_refresh, wxT( "small_refresh_dark_16.png" ), 16, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_sort_desc].emplace_back( BITMAPS::small_sort_desc, wxT( "small_sort_desc_dark_16.png" ), 16, wxT( "dark" ) );
@ -248,6 +250,7 @@ void BuildBitmapInfo( std::unordered_map<BITMAPS, std::vector<BITMAP_INFO>>& aBi
aBitmapInfoCache[BITMAPS::small_edit].emplace_back( BITMAPS::small_edit, wxT( "small_edit_32.png" ), 32, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_folder].emplace_back( BITMAPS::small_folder, wxT( "small_folder_32.png" ), 32, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_library].emplace_back( BITMAPS::small_library, wxT( "small_library_32.png" ), 32, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_new_window].emplace_back( BITMAPS::small_new_window, wxT( "small_new_window_32.png" ), 32, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_plus].emplace_back( BITMAPS::small_plus, wxT( "small_plus_32.png" ), 32, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_refresh].emplace_back( BITMAPS::small_refresh, wxT( "small_refresh_32.png" ), 32, wxT( "light" ) );
aBitmapInfoCache[BITMAPS::small_sort_desc].emplace_back( BITMAPS::small_sort_desc, wxT( "small_sort_desc_32.png" ), 32, wxT( "light" ) );
@ -330,6 +333,7 @@ void BuildBitmapInfo( std::unordered_map<BITMAPS, std::vector<BITMAP_INFO>>& aBi
aBitmapInfoCache[BITMAPS::small_edit].emplace_back( BITMAPS::small_edit, wxT( "small_edit_dark_32.png" ), 32, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_folder].emplace_back( BITMAPS::small_folder, wxT( "small_folder_dark_32.png" ), 32, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_library].emplace_back( BITMAPS::small_library, wxT( "small_library_dark_32.png" ), 32, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_new_window].emplace_back( BITMAPS::small_new_window, wxT( "small_new_window_dark_32.png" ), 32, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_plus].emplace_back( BITMAPS::small_plus, wxT( "small_plus_dark_32.png" ), 32, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_refresh].emplace_back( BITMAPS::small_refresh, wxT( "small_refresh_dark_32.png" ), 32, wxT( "dark" ) );
aBitmapInfoCache[BITMAPS::small_sort_desc].emplace_back( BITMAPS::small_sort_desc, wxT( "small_sort_desc_dark_32.png" ), 32, wxT( "dark" ) );

View File

@ -566,6 +566,7 @@ enum class BITMAPS : unsigned int
small_edit,
small_folder,
small_library,
small_new_window,
small_plus,
small_refresh,
small_sort_desc,

View File

@ -271,6 +271,7 @@ void DIALOG_PLOT::init_Dialog()
m_zoneFillCheck->SetValue( cfg->m_Plot.check_zones_before_plotting );
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
m_openDirButton->SetBitmap( KiBitmapBundle( BITMAPS::small_new_window ) );
// m_PSWidthAdjust is stored in mm in user config
m_PSWidthAdjust = KiROUND( cfg->m_Plot.ps_fine_width_adjust * pcbIUScale.IU_PER_MM );
@ -1387,6 +1388,28 @@ void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
}
void DIALOG_PLOT::onOpenOutputDirectory( wxCommandEvent& event )
{
std::function<bool( wxString* )> textResolver = [&]( wxString* token ) -> bool
{
return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
};
wxString path = m_outputDirectoryName->GetValue();
path = ExpandTextVars( path, &textResolver );
path = ExpandEnvVarSubstitutions( path, &Prj() );
path = Prj().AbsolutePath( path );
if( !wxDirExists( path ) )
{
DisplayError( this, wxString::Format( _( "Directory '%s' does not exist." ), path ) );
return;
}
wxLaunchDefaultApplication( path );
}
void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
{
PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );

View File

@ -59,6 +59,7 @@ private:
void CreateDrillFile( wxCommandEvent& event ) override;
void OnGerberX2Checked( wxCommandEvent& event ) override;
void onRunDRC( wxCommandEvent& event ) override;
void onOpenOutputDirectory( wxCommandEvent& event ) override;
void onBoardSetup( wxHyperlinkEvent& aEvent ) override;
void onPlotAllListMoveUp( wxCommandEvent& aEvent );

View File

@ -44,8 +44,11 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
bupperSizer->Add( m_outputDirectoryName, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
m_browseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
bupperSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bupperSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_openDirButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
m_openDirButton->SetToolTip(_("Open output directory"));
bupperSizer->Add( m_openDirButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_MainSizer->Add( bupperSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
@ -460,10 +463,8 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_sizerButtons->Add( m_sdbSizer1, 1, wxEXPAND, 5 );
m_MainSizer->Add( m_sizerButtons, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( m_MainSizer );
this->Layout();
m_MainSizer->Fit( this );
@ -474,6 +475,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PLOT_BASE::OnInitDialog ) );
m_plotFormatOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::SetPlotFormat ), NULL, this );
m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnOutputDirectoryBrowseClicked ), NULL, this );
m_openDirButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onOpenOutputDirectory ), NULL, this );
m_plotDNP->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onDNPCheckbox ), NULL, this );
m_sketchPadsOnFabLayers->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onSketchPads ), NULL, this );
m_scaleOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnSetScaleOpt ), NULL, this );
@ -491,6 +493,7 @@ DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE()
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PLOT_BASE::OnInitDialog ) );
m_plotFormatOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::SetPlotFormat ), NULL, this );
m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnOutputDirectoryBrowseClicked ), NULL, this );
m_openDirButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onOpenOutputDirectory ), NULL, this );
m_plotDNP->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onDNPCheckbox ), NULL, this );
m_sketchPadsOnFabLayers->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onSketchPads ), NULL, this );
m_scaleOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnSetScaleOpt ), NULL, this );
@ -500,5 +503,4 @@ DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE()
m_buttonDRC->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onRunDRC ), NULL, this );
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::CreateDrillFile ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this );
}

View File

@ -58,6 +58,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextDir;
wxTextCtrl* m_outputDirectoryName;
STD_BITMAP_BUTTON* m_browseButton;
STD_BITMAP_BUTTON* m_openDirButton;
wxBoxSizer* bmiddleSizer;
wxStaticBoxSizer* m_LayersSizer;
wxCheckListBox* m_layerCheckListBox;
@ -142,6 +143,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
virtual void OnGerberX2Checked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnChangeDXFPlotMode( wxCommandEvent& event ) { event.Skip(); }
virtual void onRunDRC( wxCommandEvent& event ) { event.Skip(); }
virtual void onOpenOutputDirectory( wxCommandEvent& event ) { event.Skip(); }
virtual void CreateDrillFile( wxCommandEvent& event ) { event.Skip(); }
virtual void Plot( wxCommandEvent& event ) { event.Skip(); }

View File

@ -125,6 +125,7 @@ set( BMAPS_SMALL
small_edit
small_folder
small_library
small_new_window
small_plus
small_refresh
small_sort_desc

Binary file not shown.

After

(image error) Size: 158 B

Binary file not shown.

After

(image error) Size: 233 B

Binary file not shown.

After

(image error) Size: 180 B

Binary file not shown.

After

(image error) Size: 281 B

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333332"
version="1.1"
id="svg5"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="small_new_window.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="true"
inkscape:document-units="px"
showgrid="false"
inkscape:snap-object-midpoints="true"
units="px"
inkscape:zoom="25.710835"
inkscape:cx="6.3980808"
inkscape:cy="8.615045"
inkscape:window-width="1440"
inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;stroke:#ded3dd;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.3812499,0.26458333 h 1.5875 l 0,1.58749997"
id="path1561"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#ded3dd;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3.9687499,0.26458333 1.8520833,2.3812499"
id="path5866"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#ded3dd;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.8520833,0.79374997 H 0.52916665 V 3.7041665 H 3.4395832 V 2.3812499"
id="path8235"
sodipodi:nodetypes="ccccc" />
</g>
<metadata
id="metadata9">
<rdf:RDF>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

(image error) Size: 3.1 KiB

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333332"
version="1.1"
id="svg5"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="small_new_window.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="true"
inkscape:document-units="px"
showgrid="false"
inkscape:snap-object-midpoints="true"
units="px"
inkscape:zoom="25.710835"
inkscape:cx="-14.760314"
inkscape:cy="8.615045"
inkscape:window-width="1440"
inkscape:window-height="836"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;stroke:#545454;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.3812499,0.26458333 h 1.5875 l 0,1.58749997"
id="path1561"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#545454;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3.9687499,0.26458333 1.8520833,2.3812499"
id="path5866"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#545454;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.8520833,0.79374997 H 0.52916665 V 1.942215 3.7041665 H 3.4395832 V 2.3812499"
id="path8235"
sodipodi:nodetypes="cccccc" />
</g>
<metadata
id="metadata9">
<rdf:RDF>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

(image error) Size: 3.1 KiB