UPD: Make language configuration page as TFrame.

UPD: Add Save result to report that options change needs restart.
This commit is contained in:
cobines 2011-08-30 21:25:58 +00:00
commit 92ebc8a69a
9 changed files with 137 additions and 59 deletions

View file

@ -100,7 +100,7 @@ type
procedure Done; override;
public
procedure Load; override;
procedure Save; override;
function Save: TOptionsEditorSaveFlags; override;
end;
implementation
@ -490,7 +490,7 @@ begin
tbInactivePanelBrightness.Position:= gInactivePanelBrightness;
end;
procedure TfrmOptionsColors.Save;
function TfrmOptionsColors.Save: TOptionsEditorSaveFlags;
begin
gForeColor := cbTextColor.Selected;
gBackColor := cbBackColor.Selected; // background color
@ -501,6 +501,7 @@ begin
gUseInvertedSelection := cbbUseInvertedSelection.Checked;
gInactivePanelBrightness := tbInactivePanelBrightness.Position;
gUseFrameCursor := cbbUseFrameCursor.Checked;
Result := [];
end;
initialization

View file

@ -31,6 +31,9 @@ type
optedArchivers,
optedTooltips);
TOptionsEditorSaveFlag = (oesfNeedsRestart);
TOptionsEditorSaveFlags = set of TOptionsEditorSaveFlag;
{ TOptionsEditorClass }
TOptionsEditorClass = class of TOptionsEditor;
@ -46,7 +49,7 @@ type
destructor Destroy; override;
procedure Load; virtual; abstract;
procedure Save; virtual; abstract;
function Save: TOptionsEditorSaveFlags; virtual; abstract;
end;
{ TOptionsEditorRec }

View file

@ -0,0 +1,12 @@
inherited frmOptionsLanguage: TfrmOptionsLanguage
Align = alClient
object lngList: TListBox[0]
Left = 0
Height = 240
Top = 0
Width = 320
Align = alClient
ItemHeight = 0
TabOrder = 0
end
end

View file

@ -0,0 +1,92 @@
unit fOptionsLanguage;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, StdCtrls,
fOptionsFrame;
type
{ TfrmOptionsLanguage }
TfrmOptionsLanguage = class(TOptionsEditor)
lngList: TListBox;
private
procedure FillLngListBox;
protected
procedure Init; override;
procedure Done; override;
public
procedure Load; override;
function Save: TOptionsEditorSaveFlags; override;
end;
implementation
{$R *.lfm}
uses
uDebug, uFindEx, uTypes, uGlobs, uGlobsPaths, uLng;
{ TfrmOptionsLanguage }
procedure TfrmOptionsLanguage.FillLngListBox;
var
fr: TSearchRecEx;
iIndex: Integer;
sLangName: String;
begin
lngList.Clear;
DCDebug('Language dir: ' + gpLngDir);
if FindFirstEx(gpLngDir+'*.po', faAnyFile, fr)<>0 then
begin
FindCloseEx(fr);
Exit;
end;
repeat
sLangName := GetLanguageName(gpLngDir + fr.Name);
lngList.Items.Add(Format('%s = (%s)', [fr.Name, sLangName]));
until FindNextEx(fr)<>0;
FindCloseEx(fr);
iIndex:=lngList.Items.IndexOfName(gPOFileName + #32);
if iIndex>=0 then
lngList.Selected[iIndex]:=True;
end;
procedure TfrmOptionsLanguage.Init;
begin
end;
procedure TfrmOptionsLanguage.Done;
begin
end;
procedure TfrmOptionsLanguage.Load;
begin
FillLngListBox;
end;
function TfrmOptionsLanguage.Save: TOptionsEditorSaveFlags;
var
SelectedPOFileName: String;
begin
Result := [];
if lngList.ItemIndex > -1 then
begin
SelectedPOFileName := Trim(lngList.Items.Names[lngList.ItemIndex]);
if SelectedPOFileName <> gPOFileName then
Include(Result, oesfNeedsRestart);
gPOFileName := SelectedPOFileName;
end;
end;
initialization
RegisterOptionsEditor(optedLanguage, TfrmOptionsLanguage);
end.

View file

@ -74,7 +74,7 @@ type
procedure Done; override;
public
procedure Load; override;
procedure Save; override;
function Save: TOptionsEditorSaveFlags; override;
end;
var
@ -603,7 +603,7 @@ begin
tmpWLXPlugins.Assign(gWLXPlugins);
end;
procedure TfrmOptionsPlugins.Save;
function TfrmOptionsPlugins.Save: TOptionsEditorSaveFlags;
begin
{ Set plugins lists }
gDSXPlugins.Assign(tmpDSXPlugins);
@ -611,6 +611,7 @@ begin
gWDXPlugins.Assign(tmpWDXPlugins);
gWFXPlugins.Assign(tmpWFXPlugins);
gWLXPlugins.Assign(tmpWLXPlugins);
Result := [];
end;
initialization

View file

@ -69,7 +69,7 @@ type
procedure Done; override;
public
procedure Load; override;
procedure Save; override;
function Save: TOptionsEditorSaveFlags; override;
end;
implementation
@ -221,7 +221,7 @@ begin
lsbCustomFields.Items.Add(FFileInfoToolTip.HintItemList[I].Name);
end;
procedure TfrmOptionsToolTips.Save;
function TfrmOptionsToolTips.Save: TOptionsEditorSaveFlags;
begin
gShowToolTipMode:= []; // Reset tool tip show mode
if rbToolTipAllFiles.Checked then
@ -230,6 +230,7 @@ begin
Include(gShowToolTipMode, stm_only_large_name);
gFileInfoToolTip.Assign(FFileInfoToolTip);
Result := [];
end;
initialization