1 #include "../filezilla.h"
2 #include "../Options.h"
3 #include "settingsdialog.h"
4 #include "optionspage.h"
5 #include "optionspage_debug.h"
6 
7 #include <wx/statbox.h>
8 
9 struct COptionsPageDebug::impl final
10 {
11 	wxCheckBox* debugMenu_{};
12 	wxChoice* level_{};
13 	wxCheckBox* rawListing_{};
14 };
15 
COptionsPageDebug()16 COptionsPageDebug::COptionsPageDebug()
17 	: impl_(std::make_unique<impl>())
18 {
19 }
20 
~COptionsPageDebug()21 COptionsPageDebug::~COptionsPageDebug()
22 {
23 }
24 
CreateControls(wxWindow * parent)25 bool COptionsPageDebug::CreateControls(wxWindow* parent)
26 {
27 	auto const& lay = m_pOwner->layout();
28 
29 	Create(parent);
30 	auto main = lay.createFlex(1);
31 	main->AddGrowableCol(0);
32 	main->AddGrowableRow(0);
33 	SetSizer(main);
34 
35 	auto [box, inner] = lay.createStatBox(main, _("Debugging settings"), 1);
36 
37 	impl_->debugMenu_ = new wxCheckBox(box, nullID, _("&Show debug menu"));
38 	inner->Add(impl_->debugMenu_);
39 
40 	inner->AddSpacer(lay.gap);
41 
42 	auto row = lay.createFlex(2);
43 	inner->Add(row);
44 	row->Add(new wxStaticText(box, nullID, _("&Debug information in message log:")), lay.valign);
45 	impl_->level_ = new wxChoice(box, nullID);
46 	row->Add(impl_->level_, lay.valign);
47 
48 	impl_->level_->AppendString(_("0 - None"));
49 	impl_->level_->AppendString(_("1 - Warning"));
50 	impl_->level_->AppendString(_("2 - Info"));
51 	impl_->level_->AppendString(_("3 - Verbose"));
52 	impl_->level_->AppendString(_("4 - Debug"));
53 
54 	inner->Add(new wxStaticText(box, nullID, _("The higher the debug level, the more information will be displayed in the message log. Displaying debug information has a negative impact on performance.")));
55 	inner->Add(new wxStaticText(box, nullID, _("If reporting bugs, please provide logs with \"Verbose\" logging level.")));
56 
57 	inner->AddSpacer(lay.gap);
58 
59 	impl_->rawListing_ = new wxCheckBox(box, nullID, _("Show &raw directory listing"));
60 	inner->Add(impl_->rawListing_);
61 
62 	return true;
63 }
64 
LoadPage()65 bool COptionsPageDebug::LoadPage()
66 {
67 	impl_->debugMenu_->SetValue(m_pOptions->get_bool(OPTION_DEBUG_MENU));
68 	impl_->level_->SetSelection(m_pOptions->get_int(OPTION_LOGGING_DEBUGLEVEL));
69 	impl_->rawListing_->SetValue(m_pOptions->get_bool(OPTION_LOGGING_RAWLISTING));
70 	return true;
71 }
72 
SavePage()73 bool COptionsPageDebug::SavePage()
74 {
75 	m_pOptions->set(OPTION_DEBUG_MENU, impl_->debugMenu_->GetValue());
76 	m_pOptions->set(OPTION_LOGGING_DEBUGLEVEL, impl_->level_->GetSelection());
77 	m_pOptions->set(OPTION_LOGGING_RAWLISTING, impl_->rawListing_->GetValue());
78 
79 	return true;
80 }
81