mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: Patch [ 1882307 ] KasMenuBar update from Dmitry Kolomiets
This commit is contained in:
parent
d6293afe18
commit
8e5ba009fe
3 changed files with 74 additions and 14 deletions
|
|
@ -46,7 +46,8 @@ type
|
|||
ParamX,
|
||||
PathX,
|
||||
MenuX,
|
||||
IconicX
|
||||
IconicX,
|
||||
MiskX
|
||||
);
|
||||
//------------------------------------------------------
|
||||
|
||||
|
|
@ -59,6 +60,7 @@ type
|
|||
PathX:string;
|
||||
MenuX:string; //Description
|
||||
IconicX:Integer; //-1 0 1 full default minimized ( as TC use)
|
||||
MiskX:string; //Aditional info (shortCut or extention or something else)
|
||||
end;
|
||||
//---------------------------------
|
||||
|
||||
|
|
@ -84,12 +86,13 @@ type
|
|||
destructor Destroy; override;
|
||||
//---------------------
|
||||
function GetButtonX(Index:integer; What:TInfor):string;
|
||||
function AddButtonX(ButtonX, CmdX, ParamX, PathX, MenuX:string ):integer;
|
||||
function AddButtonX(ButtonX, CmdX, ParamX, PathX, MenuX, MiskX:string ):integer;
|
||||
//---------------------
|
||||
procedure RemoveButton(Index: Integer);
|
||||
procedure DeleteAllButtons;
|
||||
procedure SetButtonX(Index:integer; What:Tinfor;Value: string);
|
||||
procedure LoadFromFile(FileName : String);
|
||||
procedure LoadFromStringList(List:TStringList);
|
||||
procedure SaveToFile(FileName : String);
|
||||
//---------------------
|
||||
property ButtonCount: Integer read GetButtonCount;
|
||||
|
|
@ -137,6 +140,7 @@ If Index>=XButtons.Count then XButtons.Add(TKButton.Create);
|
|||
else
|
||||
TKButton(XButtons.Items[Index]).iconicX:=StrToInt(Value);
|
||||
end;
|
||||
MiskX: TKButton(XButtons.Items[Index]).MiskX:=Value;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
|
@ -151,10 +155,11 @@ if (index>=XButtons.Count) or (Index<0) then Exit;
|
|||
pathX: Result := TKButton(XButtons.Items[Index]).PathX;
|
||||
menuX: Result := TKButton(XButtons.Items[Index]).MenuX;
|
||||
iconicX: Result := IntToStr(TKButton(XButtons.Items[Index]).IconicX);
|
||||
MiskX: Result := TKButton(XButtons.Items[Index]).MiskX;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TBarClass.AddButtonX(ButtonX, CmdX, ParamX, PathX, MenuX: string
|
||||
function TBarClass.AddButtonX(ButtonX, CmdX, ParamX, PathX, MenuX,MiskX: string
|
||||
): integer;
|
||||
begin
|
||||
Result:=XButtons.Add(TKButton.Create);
|
||||
|
|
@ -163,6 +168,7 @@ begin
|
|||
TKButton(XButtons[Result]).ParamX:=ParamX;
|
||||
TKButton(XButtons[Result]).PathX:=PathX;
|
||||
TKButton(XButtons[Result]).MenuX:=MenuX;
|
||||
TKButton(XButtons[Result]).MiskX:=MiskX;
|
||||
end;
|
||||
|
||||
procedure TBarClass.LoadFromFile(FileName: String);
|
||||
|
|
@ -183,11 +189,44 @@ begin
|
|||
TKButton(XButtons[I-1]).PathX := IniFile.ReadString('Buttonbar', 'path' + IntToStr(I), '');
|
||||
TKButton(XButtons[I-1]).MenuX := IniFile.ReadString('Buttonbar', 'menu' + IntToStr(I), '');
|
||||
TKButton(XButtons[I-1]).IconicX := IniFile.ReadInteger('Buttonbar', 'icon' + IntToStr(I),0);
|
||||
|
||||
TKButton(XButtons[I-1]).MiskX := IniFile.ReadString('Buttonbar', 'misk' + IntToStr(I), '');
|
||||
end;
|
||||
IniFile.Free;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBarClass.LoadFromStringList(List: TStringList);
|
||||
|
||||
function ItemOfList(Item:string):string;
|
||||
begin
|
||||
if (List.IndexOfName(Item)>0) then
|
||||
Result:=List.ValueFromIndex[List.IndexOfName(Item)]
|
||||
else
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
var BtnCount, I : Integer;
|
||||
begin
|
||||
DeleteAllButtons;
|
||||
if (List.IndexOfName('Buttoncount')<>0) then exit;
|
||||
BtnCount:=StrToInt(List.ValueFromIndex[List.IndexOfName('Buttoncount')]);
|
||||
|
||||
CurrentBar:='Virtual';
|
||||
for I := 1 to BtnCount do
|
||||
begin
|
||||
XButtons.Add(TKButton.Create);
|
||||
TKButton(XButtons[I-1]).ButtonX :=GetCmdDirFromEnvVar(ItemOfList('button' + IntToStr(I)));
|
||||
TKButton(XButtons[I-1]).CmdX := ItemOfList('cmd' + IntToStr(I));
|
||||
TKButton(XButtons[I-1]).ParamX :=ItemOfList('param' + IntToStr(I));
|
||||
TKButton(XButtons[I-1]).PathX := ItemOfList('path' + IntToStr(I));
|
||||
TKButton(XButtons[I-1]).MenuX := ItemOfList('menu' + IntToStr(I));
|
||||
if (ItemOfList('icon' + IntToStr(I))<>'') then
|
||||
TKButton(XButtons[I-1]).IconicX := StrToInt(ItemOfList('icon' + IntToStr(I)));
|
||||
TKButton(XButtons[I-1]).MiskX := ItemOfList('misk' + IntToStr(I));
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TBarClass.SaveToFile(FileName: String);
|
||||
var
|
||||
IniFile : Tinifile;
|
||||
|
|
@ -206,6 +245,7 @@ if FileExists(FileName) then DeleteFile(FileName);
|
|||
IniFile.WriteString('Buttonbar', 'param' + IntToStr(I + 1), GetButtonX(I,ParamX) );
|
||||
IniFile.WriteString('Buttonbar', 'path' + IntToStr(I + 1), GetButtonX(I,PathX) );
|
||||
IniFile.WriteString('Buttonbar', 'menu' + IntToStr(I + 1),GetButtonX(I,MenuX) );
|
||||
IniFile.WriteString('Buttonbar', 'misk' + IntToStr(I + 1),GetButtonX(I,MiskX) );
|
||||
end;
|
||||
IniFile.Free;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -62,8 +62,11 @@ TOnMenuButtonClick = procedure (Sender: TObject; NumberOfButton : Integer) of ob
|
|||
//---------------------
|
||||
|
||||
procedure Clear;
|
||||
procedure LoadFromStringList(List: TStringList);
|
||||
procedure LoadBarFile(FileName:string);
|
||||
procedure SaveToFile(FileName : String);
|
||||
|
||||
procedure MakeMenu;
|
||||
//------------------------------------------------------
|
||||
|
||||
published
|
||||
|
|
@ -133,13 +136,9 @@ begin
|
|||
FBar.DeleteAllButtons;
|
||||
end;
|
||||
|
||||
procedure TKASBarMenu.LoadBarFile(FileName: string);
|
||||
procedure TKASBarMenu.MakeMenu;
|
||||
var I:Integer; Item:TMenuItem;
|
||||
begin
|
||||
FBar.DeleteAllButtons;
|
||||
Self.Items.Clear;
|
||||
|
||||
FBar.LoadFromFile(FileName);
|
||||
For I:=0 to Fbar.ButtonCount-1 do
|
||||
begin
|
||||
Item:=TMenuItem.Create(Self);
|
||||
|
|
@ -156,6 +155,23 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TKASBarMenu.LoadBarFile(FileName: string);
|
||||
begin
|
||||
FBar.DeleteAllButtons;
|
||||
Self.Items.Clear;
|
||||
FBar.LoadFromFile(FileName);
|
||||
MakeMenu;
|
||||
end;
|
||||
|
||||
procedure TKASBarMenu.LoadFromStringList(List: TStringList);
|
||||
begin
|
||||
FBar.DeleteAllButtons;
|
||||
Self.Items.Clear;
|
||||
FBar.LoadFromStringList(List);
|
||||
MakeMenu;
|
||||
|
||||
end;
|
||||
|
||||
procedure TKASBarMenu.SaveToFile(FileName: String);
|
||||
begin
|
||||
FBar.SaveToFile(FileName);
|
||||
|
|
|
|||
14
default.bar
14
default.bar
|
|
@ -1,5 +1,5 @@
|
|||
[Buttonbar]
|
||||
Buttoncount=5
|
||||
Buttoncount=7
|
||||
button1=%commander_path%\pixmaps\16x16\actions\view-refresh.png
|
||||
cmd1=actRefresh
|
||||
menu1=Refresh
|
||||
|
|
@ -12,7 +12,11 @@ menu3=Select group...
|
|||
button4=%commander_path%\pixmaps\16x16\actions\list-remove.png
|
||||
cmd4=actMarkMinus
|
||||
menu4=Unselect group...
|
||||
button5=%commander_path%/pixmaps/16x16/actions/go-up.png
|
||||
cmd5=actShowButtonMenu
|
||||
param5=default.bar
|
||||
menu5=Example of ShowButtonMenu
|
||||
menu5=-
|
||||
button6=%commander_path%\pixmaps\16x16\actions\go-up.png
|
||||
cmd6=actShowButtonMenu
|
||||
param6=default.bar
|
||||
menu6=Example of ShowButtonMenu
|
||||
button7=%commander_path%\pixmaps\16x16\filesystems\archive.png
|
||||
cmd7=actPackFiles
|
||||
menu7=Pack files...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue