IconFinder: Avoid duplicate processing of default image folder.

(cherry picked from commit aef3e62e80)
This commit is contained in:
wp_xyz 2024-11-03 17:49:33 +01:00
parent 7595beee48
commit e15e3cf85e
6 changed files with 35 additions and 18 deletions

View File

@ -41,6 +41,7 @@
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit>
</Units>

View File

@ -17,7 +17,7 @@ uses
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Scaled := True;
Application.{%H-}MainFormOnTaskbar:=True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);

View File

@ -161,6 +161,7 @@ type
function FindLargestIcon(AIcon: TIconItem): TIconItem;
procedure GetIconSizesAsStrings(AList: TStrings);
procedure GetKeywordsAsStrings(AList: TStrings);
function IndexOfFolder(AFolder: String): Integer;
function IndexOfThumbnail(AIcon: TIconItem): Integer;
procedure LockFilter;
procedure PopulateIconFoldersMenu(AMenu: TMenu);
@ -997,6 +998,14 @@ begin
// end;
end;
function TIconThumbnailViewer.IndexOfFolder(AFolder: String): Integer;
begin
for Result := 0 to FIconFolders.Count-1 do
if FIconFolders[Result].FolderName = AFolder then
exit;
Result := -1;
end;
function TIconThumbnailViewer.IndexOfThumbnail(AIcon: TIconItem): Integer;
var
i: Integer;

View File

@ -6,8 +6,8 @@
for details about the license.
*****************************************************************************
A frame composed of the essential controls for viewer thumbnails and filtering
them.
A frame composed of the essential controls for viewing thumbnails and
filtering them.
Is used by the imagelist component editor, by the graphic property editor
and by the IDE settings page.
@ -92,6 +92,7 @@ type
procedure DeleteSelectedIcon;
procedure FocusKeywordFilter;
procedure GetKeywordsHistory(AList: TStrings);
function IndexOfIconFolder(AFolder: String): Integer;
procedure ReadIconFolders(AList: TStrings);
procedure SetKeywordsHistory(AList: TStrings);
procedure UpdateIconSizes(ASizeIndex: Integer);
@ -336,6 +337,11 @@ begin
end;
end;
function TIconViewerFrame.IndexOfIconFolder(AFolder: String): Integer;
begin
Result := FIconViewer.IndexOfFolder(AFolder);
end;
{ Reads the icons from the directories contained in AList and adds them to the
library. }
procedure TIconViewerFrame.ReadIconFolders(AList: TStrings);

View File

@ -182,7 +182,7 @@ begin
try
Config := GetIDEConfigStorage(ICONFINDER_CONFIG_FILENAME, true);
try
GlobalReadSettings(Config, FViewer, ANodeName);
ReadIconFinderSettings(Config, FViewer, ANodeName);
finally
Config.Free;
end;
@ -202,7 +202,7 @@ begin
try
Config := GetIDEConfigStorage(ICONFINDER_CONFIG_FILENAME, true); //, false);
try
GlobalWriteSettings(Config, FViewer, FSettingsNodeName);
WriteIconFinderSettings(Config, FViewer, FSettingsNodeName);
Config.WriteToDisk;
finally
Config.Free;

View File

@ -45,7 +45,6 @@ type
private
public
constructor Create(const {%H-}pbReadRegFile: boolean);
destructor Destroy; override;
class function GetGroupCaption: String; override;
class function GetInstance: TAbstractIDEOptions; override;
@ -85,8 +84,8 @@ type
procedure RestoreSettings({%H-}AOptions: TAbstractIDEOptions); override;
end;
procedure GlobalReadSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame; ANodeName: String);
procedure GlobalWriteSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame; ANodeName: String);
procedure ReadIconFinderSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame; ANodeName: String);
procedure WriteIconFinderSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame; ANodeName: String);
var
IconFinderOptionsGroup: integer = 260;
@ -100,11 +99,6 @@ implementation
{ TIconFinderSettings }
constructor TIconFinderSettings.Create(const pbReadRegFile: boolean);
begin
// inherited Create;
end;
destructor TIconFinderSettings.Destroy;
begin
inherited Destroy;
@ -248,7 +242,7 @@ begin
try
Config := GetIDEConfigStorage(ICONFINDER_CONFIG_FILENAME, true);
try
GlobalReadSettings(Config, FViewer, 'IDEOptions');
ReadIconFinderSettings(Config, FViewer, 'IDEOptions');
if FViewer.IconViewer.IconFolders.Count = 0 then
AddDefaultFolder;
finally
@ -301,7 +295,7 @@ begin
try
Config := GetIDEConfigStorage(ICONFINDER_CONFIG_FILENAME, true); //, false);
try
GlobalWriteSettings(Config, FViewer, 'IDEOptions');
WriteIconFinderSettings(Config, FViewer, 'IDEOptions');
finally
Config.Free;
end;
@ -319,10 +313,11 @@ end;
{------------------------------------------------------------------------------}
procedure GlobalReadSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame;
procedure ReadIconFinderSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame;
ANodeName: String);
var
folder: String;
folderIdx: Integer;
isHidden: Boolean;
n, i: Integer;
s: String;
@ -335,7 +330,13 @@ begin
folder := AConfig.GetValue(Format('IconFinder/Folders/Item%d/Value', [i]), '');
isHidden := AConfig.GetValue(Format('IconFinder/Folders/Item%d/Hidden', [i]), false);
if (folder <> '') and DirectoryExists(folder) then
AViewer.AddIconFolder(folder, isHidden);
begin
folderIdx := AViewer.IndexOfIconFolder(folder);
if folderIdx = -1 then
AViewer.AddIconFolder(folder, isHidden)
else
AViewer.IconViewer.IconFolders[folderIdx].Hidden := isHidden;
end;
end;
// Keyword filter history list
@ -362,7 +363,7 @@ begin
end;
end;
procedure GlobalWriteSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame;
procedure WriteIconFinderSettings(AConfig: TConfigStorage; AViewer: TIconViewerFrame;
ANodeName: String);
var
i: Integer;