mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Optimize file types colors editing interface (issue #1078)
(cherry picked from commit a5606c0f88)
This commit is contained in:
parent
ad1f683101
commit
91cab20d38
3 changed files with 112 additions and 125 deletions
|
|
@ -81,6 +81,7 @@ inherited frmOptionsFileTypesColors: TfrmOptionsFileTypesColors
|
|||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Bottom = 8
|
||||
TabOrder = 1
|
||||
OnChange = edtCategoryNameChange
|
||||
end
|
||||
object edtCategoryMask: TEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
|
|
@ -95,12 +96,12 @@ inherited frmOptionsFileTypesColors: TfrmOptionsFileTypesColors
|
|||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Bottom = 8
|
||||
TabOrder = 2
|
||||
OnChange = edtCategoryMaskChange
|
||||
end
|
||||
object cbCategoryColor: TKASColorBoxButton
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = edtCategoryAttr
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = btnApplyCategory
|
||||
Left = 170
|
||||
Height = 25
|
||||
Top = 249
|
||||
|
|
@ -108,13 +109,13 @@ inherited frmOptionsFileTypesColors: TfrmOptionsFileTypesColors
|
|||
Anchors = [akLeft, akRight, akBottom]
|
||||
TabOrder = 5
|
||||
BorderSpacing.Bottom = 12
|
||||
OnChange = cbCategoryColorChange
|
||||
end
|
||||
object btnAddCategory: TBitBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = btnDeleteCategory
|
||||
AnchorSideBottom.Control = btnApplyCategory
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 389
|
||||
Left = 505
|
||||
Height = 32
|
||||
Top = 286
|
||||
Width = 110
|
||||
|
|
@ -126,15 +127,14 @@ inherited frmOptionsFileTypesColors: TfrmOptionsFileTypesColors
|
|||
end
|
||||
object btnDeleteCategory: TBitBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = btnApplyCategory
|
||||
AnchorSideBottom.Control = btnApplyCategory
|
||||
AnchorSideRight.Control = lbCategories
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 505
|
||||
Left = 621
|
||||
Height = 32
|
||||
Top = 286
|
||||
Width = 110
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'D&elete'
|
||||
OnClick = btnDeleteCategoryClick
|
||||
TabOrder = 7
|
||||
|
|
@ -154,28 +154,12 @@ inherited frmOptionsFileTypesColors: TfrmOptionsFileTypesColors
|
|||
BorderSpacing.Bottom = 12
|
||||
DragMode = dmAutomatic
|
||||
ItemHeight = 0
|
||||
OnClick = lbCategoriesClick
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 0
|
||||
OnDragDrop = lbCategoriesDragDrop
|
||||
OnDragOver = lbCategoriesDragOver
|
||||
OnDrawItem = lbCategoriesDrawItem
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnApplyCategory: TBitBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = lbCategories
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = gbFileTypesColors
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 621
|
||||
Height = 32
|
||||
Top = 286
|
||||
Width = 110
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'A&pply'
|
||||
OnClick = btnApplyCategoryClick
|
||||
TabOrder = 8
|
||||
OnSelectionChange = lbCategoriesSelectionChange
|
||||
end
|
||||
object edtCategoryAttr: TEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
|
|
@ -189,6 +173,7 @@ inherited frmOptionsFileTypesColors: TfrmOptionsFileTypesColors
|
|||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Bottom = 8
|
||||
TabOrder = 4
|
||||
OnChange = edtCategoryAttrChange
|
||||
end
|
||||
object btnSearchTemplate: TBitBtn
|
||||
AnchorSideTop.Control = edtCategoryMask
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@
|
|||
{"hash":52377562,"name":"tfrmoptionsfiletypescolors.lblcategoryattr.caption","sourcebytes":[67,97,116,101,103,111,114,121,32,97,38,116,116,114,105,98,117,116,101,115,58],"value":"Category a&ttributes:"},
|
||||
{"hash":277668,"name":"tfrmoptionsfiletypescolors.btnaddcategory.caption","sourcebytes":[65,38,100,100],"value":"A&dd"},
|
||||
{"hash":114044133,"name":"tfrmoptionsfiletypescolors.btndeletecategory.caption","sourcebytes":[68,38,101,108,101,116,101],"value":"D&elete"},
|
||||
{"hash":71137081,"name":"tfrmoptionsfiletypescolors.btnapplycategory.caption","sourcebytes":[65,38,112,112,108,121],"value":"A&pply"},
|
||||
{"hash":47236478,"name":"tfrmoptionsfiletypescolors.btnsearchtemplate.hint","sourcebytes":[84,101,109,112,108,97,116,101,46,46,46],"value":"Template..."}
|
||||
]}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
File types colors options page
|
||||
|
||||
Copyright (C) 2006-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2006-2025 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -36,7 +36,6 @@ type
|
|||
|
||||
TfrmOptionsFileTypesColors = class(TOptionsEditor)
|
||||
btnAddCategory: TBitBtn;
|
||||
btnApplyCategory: TBitBtn;
|
||||
btnDeleteCategory: TBitBtn;
|
||||
btnSearchTemplate: TBitBtn;
|
||||
cbCategoryColor: TKASColorBoxButton;
|
||||
|
|
@ -50,16 +49,19 @@ type
|
|||
lblCategoryMask: TLabel;
|
||||
lblCategoryName: TLabel;
|
||||
|
||||
procedure lbCategoriesClick(Sender: TObject);
|
||||
procedure cbCategoryColorChange(Sender: TObject);
|
||||
procedure edtCategoryAttrChange(Sender: TObject);
|
||||
procedure edtCategoryMaskChange(Sender: TObject);
|
||||
procedure edtCategoryNameChange(Sender: TObject);
|
||||
procedure btnSearchTemplateClick(Sender: TObject);
|
||||
procedure btnAddCategoryClick(Sender: TObject);
|
||||
procedure btnApplyCategoryClick(Sender: TObject);
|
||||
procedure btnDeleteCategoryClick(Sender: TObject);
|
||||
procedure lbCategoriesDragDrop(Sender, {%H-}Source: TObject; {%H-}X, Y: Integer);
|
||||
procedure lbCategoriesDragOver(Sender, Source: TObject; {%H-}X, {%H-}Y: Integer;
|
||||
{%H-}State: TDragState; var Accept: Boolean);
|
||||
procedure lbCategoriesDrawItem(Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||
procedure lbCategoriesSelectionChange(Sender: TObject; User: boolean);
|
||||
|
||||
procedure Clear;
|
||||
protected
|
||||
|
|
@ -79,34 +81,33 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Graphics, uLng, uGlobs, uColorExt, fMaskInputDlg, uSearchTemplate, uDCUtils;
|
||||
Graphics, uLng, uGlobs, uColorExt, fMaskInputDlg, uSearchTemplate;
|
||||
|
||||
{ TfrmOptionsFileTypesColors }
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.lbCategoriesClick(Sender: TObject);
|
||||
var
|
||||
MaskItem : TMaskItem;
|
||||
bEnabled: Boolean;
|
||||
procedure TfrmOptionsFileTypesColors.edtCategoryNameChange(Sender: TObject);
|
||||
begin
|
||||
if (lbCategories.ItemIndex <> -1) then
|
||||
begin
|
||||
MaskItem := TMaskItem(lbCategories.Items.Objects[lbCategories.ItemIndex]);
|
||||
if lbCategories.ItemIndex < 0 then Exit;
|
||||
lbCategories.Items[lbCategories.ItemIndex]:= edtCategoryName.Text;
|
||||
TMaskItem(lbCategories.Items.Objects[lbCategories.ItemIndex]).sName:= edtCategoryName.Text;
|
||||
end;
|
||||
|
||||
edtCategoryName.Text := MaskItem.sName;
|
||||
edtCategoryMask.Text := MaskItem.sExt;
|
||||
cbCategoryColor.Selected := MaskItem.cColor;
|
||||
bEnabled:= (MaskItem.sExt = '') or (MaskItem.sExt[1] <> '>');
|
||||
edtCategoryMask.Enabled:= bEnabled;
|
||||
edtCategoryAttr.Enabled:= bEnabled;
|
||||
edtCategoryAttr.Text := MaskItem.sModeStr;
|
||||
end
|
||||
else
|
||||
begin
|
||||
edtCategoryName.Text := '';
|
||||
edtCategoryMask.Text := '';
|
||||
edtCategoryAttr.Text := '';
|
||||
cbCategoryColor.Selected := gColors.FilePanel^.ForeColor;
|
||||
end;
|
||||
procedure TfrmOptionsFileTypesColors.edtCategoryMaskChange(Sender: TObject);
|
||||
begin
|
||||
if lbCategories.ItemIndex < 0 then Exit;
|
||||
TMaskItem(lbCategories.Items.Objects[lbCategories.ItemIndex]).sExt:= edtCategoryMask.Text;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.edtCategoryAttrChange(Sender: TObject);
|
||||
begin
|
||||
if lbCategories.ItemIndex < 0 then Exit;
|
||||
TMaskItem(lbCategories.Items.Objects[lbCategories.ItemIndex]).sModeStr:= edtCategoryAttr.Text;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.cbCategoryColorChange(Sender: TObject);
|
||||
begin
|
||||
if lbCategories.ItemIndex < 0 then Exit;
|
||||
TMaskItem(lbCategories.Items.Objects[lbCategories.ItemIndex]).cColor:= cbCategoryColor.Selected;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.btnSearchTemplateClick(Sender: TObject);
|
||||
|
|
@ -130,28 +131,15 @@ var
|
|||
iIndex : Integer;
|
||||
MaskItem: TMaskItem;
|
||||
begin
|
||||
if lbCategories.Count = 0 then
|
||||
begin
|
||||
edtCategoryName.Enabled := True;
|
||||
edtCategoryMask.Enabled := True;
|
||||
edtCategoryAttr.Enabled := True;
|
||||
cbCategoryColor.Enabled := True;
|
||||
btnDeleteCategory.Enabled := True;
|
||||
btnApplyCategory.Enabled := True;
|
||||
end;
|
||||
|
||||
MaskItem := TMaskItem.Create;
|
||||
try
|
||||
edtCategoryName.Text := rsOptionsEditorFileNewFileTypes;
|
||||
edtCategoryMask.Text := '*';
|
||||
edtCategoryAttr.Text := '';
|
||||
cbCategoryColor.Selected := gColors.FilePanel^.ForeColor;
|
||||
MaskItem.sName:= rsOptionsEditorFileNewFileTypes;
|
||||
MaskItem.sExt:= AllFilesMask;
|
||||
MaskItem.sModeStr:= EmptyStr;
|
||||
MaskItem.cColor:= gColors.FilePanel^.ForeColor;
|
||||
|
||||
iIndex:= lbCategories.Items.AddObject(MaskItem.sName, MaskItem);
|
||||
|
||||
MaskItem.sName:= edtCategoryName.Text;
|
||||
MaskItem.sExt:= edtCategoryMask.Text;
|
||||
MaskItem.sModeStr:= edtCategoryAttr.Text;
|
||||
MaskItem.cColor:= clBlack;
|
||||
iIndex := lbCategories.Items.AddObject(MaskItem.sName, MaskItem);
|
||||
except
|
||||
FreeAndNil(MaskItem);
|
||||
raise;
|
||||
|
|
@ -160,33 +148,18 @@ begin
|
|||
edtCategoryName.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.btnApplyCategoryClick(Sender: TObject);
|
||||
var
|
||||
MaskItem : TMaskItem;
|
||||
begin
|
||||
if (lbCategories.ItemIndex <> -1) then
|
||||
begin
|
||||
lbCategories.Items[lbCategories.ItemIndex] := edtCategoryName.Text;
|
||||
if edtCategoryMask.Text = '' then
|
||||
edtCategoryMask.Text := '*'; // because we load colors from ini by mask
|
||||
MaskItem := TMaskItem(lbCategories.Items.Objects[lbCategories.ItemIndex]);
|
||||
|
||||
MaskItem.sName := edtCategoryName.Text;
|
||||
MaskItem.cColor := cbCategoryColor.Selected;
|
||||
MaskItem.sExt := edtCategoryMask.Text;
|
||||
MaskItem.sModeStr := edtCategoryAttr.Text;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.btnDeleteCategoryClick(Sender: TObject);
|
||||
begin
|
||||
if (lbCategories.ItemIndex <> -1) then
|
||||
begin
|
||||
lbCategories.Items.Objects[lbCategories.ItemIndex].Free;
|
||||
lbCategories.Items.Delete(lbCategories.ItemIndex);
|
||||
|
||||
if lbCategories.Count > 0 then
|
||||
lbCategories.ItemIndex := 0;
|
||||
lbCategoriesClick(lbCategories);
|
||||
lbCategories.ItemIndex:= 0
|
||||
else begin
|
||||
lbCategoriesSelectionChange(lbCategories, True);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -233,12 +206,47 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.lbCategoriesSelectionChange(
|
||||
Sender: TObject; User: boolean);
|
||||
var
|
||||
Index: Integer;
|
||||
bEnabled: Boolean;
|
||||
MaskItem: TMaskItem;
|
||||
begin
|
||||
Index:= lbCategories.ItemIndex;
|
||||
|
||||
if (Index <> -1) then
|
||||
begin
|
||||
MaskItem := TMaskItem(lbCategories.Items.Objects[Index]);
|
||||
|
||||
edtCategoryName.Text := MaskItem.sName;
|
||||
edtCategoryMask.Text := MaskItem.sExt;
|
||||
cbCategoryColor.Selected := MaskItem.cColor;
|
||||
bEnabled:= (MaskItem.sExt = '') or (MaskItem.sExt[1] <> '>');
|
||||
edtCategoryAttr.Text := MaskItem.sModeStr;
|
||||
end
|
||||
else begin
|
||||
bEnabled := False;
|
||||
edtCategoryName.Text := '';
|
||||
edtCategoryMask.Text := '';
|
||||
edtCategoryAttr.Text := '';
|
||||
cbCategoryColor.Selected := gColors.FilePanel^.ForeColor;
|
||||
end;
|
||||
|
||||
edtCategoryMask.Enabled:= bEnabled;
|
||||
edtCategoryAttr.Enabled:= bEnabled;
|
||||
edtCategoryName.Enabled:= (Index <> -1);
|
||||
cbCategoryColor.Enabled:= (Index <> -1);
|
||||
btnSearchTemplate.Enabled:= (Index <> -1);
|
||||
btnDeleteCategory.Enabled:= (Index <> -1);
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
I: Integer;
|
||||
begin
|
||||
for i := lbCategories.Count - 1 downto 0 do
|
||||
lbCategories.Items.Objects[i].Free;
|
||||
for I := lbCategories.Count - 1 downto 0 do
|
||||
lbCategories.Items.Objects[I].Free;
|
||||
|
||||
lbCategories.Clear;
|
||||
end;
|
||||
|
|
@ -274,51 +282,46 @@ begin
|
|||
|
||||
{ File lbtypes category color }
|
||||
for I := 0 to gColorExt.Count - 1 do
|
||||
begin
|
||||
MaskItem := TMaskItem.Create;
|
||||
try
|
||||
MaskItem.Assign(gColorExt[I]);
|
||||
lbCategories.Items.AddObject(MaskItem.sName, MaskItem);
|
||||
except
|
||||
FreeAndNil(MaskItem);
|
||||
raise;
|
||||
end;
|
||||
end; // for
|
||||
begin
|
||||
MaskItem := TMaskItem.Create;
|
||||
try
|
||||
MaskItem.Assign(gColorExt[I]);
|
||||
lbCategories.Items.AddObject(MaskItem.sName, MaskItem);
|
||||
except
|
||||
FreeAndNil(MaskItem);
|
||||
raise;
|
||||
end;
|
||||
end; // for
|
||||
|
||||
if lbCategories.Count > 0 then
|
||||
lbCategories.ItemIndex := 0
|
||||
else
|
||||
begin
|
||||
edtCategoryName.Enabled := False;
|
||||
edtCategoryMask.Enabled := False;
|
||||
edtCategoryAttr.Enabled := False;
|
||||
cbCategoryColor.Enabled := False;
|
||||
btnDeleteCategory.Enabled := False;
|
||||
btnApplyCategory.Enabled := False;
|
||||
end;
|
||||
lbCategoriesClick(lbCategories);
|
||||
if lbCategories.Count > 0 then
|
||||
begin
|
||||
lbCategories.ItemIndex := 0
|
||||
end;
|
||||
lbCategoriesSelectionChange(lbCategories, True);
|
||||
end;
|
||||
|
||||
function TfrmOptionsFileTypesColors.Save: TOptionsEditorSaveFlags;
|
||||
var
|
||||
i: Integer;
|
||||
I: Integer;
|
||||
MaskItem: TMaskItem;
|
||||
begin
|
||||
Result := [];
|
||||
gColorExt.Clear;
|
||||
|
||||
for I := 0 to lbCategories.Count - 1 do //write new categories
|
||||
for I := 0 to lbCategories.Count - 1 do
|
||||
begin
|
||||
if Assigned(lbCategories.Items.Objects[I]) then
|
||||
begin
|
||||
MaskItem := TMaskItem.Create;
|
||||
try
|
||||
MaskItem.Assign(TMaskItem(lbCategories.Items.Objects[I]));
|
||||
gColorExt.Add(MaskItem);
|
||||
MaskItem.Assign(TMaskItem(lbCategories.Items.Objects[I]));
|
||||
gColorExt.Add(MaskItem);
|
||||
except
|
||||
FreeAndNil(MaskItem);
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsFileTypesColors.CMThemeChanged(var Message: TLMessage);
|
||||
|
|
@ -330,7 +333,7 @@ end;
|
|||
destructor TfrmOptionsFileTypesColors.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
inherited;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue