mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 01:19:36 +02:00
LCL: High-DPI ImageList: Qt+Qt5 fixes
git-svn-id: branches/HiDPIImageList@57046 -
This commit is contained in:
parent
29f83c361a
commit
dabf59fef5
@ -12559,7 +12559,7 @@ begin
|
||||
begin
|
||||
ImgListRes := ImgList.ResolutionForImagePPI[TCustomListViewHack(LCLObject).SmallImagesWidth, TCustomListViewHack(LCLObject).Font.PixelsPerInch];
|
||||
QListWidgetItem_sizeHint(item, @ASize);
|
||||
if (ASize.cx <> ImgListSize.Width) or (ASize.cx <> ImgListSize.Height) then
|
||||
if (ASize.cx <> ImgListRes.Width) or (ASize.cx <> ImgListRes.Height) then
|
||||
begin
|
||||
ASize.cx := ImgListRes.Width;
|
||||
ASize.cy := ImgListRes.Height;
|
||||
@ -14661,6 +14661,7 @@ var
|
||||
AOk: Boolean;
|
||||
AIcon: QIconH;
|
||||
ASize: TSize;
|
||||
ImgListRes: TCustomImageListResolution;
|
||||
begin
|
||||
{do not set items during design time}
|
||||
if csDesigning in LCLObject.ComponentState then
|
||||
@ -14716,7 +14717,7 @@ begin
|
||||
ImgList := TCustomListViewHack(LCLObject).SmallImages;
|
||||
if Assigned(ImgList) then
|
||||
begin
|
||||
ImgListRes := ImgListRes.ResolutionForImagePPI[TCustomListViewHack(LCLObject).SmallImagesWidth, TCustomListViewHack(LCLObject).Font.PixelsPerInch];
|
||||
ImgListRes := ImgList.ResolutionForImagePPI[TCustomListViewHack(LCLObject).SmallImagesWidth, TCustomListViewHack(LCLObject).Font.PixelsPerInch];
|
||||
QTreeWidgetItem_sizeHint(item, @ASize, 0);
|
||||
if (ASize.cx <> ImgListRes.Width) or (ASize.cx <> ImgListRes.Height) then
|
||||
begin
|
||||
|
@ -33,9 +33,9 @@ uses
|
||||
|
||||
type
|
||||
|
||||
{ TQtWSCustomImageList }
|
||||
{ TQtWSCustomImageListResolution }
|
||||
|
||||
TQtWSCustomImageList = class(TWSCustomImageList)
|
||||
TQtWSCustomImageListResolution = class(TWSCustomImageListResolution)
|
||||
published
|
||||
end;
|
||||
|
||||
|
@ -28,6 +28,7 @@ uses
|
||||
qtwidgets, qtobjects, qtproc, QtWsControls,
|
||||
// LCL
|
||||
SysUtils, Classes, Types, LCLType, LCLProc, Graphics, Controls, Forms, Menus,
|
||||
ImgList,
|
||||
// Widgetset
|
||||
WSMenus, WSLCLClasses;
|
||||
|
||||
@ -101,7 +102,7 @@ end;
|
||||
|
||||
class function TQtWSMenuItem.CreateMenuFromMenuItem(const AMenuItem: TMenuItem): TQtMenu;
|
||||
var
|
||||
ImgList: TImageList;
|
||||
ImgList: TCustomImageList;
|
||||
begin
|
||||
Result := TQtMenu.Create(AMenuItem);
|
||||
Result.FDeleteLater := False;
|
||||
@ -118,13 +119,13 @@ begin
|
||||
Result.setShortcut(AMenuItem.ShortCut, AMenuItem.ShortCutKey2);
|
||||
if AMenuItem.HasIcon then
|
||||
begin
|
||||
ImgList := TImageList(AMenuItem.GetImageList);
|
||||
ImgList := AMenuItem.GetImageList;
|
||||
// we must check so because AMenuItem.HasIcon can return true
|
||||
// if Bitmap is setted up but not ImgList.
|
||||
if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and
|
||||
(AMenuItem.ImageIndex < ImgList.Count) then
|
||||
begin
|
||||
ImgList.GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap);
|
||||
ImgList.ResolutionForImagePPI[16, ScreenInfo.PixelsPerInchX].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(AMenuItem.Bitmap.Handle));
|
||||
end else
|
||||
if Assigned(AMenuItem.Bitmap) then
|
||||
|
@ -14575,6 +14575,7 @@ var
|
||||
AOk: Boolean;
|
||||
AIcon: QIconH;
|
||||
ASize: TSize;
|
||||
ImgListRes: TCustomImageListResolution;
|
||||
begin
|
||||
{do not set items during design time}
|
||||
if csDesigning in LCLObject.ComponentState then
|
||||
|
@ -34,7 +34,7 @@ type
|
||||
|
||||
{ TQtWSCustomImageList }
|
||||
|
||||
TQtWSCustomImageList = class(TWSCustomImageList)
|
||||
TQtWSCustomImageListResolution = class(TWSCustomImageListResolution)
|
||||
published
|
||||
end;
|
||||
|
||||
|
@ -27,6 +27,7 @@ uses
|
||||
qtwidgets, qtobjects, qtproc, QtWsControls,
|
||||
// LCL
|
||||
SysUtils, Classes, Types, LCLType, LCLProc, Graphics, Controls, Forms, Menus,
|
||||
ImgList,
|
||||
// Widgetset
|
||||
WSMenus, WSLCLClasses;
|
||||
|
||||
@ -100,7 +101,7 @@ end;
|
||||
|
||||
class function TQtWSMenuItem.CreateMenuFromMenuItem(const AMenuItem: TMenuItem): TQtMenu;
|
||||
var
|
||||
ImgList: TImageList;
|
||||
ImgList: TCustomImageList;
|
||||
begin
|
||||
Result := TQtMenu.Create(AMenuItem);
|
||||
Result.FDeleteLater := False;
|
||||
@ -117,13 +118,13 @@ begin
|
||||
Result.setShortcut(AMenuItem.ShortCut, AMenuItem.ShortCutKey2);
|
||||
if AMenuItem.HasIcon then
|
||||
begin
|
||||
ImgList := TImageList(AMenuItem.GetImageList);
|
||||
ImgList := AMenuItem.GetImageList;
|
||||
// we must check so because AMenuItem.HasIcon can return true
|
||||
// if Bitmap is setted up but not ImgList.
|
||||
if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and
|
||||
(AMenuItem.ImageIndex < ImgList.Count) then
|
||||
begin
|
||||
ImgList.GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap);
|
||||
ImgList.ResolutionForImagePPI[16, ScreenInfo.PixelsPerInchX].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items
|
||||
Result.setImage(TQtImage(AMenuItem.Bitmap.Handle));
|
||||
end else
|
||||
if Assigned(AMenuItem.Bitmap) then
|
||||
|
Loading…
Reference in New Issue
Block a user