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, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <kidialog.h>
24#include <pgm_base.h>
25#include <kiway.h>
26#include <eda_base_frame.h>
30#include <widgets/wx_infobar.h>
31
32
34 PANEL_MAINTENANCE_BASE( aParent ),
35 m_frame( aFrame )
36{
37}
38
39
41{
42 COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
43
44 applySettingsToPanel( *commonSettings );
45
46 return true;
47}
48
49
51{
52 COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
53
54 commonSettings->m_System.clear_3d_cache_interval = m_Clear3DCacheFilesOlder->GetValue();
55
56 Pgm().GetSettingsManager().Save( commonSettings );
57
58 return true;
59}
60
61
63{
64 COMMON_SETTINGS defaultSettings;
65
66 defaultSettings.ResetToDefaults();
67
68 applySettingsToPanel( defaultSettings );
69}
70
71
76
77
78void PANEL_MAINTENANCE::onClearFileHistory( wxCommandEvent& event )
79{
81
82 // We also need to clear the in-memory wxWidgets histories, update menu bars, etc.
83 m_frame->Kiway().ClearFileHistory();
84
85 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
86 dlg->GetInfoBar()->ShowMessageFor( _( "File history cleared." ), 6000, wxICON_INFORMATION );
87}
88
89
91{
92 if( COMMON_SETTINGS* settings = Pgm().GetSettingsManager().GetCommonSettings() )
93 {
94 // intra-session do-not-show-agains
95 settings->m_DoNotShowAgain = {};
96 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
97 }
98
99 // Session do-not-show-agains
101}
102
103
104void PANEL_MAINTENANCE::onClearDontShowAgain( wxCommandEvent& event )
105{
107
108 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
109 dlg->GetInfoBar()->ShowMessageFor( _( "\"Don't show again\" dialogs reset." ), 6000, wxICON_INFORMATION );
110}
111
112
114{
116
117 if( COMMON_SETTINGS* settings = Pgm().GetSettingsManager().GetCommonSettings() )
118 {
119 settings->CsInternals().m_dialogControlValues = {};
120 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
121 }
122}
123
124
125void PANEL_MAINTENANCE::onClearDialogState( wxCommandEvent& event )
126{
128
129 if( PAGED_DIALOG* dlg = PAGED_DIALOG::GetDialog( this ) )
130 dlg->GetInfoBar()->ShowMessageFor( _( "All dialogs reset to defaults." ), 6000, wxICON_INFORMATION );
131}
132
133
134void PANEL_MAINTENANCE::onResetAll( wxCommandEvent& event )
135{
138
139 // Kill changes currently in dialog
140 wxQueueEvent( m_parent, new wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
141
142 // Reopen dialog
143 wxQueueEvent( m_frame, new wxCommandEvent( wxEVT_COMMAND_MENU_SELECTED, wxID_PREFERENCES ) );
144}
The base frame for deriving all KiCad main window classes.
void ResetToDefaults()
Resets all parameters to default values.
static void ClearDoNotShowAgainDialogs()
Definition kidialog.cpp:45
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:546
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
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.
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE