mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 15:19:40 +02:00
Qt5: Adjust Form's MainMenu strategy at Design Time, to be consistent with other Interfaces
This commit is contained in:
parent
53b6b28129
commit
b96f8433e4
@ -1666,7 +1666,9 @@ type
|
||||
constructor Create(const AParent: QWidgetH); overload;
|
||||
public
|
||||
{$IFNDEF DARWIN}
|
||||
function GetDesignState: Integer;
|
||||
function IsDesigning: Boolean;
|
||||
function ShouldShowMenuBar: Boolean;
|
||||
{$ENDIF}
|
||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||
function addMenu(AMenu: QMenuH): QActionH;
|
||||
@ -7254,6 +7256,7 @@ end;
|
||||
function TQtMainWindow.MenuBarNeeded: TQtMenuBar;
|
||||
var
|
||||
AParent: QWidgetH;
|
||||
designState: Integer;
|
||||
begin
|
||||
if not Assigned(FMenuBar) then
|
||||
begin
|
||||
@ -7269,10 +7272,12 @@ begin
|
||||
if not (csDesigning in LCLObject.ComponentState) then
|
||||
FMenuBar.FIsApplicationMainMenu := {$IFDEF DARWIN}False{$ELSE}IsMainForm{$ENDIF}
|
||||
else
|
||||
begin
|
||||
{$IFNDEF DARWIN}
|
||||
FMenuBar.setProperty(FMenuBar.Widget,'lcldesignmenubar',1)
|
||||
designState := IfThen( Assigned(LCLObject.Parent), 1, 2 );
|
||||
FMenuBar.setProperty(FMenuBar.Widget,'lcldesignmenubar',designState);
|
||||
{$ENDIF}
|
||||
;
|
||||
end;
|
||||
|
||||
{$IFDEF DARWIN}
|
||||
if (csDesigning in LCLObject.ComponentState) or not IsMainForm then
|
||||
@ -7432,7 +7437,7 @@ end;
|
||||
// currently only handles the adjustments that MainMenu needs to make
|
||||
function TQtMainWindow.GetClientRectFix(): TSize;
|
||||
begin
|
||||
if Assigned(FMenuBar) and (not IsMdiChild) then
|
||||
if Assigned(FMenuBar) and FMenuBar.FVisible and (not IsMdiChild) then
|
||||
begin
|
||||
FMenuBar.sizeHint(@Result);
|
||||
if Result.Height<10 then Result.Height:=0;
|
||||
@ -16581,21 +16586,30 @@ end;
|
||||
|
||||
{$IFNDEF DARWIN}
|
||||
function TQtMenuBar.IsDesigning: Boolean;
|
||||
begin
|
||||
Result := GetDesignState() <> 0;
|
||||
end;
|
||||
|
||||
function TQtMenuBar.ShouldShowMenuBar: Boolean;
|
||||
begin
|
||||
Result := GetDesignState() <> 2;
|
||||
end;
|
||||
|
||||
function TQtMenuBar.GetDesignState: Integer;
|
||||
var
|
||||
V: QVariantH;
|
||||
B: Boolean;
|
||||
begin
|
||||
Result := (Widget <> nil);
|
||||
if not Result then
|
||||
exit(False);
|
||||
Result := 0;
|
||||
if Widget = nil then
|
||||
exit;
|
||||
|
||||
Result := False;
|
||||
v := QVariant_create();
|
||||
try
|
||||
B := False;
|
||||
QObject_property(Widget, v, 'lcldesignmenubar');
|
||||
if QVariant_isValid(v) and not QVariant_isNull(v) then
|
||||
Result := QVariant_toInt(V, @B) = 1;
|
||||
Result := QVariant_toInt(V, @B);
|
||||
finally
|
||||
QVariant_destroy(v);
|
||||
end;
|
||||
@ -16681,7 +16695,7 @@ end;
|
||||
|
||||
function TQtMenuBar.addMenu(AMenu: QMenuH): QActionH;
|
||||
begin
|
||||
if not FVisible then
|
||||
if ShouldShowMenuBar and (not FVisible) then
|
||||
begin
|
||||
FVisible := True;
|
||||
setVisible(FVisible);
|
||||
@ -16698,7 +16712,7 @@ var
|
||||
seq: QKeySequenceH;
|
||||
WStr: WideString;
|
||||
begin
|
||||
if not FVisible then
|
||||
if ShouldShowMenuBar and (not FVisible) then
|
||||
begin
|
||||
FVisible := True;
|
||||
setVisible(FVisible);
|
||||
|
Loading…
Reference in New Issue
Block a user