Skip to content

Commit 917e046

Browse files
committed
feat: switch to grayscale icons on inactive query tabs
1 parent 76aefb3 commit 917e046

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

source/apphelpers.pas

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface
99
StrUtils, Graphics, GraphUtil, LCLIntf, Forms, Clipbrd, Process, ActnList, Menus, Dialogs,
1010
Character, DateUtils, laz.VirtualTrees, SynEdit, SynCompletion, fphttpclient,
1111
dbconnection, dbstructures, jsonregistry, lazaruscompat, fpjson, SynEditKeyCmds, LazFileUtils, gettext, LazUTF8, LConvEncoding,
12-
IniFiles;
12+
IniFiles, GraphType;
1313

1414
type
1515

@@ -435,7 +435,7 @@ TAppSettings = class(TObject)
435435
function GetCommandLine: String;
436436
// This returns a stable, lowercase name "heidisql", used for configuration files and translations
437437
function GetApplicationName: String;
438-
procedure CopyImageList(SourceList, TargetList: TImageList);
438+
procedure CopyImageList(SourceList, TargetList: TImageList; AppendDisabled: Boolean);
439439

440440
var
441441
AppSettings: TAppSettings;
@@ -3147,7 +3147,7 @@ function GetApplicationName: String;
31473147
Result := LowerCase(APPNAME);
31483148
end;
31493149

3150-
procedure CopyImageList(SourceList, TargetList: TImageList);
3150+
procedure CopyImageList(SourceList, TargetList: TImageList; AppendDisabled: Boolean);
31513151
var
31523152
i, ResIdx, ResWidth: Integer;
31533153
TempBitmap: TBitmap;
@@ -3170,6 +3170,20 @@ procedure CopyImageList(SourceList, TargetList: TImageList);
31703170
end;
31713171
TargetList.AddMultipleResolutions(TempBitmapList);
31723172
end;
3173+
if AppendDisabled then begin
3174+
for i:=0 to SourceList.Count-1 do
3175+
begin
3176+
SetLength(TempBitmapList, 0);
3177+
SetLength(TempBitmapList, Length(Resolutions));
3178+
for ResIdx:=Low(Resolutions) to High(Resolutions) do begin
3179+
ResWidth := Resolutions[ResIdx];
3180+
TempBitmap := TBitmap.Create;
3181+
SourceList.Resolution[ResWidth].GetBitmap(i, TempBitmap, gdeDisabled);
3182+
TempBitmapList[ResIdx] := TempBitmap;
3183+
end;
3184+
TargetList.AddMultipleResolutions(TempBitmapList);
3185+
end;
3186+
end;
31733187
end;
31743188

31753189

source/extra_controls.pas

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,19 +407,17 @@ class function TExtForm.ScaleSize(x: Extended; Control: TControl): Integer;
407407
class procedure TExtForm.PageControlTabHighlight(PageControl: TPageControl);
408408
var
409409
i, CurrentImage, CountOriginals: Integer;
410-
Images: TImageList;
410+
Images: TCustomImageList;
411411
GrayscaleMode: Integer;
412412
IsQueryTab: Boolean;
413413
begin
414-
// Unsupported yet. We have no TVirtualImageList, see MainForm.PrepareImageList
415-
Exit;
416414
// Set grayscale icon on inactive tabs
417415
if not (PageControl.Images is TImageList) then
418416
Exit;
419417
GrayscaleMode := AppSettings.ReadInt(asTabIconsGrayscaleMode);
420418

421-
Images := PageControl.Images as TImageList;
422-
CountOriginals := Images.Count;
419+
Images := PageControl.Images;
420+
CountOriginals := Images.Count div 2;
423421

424422
for i:=0 to PageControl.PageCount-1 do begin
425423
CurrentImage := PageControl.Pages[i].ImageIndex;
@@ -437,7 +435,7 @@ class procedure TExtForm.PageControlTabHighlight(PageControl: TPageControl);
437435
PageControl.Pages[i].ImageIndex := CurrentImage + CountOriginals;
438436
end;
439437
end;
440-
end;;
438+
end;
441439
end;
442440

443441
class procedure TExtForm.ShowPopup(ClickedControl: TControl; PopupMenu: TPopupMenu);

source/main.pas

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9239,16 +9239,15 @@ procedure TMainForm.PrepareImageList;
92399239
begin
92409240
// Load preferred ImageList into ImageListMain
92419241
if ImageListIcons8.Count = 0 then begin
9242-
CopyImageList(ImageListMain, ImageListIcons8);
9242+
CopyImageList(ImageListMain, ImageListIcons8, False);
92439243
end;
92449244
IconPack := AppSettings.ReadString(asIconPack);
92459245
WantedImageCollection := FindComponent('ImageList' + IconPack);
92469246
if (WantedImageCollection <> nil) and (WantedImageCollection is TImageList) and (WantedImageCollection.Tag <> 0) then begin
92479247
SourceList := WantedImageCollection as TImageList;
9248-
CopyImageList(SourceList, ImageListMain);
9248+
// Add all icons again in disabled/grayscale mode, used in TExtForm.PageControlTabHighlight
9249+
CopyImageList(SourceList, ImageListMain, True);
92499250
end;
9250-
// Add all icons again in disabled/grayscale mode, used in TExtForm.PageControlTabHighlight
9251-
//VirtualImageListMain.AddDisabled('', 0, VirtualImageListMain.ImageCollection.Count-1);
92529251
end;
92539252

92549253

0 commit comments

Comments
 (0)