mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Make language configuration page as TFrame.
UPD: Add Save result to report that options change needs restart.
This commit is contained in:
parent
3dadcdc476
commit
92ebc8a69a
9 changed files with 137 additions and 59 deletions
|
|
@ -203,7 +203,7 @@
|
|||
<PackageName Value="viewerpackage"/>
|
||||
</Item7>
|
||||
</RequiredPackages>
|
||||
<Units Count="120">
|
||||
<Units Count="121">
|
||||
<Unit0>
|
||||
<Filename Value="doublecmd.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
|
@ -939,6 +939,13 @@
|
|||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="uWinNetExecuteOperation"/>
|
||||
</Unit119>
|
||||
<Unit120>
|
||||
<Filename Value="frames\foptionslanguage.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="frmOptionsLanguage"/>
|
||||
<ResourceBaseClass Value="Frame"/>
|
||||
<UnitName Value="fOptionsLanguage"/>
|
||||
</Unit120>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
|||
|
|
@ -128,20 +128,9 @@ object frmOptions: TfrmOptions
|
|||
Top = 24
|
||||
Width = 709
|
||||
Align = alClient
|
||||
PageIndex = 19
|
||||
PageIndex = 0
|
||||
TabOrder = 0
|
||||
object pgLng: TPage
|
||||
ClientWidth = 705
|
||||
ClientHeight = 458
|
||||
object lngList: TListBox
|
||||
Left = 0
|
||||
Height = 455
|
||||
Top = 0
|
||||
Width = 703
|
||||
Align = alClient
|
||||
ItemHeight = 0
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object pgBehav: TPage
|
||||
ClientWidth = 705
|
||||
|
|
|
|||
|
|
@ -284,7 +284,6 @@ type
|
|||
lblRunTerm: TLabel;
|
||||
lblRunInTerm: TLabel;
|
||||
lblViewerFont: TLabel;
|
||||
lngList: TListBox;
|
||||
cbLogArcOp: TCheckBox;
|
||||
cbLogCpMvLn: TCheckBox;
|
||||
cbLogDelete: TCheckBox;
|
||||
|
|
@ -441,7 +440,6 @@ type
|
|||
}
|
||||
procedure FillHKControlList();
|
||||
public
|
||||
procedure FillLngListBox;
|
||||
procedure FillFontLists;
|
||||
procedure FillColumnsList;
|
||||
procedure FillCommandsPage;
|
||||
|
|
@ -461,7 +459,7 @@ uses
|
|||
uColorExt, uDCUtils, uOSUtils, fColumnsSetConf, uShowMsg, uShowForm,
|
||||
uTypes, StrUtils, uFindEx, uKeyboard,
|
||||
fMaskInputDlg, uSearchTemplate, uMultiArc, uFile, uDebug,
|
||||
fOptionsPlugins, fOptionsToolTips, fOptionsColors;
|
||||
fOptionsPlugins, fOptionsToolTips, fOptionsColors, fOptionsLanguage;
|
||||
|
||||
const
|
||||
stgCmdCommandIndex = 0;
|
||||
|
|
@ -762,31 +760,6 @@ begin
|
|||
edtViewerBookFont.Font.Size := edtViewerBookFontSize.Value;
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.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 TfrmOptions.btnOKClick(Sender: TObject);
|
||||
begin
|
||||
// save all configuration
|
||||
|
|
@ -2040,7 +2013,6 @@ begin
|
|||
memIgnoreList.Lines.Assign(glsIgnoreList);
|
||||
chkIgnoreEnableChange(chkIgnoreEnable);
|
||||
|
||||
FillLngListBox;
|
||||
FillFontLists;
|
||||
|
||||
FillColumnsList;
|
||||
|
|
@ -2057,6 +2029,7 @@ end;
|
|||
procedure TfrmOptions.SaveConfig;
|
||||
var
|
||||
I: LongInt;
|
||||
NeedsRestart: Boolean = False;
|
||||
begin
|
||||
{ Layout page }
|
||||
gMainMenu := cbShowMainMenu.Checked;
|
||||
|
|
@ -2286,25 +2259,24 @@ begin
|
|||
|
||||
//-------------------------------------------------
|
||||
if (gIconsSizeNew <> StrToInt(Copy(cbIconsSize.Text, 1, 2))) or
|
||||
(gShowIconsNew <> gShowIcons) or ((lngList.ItemIndex>-1) and
|
||||
(Trim(gPOFileName) <> Trim(lngList.Items.Names[lngList.ItemIndex]))) then
|
||||
(gShowIconsNew <> gShowIcons) then
|
||||
begin
|
||||
gIconsSizeNew:= StrToInt(Copy(cbIconsSize.Text, 1, 2)); // new file panel icons size
|
||||
if lngList.ItemIndex > -1 then
|
||||
gPOFileName:= Trim(lngList.Items.Names[lngList.ItemIndex]); // new language file
|
||||
msgOk(rsMsgRestartForApplyChanges);
|
||||
NeedsRestart := True;
|
||||
end;
|
||||
//-------------------------------------------------
|
||||
|
||||
frmMain.UpdateWindowView;
|
||||
frmMain.Repaint; // for panels repaint
|
||||
|
||||
{save hot keys file}
|
||||
gNameSCFile := lbSCFilesList.GetSelectedText;
|
||||
|
||||
{ Save options from frames }
|
||||
for I:= 0 to FOptionsEditorList.Count - 1 do
|
||||
FOptionsEditorList[I].Save;
|
||||
if oesfNeedsRestart in FOptionsEditorList[I].Save then
|
||||
NeedsRestart := True;
|
||||
|
||||
if NeedsRestart then
|
||||
msgOk(rsMsgRestartForApplyChanges);
|
||||
|
||||
frmMain.UpdateWindowView;
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.DeleteHotkeyFromGrid(aHotkey: String);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
12
src/frames/foptionslanguage.lfm
Normal file
12
src/frames/foptionslanguage.lfm
Normal 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
|
||||
92
src/frames/foptionslanguage.pas
Normal file
92
src/frames/foptionslanguage.pas
Normal 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.
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue