Add policy to enable/disable pcm
This commit is contained in:
parent
74c3ad0b3a
commit
392ed5fecd
|
@ -28,13 +28,14 @@
|
|||
#include <dialog_shim.h>
|
||||
#include <gal/dpi_scaling.h>
|
||||
#include <kiface_base.h>
|
||||
#include <kiplatform/policy.h>
|
||||
#include <kiplatform/ui.h>
|
||||
#include <pgm_base.h>
|
||||
#include <policy_keys.h>
|
||||
#include <id.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
#include <kiplatform/policy.h>
|
||||
|
||||
PANEL_DATA_COLLECTION::PANEL_DATA_COLLECTION( PAGED_DIALOG* aDialog, wxWindow* aParent ) :
|
||||
PANEL_DATA_COLLECTION_BASE( aParent ), m_dialog( aDialog )
|
||||
|
@ -47,7 +48,7 @@ bool PANEL_DATA_COLLECTION::TransferDataToWindow()
|
|||
applySettingsToPanel();
|
||||
|
||||
KIPLATFORM::POLICY::STATE policyState =
|
||||
KIPLATFORM::POLICY::GetPolicyState( "DataCollection" );
|
||||
KIPLATFORM::POLICY::GetPolicyState( POLICY_KEY_DATACOLLECTION );
|
||||
if( policyState != KIPLATFORM::POLICY::STATE::NOT_CONFIGURED )
|
||||
{
|
||||
Disable();
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <eda_draw_frame.h>
|
||||
#include <gestfich.h>
|
||||
#include <id.h>
|
||||
#include <kiplatform/policy.h>
|
||||
#include <lockfile.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <pgm_base.h>
|
||||
|
@ -59,8 +60,7 @@
|
|||
#include <systemdirsappend.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <paths.h>
|
||||
|
||||
#include <kiplatform/policy.h>
|
||||
#include <policy_keys.h>
|
||||
|
||||
#ifdef KICAD_USE_SENTRY
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
|
@ -221,7 +221,7 @@ const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEdit
|
|||
bool PGM_BASE::IsSentryOptedIn()
|
||||
{
|
||||
KIPLATFORM::POLICY::STATE policyState =
|
||||
KIPLATFORM::POLICY::GetPolicyState( wxT( "DataCollection" ) );
|
||||
KIPLATFORM::POLICY::GetPolicyState( POLICY_KEY_DATACOLLECTION );
|
||||
if( policyState != KIPLATFORM::POLICY::STATE::NOT_CONFIGURED )
|
||||
{
|
||||
return policyState == KIPLATFORM::POLICY::STATE::ENABLED;
|
||||
|
@ -329,7 +329,7 @@ void PGM_BASE::sentryInit()
|
|||
void PGM_BASE::sentryPrompt()
|
||||
{
|
||||
KIPLATFORM::POLICY::STATE policyState =
|
||||
KIPLATFORM::POLICY::GetPolicyState( wxT( "DataCollection" ) );
|
||||
KIPLATFORM::POLICY::GetPolicyState( POLICY_KEY_DATACOLLECTION );
|
||||
|
||||
if( policyState == KIPLATFORM::POLICY::STATE::NOT_CONFIGURED
|
||||
&& !m_settings_manager->GetCommonSettings()->m_DoNotShowAgain.data_collection_prompt )
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef POLICY_KEYS_H_
|
||||
#define POLICY_KEYS_H_
|
||||
|
||||
#define POLICY_KEY_DATACOLLECTION wxT( "DataCollection" )
|
||||
#define POLICY_KEY_PCM wxT( "PluginAndContentManager" )
|
||||
|
||||
#endif // POLICY_KEYS_H_
|
|
@ -20,6 +20,8 @@
|
|||
#include <bitmaps.h>
|
||||
#include <bitmap_store.h>
|
||||
#include <kicad_manager_frame.h>
|
||||
#include <kiplatform/policy.h>
|
||||
#include <policy_keys.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/kicad_manager_actions.h>
|
||||
#include <widgets/bitmap_button.h>
|
||||
|
@ -58,10 +60,11 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
|
|||
helpFont.SetStyle( wxFONTSTYLE_ITALIC );
|
||||
|
||||
auto addLauncher =
|
||||
[&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, const wxString& aHelpText )
|
||||
[&]( const TOOL_ACTION& aAction, const wxBitmap& aBitmap, const wxString& aHelpText, bool enabled = true )
|
||||
{
|
||||
BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY );
|
||||
btn->SetBitmap( aBitmap );
|
||||
btn->SetDisabledBitmap( wxBitmap( aBitmap.ConvertToImage().ConvertToGreyscale() ) );
|
||||
btn->SetPadding( 5 );
|
||||
btn->SetToolTip( aAction.GetDescription() );
|
||||
|
||||
|
@ -109,7 +112,14 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
|
|||
|
||||
m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ),
|
||||
wxALIGN_TOP | wxTOP, 1 );
|
||||
};
|
||||
|
||||
btn->Enable( enabled );
|
||||
if( !enabled )
|
||||
{
|
||||
help->Disable();
|
||||
label->Disable();
|
||||
}
|
||||
};
|
||||
|
||||
addLauncher( KICAD_MANAGER_ACTIONS::editSchematic,
|
||||
KiScaledBitmap( BITMAPS::icon_eeschema, this, 48, true ),
|
||||
|
@ -145,8 +155,9 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
|
|||
"designs" ) );
|
||||
|
||||
addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager,
|
||||
KiScaledBitmap( BITMAPS::icon_pcm, this, 48, true ),
|
||||
_( "Manage downloadable packages from KiCad and 3rd party repositories" ) );
|
||||
KiScaledBitmap( BITMAPS::icon_pcm, this, 48, true ),
|
||||
_( "Manage downloadable packages from KiCad and 3rd party repositories" ),
|
||||
( KIPLATFORM::POLICY::GetPolicyState( POLICY_KEY_PCM ) != KIPLATFORM::POLICY::STATE::DISABLED ) );
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
|
||||
#include <bitmaps.h>
|
||||
#include <filehistory.h>
|
||||
#include <kiplatform/policy.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <paths.h>
|
||||
#include <policy_keys.h>
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
@ -159,7 +161,14 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
toolsMenu->Add( KICAD_MANAGER_ACTIONS::convertImage );
|
||||
toolsMenu->Add( KICAD_MANAGER_ACTIONS::showCalculator );
|
||||
toolsMenu->Add( KICAD_MANAGER_ACTIONS::editDrawingSheet );
|
||||
toolsMenu->Add( KICAD_MANAGER_ACTIONS::showPluginManager );
|
||||
|
||||
wxMenuItem* pcmMenuItem = toolsMenu->Add( KICAD_MANAGER_ACTIONS::showPluginManager );
|
||||
|
||||
if( KIPLATFORM::POLICY::GetPolicyState( POLICY_KEY_PCM )
|
||||
== KIPLATFORM::POLICY::STATE::DISABLED )
|
||||
{
|
||||
pcmMenuItem->Enable( false );
|
||||
}
|
||||
|
||||
toolsMenu->AppendSeparator();
|
||||
toolsMenu->Add( _( "Edit Local File..." ),
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
#include <wildcards_and_files_ext.h>
|
||||
#include <executable_names.h>
|
||||
#include <pgm_base.h>
|
||||
#include <policy_keys.h>
|
||||
#include <kiway.h>
|
||||
#include <kicad_manager_frame.h>
|
||||
#include <kiplatform/policy.h>
|
||||
#include <confirm.h>
|
||||
#include <project/project_file.h>
|
||||
#include <project/project_local_settings.h>
|
||||
|
@ -813,6 +815,13 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
|
|||
|
||||
int KICAD_MANAGER_CONTROL::ShowPluginManager( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( KIPLATFORM::POLICY::GetPolicyState( POLICY_KEY_PCM )
|
||||
== KIPLATFORM::POLICY::STATE::DISABLED )
|
||||
{
|
||||
// policy disables the plugin manager
|
||||
return 0;
|
||||
}
|
||||
|
||||
// For some reason, after a click or a double click the bitmap button calling
|
||||
// PCM keeps the focus althougt the focus was not set to this button.
|
||||
// This hack force removing the focus from this button
|
||||
|
|
|
@ -32,7 +32,7 @@ KIPLATFORM::POLICY::STATE KIPLATFORM::POLICY::GetPolicyState( const wxString& aK
|
|||
if( key.Exists() )
|
||||
{
|
||||
long value;
|
||||
if( key.QueryValue( aKey, &value ) )
|
||||
if( key.HasValue( aKey ) && key.QueryValue( aKey, &value ) )
|
||||
{
|
||||
if( value == 1 )
|
||||
return POLICY::STATE::ENABLED;
|
||||
|
|
Loading…
Reference in New Issue