Allow all common settings panels to be reset
This commit is contained in:
parent
7d1deb8a3b
commit
21e199f675
|
@ -83,41 +83,7 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow()
|
|||
{
|
||||
COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
|
||||
|
||||
int timevalue = commonSettings->m_System.autosave_interval;
|
||||
wxString msg;
|
||||
|
||||
msg << timevalue / 60;
|
||||
m_SaveTime->SetValue( msg );
|
||||
|
||||
m_fileHistorySize->SetValue( commonSettings->m_System.file_history_size );
|
||||
|
||||
m_antialiasing->SetSelection( commonSettings->m_Graphics.opengl_aa_mode );
|
||||
m_antialiasingFallback->SetSelection( commonSettings->m_Graphics.cairo_aa_mode );
|
||||
|
||||
int icon_scale_fourths = commonSettings->m_Appearance.icon_scale;
|
||||
|
||||
if( icon_scale_fourths <= 0 )
|
||||
{
|
||||
m_iconScaleAuto->SetValue( true );
|
||||
m_iconScaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iconScaleAuto->SetValue( false );
|
||||
m_iconScaleSlider->SetValue( icon_scale_fourths * 25 );
|
||||
}
|
||||
|
||||
{
|
||||
const DPI_SCALING dpi( commonSettings, this );
|
||||
m_canvasScaleCtrl->SetValue( dpi.GetScaleFactor() );
|
||||
m_canvasScaleAuto->SetValue( dpi.GetCanvasIsAutoScaled() );
|
||||
}
|
||||
|
||||
m_checkBoxIconsInMenus->SetValue( commonSettings->m_Appearance.use_icons_in_menus );
|
||||
|
||||
m_PreferSelectToDrag->SetValue( commonSettings->m_Input.prefer_select_to_drag );
|
||||
m_warpMouseOnMove->SetValue( commonSettings->m_Input.warp_mouse_on_move );
|
||||
m_NonImmediateActions->SetValue( !commonSettings->m_Input.immediate_actions );
|
||||
applySettingsToPanel( *commonSettings );
|
||||
|
||||
// TODO(JE) Move these into COMMON_SETTINGS probably
|
||||
m_textEditorPath->SetValue( Pgm().GetEditorName( false ) );
|
||||
|
@ -125,13 +91,6 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow()
|
|||
m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() );
|
||||
m_PDFViewerPath->SetValue( Pgm().GetPdfBrowserName() );
|
||||
|
||||
m_cbBackupEnabled->SetValue( commonSettings->m_Backup.enabled );
|
||||
m_cbBackupAutosave->SetValue( commonSettings->m_Backup.backup_on_autosave );
|
||||
m_backupLimitTotalFiles->SetValue( commonSettings->m_Backup.limit_total_files );
|
||||
m_backupLimitDailyFiles->SetValue( commonSettings->m_Backup.limit_daily_files );
|
||||
m_backupMinInterval->SetValue( commonSettings->m_Backup.min_interval / 60 );
|
||||
m_backupLimitTotalSize->SetValue( commonSettings->m_Backup.limit_total_size / ( 1024 * 1024 ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -179,6 +138,69 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
|
|||
}
|
||||
|
||||
|
||||
void PANEL_COMMON_SETTINGS::ResetPanel()
|
||||
{
|
||||
COMMON_SETTINGS defaultSettings;
|
||||
|
||||
defaultSettings.ResetToDefaults();
|
||||
|
||||
applySettingsToPanel( defaultSettings );
|
||||
|
||||
// TODO(JE) Move these into COMMON_SETTINGS probably
|
||||
m_textEditorPath->SetValue( defaultSettings.m_System.editor_name );
|
||||
m_defaultPDFViewer->SetValue( defaultSettings.m_System.use_system_pdf_viewer );
|
||||
m_otherPDFViewer->SetValue( !defaultSettings.m_System.use_system_pdf_viewer );
|
||||
m_PDFViewerPath->SetValue( defaultSettings.m_System.pdf_viewer_name );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings )
|
||||
{
|
||||
int timevalue = aSettings.m_System.autosave_interval;
|
||||
wxString msg;
|
||||
|
||||
msg << timevalue / 60;
|
||||
m_SaveTime->SetValue( msg );
|
||||
|
||||
m_fileHistorySize->SetValue( aSettings.m_System.file_history_size );
|
||||
|
||||
m_antialiasing->SetSelection( aSettings.m_Graphics.opengl_aa_mode );
|
||||
m_antialiasingFallback->SetSelection( aSettings.m_Graphics.cairo_aa_mode );
|
||||
|
||||
int icon_scale_fourths = aSettings.m_Appearance.icon_scale;
|
||||
|
||||
if( icon_scale_fourths <= 0 )
|
||||
{
|
||||
m_iconScaleAuto->SetValue( true );
|
||||
m_iconScaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iconScaleAuto->SetValue( false );
|
||||
m_iconScaleSlider->SetValue( icon_scale_fourths * 25 );
|
||||
}
|
||||
|
||||
{
|
||||
const DPI_SCALING dpi( &aSettings, this );
|
||||
m_canvasScaleCtrl->SetValue( dpi.GetScaleFactor() );
|
||||
m_canvasScaleAuto->SetValue( dpi.GetCanvasIsAutoScaled() );
|
||||
}
|
||||
|
||||
m_checkBoxIconsInMenus->SetValue( aSettings.m_Appearance.use_icons_in_menus );
|
||||
|
||||
m_PreferSelectToDrag->SetValue( aSettings.m_Input.prefer_select_to_drag );
|
||||
m_warpMouseOnMove->SetValue( aSettings.m_Input.warp_mouse_on_move );
|
||||
m_NonImmediateActions->SetValue( !aSettings.m_Input.immediate_actions );
|
||||
|
||||
m_cbBackupEnabled->SetValue( aSettings.m_Backup.enabled );
|
||||
m_cbBackupAutosave->SetValue( aSettings.m_Backup.backup_on_autosave );
|
||||
m_backupLimitTotalFiles->SetValue( aSettings.m_Backup.limit_total_files );
|
||||
m_backupLimitDailyFiles->SetValue( aSettings.m_Backup.limit_daily_files );
|
||||
m_backupMinInterval->SetValue( aSettings.m_Backup.min_interval / 60 );
|
||||
m_backupLimitTotalSize->SetValue( aSettings.m_Backup.limit_total_size / ( 1024 * 1024 ) );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_COMMON_SETTINGS::OnScaleSlider( wxScrollEvent& aEvent )
|
||||
{
|
||||
m_iconScaleAuto->SetValue( false );
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "panel_common_settings_base.h"
|
||||
|
||||
|
||||
class COMMON_SETTINGS;
|
||||
class DIALOG_SHIM;
|
||||
|
||||
|
||||
|
@ -36,10 +37,14 @@ public:
|
|||
PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aParent );
|
||||
~PANEL_COMMON_SETTINGS() override;
|
||||
|
||||
void ResetPanel() override;
|
||||
|
||||
protected:
|
||||
bool TransferDataFromWindow() override;
|
||||
bool TransferDataToWindow() override;
|
||||
|
||||
void applySettingsToPanel( COMMON_SETTINGS& aSettings );
|
||||
|
||||
void OnScaleSlider( wxScrollEvent& aEvent ) override;
|
||||
void OnIconScaleAuto( wxCommandEvent& aEvent ) override;
|
||||
void OnTextEditorClick( wxCommandEvent& event ) override;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
|
||||
PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
|
||||
{
|
||||
wxBoxSizer* bPanelSizer;
|
||||
bPanelSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<property name="name">PANEL_COMMON_SETTINGS_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="subclass">; forward_declare</property>
|
||||
<property name="subclass">RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include "widgets/stepped_slider.h"
|
||||
#include "widgets/resettable_panel.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/gdicmn.h>
|
||||
|
@ -38,7 +39,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class PANEL_COMMON_SETTINGS_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class PANEL_COMMON_SETTINGS_BASE : public wxPanel
|
||||
class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL
|
||||
{
|
||||
private:
|
||||
|
||||
|
|
|
@ -62,52 +62,9 @@ PANEL_MOUSE_SETTINGS::~PANEL_MOUSE_SETTINGS()
|
|||
|
||||
bool PANEL_MOUSE_SETTINGS::TransferDataToWindow()
|
||||
{
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
const COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
|
||||
m_checkZoomCenter->SetValue( cfg->m_Input.center_on_zoom );
|
||||
m_checkAutoPan->SetValue( cfg->m_Input.auto_pan );
|
||||
m_checkZoomAcceleration->SetValue( cfg->m_Input.zoom_acceleration );
|
||||
m_zoomSpeed->SetValue( cfg->m_Input.zoom_speed );
|
||||
m_checkAutoZoomSpeed->SetValue( cfg->m_Input.zoom_speed_auto );
|
||||
m_checkEnablePanH->SetValue( cfg->m_Input.horizontal_pan );
|
||||
m_autoPanSpeed->SetValue( cfg->m_Input.auto_pan_acceleration );
|
||||
|
||||
m_zoomSpeed->Enable( !cfg->m_Input.zoom_speed_auto );
|
||||
|
||||
auto set_mouse_buttons =
|
||||
[]( const MOUSE_DRAG_ACTION& aVal, wxChoice* aChoice )
|
||||
{
|
||||
switch( aVal )
|
||||
{
|
||||
case MOUSE_DRAG_ACTION::PAN:
|
||||
aChoice->SetSelection( 0 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::ZOOM:
|
||||
aChoice->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::NONE:
|
||||
aChoice->SetSelection( 2 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::SELECT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
set_mouse_buttons(
|
||||
static_cast<MOUSE_DRAG_ACTION>( cfg->m_Input.drag_middle ), m_choiceMiddleButtonDrag );
|
||||
|
||||
set_mouse_buttons(
|
||||
static_cast<MOUSE_DRAG_ACTION>( cfg->m_Input.drag_right ), m_choiceRightButtonDrag );
|
||||
|
||||
m_currentScrollMod.zoom = cfg->m_Input.scroll_modifier_zoom;
|
||||
m_currentScrollMod.panh = cfg->m_Input.scroll_modifier_pan_h;
|
||||
m_currentScrollMod.panv = cfg->m_Input.scroll_modifier_pan_v;
|
||||
|
||||
updateScrollModButtons();
|
||||
applySettingsToPanel( *cfg );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -174,6 +131,65 @@ bool PANEL_MOUSE_SETTINGS::TransferDataFromWindow()
|
|||
}
|
||||
|
||||
|
||||
void PANEL_MOUSE_SETTINGS::ResetPanel()
|
||||
{
|
||||
COMMON_SETTINGS defaultSettings;
|
||||
|
||||
defaultSettings.ResetToDefaults();
|
||||
|
||||
applySettingsToPanel( defaultSettings );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_MOUSE_SETTINGS::applySettingsToPanel( const COMMON_SETTINGS& aSettings )
|
||||
{
|
||||
m_checkZoomCenter->SetValue( aSettings.m_Input.center_on_zoom );
|
||||
m_checkAutoPan->SetValue( aSettings.m_Input.auto_pan );
|
||||
m_checkZoomAcceleration->SetValue( aSettings.m_Input.zoom_acceleration );
|
||||
m_zoomSpeed->SetValue( aSettings.m_Input.zoom_speed );
|
||||
m_checkAutoZoomSpeed->SetValue( aSettings.m_Input.zoom_speed_auto );
|
||||
m_checkEnablePanH->SetValue( aSettings.m_Input.horizontal_pan );
|
||||
m_autoPanSpeed->SetValue( aSettings.m_Input.auto_pan_acceleration );
|
||||
|
||||
m_zoomSpeed->Enable( !aSettings.m_Input.zoom_speed_auto );
|
||||
|
||||
auto set_mouse_buttons =
|
||||
[]( const MOUSE_DRAG_ACTION& aVal, wxChoice* aChoice )
|
||||
{
|
||||
switch( aVal )
|
||||
{
|
||||
case MOUSE_DRAG_ACTION::PAN:
|
||||
aChoice->SetSelection( 0 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::ZOOM:
|
||||
aChoice->SetSelection( 1 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::NONE:
|
||||
aChoice->SetSelection( 2 );
|
||||
break;
|
||||
|
||||
case MOUSE_DRAG_ACTION::SELECT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
set_mouse_buttons(
|
||||
static_cast<MOUSE_DRAG_ACTION>( aSettings.m_Input.drag_middle ), m_choiceMiddleButtonDrag );
|
||||
|
||||
set_mouse_buttons(
|
||||
static_cast<MOUSE_DRAG_ACTION>( aSettings.m_Input.drag_right ), m_choiceRightButtonDrag );
|
||||
|
||||
m_currentScrollMod.zoom = aSettings.m_Input.scroll_modifier_zoom;
|
||||
m_currentScrollMod.panh = aSettings.m_Input.scroll_modifier_pan_h;
|
||||
m_currentScrollMod.panv = aSettings.m_Input.scroll_modifier_pan_v;
|
||||
|
||||
updateScrollModButtons();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_MOUSE_SETTINGS::OnScrollRadioButton( wxCommandEvent& event )
|
||||
{
|
||||
wxRadioButton* btn = dynamic_cast<wxRadioButton*>( event.GetEventObject() );
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <dialogs/panel_mouse_settings_base.h>
|
||||
|
||||
|
||||
class COMMON_SETTINGS;
|
||||
class DIALOG_SHIM;
|
||||
|
||||
|
||||
|
@ -42,6 +43,8 @@ public:
|
|||
|
||||
~PANEL_MOUSE_SETTINGS();
|
||||
|
||||
void ResetPanel() override;
|
||||
|
||||
protected:
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
|
@ -52,6 +55,8 @@ protected:
|
|||
DIALOG_SHIM* m_dialog;
|
||||
|
||||
private:
|
||||
void applySettingsToPanel( const COMMON_SETTINGS& aSettings );
|
||||
|
||||
SCROLL_MOD_SET getScrollModSet();
|
||||
|
||||
void updateScrollModButtons();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
|
||||
PANEL_MOUSE_SETTINGS_BASE::PANEL_MOUSE_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
|
||||
{
|
||||
wxBoxSizer* bSizer1;
|
||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<property name="name">PANEL_MOUSE_SETTINGS_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">584,550</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="subclass">RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include "widgets/resettable_panel.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/gdicmn.h>
|
||||
|
@ -30,7 +31,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class PANEL_MOUSE_SETTINGS_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class PANEL_MOUSE_SETTINGS_BASE : public wxPanel
|
||||
class PANEL_MOUSE_SETTINGS_BASE : public RESETTABLE_PANEL
|
||||
{
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in New Issue