From 886dc2f43ef08ba1f35151a70897417ce030bc3b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 27 Jul 2021 15:13:26 +0100 Subject: [PATCH] Do-not-show-again section for common prefs & zone fill warning infobar. Note that the dialogs which have mutliple options were not moved over as it seems perahps not the right choice to have them save state between sessions. Fixes https://gitlab.com/kicad/code/kicad/issues/8762 --- common/dialogs/dialog_configure_paths.cpp | 9 ++- common/pgm_base.cpp | 6 -- common/settings/common_settings.cpp | 12 +++- include/pgm_base.h | 3 - include/settings/common_settings.h | 15 +++-- pcbnew/dialogs/dialog_export_step.cpp | 10 +++- pcbnew/tools/pcb_control.cpp | 68 +++++++++++++++++------ pcbnew/tools/pcb_control.h | 7 +++ 8 files changed, 89 insertions(+), 41 deletions(-) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 43c5b130bb..d303e13916 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -348,7 +348,8 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event ) if( grid == m_EnvVars ) { - if( col == TV_VALUE_COL && m_EnvVars->GetCellValue( row, TV_FLAG_COL ).Length() ) + if( col == TV_VALUE_COL && m_EnvVars->GetCellValue( row, TV_FLAG_COL ).Length() + && !Pgm().GetCommonSettings()->m_DoNotShowAgain.env_var_overwrite_warning ) { wxString msg1 = _( "This path was defined externally to the running process and\n" "will only be temporarily overwritten." ); @@ -361,14 +362,16 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event ) dlg.ShowDetailedText( msg2 ); dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); dlg.ShowModal(); + + if( dlg.DoNotShowAgain() ) + Pgm().GetCommonSettings()->m_DoNotShowAgain.env_var_overwrite_warning = true; } else if( col == TV_NAME_COL && m_EnvVars->GetCellValue( row, TV_NAME_COL ) != text ) { // This env var name is reserved and cannot be added here. if( text == PROJECT_VAR_NAME ) { - wxMessageBox( wxString::Format( - _( "The name %s is reserved, and cannot be used here" ), + wxMessageBox( wxString::Format( _( "The name %s is reserved, and cannot be used." ), PROJECT_VAR_NAME ) ); event.Veto(); } diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 5b2aa4a27e..1435888a8c 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -106,8 +106,6 @@ PGM_BASE::PGM_BASE() m_Printing = false; m_ModalDialogCount = 0; - m_show_env_var_dialog = true; - setLanguageId( wxLANGUAGE_DEFAULT ); ForceSystemPdfBrowser( false ); @@ -338,7 +336,6 @@ bool PGM_BASE::setExecutablePath() void PGM_BASE::loadCommonSettings() { - m_show_env_var_dialog = GetCommonSettings()->m_Env.show_warning_dialog; m_editor_name = GetCommonSettings()->m_System.editor_name; for( const std::pair it : GetCommonSettings()->m_Env.vars ) @@ -369,10 +366,7 @@ void PGM_BASE::SaveCommonSettings() // GetCommonSettings() is not initialized until fairly late in the // process startup: InitPgm(), so test before using: if( GetCommonSettings() ) - { GetCommonSettings()->m_System.working_dir = wxGetCwd(); - GetCommonSettings()->m_Env.show_warning_dialog = m_show_env_var_dialog; - } } diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp index 6ff93f11f9..6b60237cad 100644 --- a/common/settings/common_settings.cpp +++ b/common/settings/common_settings.cpp @@ -97,9 +97,6 @@ COMMON_SETTINGS::COMMON_SETTINGS() : m_params.emplace_back( new PARAM( "auto_backup.min_interval", &m_Backup.min_interval, 300 ) ); - m_params.emplace_back( new PARAM( "environment.show_warning_dialog", - &m_Env.show_warning_dialog, false ) ); - m_params.emplace_back( new PARAM_LAMBDA( "environment.vars", [&]() -> nlohmann::json { @@ -276,6 +273,15 @@ COMMON_SETTINGS::COMMON_SETTINGS() : m_params.emplace_back( new PARAM( "system.clear_3d_cache_interval", &m_System.clear_3d_cache_interval, 30 ) ); + m_params.emplace_back( new PARAM( "do_not_show_again.zone_fill_warning", + &m_DoNotShowAgain.zone_fill_warning, false ) ); + + m_params.emplace_back( new PARAM( "do_not_show_again.env_var_overwrite_warning", + &m_DoNotShowAgain.env_var_overwrite_warning, false ) ); + + m_params.emplace_back( new PARAM( "do_not_show_again.scaled_3d_models_warning", + &m_DoNotShowAgain.scaled_3d_models_warning, false ) ); + m_params.emplace_back( new PARAM( "session.remember_open_files", &m_Session.remember_open_files, false ) ); diff --git a/include/pgm_base.h b/include/pgm_base.h index 56c8112631..2b81c9e7ef 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -327,9 +327,6 @@ protected: wxString m_pdf_browser; wxString m_editor_name; - /// Flag to indicate if the environment variable overwrite warning dialog should be shown. - bool m_show_env_var_dialog; - }; diff --git a/include/settings/common_settings.h b/include/settings/common_settings.h index f05499abcb..00ad7980e2 100644 --- a/include/settings/common_settings.h +++ b/include/settings/common_settings.h @@ -69,7 +69,6 @@ public: struct ENVIRONMENT { - bool show_warning_dialog; ENV_VAR_MAP vars; }; @@ -118,6 +117,13 @@ public: int clear_3d_cache_interval; }; + struct DO_NOT_SHOW_AGAIN + { + bool zone_fill_warning; + bool env_var_overwrite_warning; + bool scaled_3d_models_warning; + }; + struct NETCLASS_PANEL { int sash_pos; @@ -153,12 +159,9 @@ public: SYSTEM m_System; + DO_NOT_SHOW_AGAIN m_DoNotShowAgain; + NETCLASS_PANEL m_NetclassPanel; - - // TODO: These may not want to be in common - wxString m_3DLibsUrl; - - wxString m_3DLibsDownloadPath; }; #endif diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 9af0e768de..bc2681a2c0 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -26,7 +26,7 @@ #include #include - +#include #include #include #include @@ -182,17 +182,21 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& break; } - if( !bad_scales.empty() ) + if( !bad_scales.empty() + && !Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning ) { wxString extendedMsg = _( "Non-unity scaled models:" ) + "\n" + bad_scales; KIDIALOG msgDlg( m_parent, _( "Scaled models detected. " - "Model scaling is not reliable for mechanical export." ), + "Model scaling is not reliable for mechanical export." ), _( "Model Scale Warning" ), wxOK | wxICON_WARNING ); msgDlg.SetExtendedMessage( extendedMsg ); msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); msgDlg.ShowModal(); + + if( msgDlg.DoNotShowAgain() ) + Pgm().GetCommonSettings()->m_DoNotShowAgain.scaled_3d_models_warning = true; } // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 7be561aca0..723614d22e 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -24,6 +24,7 @@ */ #include "edit_tool.h" +#include #include "pcb_actions.h" #include "pcb_control.h" #include "pcb_picker_tool.h" @@ -52,10 +53,11 @@ #include #include #include -#include #include #include #include +#include +#include using namespace std::placeholders; @@ -185,6 +187,53 @@ int PCB_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent ) } +/** + * We have bug reports indicating that some new users confuse zone filling/unfilling with the + * display modes. This will put up a warning if they show zone fills when one or more zones + * are unfilled. + */ +void PCB_CONTROL::unfilledZoneCheck() +{ + if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning ) + return; + + bool unfilledZones = false; + + for( const ZONE* zone : board()->Zones() ) + { + if( !zone->IsFilled() ) + { + unfilledZones = true; + break; + } + } + + if( unfilledZones ) + { + WX_INFOBAR* infobar = frame()->GetInfoBar(); + wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ), + wxEmptyString ); + + button->Bind( wxEVT_COMMAND_HYPERLINK, std::function( + [&]( wxHyperlinkEvent& aEvent ) + { + Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning = true; + frame()->GetInfoBar()->Dismiss(); + } ) ); + + infobar->RemoveAllButtons(); + infobar->AddButton( button ); + + wxString msg; + msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) " + "if you wish to see all fills." ), + KeyNameFromKeyCode( PCB_ACTIONS::zoneFillAll.GetHotKey() ) ); + + infobar->ShowMessageFor( msg, 10000, wxICON_WARNING ); + } +} + + int PCB_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent ) { PCB_DISPLAY_OPTIONS opts = displayOptions(); @@ -192,22 +241,7 @@ int PCB_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent ) // Apply new display options to the GAL canvas if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFilled ) ) { - if( opts.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED ) - { - // Check for user misunderstanding between fills and display mode - for( const ZONE* zone : board()->Zones() ) - { - if( !zone->IsFilled() ) - { - wxString msg; - msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) " - "if you wish to see all fills." ), - KeyNameFromKeyCode( PCB_ACTIONS::zoneFillAll.GetHotKey() ) ); - m_frame->ShowInfoBarMsg( msg, true ); - break; - } - } - } + unfilledZoneCheck(); opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED; } diff --git a/pcbnew/tools/pcb_control.h b/pcbnew/tools/pcb_control.h index 0bff88fa5d..ffb428bbc8 100644 --- a/pcbnew/tools/pcb_control.h +++ b/pcbnew/tools/pcb_control.h @@ -100,6 +100,13 @@ private: ///< Sets up handlers for various events. void setTransitions() override; + /** + * We have bug reports indicating that some new users confuse zone filling/unfilling with + * the display modes. This will put up a warning if they show zone fills when one or more + * zones are unfilled. + */ + void unfilledZoneCheck(); + /** * Add and select or just select for move/place command a list of board items. *