mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: In the option editor for "Mouse - Drag & Drop", the names of the possible text formats may now be localized (translatable). This is in response to issue [0001141].
This commit is contained in:
parent
9a46e35568
commit
2efe5e73c2
2 changed files with 81 additions and 39 deletions
|
|
@ -51,8 +51,12 @@ type
|
|||
procedure GenericSomethingChanged(Sender: TObject);
|
||||
protected
|
||||
FModificationTookPlace: boolean;
|
||||
slUserLanguageName, slLegacyName: TStringList;
|
||||
procedure Init; override;
|
||||
procedure Done; override;
|
||||
procedure Load; override;
|
||||
function Save: TOptionsEditorSaveFlags; override;
|
||||
function GetUserNameFromLegacyName(sLegacyName: string): string;
|
||||
procedure LoadDesiredOrderTextFormatList;
|
||||
procedure SaveDesiredOrderTextFormatList;
|
||||
public
|
||||
|
|
@ -68,15 +72,47 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
fOptions, uShowMsg, uGlobs, uLng;
|
||||
DCStrUtils, fOptions, uShowMsg, uGlobs, uLng;
|
||||
|
||||
{ TfrmOptionsDragDrop }
|
||||
|
||||
{ TfrmOptionsDragDrop.Init }
|
||||
procedure TfrmOptionsDragDrop.Init;
|
||||
var
|
||||
iFormat: integer;
|
||||
begin
|
||||
slUserLanguageName := TStringList.Create;
|
||||
ParseLineToList(rsDragAndDropTextFormat, slUserLanguageName);
|
||||
|
||||
slLegacyName := TStringList.Create;
|
||||
for iFormat := 0 to pred(NbOfDropTextFormat) do
|
||||
slLegacyName.Add(gDragAndDropDesiredTextFormat[iFormat].Name);
|
||||
end;
|
||||
|
||||
{ TfrmOptionsDragDrop.Done }
|
||||
procedure TfrmOptionsDragDrop.Done;
|
||||
begin
|
||||
FreeAndNil(slUserLanguageName);
|
||||
FreeAndNil(slLegacyName);
|
||||
end;
|
||||
|
||||
{ TfrmOptionsDragDrop.GetUserNameFromLegacyName }
|
||||
function TfrmOptionsDragDrop.GetUserNameFromLegacyName(sLegacyName: string): string;
|
||||
var
|
||||
iPos: integer;
|
||||
begin
|
||||
Result := '???';
|
||||
iPos := slLegacyName.indexof(sLegacyName);
|
||||
if (iPos >= 0) and (iPos < NbOfDropTextFormat) then
|
||||
Result := slUserLanguageName.Strings[iPos];
|
||||
end;
|
||||
|
||||
{ TfrmOptionsDragDrop.Load }
|
||||
procedure TfrmOptionsDragDrop.Load;
|
||||
begin
|
||||
cbShowConfirmationDialog.Checked := gShowDialogOnDragDrop;
|
||||
{$IFDEF MSWINDOWS}
|
||||
gbTextDragAndDropRelatedOptions.Visible:=TRUE;
|
||||
gbTextDragAndDropRelatedOptions.Visible := True;
|
||||
LoadDesiredOrderTextFormatList;
|
||||
cbDragAndDropAskFormatEachTime.Checked := gDragAndDropAskFormatEachTime;
|
||||
cbDragAndDropTextAutoFilename.Checked := gDragAndDropTextAutoFilename;
|
||||
|
|
@ -137,36 +173,41 @@ end;
|
|||
|
||||
procedure TfrmOptionsDragDrop.LoadDesiredOrderTextFormatList;
|
||||
var
|
||||
IndexDropTextFormat, ExpectedPosition, ActualPosition:integer;
|
||||
IndexDropTextFormat, ExpectedPosition, ActualPosition: integer;
|
||||
TempoString: string;
|
||||
begin
|
||||
lbMostDesiredTextFormat.Clear;
|
||||
for IndexDropTextFormat:=0 to pred(NbOfDropTextFormat) do
|
||||
for IndexDropTextFormat := 0 to pred(NbOfDropTextFormat) do
|
||||
lbMostDesiredTextFormat.Items.Add(gDragAndDropDesiredTextFormat[IndexDropTextFormat].Name);
|
||||
|
||||
for IndexDropTextFormat:=0 to pred(NbOfDropTextFormat) do
|
||||
for IndexDropTextFormat := 0 to pred(NbOfDropTextFormat) do
|
||||
begin
|
||||
ExpectedPosition := gDragAndDropDesiredTextFormat[IndexDropTextFormat].DesireLevel;
|
||||
if (ExpectedPosition < 0) or (ExpectedPosition > pred(NbOfDropTextFormat)) then ExpectedPosition := pred(NbOfDropTextFormat);
|
||||
ActualPosition := lbMostDesiredTextFormat.Items.IndexOf(gDragAndDropDesiredTextFormat[IndexDropTextFormat].Name);
|
||||
if (ActualPosition <> -1) and (ExpectedPosition <> ActualPosition) then
|
||||
begin
|
||||
ExpectedPosition:=gDragAndDropDesiredTextFormat[IndexDropTextFormat].DesireLevel;
|
||||
if (ExpectedPosition<0) OR (ExpectedPosition>pred(NbOfDropTextFormat)) then ExpectedPosition:=pred(NbOfDropTextFormat);
|
||||
ActualPosition:=lbMostDesiredTextFormat.Items.IndexOf(gDragAndDropDesiredTextFormat[IndexDropTextFormat].Name);
|
||||
if (ActualPosition<>-1) AND (ExpectedPosition<>ActualPosition) then
|
||||
begin
|
||||
TempoString:=lbMostDesiredTextFormat.Items.Strings[ActualPosition];
|
||||
lbMostDesiredTextFormat.Items.Strings[ActualPosition]:=lbMostDesiredTextFormat.Items.Strings[ExpectedPosition];
|
||||
lbMostDesiredTextFormat.Items.Strings[ExpectedPosition]:=TempoString;
|
||||
end;
|
||||
TempoString := lbMostDesiredTextFormat.Items.Strings[ActualPosition];
|
||||
lbMostDesiredTextFormat.Items.Strings[ActualPosition] := lbMostDesiredTextFormat.Items.Strings[ExpectedPosition];
|
||||
lbMostDesiredTextFormat.Items.Strings[ExpectedPosition] := TempoString;
|
||||
end;
|
||||
end;
|
||||
|
||||
// At the last minutes, we translate to user's language the format names
|
||||
for ActualPosition := 0 to pred(lbMostDesiredTextFormat.Items.Count) do
|
||||
lbMostDesiredTextFormat.Items.Strings[ActualPosition] := GetUserNameFromLegacyName(lbMostDesiredTextFormat.Items.Strings[ActualPosition]);
|
||||
|
||||
lbMostDesiredTextFormat.ItemIndex := -1;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsDragDrop.SaveDesiredOrderTextFormatList;
|
||||
var
|
||||
IndexDropTextFormat, ActualPosition:integer;
|
||||
TempoString: string;
|
||||
IndexDropTextFormat, ActualPosition: integer;
|
||||
begin
|
||||
for IndexDropTextFormat:=0 to pred(NbOfDropTextFormat) do
|
||||
for IndexDropTextFormat := 0 to pred(NbOfDropTextFormat) do
|
||||
begin
|
||||
ActualPosition:=lbMostDesiredTextFormat.Items.IndexOf(gDragAndDropDesiredTextFormat[IndexDropTextFormat].Name);
|
||||
if (ActualPosition<>-1) then gDragAndDropDesiredTextFormat[IndexDropTextFormat].DesireLevel:=ActualPosition;
|
||||
ActualPosition := lbMostDesiredTextFormat.Items.IndexOf(GetUserNameFromLegacyName(gDragAndDropDesiredTextFormat[IndexDropTextFormat].Name));
|
||||
if (ActualPosition <> -1) then gDragAndDropDesiredTextFormat[IndexDropTextFormat].DesireLevel := ActualPosition;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -197,36 +238,36 @@ end;
|
|||
|
||||
// Arrange the list in such way that the most desired format is on top.
|
||||
// This routine is also used in "uOleDragDrop" for offering user's suggestion so the list is arranged according to user's desire
|
||||
procedure SortThisListAccordingToDragAndDropDesiredFormat(ListToSort:TStringList);
|
||||
function GetDesireLevel(SearchingText:string):integer;
|
||||
procedure SortThisListAccordingToDragAndDropDesiredFormat(ListToSort: TStringList);
|
||||
function GetDesireLevel(SearchingText: string): integer;
|
||||
var
|
||||
SearchingIndex:integer;
|
||||
SearchingIndex: integer;
|
||||
begin
|
||||
result:=-1;
|
||||
SearchingIndex:=0;
|
||||
while (SearchingIndex<NbOfDropTextFormat) AND (result=-1) do
|
||||
begin
|
||||
if gDragAndDropDesiredTextFormat[SearchingIndex].Name=SearchingText then result:=gDragAndDropDesiredTextFormat[SearchingIndex].DesireLevel;
|
||||
inc(SearchingIndex);
|
||||
end;
|
||||
Result := -1;
|
||||
SearchingIndex := 0;
|
||||
while (SearchingIndex < NbOfDropTextFormat) and (Result = -1) do
|
||||
begin
|
||||
if gDragAndDropDesiredTextFormat[SearchingIndex].Name = SearchingText then Result := gDragAndDropDesiredTextFormat[SearchingIndex].DesireLevel;
|
||||
Inc(SearchingIndex);
|
||||
end;
|
||||
end;
|
||||
var
|
||||
Index, InnerIndex, DesireLevelIndex, DesireLevelInnerIndex : integer;
|
||||
TempoString : string;
|
||||
Index, InnerIndex, DesireLevelIndex, DesireLevelInnerIndex: integer;
|
||||
TempoString: string;
|
||||
begin
|
||||
//It's a poor sort... But we don't have too many so we keep it simple.
|
||||
for Index:=0 to (ListToSort.Count-2) do
|
||||
for Index := 0 to (ListToSort.Count - 2) do
|
||||
begin
|
||||
for InnerIndex:=Index+1 to pred(ListToSort.Count) do
|
||||
for InnerIndex := Index + 1 to pred(ListToSort.Count) do
|
||||
begin
|
||||
DesireLevelIndex:=GetDesireLevel(ListToSort.Strings[Index]);
|
||||
DesireLevelInnerIndex:=GetDesireLevel(ListToSort.Strings[InnerIndex]);
|
||||
DesireLevelIndex := GetDesireLevel(ListToSort.Strings[Index]);
|
||||
DesireLevelInnerIndex := GetDesireLevel(ListToSort.Strings[InnerIndex]);
|
||||
|
||||
if (DesireLevelIndex>DesireLevelInnerIndex) AND (DesireLevelIndex<>-1) AND (DesireLevelInnerIndex<>-1) then
|
||||
if (DesireLevelIndex > DesireLevelInnerIndex) and (DesireLevelIndex <> -1) and (DesireLevelInnerIndex <> -1) then
|
||||
begin
|
||||
TempoString:=ListToSort.Strings[Index];
|
||||
ListToSort.Strings[Index]:=ListToSort.Strings[InnerIndex];
|
||||
ListToSort.Strings[InnerIndex]:=TempoString;
|
||||
TempoString := ListToSort.Strings[Index];
|
||||
ListToSort.Strings[Index] := ListToSort.Strings[InnerIndex];
|
||||
ListToSort.Strings[InnerIndex] := TempoString;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ resourcestring
|
|||
rsDefaultSuffixDroppedTextUnicodeUTF16Filename = '_DroppedUnicodeUTF16text';
|
||||
rsDefaultSuffixDroppedTextUnicodeUTF8Filename = '_DroppedUnicodeUTF8text';
|
||||
rsDefaultSuffixDroppedTextSimpleFilename = '_DroppedSimpleText';
|
||||
rsDragAndDropTextFormat = 'Rich Text Format;HTML Format;Unicode Format;Simple Text Format';
|
||||
rsCaptionForAskingFilename = 'Enter filename, with extension, for dropped text';
|
||||
rsMsgPromptAskingFilename = 'Filename for dropped text:';
|
||||
rsCaptionForTextFormatToImport = 'Text format to import';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue