diff --git a/lcl/interfaces/qt5/qtwinapi.inc b/lcl/interfaces/qt5/qtwinapi.inc index 3203dca443..8f3fa74cd0 100644 --- a/lcl/interfaces/qt5/qtwinapi.inc +++ b/lcl/interfaces/qt5/qtwinapi.inc @@ -4788,6 +4788,74 @@ begin CritSection:=TCriticalSection(ACritSec); end; +function TQtWidgetSet.InitStockFont(AFont: TObject; AStockFont: TStockFont + ): Boolean; +var + Font: TFont absolute AFont; + AMenu: QMenuH; + QtFont: QFontH; + AName: WideString; +begin + Result := False; + if AStockFont = sfMenu then + begin + AName := 'MenuTitle'; + AMenu := QMenu_create(@AName, nil); + try + QtFont := QWidget_font(AMenu); + QFont_family(QtFont, @AName); + Font.Name := UTF16ToUTF8(AName); + if QFont_pointSize(QtFont) > 0 then + Font.Size := QFont_pointSize(QtFont) + else + Font.Height := QFont_pixelSize(QtFont); + if QFont_bold(QtFont) then + Font.Style := Font.Style + [fsBold]; + if QFont_italic(QtFont) then + Font.Style := Font.Style + [fsItalic]; + if QFont_underline(QtFont) then + Font.Style := Font.Style + [fsUnderline]; + if QFont_strikeOut(QtFont) then + Font.Style := Font.Style + [fsStrikeOut]; + Font.Color := clMenuText; + Result := True; + finally + QWidget_destroy(AMenu); + end; + end else + begin + QtFont := QFont_create; + try + if AStockFont = sfHint then + QToolTip_font(QtFont) + else + QApplication_font(QtFont); + QFont_family(QtFont, @AName); + Font.Name := UTF16ToUTF8(AName); + if QFont_pointSize(QtFont) > 0 then + Font.Size := QFont_pointSize(QtFont) + else + Font.Height := QFont_pixelSize(QtFont); + if QFont_bold(QtFont) then + Font.Style := Font.Style + [fsBold]; + if QFont_italic(QtFont) then + Font.Style := Font.Style + [fsItalic]; + if QFont_underline(QtFont) then + Font.Style := Font.Style + [fsUnderline]; + if QFont_strikeOut(QtFont) then + Font.Style := Font.Style + [fsStrikeOut]; + + {comment font.color for check if hintfont works correct} + if AStockFont = sfHint then + Font.Color := clInfoText; + + Result := True; + finally + QFont_destroy(QtFont); + end; + end; +end; + function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; var QtDC: TQtDeviceContext absolute dc; diff --git a/lcl/interfaces/qt5/qtwinapih.inc b/lcl/interfaces/qt5/qtwinapih.inc index e0f56c3988..112c45688e 100644 --- a/lcl/interfaces/qt5/qtwinapih.inc +++ b/lcl/interfaces/qt5/qtwinapih.inc @@ -142,6 +142,7 @@ function HideCaret(hWnd: HWND): Boolean; override; function InvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean; override; function InvalidateRgn(aHandle: HWND; Rgn: HRGN; Erase: Boolean): Boolean; override; procedure InitializeCriticalSection(var CritSection: TCriticalSection); override; +function InitStockFont(AFont: TObject; AStockFont: TStockFont): Boolean; override; function IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; override; function IsIconic(Handle: HWND): boolean; override; function IsWindow(handle: HWND): boolean; override;