42#include <wx/filedlg.h>
46#define GRID_CELL_MARGIN 4
52 {
PT_FAB,
_(
"Fabrication plugins (%d)" ) },
60 m_parentFrame( parent ),
64 SetMinSize( FromDIP( GetMinSize() ) );
66 SetDoubleBuffered(
true );
70 m_pcm->SetDialogWindow(
this );
71 m_pcm->StopBackgroundUpdate();
79 const wxString& aVersion )
83 if( wxMessageBox( wxString::Format(
_(
"Are you sure you want to update pinned package "
84 "from version %s to %s?" ),
86 _(
"Confirm update" ), wxICON_QUESTION | wxYES_NO,
this )
115 wxString::Format( wxT(
"%s \u279C %s" ),
139 [
this](
const wxString& aPackageId,
const PCM_PACKAGE_STATE aState,
const bool aPinned )
141 m_pcm->SetPinned( aPackageId, aPinned );
154 wxString label = wxGetTranslation( entry.second );
159 m_dialogNotebook->SetPageText( 0, wxString::Format(
_(
"Repository (%d)" ), 0 ) );
167 { wxID_APPLY,
_(
"Apply Pending Changes" ) },
168 { wxID_CANCEL,
_(
"Discard Pending Changes" ) } } );
196 m_pcm->SaveInstalledPackages();
197 m_pcm->SetDialogWindow(
nullptr );
198 m_pcm->RunBackgroundUpdate();
213 || wxMessageBox(
_(
"Are you sure you want to close the package manager "
214 "and discard pending changes?" ),
215 _(
"Plugin and Content Manager" ), wxICON_QUESTION | wxYES_NO,
this )
225 wxCommandEvent
dummy;
235 std::vector<std::pair<wxString, wxString>> dialog_data;
236 std::vector<std::tuple<wxString, wxString, wxString>> repo_list =
m_pcm->GetRepositoryList();
238 for(
const auto& [
id, url,
name] : repo_list )
239 dialog_data.push_back( std::make_pair( url,
name ) );
241 dialog->
SetData( dialog_data );
245 dialog_data = dialog->
GetData();
246 m_pcm->SetRepositoryList( dialog_data );
248 if(
KICAD_SETTINGS* cfg = GetAppSettings<KICAD_SETTINGS>(
"kicad" ) )
249 cfg->m_PcmRepositories = std::move( dialog_data );
260 std::vector<std::tuple<wxString, wxString, wxString>> repositories =
m_pcm->GetRepositoryList();
264 for(
const auto& [
id, url,
name] : repositories )
267 if( repositories.size() > 0 )
289 wxFileDialog open_file_dialog(
this,
_(
"Install Package" ), wxEmptyString, wxEmptyString,
290 wxT(
"Zip files (*.zip)|*.zip" ), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
292 if( open_file_dialog.ShowModal() == wxID_CANCEL )
309 wxStringClientData* data =
static_cast<wxStringClientData*
>(
322 if(
m_pcm->CacheRepository( aRepositoryId ) )
325 packagesView->ClearData();
329 const std::vector<PCM_PACKAGE> packages =
m_pcm->GetRepositoryPackages( aRepositoryId );
331 std::unordered_map<PCM_PACKAGE_TYPE, std::vector<PACKAGE_VIEW_DATA>> data;
342 package_data.
state =
m_pcm->GetPackageState( aRepositoryId, pkg.identifier );
347 package_data.
pinned =
m_pcm->IsPackagePinned( pkg.identifier );
356 if( action.package.identifier != pkg.identifier )
359 switch( action.action )
375 data[type].emplace_back( package_data );
384 (
int) data[type].size() ) );
388 (
int) packages.size() ) );
419 const std::vector<PCM_INSTALLATION_ENTRY> installed =
m_pcm->GetInstalledPackages();
420 std::vector<PACKAGE_VIEW_DATA> package_list;
433 package_data.
state =
m_pcm->GetPackageState( entry.repository_id,
434 entry.package.identifier );
439 package_list.emplace_back( package_data );
445 (
int) package_list.size() ) );
464 task_manager.
Uninstall( action.package );
469 task_manager.
DownloadAndInstall( action.package, action.version, action.repository_id,
483 wxCommandEvent
dummy;
507 std::sort( rows.begin(), rows.end(),
508 [](
const int& a,
const int& b )
515 for(
int row : rows )
540 bool pinned =
m_pcm->IsPackagePinned( aPackageId );
545 packagesView->SetPackageState( aPackageId, aState, pinned );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Implementing DIALOG_MANAGE_REPOSITORIES_BASE.
std::vector< std::pair< wxString, wxString > > GetData()
void SetData(const std::vector< std::pair< wxString, wxString > > &aData)
wxChoice * m_choiceRepository
wxNotebook * m_contentNotebook
WX_GRID * m_gridPendingActions
wxButton * m_sdbSizer1Cancel
wxBitmapButton * m_discardActionButton
wxNotebook * m_dialogNotebook
wxButton * m_sdbSizer1Apply
wxPanel * m_panelInstalledHolder
ActionCallback m_actionCallback
void OnDiscardChangesClicked(wxCommandEvent &event) override
Switches to another repository.
std::unordered_map< wxString, wxBitmap > m_installedBitmaps
std::unordered_map< wxString, wxBitmap > m_packageBitmaps
void OnManageRepositoriesClicked(wxCommandEvent &event) override
Discards current repo cache, fetches it anew and displays.
void updatePackageState(const wxString &aPackageId, const PCM_PACKAGE_STATE aState)
Discards specified pending action.
void OnApplyChangesClicked(wxCommandEvent &event) override
Discards all pending changes.
void OnDiscardActionClicked(wxCommandEvent &event) override
Handles modification of the buttons' status.
void OnUpdateEventButtons(wxUpdateUIEvent &event)
Returns types of packages that were installed/uninstalled.
std::unordered_map< PCM_PACKAGE_TYPE, PANEL_PACKAGES_VIEW * > m_repositoryContentPanels
void OnOpenPackageDirClicked(wxCommandEvent &event) override
Enqueues current pending actions in PCM_TASK_MANAGER and runs the queue.
PinCallback m_pinCallback
std::unordered_set< PCM_PACKAGE_TYPE > m_changed_package_types
DIALOG_PCM(EDA_BASE_FRAME *parent, std::shared_ptr< PLUGIN_CONTENT_MANAGER > pcm)
Constructor.
void updatePendingActionsTab()
Gets installed packages list from PCM and displays it on installed tab.
std::vector< PENDING_ACTION > m_pendingActions
void setRepositoryListFromPcm()
Updates pending actions tab caption and content-fits the grid.
void OnInstallFromFileClicked(wxCommandEvent &event) override
Opens local directory where packages are installed in file manager.
void OnCloseWindow(wxCloseEvent &aEvent)
Opens repository management dialog, saves changes to PCM.
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
void OnRepositoryChoice(wxCommandEvent &event) override
Selects the whole row in the grid if a cell is clicked.
wxString m_selectedRepositoryId
PANEL_PACKAGES_VIEW * m_installedPanel
void setInstalledPackages()
Reflects new state of the package in all panels where it is displayed.
void OnPendingActionsCellClicked(wxGridEvent &event) override
Discards selected pending actions.
void setRepositoryData(const wxString &aRepositoryId)
Gets package data from PCM and displays it on repository tab.
void discardAction(int aIndex)
void OnRefreshClicked(wxCommandEvent &event) override
Opens file selection dialog and installs selected package archive.
void OnCloseClicked(wxCommandEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
The base frame for deriving all KiCad main window classes.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
void ClearData()
Selects full row of the clicked cell.
void SetData(const std::vector< PACKAGE_VIEW_DATA > &aPackageData)
Recreates package panels and displays data.
void SetPackageState(const wxString &aPackageId, const PCM_PACKAGE_STATE aState, const bool aPinned)
Set the state of package.
Helper class that handles package (un)installation.
std::unordered_set< PCM_PACKAGE_TYPE > & GetChangedPackageTypes()
PCM_TASK_MANAGER::STATUS DownloadAndInstall(const PCM_PACKAGE &aPackage, const wxString &aVersion, const wxString &aRepositoryId, const bool isUpdate)
Enqueue package download and installation.
void RunQueue(wxWindow *aParent)
Run queue of pending actions.
PCM_TASK_MANAGER::STATUS Uninstall(const PCM_PACKAGE &aPackage)
Enqueue package uninstallation.
PCM_TASK_MANAGER::STATUS InstallFromFile(wxWindow *aParent, const wxString &aFilePath)
Installs package from an archive file on disk.
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate the specified column based on the actual size of the text on screen.
static std::vector< std::pair< PCM_PACKAGE_TYPE, wxString > > PACKAGE_TYPE_LIST
Base window classes and related definitions.
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
PCM_PACKAGE_TYPE
< Supported package types
std::vector< FAB_LAYER_COLOR > dummy
< Collection of data relevant to the package display panel Callback for (un)install button
const PCM_PACKAGE package
Repository reference to a resource.