mirror of
https://github.com/rejetto/hfs2.git
synced 2025-12-19 18:13:46 +01:00
better code
This commit is contained in:
parent
bf2237d5f9
commit
c77912c94e
50
main.pas
50
main.pas
@ -1157,7 +1157,6 @@ var
|
|||||||
selfTesting: boolean;
|
selfTesting: boolean;
|
||||||
tplIsCustomized: boolean;
|
tplIsCustomized: boolean;
|
||||||
fakingMinimize: boolean; // user clicked the [X] but we simulate the [_]
|
fakingMinimize: boolean; // user clicked the [X] but we simulate the [_]
|
||||||
sysidx2index: array of record sysidx, idx:integer; end; // maps system imagelist icons to internal imagelist
|
|
||||||
loginRealm: string;
|
loginRealm: string;
|
||||||
serializedConnColumns: string;
|
serializedConnColumns: string;
|
||||||
VFScounterMod: boolean; // if any counter has changed
|
VFScounterMod: boolean; // if any counter has changed
|
||||||
@ -1981,7 +1980,8 @@ begin
|
|||||||
result:='';
|
result:='';
|
||||||
if idx < 0 then exit;
|
if idx < 0 then exit;
|
||||||
idx:=idx_ico2img(idx);
|
idx:=idx_ico2img(idx);
|
||||||
if length(imagescache) < idx+1 then setlength(imagescache, idx+1);
|
if length(imagescache) < idx+1 then
|
||||||
|
setlength(imagescache, idx+1);
|
||||||
result:=imagescache[idx];
|
result:=imagescache[idx];
|
||||||
if result > '' then exit;
|
if result > '' then exit;
|
||||||
pic:=Tbitmap.create();
|
pic:=Tbitmap.create();
|
||||||
@ -2017,9 +2017,12 @@ try
|
|||||||
finally gif.free end;
|
finally gif.free end;
|
||||||
end; // str2pic
|
end; // str2pic
|
||||||
|
|
||||||
|
type Tint2int = Tdictionary<integer,integer>;
|
||||||
|
var sysidx2index: Tint2int; // maps system imagelist icons to internal imagelist
|
||||||
|
|
||||||
function getImageIndexForFile(fn:string):integer;
|
function getImageIndexForFile(fn:string):integer;
|
||||||
var
|
var
|
||||||
i, n: integer;
|
i, j: integer;
|
||||||
ico: Ticon;
|
ico: Ticon;
|
||||||
shfi: TShFileInfo;
|
shfi: TShFileInfo;
|
||||||
s: ansistring;
|
s: ansistring;
|
||||||
@ -2037,41 +2040,31 @@ if shfi.iIcon = 0 then
|
|||||||
if shfi.hIcon <> 0 then
|
if shfi.hIcon <> 0 then
|
||||||
destroyIcon(shfi.hIcon);
|
destroyIcon(shfi.hIcon);
|
||||||
|
|
||||||
// have we already met this sysidx before?
|
if sysidx2index = NIL then // firt time
|
||||||
for i:=0 to length(sysidx2index)-1 do
|
sysidx2index:=Tint2int.Create();
|
||||||
if sysidx2index[i].sysidx = shfi.iIcon then
|
try result:=sysidx2index[shfi.iIcon]; // already met?
|
||||||
begin
|
except
|
||||||
result:=sysidx2index[i].idx;
|
// found not, let's check deeper: byte comparison.
|
||||||
exit;
|
// we first add the ico to the list, so we can use pic2str()
|
||||||
end;
|
ico:=Ticon.create();
|
||||||
// found not, let's check deeper: byte comparison.
|
try
|
||||||
// we first add the ico to the list, so we can use pic2str()
|
|
||||||
ico:=Ticon.create();
|
|
||||||
try
|
|
||||||
systemimages.getIcon(shfi.iIcon, ico);
|
systemimages.getIcon(shfi.iIcon, ico);
|
||||||
i:=mainfrm.images.addIcon(ico);
|
i:=mainfrm.images.addIcon(ico);
|
||||||
s:=pic2str(i);
|
s:=pic2str(i);
|
||||||
etags.values['icon.'+intToStr(i)] := strMD5(s);
|
etags.values['icon.'+intToStr(i)] := strMD5(s);
|
||||||
finally ico.free end;
|
finally ico.free end;
|
||||||
// now we can search if the icon was already there, by byte comparison
|
// now we can search if the icon was already there, by byte comparison
|
||||||
n:=0;
|
for j in sysidx2index.Values do
|
||||||
while n < length(sysidx2index) do
|
if pic2str(j) = s then
|
||||||
begin
|
|
||||||
if pic2str(sysidx2index[n].idx) = s then
|
|
||||||
begin // found, delete the duplicate
|
begin // found, delete the duplicate
|
||||||
mainfrm.images.delete(i);
|
mainfrm.images.delete(i);
|
||||||
setlength(imagescache, i);
|
setlength(imagescache, i);
|
||||||
i:=sysidx2index[n].idx;
|
i:=j;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
inc(n);
|
sysidx2index.Add(shfi.iIcon, i);
|
||||||
|
result:=i;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
n:=length(sysidx2index);
|
|
||||||
setlength(sysidx2index, n+1);
|
|
||||||
sysidx2index[n].sysidx:=shfi.iIcon;
|
|
||||||
sysidx2index[n].idx:=i;
|
|
||||||
result:=i;
|
|
||||||
end; // getImageIndexForFile
|
end; // getImageIndexForFile
|
||||||
|
|
||||||
function getBaseTrayIcon(perc:real=0):Tbitmap;
|
function getBaseTrayIcon(perc:real=0):Tbitmap;
|
||||||
@ -12470,6 +12463,7 @@ Form := Screen.ActiveCustomForm;
|
|||||||
if (Form=NIL) or (Form.ClassName<>'TInputQueryForm') then
|
if (Form=NIL) or (Form.ClassName<>'TInputQueryForm') then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
edit:=NIL; prompt:=NIL; // hush compiler warning
|
||||||
for I := 0 to Form.ControlCount-1 do
|
for I := 0 to Form.ControlCount-1 do
|
||||||
begin
|
begin
|
||||||
Ctrl := Form.Controls[i];
|
Ctrl := Form.Controls[i];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user