Qt5: added read only property MenuBar, renamed GetMenuBar to MenuBarNeeded

This commit is contained in:
Željan Rikalo 2023-02-01 16:26:09 +01:00
parent 1945f6863b
commit 317b0691ca
5 changed files with 12 additions and 10 deletions

View File

@ -1687,7 +1687,8 @@ begin
begin begin
MainWin := TQtMainWindow(Application.MainForm.Handle); MainWin := TQtMainWindow(Application.MainForm.Handle);
MainWin.Activate; MainWin.Activate;
QMenuBar_setActiveAction(QMenuBarH(MainWin.GetMenuBar.Widget), Action); if Assigned(MainWin.MenuBar) then
QMenuBar_setActiveAction(QMenuBarH(MainWin.MenuBar.Widget), Action);
end; end;
end; end;

View File

@ -668,7 +668,7 @@ type
procedure Activate; override; procedure Activate; override;
function CanAdjustClientRectOnResize: Boolean; override; function CanAdjustClientRectOnResize: Boolean; override;
function GetMenuBar: TQtMenuBar; function MenuBarNeeded: TQtMenuBar;
function getAcceptDropFiles: Boolean; override; function getAcceptDropFiles: Boolean; override;
function GetContainerWidget: QWidgetH; override; function GetContainerWidget: QWidgetH; override;
procedure grabMouse; override; procedure grabMouse; override;
@ -705,6 +705,7 @@ type
property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame} property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame}
property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate} property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate}
property ShowOnTaskBar: Boolean read FShowOnTaskBar; property ShowOnTaskBar: Boolean read FShowOnTaskBar;
property MenuBar: TQtMenuBar read FMenuBar;
public public
function WinIDNeeded: boolean; override; function WinIDNeeded: boolean; override;
procedure AttachEvents; override; procedure AttachEvents; override;
@ -7249,7 +7250,7 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function TQtMainWindow.GetMenuBar: TQtMenuBar; function TQtMainWindow.MenuBarNeeded: TQtMenuBar;
var var
AParent: QWidgetH; AParent: QWidgetH;
begin begin

View File

@ -6143,13 +6143,13 @@ begin
if AMenuWidget is TQtMenuBar then if AMenuWidget is TQtMenuBar then
begin begin
R := AWidget.LCLObject.ClientRect; R := AWidget.LCLObject.ClientRect;
R1 := QtMainWindow.GetMenuBar.getGeometry; R1 := QtMainWindow.MenuBar.getGeometry;
R1.Right := R.Right; R1.Right := R.Right;
QtMenuBar.setGeometry(R1); QtMenuBar.setGeometry(R1);
QtMainWindow.setMenuBar(QMenuBarH(QtMenuBar.Widget)); QtMainWindow.setMenuBar(QMenuBarH(QtMenuBar.Widget));
end end else
else if Assigned(QtMainWindow.MenuBar) then
QtMainWindow.setMenuBar(QMenuBarH(QtMainWindow.GetMenuBar.Widget)); QtMainWindow.setMenuBar(QMenuBarH(QtMainWindow.MenuBar.Widget));
end; end;
end; end;

View File

@ -1033,7 +1033,7 @@ begin
if Assigned(TCustomForm(AWinControl).Menu) then if Assigned(TCustomForm(AWinControl).Menu) then
begin begin
AWin := TQtMainWindow(AWinControl.Handle); AWin := TQtMainWindow(AWinControl.Handle);
AWin.GetMenuBar.sizeHint(@ASize); AWin.MenuBar.sizeHint(@ASize);
// geometry isn't updated yet // geometry isn't updated yet
if ASize.cy < 10 then if ASize.cy < 10 then
ASize.cy := 0; ASize.cy := 0;

View File

@ -442,9 +442,9 @@ begin
((AParent is TCustomForm) or (AParent is TCustomFrame)) then ((AParent is TCustomForm) or (AParent is TCustomFrame)) then
begin begin
if (AParent is TCustomForm) then if (AParent is TCustomForm) then
MenuBar := TQtMainWindow(TCustomForm(AParent).Handle).GetMenuBar MenuBar := TQtMainWindow(TCustomForm(AParent).Handle).MenuBarNeeded
else else
MenuBar := TQtMainWindow(TCustomFrame(AParent).Handle).GetMenuBar; MenuBar := TQtMainWindow(TCustomFrame(AParent).Handle).MenuBarNeeded;
Result := HMENU(MenuBar); Result := HMENU(MenuBar);
end else end else
begin begin