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>
27#include <pgm_base.h>
28#include <kiway.h>
29#include <eda_base_frame.h>
33
34
36 PANEL_MAINTENANCE_BASE( aParent ),
37 m_frame( aFrame )
38{
39}
40
41
43{
44 COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
45
46 applySettingsToPanel( *commonSettings );
47
48 return true;
49}
50
51
53{
54 COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
55
56 commonSettings->m_System.clear_3d_cache_interval = m_Clear3DCacheFilesOlder->GetValue();
57
58 Pgm().GetSettingsManager().Save( commonSettings );
59
60 return true;
61}
62
63
65{
66 COMMON_SETTINGS defaultSettings;
67
68 defaultSettings.ResetToDefaults();
69
70 applySettingsToPanel( defaultSettings );
71}
72
73
78
79
80void PANEL_MAINTENANCE::onClearFileHistory( wxCommandEvent& event )
81{
83
84 // We also need to clear the in-memory wxWidgets histories, update menu bars, etc.
85 m_frame->Kiway().ClearFileHistory();
86
87 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
88 dlg->GetInfoBar()->ShowMessageFor( _( "File history cleared." ), 6000, wxICON_INFORMATION );
89}
90
91
93{
94 if( COMMON_SETTINGS* settings = Pgm().GetSettingsManager().GetCommonSettings() )
95 {
96 // intra-session do-not-show-agains
97 settings->m_DoNotShowAgain = {};
98 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
99 }
100
101 // Session do-not-show-agains
103}
104
105
106void PANEL_MAINTENANCE::onClearDontShowAgain( wxCommandEvent& event )
107{
109
110 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
111 dlg->GetInfoBar()->ShowMessageFor( _( "\"Don't show again\" dialogs reset." ), 6000, wxICON_INFORMATION );
112}
113
114
116{
118
119 if( COMMON_SETTINGS* settings = Pgm().GetSettingsManager().GetCommonSettings() )
120 {
121 settings->m_dialogControlValues = {};
122 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
123 }
124}
125
126
127void PANEL_MAINTENANCE::onClearDialogState( wxCommandEvent& event )
128{
130
131 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
132 dlg->GetInfoBar()->ShowMessageFor( _( "All dialogs reset to defaults." ), 6000, wxICON_INFORMATION );
133}
134
135
136void PANEL_MAINTENANCE::onResetAll( wxCommandEvent& event )
137{
140
141 // Kill changes currently in dialog
142 wxQueueEvent( m_parent, new wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
143
144 // Reopen dialog
145 wxQueueEvent( m_frame, new wxCommandEvent( wxEVT_COMMAND_MENU_SELECTED, wxID_PREFERENCES ) );
146}
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:576
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:125
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.
Definition pgm_base.cpp:913
see class PGM_BASE