41#include <wx/filedlg.h>
45#define GRID_CELL_MARGIN 4
62 m_pcm->SetDialogWindow(
this );
63 m_pcm->StopBackgroundUpdate();
71 const wxString& aVersion )
75 if( wxMessageBox(
wxString::Format(
_(
"Are you sure you want to update pinned package "
76 "from version %s to %s?" ),
78 _(
"Confirm update" ), wxICON_QUESTION | wxYES_NO,
this )
131 [
this](
const wxString& aPackageId,
const PCM_PACKAGE_STATE aState,
const bool aPinned )
133 m_pcm->SetPinned( aPackageId, aPinned );
147 wxString label = wxGetTranslation( entry.second );
160 { wxID_APPLY,
_(
"Apply Pending Changes" ) },
161 { wxID_CANCEL,
_(
"Discard Pending Changes" ) } } );
185 m_pcm->SaveInstalledPackages();
186 m_pcm->SetDialogWindow(
nullptr );
187 m_pcm->RunBackgroundUpdate();
202 || wxMessageBox(
_(
"Are you sure you want to close the package manager "
203 "and discard pending changes?" ),
204 _(
"Plugin and Content Manager" ), wxICON_QUESTION | wxYES_NO,
this )
214 wxCommandEvent
dummy;
224 std::vector<std::pair<wxString, wxString>> dialog_data;
225 std::vector<std::tuple<wxString, wxString, wxString>> repo_list =
m_pcm->GetRepositoryList();
227 for(
const std::tuple<wxString, wxString, wxString>& repo : repo_list )
228 dialog_data.push_back( std::make_pair( std::get<1>( repo ), std::get<2>( repo ) ) );
230 dialog->
SetData( dialog_data );
232 if( dialog->ShowModal() == wxID_SAVE )
234 dialog_data = dialog->
GetData();
235 m_pcm->SetRepositoryList( dialog_data );
251 std::vector<std::tuple<wxString, wxString, wxString>> repositories =
m_pcm->GetRepositoryList();
255 for(
const std::tuple<wxString, wxString, wxString>& entry : repositories )
258 new wxStringClientData( std::get<0>( entry ) ) );
261 if( repositories.size() > 0 )
283 wxFileDialog open_file_dialog(
this,
_(
"Choose package file" ), wxEmptyString, wxEmptyString,
284 wxT(
"Zip files (*.zip)|*.zip" ),
285 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
287 if( open_file_dialog.ShowModal() == wxID_CANCEL )
299 Pgm().GetSettingsManager().ReloadColorSettings();
305 wxStringClientData* data =
static_cast<wxStringClientData*
>(
316 if(
m_pcm->CacheRepository( aRepositoryId ) )
319 packagesView->ClearData();
323 const std::vector<PCM_PACKAGE> packages =
m_pcm->GetRepositoryPackages( aRepositoryId );
325 std::unordered_map<PCM_PACKAGE_TYPE, std::vector<PACKAGE_VIEW_DATA>> data;
336 package_data.
state =
m_pcm->GetPackageState( aRepositoryId, pkg.identifier );
341 package_data.
pinned =
m_pcm->IsPackagePinned( pkg.identifier );
350 if( action.package.identifier != pkg.identifier )
353 switch( action.action )
366 data[pkg.type].emplace_back( package_data );
375 (
int) data[type].size() ) );
379 (
int) packages.size() ) );
408 const std::vector<PCM_INSTALLATION_ENTRY> installed =
m_pcm->GetInstalledPackages();
409 std::vector<PACKAGE_VIEW_DATA> package_list;
422 package_data.
state =
m_pcm->GetPackageState( entry.repository_id,
423 entry.package.identifier );
428 package_list.emplace_back( package_data );
434 (
int) package_list.size() ) );
453 task_manager.
Uninstall( action.package );
458 task_manager.
DownloadAndInstall( action.package, action.version, action.repository_id,
470 wxCommandEvent
dummy;
477 Pgm().GetSettingsManager().ReloadColorSettings();
497 std::sort( rows.begin(), rows.end(),
498 [](
const int& a,
const int& b )
505 for(
int row : rows )
530 bool pinned =
m_pcm->IsPackagePinned( aPackageId );
535 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...
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)
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
DIALOG_PCM(wxWindow *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
~DIALOG_PCM()
Closes the window, asks user confirmation if there are pending actions.
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...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
std::vector< std::pair< wxString, wxString > > m_PcmRepositories
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.
void InstallFromFile(wxWindow *aParent, const wxString &aFilePath)
Installs package from an archive file on disk.
void Uninstall(const PCM_PACKAGE &aPackage)
Enqueue package uninstallation.
void 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.
bool ColorSettingsChanged() const
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates 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
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
PCM_PACKAGE_TYPE
< Supported package types
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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.