Refactor logic for reading and writing application and session settings:

* Introduce TAppSettings, created in dpr file
* Implement read and write methods, and replace callers of GetRegValue and MainReg.WriteInt/... with these
* Optimize read and write methods for avoiding redundant accesses to registry
* Auto-remove stored default settings from registry to avoid registry spam
* Replace synced MainForm.pref* variables with TAppSettings.Read* calls
* Move SetLocales call to dpr file
* Move MainForm.FDirname* variables to appropriate methods in helpers.pas
* Implement TQueryHistory.Create(SessionPath), reading its items within constructor
This commit is contained in:
Ansgar Becker
2012-08-19 10:55:08 +00:00
parent bab15cf16b
commit 90ab0b6cf1
26 changed files with 1593 additions and 1461 deletions

View File

@ -82,12 +82,12 @@ begin
// Set window-layout
InheritFont(Font);
SetWindowSizeGrip(Handle, True);
Top := GetRegValue( REGNAME_SQLHELPWINTOP, Top );
Left := GetRegValue( REGNAME_SQLHELPWINLEFT, Left );
Width := GetRegValue( REGNAME_SQLHELPWINWIDTH, Width );
Height := GetRegValue( REGNAME_SQLHELPWINHEIGHT, Height );
pnlLeft.Width := GetRegValue( REGNAME_SQLHELPPLWIDTH, pnlLeft.Width );
memoDescription.Height := GetRegValue( REGNAME_SQLHELPPRHEIGHT, memoDescription.Height );
Top := AppSettings.ReadInt(asSQLHelpWindowTop);
Left := AppSettings.ReadInt(asSQLHelpWindowLeft);
Width := AppSettings.ReadInt(asSQLHelpWindowWidth);
Height := AppSettings.ReadInt(asSQLHelpWindowHeight);
pnlLeft.Width := AppSettings.ReadInt(asSQLHelpPnlLeftWidth);
memoDescription.Height := AppSettings.ReadInt(asSQLHelpPnlRightTopHeight);
Caption := DEFAULT_WINDOW_CAPTION;
MainForm.SetupSynEditors;
FixVT(treeTopics);
@ -259,13 +259,12 @@ end;
procedure TfrmSQLhelp.FormDestroy(Sender: TObject);
begin
OpenRegistry;
MainReg.WriteInteger( REGNAME_SQLHELPWINLEFT, Left );
MainReg.WriteInteger( REGNAME_SQLHELPWINTOP, Top );
MainReg.WriteInteger( REGNAME_SQLHELPWINWIDTH, Width );
MainReg.WriteInteger( REGNAME_SQLHELPWINHEIGHT, Height );
MainReg.WriteInteger( REGNAME_SQLHELPPLWIDTH, pnlLeft.Width );
MainReg.WriteInteger( REGNAME_SQLHELPPRHEIGHT, memoDescription.Height );
AppSettings.WriteInt(asSQLHelpWindowLeft, Left );
AppSettings.WriteInt(asSQLHelpWindowTop, Top );
AppSettings.WriteInt(asSQLHelpWindowWidth, Width );
AppSettings.WriteInt(asSQLHelpWindowHeight, Height );
AppSettings.WriteInt(asSQLHelpPnlLeftWidth, pnlLeft.Width );
AppSettings.WriteInt(asSQLHelpPnlRightTopHeight, memoDescription.Height );
end;