Qt,Gtk2: added minimize/restore ability to get consistent behaviour on all platforms. Patch by Flavio Etrusco modified by me for qt. fixes #13919

git-svn-id: trunk@25407 -
This commit is contained in:
zeljko 2010-05-14 19:12:02 +00:00
parent dda71573f7
commit 2773d06487
5 changed files with 80 additions and 1 deletions

View File

@ -4,7 +4,6 @@ inherited MessagesView: TMessagesView
Top = 640
Width = 722
ActiveControl = MessageTreeView
BorderStyle = bsSizeToolWin
Caption = 'MessagesView'
ClientHeight = 79
ClientWidth = 722

View File

@ -629,6 +629,11 @@ begin
end;
if OldState <> FWindowState then
begin
if (OldState = wsMinimized) and (Application.MainForm = Self)
and (WidgetSet.GetLCLCapability(lcNeedMininimizeAppWithMainForm) <> LCL_CAPABILITY_NO) then
begin
Application.Restore;
end;
if Assigned(OnWindowStateChange) then
OnWindowStateChange(Self);
end;

View File

@ -64,6 +64,8 @@ type
function LCLPlatform: TLCLPlatform; override;
procedure AppInit(var ScreenInfo: TScreenInfo); override;
procedure AppMinimize; override;
procedure AppRestore; override;
function AppHandle: THandle; override;
procedure SetCallbackEx(const AMsg: LongInt; const AGTKObject: PGTKObject; const ALCLObject: TObject; Direct: Boolean);override;

View File

@ -598,6 +598,38 @@ begin
{$ifend}
end;
procedure TGtk2WidgetSet.AppMinimize;
var
i: Integer;
AForm: TCustomForm;
begin
if Screen=nil then exit;
for i:= 0 to Screen.CustomFormZOrderCount-1 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if (AForm.Parent=nil) and AForm.HandleAllocated and AForm.Visible and
not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle in [bsNone]) then
gtk_window_iconify(PGtkWindow(AForm.Handle));
end;
end;
procedure TGtk2WidgetSet.AppRestore;
var
i: Integer;
AForm: TCustomForm;
begin
if Screen=nil then exit;
for i:= Screen.CustomFormZOrderCount-1 downto 0 do
begin
AForm:=Screen.CustomFormsZOrdered[i];
if (AForm.Parent=nil) and AForm.HandleAllocated and AForm.Visible and
not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle in [bsNone]) then
gtk_window_deiconify(PGtkWindow(AForm.Handle));
end;
end;
function TGtk2WidgetSet.AppHandle: Thandle;
begin
{$ifdef windows}

View File

@ -216,15 +216,54 @@ begin
end;
procedure TQtWidgetSet.AppMinimize;
{$IFDEF LINUX}
var
i: Integer;
AForm: TCustomForm;
{$ENDIF}
begin
if (Application.MainForm <> nil) and (Application.MainForm.HandleAllocated) then
begin
{$IFDEF LINUX}
for i := 0 to Screen.CustomFormZOrderCount-1 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if (AForm.Parent=nil) and AForm.HandleAllocated and AForm.Visible and
not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle in [bsNone])
then
TQtMainWindow(AForm.Handle).ShowMinimized;
end;
{$ELSE}
TQtMainWindow(Application.MainForm.Handle).ShowMinimized;
{$ENDIF}
end;
end;
procedure TQtWidgetSet.AppRestore;
{$IFDEF LINUX}
var
i: Integer;
AForm: TCustomForm;
{$ENDIF}
begin
if (Application.MainForm <> nil) and (Application.MainForm.HandleAllocated) then
begin
{$IFDEF LINUX}
if Screen = nil then exit;
for i := Screen.CustomFormZOrderCount-1 downto 0 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if (AForm.Parent=nil) and AForm.HandleAllocated and AForm.Visible and
not (AForm.FormStyle in [fsMDIChild, fsSplash]) and
not (AForm.BorderStyle in [bsNone])
then
TQtMainWindow(AForm.Handle).ShowNormal;
end;
{$ELSE}
TQtMainWindow(Application.MainForm.Handle).ShowNormal;
{$ENDIF}
end;
end;
procedure TQtWidgetSet.AppBringToFront;
@ -367,6 +406,8 @@ begin
lcCanDrawOutsideOnPaint: Result := LCL_CAPABILITY_NO;
lcDragDockStartOnTitleClick: Result :=
{$ifdef MSWINDOWS} LCL_CAPABILITY_YES {$else} LCL_CAPABILITY_NO {$endif};
lcNeedMininimizeAppWithMainForm: Result :=
{$ifdef LINUX} LCL_CAPABILITY_YES {$else} LCL_CAPABILITY_NO {$endif};
else
Result := inherited GetLCLCapability(ACapability);
end;