qt: implement TCustomForm.PopupParent

git-svn-id: trunk@23738 -
This commit is contained in:
paul 2010-02-19 03:49:39 +00:00
parent 8cd529b88e
commit 7d223ed75b
2 changed files with 85 additions and 31 deletions

View File

@ -453,8 +453,13 @@ type
private
LayoutWidget: QBoxLayoutH;
FCWEventHook: QObject_hookH;
FShowOnTaskBar: Boolean;
FPopupMode: TPopupMode;
FPopupParent: QWidgetH;
protected
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
procedure ChangeParent(NewParent: QWidgetH);
procedure UpdateParent;
public
IsMainForm: Boolean;
MDIAreaHandle: QMDIAreaH;
@ -472,6 +477,7 @@ type
procedure setAcceptDropFiles(AValue: Boolean);
procedure slotWindowStateChange; cdecl;
procedure setShowInTaskBar(AValue: Boolean);
procedure setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH);
public
procedure AttachEvents; override;
procedure DetachEvents; override;
@ -4228,6 +4234,9 @@ begin
WriteLn('TQtMainWindow.CreateWidget Name: ', LCLObject.Name);
{$endif}
FHasPaint := True;
FPopupMode := pmNone;
FPopupParent := nil;
IsMainForm := False;
w := QApplication_activeWindow;
@ -4322,6 +4331,43 @@ begin
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
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
Params: None
@ -4484,31 +4530,16 @@ begin
end;
procedure TQtMainWindow.setShowInTaskBar(AValue: Boolean);
var
w: QWidgetH;
Flags: QtWindowFlags;
Visible: Boolean;
begin
if not AValue then
begin
w := TQtMainWindow(Application.MainForm.Handle).Widget;
if w <> Widget then
begin
Visible := getVisible;
Flags := windowFlags;
setParent(w);
setWindowFlags(Flags);
setVisible(Visible);
end;
end
else
begin
Visible := getVisible;
Flags := windowFlags;
setParent(nil);
setWindowFlags(Flags);
setVisible(Visible);
end;
FShowOnTaskBar := AValue;
UpdateParent;
end;
procedure TQtMainWindow.setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH);
begin
FPopupMode := APopupMode;
FPopupParent := NewParent;
UpdateParent;
end;
procedure TQtMainWindow.AttachEvents;

View File

@ -84,6 +84,8 @@ type
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle: TFormStyle); 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 ShowModal(const ACustomForm: TCustomForm); override;
class procedure SetBorderIcons(const AForm: TCustomForm; const ABorderIcons: TBorderIcons); override;
@ -133,6 +135,7 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
var
QtMainWindow: TQtMainWindow;
Str: WideString;
PopupParent: QWidgetH;
begin
{$ifdef VerboseQt}
WriteLn('[TQtWSCustomForm.CreateHandle] Height: ', IntToStr(AWinControl.Height),
@ -158,17 +161,25 @@ begin
TCustomForm(AWinControl).BorderIcons, TCustomForm(AWinControl).FormStyle);
end;
if (TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]) and not
(TCustomForm(AWinControl).FormStyle in [fsMDIChild]) and
{QtTool have not minimize button !}
{$ifdef linux}
not (TCustomForm(AWinControl).BorderStyle in [bsSizeToolWin, bsToolWindow]) and
{$endif}
if not (TCustomForm(AWinControl).FormStyle in [fsMDIChild]) and
(Application <> nil) and
(Application.MainForm <> nil) and
(Application.MainForm.HandleAllocated) and
(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
QtMainWindow.AttachEvents;
@ -241,6 +252,18 @@ begin
TQtWidget(AForm.Handle).setWindowIcon(nil);
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
Params: