mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 03:19:17 +02:00
Qt: moved ShowHide() to QtWSForms to reduce casts, call QApplication_syncX() on X11 to get better visual performance. fixes #16550
git-svn-id: trunk@25655 -
This commit is contained in:
parent
c7f1b52257
commit
ef9ab37cc9
@ -110,7 +110,6 @@ type
|
|||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl;
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtWSImageList }
|
{ TQtWSImageList }
|
||||||
@ -157,76 +156,6 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Method: TQtWSCustomControl.ShowHide
|
|
||||||
Params: AWinControl - the calling object
|
|
||||||
|
|
||||||
Returns: Nothing
|
|
||||||
|
|
||||||
Shows or hides a widget.
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
class procedure TQtWSCustomControl.ShowHide(const AWinControl: TWinControl);
|
|
||||||
const
|
|
||||||
LCLToQtWindowState: array[TWindowState] of QtWindowState = (
|
|
||||||
{ wsNormal } QtWindowNoState,
|
|
||||||
{ wsMinimized } QtWindowMinimized,
|
|
||||||
{ wsMaximized } QtWindowMaximized
|
|
||||||
);
|
|
||||||
var
|
|
||||||
Widget: TQtWidget;
|
|
||||||
R: TRect;
|
|
||||||
begin
|
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'ShowHide') then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
Widget := TQtWidget(AWinControl.Handle);
|
|
||||||
|
|
||||||
if AWinControl.HandleObjectShouldBeVisible and (Widget is TQtMainWindow) then
|
|
||||||
begin
|
|
||||||
if fsModal in TForm(AWinControl).FormState then
|
|
||||||
begin
|
|
||||||
{$ifdef HASX11}
|
|
||||||
QWidget_setParent(Widget.Widget, QApplication_activeWindow());
|
|
||||||
QWidget_setWindowFlags(Widget.Widget, QtDialog);
|
|
||||||
{$endif}
|
|
||||||
{$ifdef darwin}
|
|
||||||
QWidget_setWindowFlags(Widget.Widget, QtDialog or QtWindowSystemMenuHint or QtCustomizeWindowHint
|
|
||||||
or QtWindowTitleHint or QtWindowCloseButtonHint);
|
|
||||||
{$endif}
|
|
||||||
Widget.setWindowModality(QtApplicationModal);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if TForm(AWinControl).FormStyle = fsMDIChild then
|
|
||||||
begin
|
|
||||||
{MDI windows have to be resized , since titlebar is included into widget geometry !}
|
|
||||||
if not (csDesigning in AWinControl.ComponentState)
|
|
||||||
and not Widget.isMaximized then
|
|
||||||
begin
|
|
||||||
QWidget_contentsRect(Widget.Widget, @R);
|
|
||||||
R.Right := TForm(AWinControl).Width + R.Left;
|
|
||||||
R.Bottom := TForm(AWinControl).Height + R.Top;
|
|
||||||
R.Left := TQtMainWindow(Widget).MdiChildCount * 10;
|
|
||||||
R.Top := TQtMainWindow(Widget).MdiChildCount * 10;
|
|
||||||
Widget.move(R.Left, R.Top);
|
|
||||||
Widget.resize(R.Right, R.Bottom);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if TForm(AWinControl).FormStyle <> fsMDIChild then
|
|
||||||
begin
|
|
||||||
if (csDesigning in AWinControl.ComponentState) and
|
|
||||||
(TCustomForm(AWinControl).WindowState = wsMaximized) then
|
|
||||||
TQtMainWindow(Widget).setWindowState(LCLToQtWindowState[wsNormal])
|
|
||||||
else
|
|
||||||
TQtMainWindow(Widget).setWindowState(LCLToQtWindowState[TCustomForm(AWinControl).WindowState]);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Widget.BeginUpdate;
|
|
||||||
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
|
|
||||||
Widget.EndUpdate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtWSWinControl.CanFocus
|
Function: TQtWSWinControl.CanFocus
|
||||||
Params: TWinControl
|
Params: TWinControl
|
||||||
|
@ -88,6 +88,7 @@ type
|
|||||||
class procedure SetPopupParent(const ACustomForm: TCustomForm;
|
class procedure SetPopupParent(const ACustomForm: TCustomForm;
|
||||||
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override;
|
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 ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
|
||||||
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;
|
||||||
class procedure SetAlphaBlend(const ACustomForm: TCustomForm;
|
class procedure SetAlphaBlend(const ACustomForm: TCustomForm;
|
||||||
@ -326,6 +327,72 @@ begin
|
|||||||
TQtMainWindow(AForm.Handle).setShowInTaskBar(Enable);
|
TQtMainWindow(AForm.Handle).setShowInTaskBar(Enable);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TQtWSCustomForm.ShowHide(const AWinControl: TWinControl);
|
||||||
|
const
|
||||||
|
LCLToQtWindowState: array[TWindowState] of QtWindowState = (
|
||||||
|
{ wsNormal } QtWindowNoState,
|
||||||
|
{ wsMinimized } QtWindowMinimized,
|
||||||
|
{ wsMaximized } QtWindowMaximized
|
||||||
|
);
|
||||||
|
var
|
||||||
|
Widget: TQtMainWindow;
|
||||||
|
R: TRect;
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AWinControl, 'ShowHide') then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
Widget := TQtMainWindow(AWinControl.Handle);
|
||||||
|
|
||||||
|
if AWinControl.HandleObjectShouldBeVisible then
|
||||||
|
begin
|
||||||
|
if fsModal in TForm(AWinControl).FormState then
|
||||||
|
begin
|
||||||
|
{$ifdef HASX11}
|
||||||
|
QWidget_setParent(Widget.Widget, QApplication_activeWindow());
|
||||||
|
QWidget_setWindowFlags(Widget.Widget, QtDialog);
|
||||||
|
{$endif}
|
||||||
|
{$ifdef darwin}
|
||||||
|
QWidget_setWindowFlags(Widget.Widget, QtDialog or QtWindowSystemMenuHint or QtCustomizeWindowHint
|
||||||
|
or QtWindowTitleHint or QtWindowCloseButtonHint);
|
||||||
|
{$endif}
|
||||||
|
Widget.setWindowModality(QtApplicationModal);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if TForm(AWinControl).FormStyle = fsMDIChild then
|
||||||
|
begin
|
||||||
|
{MDI windows have to be resized , since titlebar is included into widget geometry !}
|
||||||
|
if not (csDesigning in AWinControl.ComponentState)
|
||||||
|
and not Widget.isMaximized then
|
||||||
|
begin
|
||||||
|
QWidget_contentsRect(Widget.Widget, @R);
|
||||||
|
R.Right := TForm(AWinControl).Width + R.Left;
|
||||||
|
R.Bottom := TForm(AWinControl).Height + R.Top;
|
||||||
|
R.Left := Widget.MdiChildCount * 10;
|
||||||
|
R.Top := Widget.MdiChildCount * 10;
|
||||||
|
Widget.move(R.Left, R.Top);
|
||||||
|
Widget.resize(R.Right, R.Bottom);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if TForm(AWinControl).FormStyle <> fsMDIChild then
|
||||||
|
begin
|
||||||
|
if (csDesigning in AWinControl.ComponentState) and
|
||||||
|
(TCustomForm(AWinControl).WindowState = wsMaximized) then
|
||||||
|
Widget.setWindowState(LCLToQtWindowState[wsNormal])
|
||||||
|
else
|
||||||
|
Widget.setWindowState(LCLToQtWindowState[TCustomForm(AWinControl).WindowState]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Widget.BeginUpdate;
|
||||||
|
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
|
||||||
|
Widget.EndUpdate;
|
||||||
|
{$IFDEF HASX11}
|
||||||
|
if TForm(AWinControl).FormStyle <> fsMDIChild then
|
||||||
|
QApplication_syncX();
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TQtWSCustomForm.ShowModal
|
Method: TQtWSCustomForm.ShowModal
|
||||||
Params:
|
Params:
|
||||||
|
Loading…
Reference in New Issue
Block a user