mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 07:20:01 +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;
|
constructor Create(const AParent: QWidgetH); overload;
|
||||||
public
|
public
|
||||||
{$IFNDEF DARWIN}
|
{$IFNDEF DARWIN}
|
||||||
|
function GetDesignState: Integer;
|
||||||
function IsDesigning: Boolean;
|
function IsDesigning: Boolean;
|
||||||
|
function ShouldShowMenuBar: Boolean;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||||
function addMenu(AMenu: QMenuH): QActionH;
|
function addMenu(AMenu: QMenuH): QActionH;
|
||||||
@ -7254,6 +7256,7 @@ end;
|
|||||||
function TQtMainWindow.MenuBarNeeded: TQtMenuBar;
|
function TQtMainWindow.MenuBarNeeded: TQtMenuBar;
|
||||||
var
|
var
|
||||||
AParent: QWidgetH;
|
AParent: QWidgetH;
|
||||||
|
designState: Integer;
|
||||||
begin
|
begin
|
||||||
if not Assigned(FMenuBar) then
|
if not Assigned(FMenuBar) then
|
||||||
begin
|
begin
|
||||||
@ -7269,10 +7272,12 @@ begin
|
|||||||
if not (csDesigning in LCLObject.ComponentState) then
|
if not (csDesigning in LCLObject.ComponentState) then
|
||||||
FMenuBar.FIsApplicationMainMenu := {$IFDEF DARWIN}False{$ELSE}IsMainForm{$ENDIF}
|
FMenuBar.FIsApplicationMainMenu := {$IFDEF DARWIN}False{$ELSE}IsMainForm{$ENDIF}
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
{$IFNDEF DARWIN}
|
{$IFNDEF DARWIN}
|
||||||
FMenuBar.setProperty(FMenuBar.Widget,'lcldesignmenubar',1)
|
designState := IfThen( Assigned(LCLObject.Parent), 1, 2 );
|
||||||
|
FMenuBar.setProperty(FMenuBar.Widget,'lcldesignmenubar',designState);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
;
|
end;
|
||||||
|
|
||||||
{$IFDEF DARWIN}
|
{$IFDEF DARWIN}
|
||||||
if (csDesigning in LCLObject.ComponentState) or not IsMainForm then
|
if (csDesigning in LCLObject.ComponentState) or not IsMainForm then
|
||||||
@ -7432,7 +7437,7 @@ end;
|
|||||||
// currently only handles the adjustments that MainMenu needs to make
|
// currently only handles the adjustments that MainMenu needs to make
|
||||||
function TQtMainWindow.GetClientRectFix(): TSize;
|
function TQtMainWindow.GetClientRectFix(): TSize;
|
||||||
begin
|
begin
|
||||||
if Assigned(FMenuBar) and (not IsMdiChild) then
|
if Assigned(FMenuBar) and FMenuBar.FVisible and (not IsMdiChild) then
|
||||||
begin
|
begin
|
||||||
FMenuBar.sizeHint(@Result);
|
FMenuBar.sizeHint(@Result);
|
||||||
if Result.Height<10 then Result.Height:=0;
|
if Result.Height<10 then Result.Height:=0;
|
||||||
@ -16581,21 +16586,30 @@ end;
|
|||||||
|
|
||||||
{$IFNDEF DARWIN}
|
{$IFNDEF DARWIN}
|
||||||
function TQtMenuBar.IsDesigning: Boolean;
|
function TQtMenuBar.IsDesigning: Boolean;
|
||||||
|
begin
|
||||||
|
Result := GetDesignState() <> 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtMenuBar.ShouldShowMenuBar: Boolean;
|
||||||
|
begin
|
||||||
|
Result := GetDesignState() <> 2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtMenuBar.GetDesignState: Integer;
|
||||||
var
|
var
|
||||||
V: QVariantH;
|
V: QVariantH;
|
||||||
B: Boolean;
|
B: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (Widget <> nil);
|
Result := 0;
|
||||||
if not Result then
|
if Widget = nil then
|
||||||
exit(False);
|
exit;
|
||||||
|
|
||||||
Result := False;
|
|
||||||
v := QVariant_create();
|
v := QVariant_create();
|
||||||
try
|
try
|
||||||
B := False;
|
B := False;
|
||||||
QObject_property(Widget, v, 'lcldesignmenubar');
|
QObject_property(Widget, v, 'lcldesignmenubar');
|
||||||
if QVariant_isValid(v) and not QVariant_isNull(v) then
|
if QVariant_isValid(v) and not QVariant_isNull(v) then
|
||||||
Result := QVariant_toInt(V, @B) = 1;
|
Result := QVariant_toInt(V, @B);
|
||||||
finally
|
finally
|
||||||
QVariant_destroy(v);
|
QVariant_destroy(v);
|
||||||
end;
|
end;
|
||||||
@ -16681,7 +16695,7 @@ end;
|
|||||||
|
|
||||||
function TQtMenuBar.addMenu(AMenu: QMenuH): QActionH;
|
function TQtMenuBar.addMenu(AMenu: QMenuH): QActionH;
|
||||||
begin
|
begin
|
||||||
if not FVisible then
|
if ShouldShowMenuBar and (not FVisible) then
|
||||||
begin
|
begin
|
||||||
FVisible := True;
|
FVisible := True;
|
||||||
setVisible(FVisible);
|
setVisible(FVisible);
|
||||||
@ -16698,7 +16712,7 @@ var
|
|||||||
seq: QKeySequenceH;
|
seq: QKeySequenceH;
|
||||||
WStr: WideString;
|
WStr: WideString;
|
||||||
begin
|
begin
|
||||||
if not FVisible then
|
if ShouldShowMenuBar and (not FVisible) then
|
||||||
begin
|
begin
|
||||||
FVisible := True;
|
FVisible := True;
|
||||||
setVisible(FVisible);
|
setVisible(FVisible);
|
||||||
|
Loading…
Reference in New Issue
Block a user