KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_maintenance.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <kidialog.h>
28#include <pgm_base.h>
29#include <kiway.h>
30#include <eda_base_frame.h>
34#include <widgets/wx_infobar.h>
35
36
38 PANEL_MAINTENANCE_BASE( aParent ),
39 m_frame( aFrame )
40{
41}
42
43
45{
46 COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
47
48 applySettingsToPanel( *commonSettings );
49
50 return true;
51}
52
53
55{
56 COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
57
58 commonSettings->m_System.clear_3d_cache_interval = m_Clear3DCacheFilesOlder->GetValue();
59
60 Pgm().GetSettingsManager().Save( commonSettings );
61
62 return true;
63}
64
65
67{
68 COMMON_SETTINGS defaultSettings;
69
70 defaultSettings.ResetToDefaults();
71
72 applySettingsToPanel( defaultSettings );
73}
74
75
80
81
82void PANEL_MAINTENANCE::onClearFileHistory( wxCommandEvent& event )
83{
85
86 // We also need to clear the in-memory wxWidgets histories, update menu bars, etc.
87 m_frame->Kiway().ClearFileHistory();
88
89 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
90 dlg->GetInfoBar()->ShowMessageFor( _( "File history cleared." ), 6000, wxICON_INFORMATION );
91}
92
93
95{
96 if( COMMON_SETTINGS* settings = Pgm().GetSettingsManager().GetCommonSettings() )
97 {
98 // intra-session do-not-show-agains
99 settings->m_DoNotShowAgain = {};
100 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
101 }
102
103 // Session do-not-show-agains
105}
106
107
108void PANEL_MAINTENANCE::onClearDontShowAgain( wxCommandEvent& event )
109{
111
112 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
113 dlg->GetInfoBar()->ShowMessageFor( _( "\"Don't show again\" dialogs reset." ), 6000, wxICON_INFORMATION );
114}
115
116
118{
120
121 if( COMMON_SETTINGS* settings = Pgm().GetSettingsManager().GetCommonSettings() )
122 {
123 settings->CsInternals().m_dialogControlValues = {};
124 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
125 }
126}
127
128
129void PANEL_MAINTENANCE::onClearDialogState( wxCommandEvent& event )
130{
132
133 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
134 dlg->GetInfoBar()->ShowMessageFor( _( "All dialogs reset to defaults." ), 6000, wxICON_INFORMATION );
135}
136
137
138void PANEL_MAINTENANCE::onResetAll( wxCommandEvent& event )
139{
142
143 // Kill changes currently in dialog
144 wxQueueEvent( m_parent, new wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
145
146 // Reopen dialog
147 wxQueueEvent( m_frame, new wxCommandEvent( wxEVT_COMMAND_MENU_SELECTED, wxID_PREFERENCES ) );
148}
The base frame for deriving all KiCad main window classes.
void ResetToDefaults()
Resets all parameters to default values.
static void ClearDoNotShowAgainDialogs()
Dialog type. Selects appropriate icon and default dialog title.
Definition kidialog.cpp:49
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
PANEL_MAINTENANCE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
EDA_BASE_FRAME * m_frame
void onClearDontShowAgain(wxCommandEvent &event) override
void onClearFileHistory(wxCommandEvent &event) override
void applySettingsToPanel(COMMON_SETTINGS &aSettings)
void onClearDialogState(wxCommandEvent &event) override
bool TransferDataToWindow() override
PANEL_MAINTENANCE(wxWindow *aParent, EDA_BASE_FRAME *aFrame)
bool TransferDataFromWindow() override
void onResetAll(wxCommandEvent &event) override
void ResetPanel() override
Reset the contents of this panel.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:541
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:131
void ClearFileHistory()
Clear saved file history from all settings files.
void ResetToDefaults()
Reset all program settings to defaults.
#define _(s)
Base window classes and related definitions.
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE