ADD: Option to on/off icons in menus

This commit is contained in:
Alexander Koblov 2013-02-20 15:23:33 +00:00
commit 5edbee9e03
6 changed files with 127 additions and 35 deletions

View file

@ -535,7 +535,7 @@ type
procedure CheckCommandLine(ShiftEx: TShiftState; var Key: Word);
function ExecuteCommandFromEdit(sCmd: String; bRunInTerm: Boolean): Boolean;
procedure LoadActionIcons;
procedure UpdateActionIcons;
procedure TypeInCommandLine(Str: String);
procedure AddVirtualDriveButton(dskPanel: TKASToolBar);
procedure AddSpecialButtons(dskPanel: TKASToolBar);
@ -2241,11 +2241,9 @@ constructor TfrmMain.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FCommands := TMainCommands.Create(Self, actionLst);
LoadActionIcons();
end;
procedure TfrmMain.LoadActionIcons();
procedure TfrmMain.UpdateActionIcons();
var
I: Integer;
imgIndex: Integer;
@ -2254,35 +2252,48 @@ var
iconImg: TPicture;
actionName: TComponentName;
begin
// Temporarily while feature is not implemented
// http://doublecmd.sourceforge.net/mantisbt/view.php?id=11
iconsDir := gpPixmapPath + PathDelim + 'dctheme\16x16\actions';
if not mbDirectoryExists(iconsDir) then Exit;
actionLst.Images := nil;
pmTabMenu.Images := nil;
mnuMain.Images := nil;
imgLstActions.Clear;
iconImg := TPicture.Create;
actionLst.Images := imgLstActions;
pmTabMenu.Images := imgLstActions;
mnuMain.Images := imgLstActions;
for I:= 0 to actionLst.ActionCount - 1 do
if gIconsInMenus then
begin
actionName := UTF8LowerCase(actionLst.Actions[I].Name);
fileName := iconsDir + PathDelim + 'cm_' + UTF8Copy(actionName, 4, Length(actionName) - 3) + '.png';
if mbFileExists(fileName) then
try
iconImg.LoadFromFile(fileName);
imgIndex := imgLstActions.Add(iconImg.Bitmap, nil);
if imgIndex >= 0 then
begin
TAction(actionLst.Actions[I]).ImageIndex := imgIndex;
end;
except
// Skip
end;
end;
// Temporarily while feature is not implemented
// http://doublecmd.sourceforge.net/mantisbt/view.php?id=11
fileName := IntToStr(gIconsInMenusSize);
iconsDir := gpPixmapPath + PathDelim + 'dctheme' + PathDelim + fileName;
iconsDir := iconsDir + 'x' + fileName + PathDelim + 'actions';
if not mbDirectoryExists(iconsDir) then Exit;
FreeAndNil(iconImg);
iconImg := TPicture.Create;
imgLstActions.Width := gIconsInMenusSize;
imgLstActions.Height := gIconsInMenusSize;
actionLst.Images := imgLstActions;
pmTabMenu.Images := imgLstActions;
mnuMain.Images := imgLstActions;
for I:= 0 to actionLst.ActionCount - 1 do
begin
actionName := UTF8LowerCase(actionLst.Actions[I].Name);
fileName := iconsDir + PathDelim + 'cm_' + UTF8Copy(actionName, 4, Length(actionName) - 3) + '.png';
if mbFileExists(fileName) then
try
iconImg.LoadFromFile(fileName);
imgIndex := imgLstActions.Add(iconImg.Bitmap, nil);
if imgIndex >= 0 then
begin
TAction(actionLst.Actions[I]).ImageIndex := imgIndex;
end;
except
// Skip
end;
end;
FreeAndNil(iconImg);
end;
end;
procedure TfrmMain.CreateDefaultToolbar;
@ -4123,6 +4134,7 @@ begin
UpdateFreeSpace(fpRight);
end;
UpdateActionIcons;
ShowTrayIcon(gAlwaysShowTrayIcon);
FInitializedView := True;

View file

@ -94,7 +94,7 @@ inherited frmOptionsIcons: TfrmOptionsIcons
Left = 10
Height = 17
Top = 31
Width = 29
Width = 31
BorderSpacing.Left = 10
BorderSpacing.Top = 6
Caption = 'A&ll'
@ -109,7 +109,7 @@ inherited frmOptionsIcons: TfrmOptionsIcons
Left = 10
Height = 17
Top = 54
Width = 113
Width = 115
BorderSpacing.Left = 10
BorderSpacing.Top = 6
Caption = 'Only &standard icons'
@ -122,7 +122,7 @@ inherited frmOptionsIcons: TfrmOptionsIcons
Left = 10
Height = 17
Top = 77
Width = 58
Width = 60
BorderSpacing.Left = 10
BorderSpacing.Top = 6
Caption = '&No icons'
@ -135,7 +135,7 @@ inherited frmOptionsIcons: TfrmOptionsIcons
Left = 10
Height = 17
Top = 8
Width = 169
Width = 171
BorderSpacing.Left = 10
Caption = 'All associated + &EXE/LNK (slow)'
TabOrder = 0
@ -147,7 +147,7 @@ inherited frmOptionsIcons: TfrmOptionsIcons
Left = 10
Height = 17
Top = 102
Width = 177
Width = 179
BorderSpacing.Left = 10
BorderSpacing.Top = 8
Caption = 'Show o&verlay icons, e.g. for links'
@ -194,11 +194,63 @@ inherited frmOptionsIcons: TfrmOptionsIcons
Left = 10
Height = 17
Top = 8
Width = 248
Width = 250
BorderSpacing.Left = 10
Caption = 'For the following &paths and their subdirectories:'
OnChange = cbIconsExcludeChange
TabOrder = 0
end
end
object gbIconsInMenus: TGroupBox[3]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = gbIconsSize
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 55
Top = 330
Width = 466
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Icons in menus'
ChildSizing.LeftRightSpacing = 10
ChildSizing.TopBottomSpacing = 8
ClientHeight = 37
ClientWidth = 462
TabOrder = 3
object cbIconsInMenus: TCheckBox
AnchorSideLeft.Control = gbIconsInMenus
AnchorSideTop.Control = cbIconsInMenusSize
AnchorSideTop.Side = asrCenter
Left = 10
Height = 17
Top = 10
Width = 172
Caption = 'Show icons for actions in &menus'
TabOrder = 0
end
object cbIconsInMenusSize: TComboBox
AnchorSideTop.Control = gbIconsInMenus
AnchorSideRight.Control = gbIconsInMenus
AnchorSideRight.Side = asrBottom
Left = 321
Height = 21
Top = 8
Width = 131
Anchors = [akTop, akRight]
ItemHeight = 13
ItemIndex = 0
Items.Strings = (
'16x16'
'22x22'
'32x32'
)
OnChange = cbIconsSizeChange
Style = csDropDownList
TabOrder = 1
Text = '16x16'
end
end
end

View file

@ -8,3 +8,6 @@ TFRMOPTIONSICONS.RBICONSSHOWALLANDEXE.CAPTION=All associated + &EXE/LNK (slow)
TFRMOPTIONSICONS.CBICONSSHOWOVERLAY.CAPTION=Show o&verlay icons, e.g. for links
TFRMOPTIONSICONS.GBDISABLESPECIALICONS.CAPTION=Disable special icons
TFRMOPTIONSICONS.CBICONSEXCLUDE.CAPTION=For the following &paths and their subdirectories:
TFRMOPTIONSICONS.GBICONSINMENUS.CAPTION=Icons in menus
TFRMOPTIONSICONS.CBICONSINMENUS.CAPTION=Show icons for actions in &menus
TFRMOPTIONSICONS.CBICONSINMENUSSIZE.TEXT=16x16

View file

@ -37,10 +37,13 @@ type
cbIconsShowOverlay: TCheckBox;
cbIconsSize: TComboBox;
cbIconsExclude: TCheckBox;
cbIconsInMenusSize: TComboBox;
cbIconsInMenus: TCheckBox;
edtIconsExcludeDirs: TEdit;
gbIconsSize: TGroupBox;
gbShowIconsMode: TGroupBox;
gbDisableSpecialIcons: TGroupBox;
gbIconsInMenus: TGroupBox;
imgIconExample: TImage;
pnlIconExample: TPanel;
rbIconsShowAll: TRadioButton;
@ -113,9 +116,11 @@ begin
end;
cbIconsShowOverlay.Checked:= gIconOverlays;
cbIconsExclude.Checked:= gIconsExclude;
cbIconsInMenus.Checked := gIconsInMenus;
edtIconsExcludeDirs.Text:= gIconsExcludeDirs;
edtIconsExcludeDirs.Enabled:= gIconsExclude;
cbIconsSize.Text := IntToStr(gIconsSizeNew) + 'x' + IntToStr(gIconsSizeNew);
cbIconsInMenusSize.Text := IntToStr(gIconsInMenusSizeNew) + 'x' + IntToStr(gIconsInMenusSizeNew);
cbIconsSizeChange(nil);
end;
@ -142,8 +147,15 @@ begin
else SelectedIconsSize := gIconsSizeNew;
end;
case cbIconsInMenusSize.ItemIndex of
0: gIconsInMenusSizeNew := 16;
1: gIconsInMenusSizeNew := 22;
2: gIconsInMenusSizeNew := 32;
end;
if (gIconsSizeNew <> SelectedIconsSize) or
(gShowIconsNew <> SelectedShowIcons) then
(gShowIconsNew <> SelectedShowIcons) or
(gIconsInMenusSizeNew <> gIconsInMenusSize) then
begin
Include(Result, oesfNeedsRestart);
end;
@ -153,6 +165,7 @@ begin
gIconOverlays := cbIconsShowOverlay.Checked;
gIconsExclude := cbIconsExclude.Checked;
gIconsExcludeDirs := edtIconsExcludeDirs.Text;
gIconsInMenus := cbIconsInMenus.Checked;
end;
end.

View file

@ -141,7 +141,7 @@ implementation
{$R *.lfm}
uses
LCLVersion, Toolwin,
LCLProc, LCLVersion, Toolwin,
DCStrUtils, uGlobs, uLng, uOSForms, uDCUtils, uPixMapManager,
uKASToolItemsExtended,
fMain;
@ -678,6 +678,7 @@ begin
Command := cbInternalCommand.Items[cbInternalCommand.ItemIndex];
edtToolTip.Text := FFormCommands.GetCommandCaption(Command, cctLong);
edtInternalParameters.HelpKeyword := '/cmds.html#' + Command;
edtIconFileName.Text := UTF8LowerCase(Command);
end;
procedure TfrmOptionsToolbar.CloseToolbarsBelowCurrentButton;

View file

@ -239,6 +239,9 @@ var
gIconsExclude: Boolean;
gIconsExcludeDirs: String;
gCustomDriveIcons : Boolean; // for use custom drive icons under windows
gIconsInMenus: Boolean;
gIconsInMenusSize,
gIconsInMenusSizeNew: Integer;
{ Keys page }
gKeyTyping: array[TKeyTypingModifier] of TKeyTypingAction;
@ -1085,6 +1088,9 @@ begin
gIconsExclude := False;
gIconsExcludeDirs := EmptyStr;
gCustomDriveIcons := False;
gIconsInMenus := False;
gIconsInMenusSize := 16;
gIconsInMenusSizeNew := gIconsInMenusSize;
{ Ignore list page }
gIgnoreListFileEnabled := False;
@ -1296,6 +1302,7 @@ begin
// Set secondary variables for options that need restart.
gShowIconsNew := gShowIcons;
gIconsSizeNew := gIconsSize;
gIconsInMenusSizeNew := gIconsInMenusSize;
CopySettingsFiles;
@ -2094,6 +2101,8 @@ begin
gIconsExclude := GetValue(Node, 'Exclude', gIconsExclude);
gIconsExcludeDirs := GetValue(Node, 'ExcludeDirs', gIconsExcludeDirs);
gCustomDriveIcons := GetValue(Node, 'CustomDriveIcons', gCustomDriveIcons);
gIconsInMenus := GetAttr(Node, 'ShowInMenus/Enabled', gIconsInMenus);
gIconsInMenusSize := GetValue(Node, 'ShowInMenus/Size', gIconsInMenusSize);
end;
{ Ignore list page }
@ -2390,6 +2399,8 @@ begin
SetValue(Node, 'Exclude', gIconsExclude);
SetValue(Node, 'ExcludeDirs', gIconsExcludeDirs);
SetValue(Node, 'CustomDriveIcons', gCustomDriveIcons);
SetAttr(Node, 'ShowInMenus/Enabled', gIconsInMenus);
SetValue(Node, 'ShowInMenus/Size', gIconsInMenusSizeNew);
{ Ignore list page }
Node := FindNode(Root, 'IgnoreList', True);