mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-03-30 05:16:58 +00:00
PCM: Prompt to enable IPC API when required
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20062
This commit is contained in:
parent
58d2b34304
commit
3525731a4e
include
kicad/pcm
@ -401,7 +401,7 @@ public:
|
||||
*
|
||||
* Use after changing suite-wide options such as panning, autosave interval, etc.
|
||||
*/
|
||||
virtual void CommonSettingsChanged( int aFlags );
|
||||
virtual void CommonSettingsChanged( int aFlags = 0 );
|
||||
|
||||
/**
|
||||
* Calls ProjectChanged() on all KIWAY_PLAYERs.
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "bitmaps.h"
|
||||
#include "dialog_manage_repositories.h"
|
||||
#include "dialog_pcm.h"
|
||||
#include <eda_base_frame.h>
|
||||
#include "grid_tricks.h"
|
||||
#include "ki_exception.h"
|
||||
#include "pcm_task_manager.h"
|
||||
@ -54,8 +55,9 @@ static std::vector<std::pair<PCM_PACKAGE_TYPE, wxString>> PACKAGE_TYPE_LIST = {
|
||||
};
|
||||
|
||||
|
||||
DIALOG_PCM::DIALOG_PCM( wxWindow* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm ) :
|
||||
DIALOG_PCM::DIALOG_PCM( EDA_BASE_FRAME* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm ) :
|
||||
DIALOG_PCM_BASE( parent ),
|
||||
m_parentFrame( parent ),
|
||||
m_pcm( pcm )
|
||||
{
|
||||
// correct the min size from wxfb with fromdip
|
||||
|
@ -30,15 +30,19 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class EDA_BASE_FRAME;
|
||||
|
||||
|
||||
/** Implementing pcm main dialog. */
|
||||
class DIALOG_PCM : public DIALOG_PCM_BASE
|
||||
{
|
||||
public:
|
||||
/** Constructor */
|
||||
DIALOG_PCM( wxWindow* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm );
|
||||
DIALOG_PCM( EDA_BASE_FRAME* parent, std::shared_ptr<PLUGIN_CONTENT_MANAGER> pcm );
|
||||
~DIALOG_PCM();
|
||||
|
||||
EDA_BASE_FRAME* ParentFrame() const { return m_parentFrame; }
|
||||
|
||||
///< Closes the window, asks user confirmation if there are pending actions
|
||||
void OnCloseClicked( wxCommandEvent& event ) override;
|
||||
void OnCloseWindow( wxCloseEvent& aEvent );
|
||||
@ -102,6 +106,7 @@ private:
|
||||
///< Discards specified pending action
|
||||
void discardAction( int aIndex );
|
||||
|
||||
EDA_BASE_FRAME* m_parentFrame;
|
||||
std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
|
||||
ActionCallback m_actionCallback;
|
||||
PinCallback m_pinCallback;
|
||||
|
@ -30,10 +30,14 @@
|
||||
#include "build_version.h"
|
||||
#include "paths.h"
|
||||
#include "pcm.h"
|
||||
#include <eda_base_frame.h>
|
||||
#include "dialogs/dialog_pcm.h"
|
||||
#include "pgm_base.h"
|
||||
#include "picosha2.h"
|
||||
#include "settings/settings_manager.h"
|
||||
#include <wx_filename.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <kiway.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@ -766,6 +770,21 @@ void PLUGIN_CONTENT_MANAGER::MarkInstalled( const PCM_PACKAGE& aPackage, const w
|
||||
entry.pinned = pinned;
|
||||
|
||||
m_installed.emplace( aPackage.identifier, entry );
|
||||
|
||||
if( m_dialog
|
||||
&& ( aPackage.versions[0].runtime.value_or( PCM_PACKAGE_RUNTIME::PPR_SWIG )
|
||||
== PCM_PACKAGE_RUNTIME::PPR_IPC )
|
||||
&& !Pgm().GetCommonSettings()->m_Api.enable_server )
|
||||
{
|
||||
if( wxMessageBox( _( "This plugin requires the KiCad API, which is currently "
|
||||
"disabled in preferences. Would you like to enable it?" ),
|
||||
_( "Enable KiCad API" ), wxICON_QUESTION | wxYES_NO, m_dialog )
|
||||
== wxYES )
|
||||
{
|
||||
Pgm().GetCommonSettings()->m_Api.enable_server = true;
|
||||
m_dialog->ParentFrame()->Kiway().CommonSettingsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,6 +80,7 @@ typedef std::vector<std::tuple<wxString, wxString, wxString>> STRING_TUPLE_LIST;
|
||||
|
||||
|
||||
struct BACKGROUND_JOB;
|
||||
class DIALOG_PCM;
|
||||
|
||||
|
||||
/**
|
||||
@ -326,7 +327,7 @@ public:
|
||||
*
|
||||
* @param aDialog parent dialog for progress window
|
||||
*/
|
||||
void SetDialogWindow( wxWindow* aDialog ) { m_dialog = aDialog; };
|
||||
void SetDialogWindow( DIALOG_PCM* aDialog ) { m_dialog = aDialog; };
|
||||
|
||||
/**
|
||||
* @brief Runs a background update thread that checks for new package versions
|
||||
@ -392,7 +393,7 @@ private:
|
||||
///< Returns current UTC timestamp
|
||||
time_t getCurrentTimestamp() const;
|
||||
|
||||
wxWindow* m_dialog;
|
||||
DIALOG_PCM* m_dialog;
|
||||
std::unique_ptr<JSON_SCHEMA_VALIDATOR> m_schema_validator;
|
||||
wxString m_3rdparty_path;
|
||||
wxString m_cache_path;
|
||||
|
@ -54,6 +54,9 @@ void to_json( json& j, const PACKAGE_VERSION& v )
|
||||
if( v.install_size )
|
||||
j["install_size"] = *v.install_size;
|
||||
|
||||
if( v.runtime )
|
||||
j["runtime"] = *v.runtime;
|
||||
|
||||
if( v.platforms.size() > 0 )
|
||||
nlohmann::to_json( j["platforms"], v.platforms );
|
||||
|
||||
@ -77,6 +80,7 @@ void from_json( const json& j, PACKAGE_VERSION& v )
|
||||
to_optional( j, "download_size", v.download_size );
|
||||
to_optional( j, "install_size", v.install_size );
|
||||
to_optional( j, "kicad_version_max", v.kicad_version_max );
|
||||
to_optional( j, "runtime", v.runtime );
|
||||
|
||||
if( j.contains( "platforms" ) )
|
||||
j.at( "platforms" ).get_to( v.platforms );
|
||||
|
@ -66,6 +66,13 @@ enum PCM_PACKAGE_VERSION_STATUS
|
||||
PVS_DEPRECATED
|
||||
};
|
||||
|
||||
///< The runtime a plugin package uses
|
||||
enum class PCM_PACKAGE_RUNTIME
|
||||
{
|
||||
PPR_SWIG,
|
||||
PPR_IPC
|
||||
};
|
||||
|
||||
|
||||
///< Describes a person's name and contact information
|
||||
struct PCM_CONTACT
|
||||
@ -93,6 +100,7 @@ struct PACKAGE_VERSION
|
||||
wxString kicad_version;
|
||||
std::optional<wxString> kicad_version_max;
|
||||
std::vector<std::string> keep_on_update;
|
||||
std::optional<PCM_PACKAGE_RUNTIME> runtime;
|
||||
|
||||
// Not serialized fields
|
||||
std::tuple<int, int, int, int> parsed_version; // Full version tuple for sorting
|
||||
@ -183,6 +191,12 @@ NLOHMANN_JSON_SERIALIZE_ENUM( PCM_PACKAGE_VERSION_STATUS,
|
||||
{ PVS_DEPRECATED, "deprecated" },
|
||||
} )
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM( PCM_PACKAGE_RUNTIME,
|
||||
{
|
||||
{ PCM_PACKAGE_RUNTIME::PPR_SWIG, "swig" },
|
||||
{ PCM_PACKAGE_RUNTIME::PPR_IPC, "ipc" },
|
||||
} )
|
||||
|
||||
|
||||
// Following are templates and definitions for en/decoding above structs
|
||||
// to/from json
|
||||
|
@ -191,6 +191,14 @@
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"runtime": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"swig",
|
||||
"ipc"
|
||||
],
|
||||
"description": "What runtime a plugin requires. Assumed to be swig if absent. Not used for non-plugin packages."
|
||||
},
|
||||
"kicad_version": {
|
||||
"type": "string",
|
||||
"description": "Minimum supported KiCad version",
|
||||
@ -391,4 +399,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user