Qt: finally fixed AppMinimize for designed forms.

git-svn-id: trunk@47744 -
This commit is contained in:
zeljko 2015-02-13 17:29:51 +00:00
parent d54f5572fa
commit 41a6b409a2

View File

@ -349,24 +349,56 @@ var
i: Integer;
AForm: TCustomForm;
States: QtWindowStates;
AWidget: TQtWidget;
{$ENDIF}
begin
if (Application.MainForm <> nil) and (Application.MainForm.HandleAllocated) then
begin
{$IFDEF HASX11}
HideAllHints;
// first minimize all designed forms
for i := 0 to Screen.CustomFormZOrderCount-1 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if (AForm.Parent=nil) and AForm.HandleAllocated and
TQtWidget(AForm.Handle).getVisible and
((not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle = bsNone)) or
(csDesigning in AForm.ComponentState)) then
if not AForm.HandleAllocated or Assigned(AForm.Parent) then
continue;
{$IFDEF DEBUGQTAPPMINIMIZE}
DebugLn('1.MUST MINIMIZE ',dbgsName(AForm),' design ? ',dbgs(csDesigning in AForm.ComponentState),
' HANDLEVISIBLE ',dbgs(TQtWidget(AForm.Handle).getVisible),' FORMVISIBLE=',dbgs(AForm.Visible));
{$ENDIF}
AWidget := TQtWidget(AForm.Handle);
if AWidget.getVisible and
(csDesigning in AForm.ComponentState) then
begin
States := TQtMainWindow(AForm.Handle).getWindowState;
if not TQtMainWindow(AForm.Handle).isMinimized then
TQtMainWindow(AForm.Handle).setWindowState(States or QtWindowMinimized);
States := AWidget.getWindowState;
{$IFDEF DEBUGQTAPPMINIMIZE}
DebugLn('1. **** TRYING TO MINIMIZE ',dbgsName(AForm),' already minimized ? ',dbgs(AWidget.isMinimized));
{$ENDIF}
if not AWidget.isMinimized then
AWidget.setWindowState(States or QtWindowMinimized);
end;
end;
for i := 0 to Screen.CustomFormZOrderCount-1 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if not AForm.HandleAllocated or Assigned(AForm.Parent) or
(csDesigning in AForm.ComponentState) then
continue;
{$IFDEF DEBUGQTAPPMINIMIZE}
DebugLn('2. MUST MINIMIZE ',dbgsName(AForm),' design ? ',dbgs(csDesigning in AForm.ComponentState),
' HANDLEVISIBLE ',dbgs(TQtWidget(AForm.Handle).getVisible),' FORMVISIBLE=',dbgs(AForm.Visible));
{$ENDIF}
AWidget := TQtWidget(AForm.Handle);
if AWidget.getVisible and
not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle = bsNone) then
begin
States := AWidget.getWindowState;
{$IFDEF DEBUGQTAPPMINIMIZE}
DebugLn('2. **** TRYING TO MINIMIZE ',dbgsName(AForm),' already minimized ? ',dbgs(AWidget.isMinimized));
{$ENDIF}
if not AWidget.isMinimized then
AWidget.setWindowState(States or QtWindowMinimized);
end;
end;
{$ELSE}
@ -381,6 +413,7 @@ var
i: Integer;
AForm: TCustomForm;
States: QtWindowStates;
AWidget: TQtWidget;
{$ENDIF}
begin
if (Application.MainForm <> nil) and (Application.MainForm.HandleAllocated) then
@ -390,15 +423,24 @@ begin
for i := Screen.CustomFormZOrderCount-1 downto 0 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if (AForm.Parent=nil) and AForm.HandleAllocated and
TQtWidget(AForm.Handle).getVisible and
if not AForm.HandleAllocated or Assigned(AForm.Parent) then
continue;
{$IFDEF DEBUGQTAPPMINIMIZE}
DebugLn('MUST RESTORE ',dbgsName(AForm),' design ? ',dbgs(csDesigning in AForm.ComponentState),
' HANDLEVISIBLE ',dbgs(TQtWidget(AForm.Handle).getVisible),' FORMVISIBLE=',dbgs(AForm.Visible));
{$ENDIF}
AWidget := TQtWidget(AForm.Handle);
if AWidget.getVisible and
((not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle = bsNone)) or
(csDesigning in AForm.ComponentState)) then
begin
States := TQtMainWindow(AForm.Handle).getWindowState;
if TQtMainWindow(AForm.Handle).isMinimized then
TQtMainWindow(AForm.Handle).setWindowState(States and not QtWindowMinimized);
States := AWidget.getWindowState;
{$IFDEF DEBUGQTAPPMINIMIZE}
DebugLn('TRYING TO RESTORE ',dbgsName(AForm),' already minimized ? ',dbgs(AWidget.isMinimized));
{$ENDIF}
if AWidget.isMinimized then
AWidget.setWindowState(States and not QtWindowMinimized);
end;
end;
RestoreAllHints;