mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 23:57:11 +02:00
Qt: Fixed menus backed by multi-resolution image lists always using the 96ppi image rather than the resolution-specific one.
The existing code attempts to use/overwrite the preexisting AMenuItem.Bitmap property, but the ImageList.ResolutionForPPI.GetBitmap call triggers TMenuItem.BitmapChange, which frees the updated image. The subsequent setImage(AMenuItem.Bitmap.Handle) call then goes through its standard behavior again, which is to always retrieve the 96ppi variant.
(cherry picked from commit 532ecb2653
)
Co-authored-by: Zoë Peterson <zoe@scootersoftware.com>
This commit is contained in:
parent
7a0060b726
commit
b6a59c00e9
@ -136,8 +136,13 @@ begin
|
||||
if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and
|
||||
(AMenuItem.ImageIndex < ImgList.Count) then
|
||||
begin
|
||||
ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(AMenuItem.Bitmap.Handle));
|
||||
Bmp := TBitmap.Create;
|
||||
try
|
||||
ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, Bmp); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(Bmp.Handle));
|
||||
finally
|
||||
Bmp.Free;
|
||||
end;
|
||||
end else
|
||||
if Assigned(AMenuItem.Bitmap) then
|
||||
begin
|
||||
|
@ -135,8 +135,13 @@ begin
|
||||
if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and
|
||||
(AMenuItem.ImageIndex < ImgList.Count) then
|
||||
begin
|
||||
ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(AMenuItem.Bitmap.Handle));
|
||||
Bmp := TBitmap.Create;
|
||||
try
|
||||
ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, Bmp); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(Bmp.Handle));
|
||||
finally
|
||||
Bmp.Free;
|
||||
end;
|
||||
end else
|
||||
if Assigned(AMenuItem.Bitmap) then
|
||||
begin
|
||||
|
@ -135,8 +135,13 @@ begin
|
||||
if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and
|
||||
(AMenuItem.ImageIndex < ImgList.Count) then
|
||||
begin
|
||||
ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(AMenuItem.Bitmap.Handle));
|
||||
Bmp := TBitmap.Create;
|
||||
try
|
||||
ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, Bmp); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(Bmp.Handle));
|
||||
finally
|
||||
Bmp.Free;
|
||||
end;
|
||||
end else
|
||||
if Assigned(AMenuItem.Bitmap) then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user