mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 10:39:15 +02:00
qt: implement TCustomForm.PopupParent
git-svn-id: trunk@23738 -
This commit is contained in:
parent
8cd529b88e
commit
7d223ed75b
@ -453,8 +453,13 @@ type
|
|||||||
private
|
private
|
||||||
LayoutWidget: QBoxLayoutH;
|
LayoutWidget: QBoxLayoutH;
|
||||||
FCWEventHook: QObject_hookH;
|
FCWEventHook: QObject_hookH;
|
||||||
|
FShowOnTaskBar: Boolean;
|
||||||
|
FPopupMode: TPopupMode;
|
||||||
|
FPopupParent: QWidgetH;
|
||||||
protected
|
protected
|
||||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||||
|
procedure ChangeParent(NewParent: QWidgetH);
|
||||||
|
procedure UpdateParent;
|
||||||
public
|
public
|
||||||
IsMainForm: Boolean;
|
IsMainForm: Boolean;
|
||||||
MDIAreaHandle: QMDIAreaH;
|
MDIAreaHandle: QMDIAreaH;
|
||||||
@ -472,6 +477,7 @@ type
|
|||||||
procedure setAcceptDropFiles(AValue: Boolean);
|
procedure setAcceptDropFiles(AValue: Boolean);
|
||||||
procedure slotWindowStateChange; cdecl;
|
procedure slotWindowStateChange; cdecl;
|
||||||
procedure setShowInTaskBar(AValue: Boolean);
|
procedure setShowInTaskBar(AValue: Boolean);
|
||||||
|
procedure setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH);
|
||||||
public
|
public
|
||||||
procedure AttachEvents; override;
|
procedure AttachEvents; override;
|
||||||
procedure DetachEvents; override;
|
procedure DetachEvents; override;
|
||||||
@ -4228,6 +4234,9 @@ begin
|
|||||||
WriteLn('TQtMainWindow.CreateWidget Name: ', LCLObject.Name);
|
WriteLn('TQtMainWindow.CreateWidget Name: ', LCLObject.Name);
|
||||||
{$endif}
|
{$endif}
|
||||||
FHasPaint := True;
|
FHasPaint := True;
|
||||||
|
FPopupMode := pmNone;
|
||||||
|
FPopupParent := nil;
|
||||||
|
|
||||||
IsMainForm := False;
|
IsMainForm := False;
|
||||||
|
|
||||||
w := QApplication_activeWindow;
|
w := QApplication_activeWindow;
|
||||||
@ -4322,6 +4331,43 @@ begin
|
|||||||
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
|
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TQtMainWindow.ChangeParent(NewParent: QWidgetH);
|
||||||
|
var
|
||||||
|
Flags: QtWindowFlags;
|
||||||
|
Visible: Boolean;
|
||||||
|
begin
|
||||||
|
if NewParent <> Widget then
|
||||||
|
begin
|
||||||
|
Visible := getVisible;
|
||||||
|
Flags := windowFlags;
|
||||||
|
setParent(NewParent);
|
||||||
|
setWindowFlags(Flags);
|
||||||
|
setVisible(Visible);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtMainWindow.UpdateParent;
|
||||||
|
var
|
||||||
|
NewParent: QWidgetH;
|
||||||
|
begin
|
||||||
|
NewParent := nil;
|
||||||
|
case FPopupMode of
|
||||||
|
pmNone: ;// no popup parent
|
||||||
|
pmAuto:
|
||||||
|
// active form is parent
|
||||||
|
if Screen.ActiveForm <> nil then
|
||||||
|
NewParent := TQtWidget(Screen.ActiveForm).Widget;
|
||||||
|
pmExplicit:
|
||||||
|
// parent is FPopupParent
|
||||||
|
if FPopupParent <> nil then
|
||||||
|
NewParent := FPopupParent;
|
||||||
|
end;
|
||||||
|
if (NewParent = nil) and not FShowOnTaskBar and not IsMainForm then
|
||||||
|
NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
|
||||||
|
|
||||||
|
ChangeParent(NewParent);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtMainWindow.Destroy
|
Function: TQtMainWindow.Destroy
|
||||||
Params: None
|
Params: None
|
||||||
@ -4484,31 +4530,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtMainWindow.setShowInTaskBar(AValue: Boolean);
|
procedure TQtMainWindow.setShowInTaskBar(AValue: Boolean);
|
||||||
var
|
|
||||||
w: QWidgetH;
|
|
||||||
Flags: QtWindowFlags;
|
|
||||||
Visible: Boolean;
|
|
||||||
begin
|
begin
|
||||||
if not AValue then
|
FShowOnTaskBar := AValue;
|
||||||
begin
|
UpdateParent;
|
||||||
w := TQtMainWindow(Application.MainForm.Handle).Widget;
|
end;
|
||||||
if w <> Widget then
|
|
||||||
begin
|
procedure TQtMainWindow.setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH);
|
||||||
Visible := getVisible;
|
begin
|
||||||
Flags := windowFlags;
|
FPopupMode := APopupMode;
|
||||||
setParent(w);
|
FPopupParent := NewParent;
|
||||||
setWindowFlags(Flags);
|
UpdateParent;
|
||||||
setVisible(Visible);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Visible := getVisible;
|
|
||||||
Flags := windowFlags;
|
|
||||||
setParent(nil);
|
|
||||||
setWindowFlags(Flags);
|
|
||||||
setVisible(Visible);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtMainWindow.AttachEvents;
|
procedure TQtMainWindow.AttachEvents;
|
||||||
|
@ -84,6 +84,8 @@ type
|
|||||||
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
|
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
|
||||||
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle: TFormStyle); override;
|
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle: TFormStyle); override;
|
||||||
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
|
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
|
||||||
|
class procedure SetPopupParent(const ACustomForm: TCustomForm;
|
||||||
|
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override;
|
||||||
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
|
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
|
||||||
class procedure ShowModal(const ACustomForm: TCustomForm); override;
|
class procedure ShowModal(const ACustomForm: TCustomForm); override;
|
||||||
class procedure SetBorderIcons(const AForm: TCustomForm; const ABorderIcons: TBorderIcons); override;
|
class procedure SetBorderIcons(const AForm: TCustomForm; const ABorderIcons: TBorderIcons); override;
|
||||||
@ -133,6 +135,7 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
|||||||
var
|
var
|
||||||
QtMainWindow: TQtMainWindow;
|
QtMainWindow: TQtMainWindow;
|
||||||
Str: WideString;
|
Str: WideString;
|
||||||
|
PopupParent: QWidgetH;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('[TQtWSCustomForm.CreateHandle] Height: ', IntToStr(AWinControl.Height),
|
WriteLn('[TQtWSCustomForm.CreateHandle] Height: ', IntToStr(AWinControl.Height),
|
||||||
@ -158,17 +161,25 @@ begin
|
|||||||
TCustomForm(AWinControl).BorderIcons, TCustomForm(AWinControl).FormStyle);
|
TCustomForm(AWinControl).BorderIcons, TCustomForm(AWinControl).FormStyle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]) and not
|
if not (TCustomForm(AWinControl).FormStyle in [fsMDIChild]) and
|
||||||
(TCustomForm(AWinControl).FormStyle in [fsMDIChild]) and
|
|
||||||
{QtTool have not minimize button !}
|
|
||||||
{$ifdef linux}
|
|
||||||
not (TCustomForm(AWinControl).BorderStyle in [bsSizeToolWin, bsToolWindow]) and
|
|
||||||
{$endif}
|
|
||||||
(Application <> nil) and
|
(Application <> nil) and
|
||||||
(Application.MainForm <> nil) and
|
(Application.MainForm <> nil) and
|
||||||
(Application.MainForm.HandleAllocated) and
|
(Application.MainForm.HandleAllocated) and
|
||||||
(Application.MainForm <> AWinControl) then
|
(Application.MainForm <> AWinControl) then
|
||||||
QtMainWindow.setShowInTaskBar(False);
|
begin
|
||||||
|
if TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]
|
||||||
|
{$ifdef linux}
|
||||||
|
{QtTool have not minimize button !}
|
||||||
|
and not (TCustomForm(AWinControl).BorderStyle in [bsSizeToolWin, bsToolWindow])
|
||||||
|
{$endif} then
|
||||||
|
QtMainWindow.setShowInTaskBar(False);
|
||||||
|
|
||||||
|
if Assigned(TCustomForm(AWinControl).PopupParent) then
|
||||||
|
PopupParent := TQtWidget(TCustomForm(AWinControl).PopupParent.Handle).Widget
|
||||||
|
else
|
||||||
|
PopupParent := nil;
|
||||||
|
QtMainWindow.setPopupParent(TCustomForm(AWinControl).PopupMode, PopupParent);
|
||||||
|
end;
|
||||||
|
|
||||||
// Sets Various Events
|
// Sets Various Events
|
||||||
QtMainWindow.AttachEvents;
|
QtMainWindow.AttachEvents;
|
||||||
@ -241,6 +252,18 @@ begin
|
|||||||
TQtWidget(AForm.Handle).setWindowIcon(nil);
|
TQtWidget(AForm.Handle).setWindowIcon(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TQtWSCustomForm.SetPopupParent(const ACustomForm: TCustomForm;
|
||||||
|
const APopupMode: TPopupMode; const APopupParent: TCustomForm);
|
||||||
|
var
|
||||||
|
PopupParent: QWidgetH;
|
||||||
|
begin
|
||||||
|
if Assigned(APopupParent) then
|
||||||
|
PopupParent := TQtWidget(APopupParent.Handle).Widget
|
||||||
|
else
|
||||||
|
PopupParent := nil;
|
||||||
|
TQtMainWindow(ACustomForm.Handle).setPopupParent(APopupMode, PopupParent);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TQtWSCustomForm.SetShowInTaskbar
|
Method: TQtWSCustomForm.SetShowInTaskbar
|
||||||
Params:
|
Params:
|
||||||
|
Loading…
Reference in New Issue
Block a user