ADD: Option to display free space label at the drive bar (issue #2498)

This commit is contained in:
Alexander Koblov 2025-10-04 16:46:34 +03:00
commit 70b656b88d
2 changed files with 74 additions and 5 deletions

View file

@ -5052,10 +5052,37 @@ procedure TfrmMain.AddSpecialButtons(dskPanel: TKASToolBar);
Button := dskPanel.AddButton(ToolItem);
Button.GroupIndex := 0;
end;
procedure AddFreeSpace;
var
S: String;
Button: TKASToolButton;
ToolItem: TKASLabelItem;
begin
ToolItem := TKASLabelItem.Create;
Button := dskPanel.AddButton(ToolItem);
Button.GroupIndex := 0;
if gShortFormatDriveInfo then
S := Format(rsFreeMsgShort, [cnvFormatFileSize(High(Int64), uoscHeader)])
else begin
S := Format(rsFreeMsg, [cnvFormatFileSize(High(Int64), uoscHeader), cnvFormatFileSize(High(Int64), uoscHeader)]);;
end;
Button.Alignment:= taLeftJustify;
Button.Constraints.MinWidth:= Button.Canvas.TextWidth(S) + ScaleX(16, 96);
end;
begin
AddItem(btnLeftRoot);
AddItem(btnLeftUp);
AddItem(btnLeftHome);
if gDriveFreeSpace and gDriveBarFreeSpace then
begin
AddFreeSpace;
end;
end;
procedure TfrmMain.CreateDiskPanel(dskPanel: TKASToolBar);
@ -5658,9 +5685,9 @@ begin
btnLeftDirectoryHotlist.Flat := gInterfaceFlat;
btnLeftEqualRight.Visible := gDrivesListButton;
btnLeftEqualRight.Flat:= gInterfaceFlat;
lblLeftDriveInfo.Visible:= gDriveFreeSpace;
lblLeftDriveInfo.Visible:= (gDriveFreeSpace and not (gDriveBarFreeSpace and not gDrivesListButton));
pbxLeftDrive.Visible := gDriveInd;
pnlLeftTools.Visible:= gDrivesListButton or gDriveFreeSpace or gDriveInd;
pnlLeftTools.Visible:= gDrivesListButton or gDriveInd or lblLeftDriveInfo.Visible;
pnlLeftTools.DoubleBuffered := True;
btnRightDrive.Visible := gDrivesListButton;
@ -5675,13 +5702,13 @@ begin
btnRightDirectoryHotlist.Flat := gInterfaceFlat;
btnRightEqualLeft.Visible := gDrivesListButton;
btnRightEqualLeft.Flat:= gInterfaceFlat;
lblRightDriveInfo.Visible:= gDriveFreeSpace;
lblRightDriveInfo.Visible:= (gDriveFreeSpace and not (gDriveBarFreeSpace and not gDrivesListButton));
pbxRightDrive.Visible := gDriveInd;
pnlRightTools.Visible:= gDrivesListButton or gDriveFreeSpace or gDriveInd;
pnlRightTools.Visible:= gDrivesListButton or gDriveInd or lblRightDriveInfo.Visible;
pnlRightTools.DoubleBuffered := True;
// Free space indicator.
if gDriveFreeSpace then
if (gDriveFreeSpace and not (gDriveBarFreeSpace and not gDrivesListButton)) then
begin
AnchorFreeSpace(lblLeftDriveInfo, lblRightDriveInfo, gDriveInd);
if gDriveInd then
@ -6899,6 +6926,7 @@ var
aFileView: TFileView;
sboxDrive: TPaintBox;
lblDriveInfo: TLabel;
Button: TKASToolButton = nil;
AData: TFreeSpaceData absolute Data;
begin
case AData.Panel of
@ -6915,10 +6943,26 @@ begin
lblDriveInfo := lblRightDriveInfo;
end;
end;
if gDriveFreeSpace and gDriveBar1 and (gDriveBarFreeSpace and not gDrivesListButton) then
begin
if gDriveBar2 or (AData.Panel = PanelSelected) then
begin
if (AData.Panel = fpRight) or (not gDriveBar2) then
Button:= dskRight.Buttons[dskRight.ButtonCount - 1]
else begin
Button:= dskLeft.Buttons[dskLeft.ButtonCount - 1];
end;
end;
end;
if mbCompareFileNames(AData.Path, aFileView.CurrentPath) then
begin
if not AData.Result then
begin
if Assigned(Button) then
begin
Button.Hint:= '';
Button.Caption:= '';
end;
lblDriveInfo.Caption := '';
lblDriveInfo.Hint := '';
sboxDrive.Hint := '';
@ -6942,6 +6986,12 @@ begin
lblDriveInfo.Caption := lblDriveInfo.Hint;
end;
sboxDrive.Hint := lblDriveInfo.Hint;
if Assigned(Button) then
begin
Button.Hint:= lblDriveInfo.Hint;
Button.Caption:= lblDriveInfo.Caption;
end;
end;
end;
AData.Free;
@ -6953,6 +7003,7 @@ var
sboxDrive: TPaintBox;
lblDriveInfo: TLabel;
AData: TFreeSpaceData;
Button: TKASToolButton;
begin
case Panel of
fpLeft :
@ -6976,6 +7027,20 @@ begin
sboxDrive.Hint := '';
sboxDrive.Tag := -1;
sboxDrive.Invalidate;
if gDriveFreeSpace and gDriveBar1 and (gDriveBarFreeSpace and not gDrivesListButton) then
begin
if gDriveBar2 or (Panel = PanelSelected) then
begin
if (Panel = fpRight) or (not gDriveBar2) then
Button:= dskRight.Buttons[dskRight.ButtonCount - 1]
else begin
Button:= dskLeft.Buttons[dskLeft.ButtonCount - 1];
end;
Button.Hint:= '';
Button.Caption:= '';
end;
end;
end;
AData := TFreeSpaceData.Create;

View file

@ -277,6 +277,7 @@ var
gDriveBar1,
gDriveBar2,
gDriveBarFlat,
gDriveBarFreeSpace,
gDriveBarSyncWidth,
gDrivesListButton,
gDirectoryTabs,
@ -1924,6 +1925,7 @@ begin
gDriveBar2 := True;
gDriveBarFlat := True;
gDrivesListButton := True;
gDriveBarFreeSpace := False;
gDriveBarSyncWidth := False;
gDirectoryTabs := True;
gCurDir := True;
@ -2831,6 +2833,7 @@ begin
gDriveBar1 := GetValue(Node, 'DriveBar1', gDriveBar1);
gDriveBar2 := GetValue(Node, 'DriveBar2', gDriveBar2);
gDriveBarFlat := GetValue(Node, 'DriveBarFlat', gDriveBarFlat);
gDriveBarFreeSpace := GetValue(Node, 'DriveBarFreeSpace', gDriveBarFreeSpace);
if LoadedConfigVersion < 3 then
gDrivesListButton := GetValue(Node, 'DriveMenuButton', gDrivesListButton)
else
@ -3548,6 +3551,7 @@ begin
SetValue(Node, 'DriveBar1', gDriveBar1);
SetValue(Node, 'DriveBar2', gDriveBar2);
SetValue(Node, 'DriveBarFlat', gDriveBarFlat);
SetValue(Node, 'DriveBarFreeSpace', gDriveBarFreeSpace);
SubNode := FindNode(Node, 'DrivesListButton', True);
SetAttr(SubNode, 'Enabled', gDrivesListButton);
SetValue(SubNode, 'ShowLabel', dlbShowLabel in gDrivesListButtonOptions);