Qt: remove stayontop in appdeactivate, restore in appactivate.

git-svn-id: trunk@25537 -
This commit is contained in:
zeljko 2010-05-20 11:14:21 +00:00
parent a72bba258d
commit 86443fce56

View File

@ -336,6 +336,12 @@ begin
FOverrideCursor := AValue; FOverrideCursor := AValue;
end; end;
type
TQtTempFormStyleSet = Set of TFormStyle;
const
TQtTopForms: Array[Boolean] of TQtTempFormStyleSet = (fsAllNonSystemStayOnTop,
fsAllStayOnTop);
procedure TQtWidgetSet.QtRemoveStayOnTop(const ASystemTopAlso: Boolean = False); procedure TQtWidgetSet.QtRemoveStayOnTop(const ASystemTopAlso: Boolean = False);
var var
i: Integer; i: Integer;
@ -345,7 +351,6 @@ var
begin begin
if StayOnTopList = nil then if StayOnTopList = nil then
StayOnTopList := TMap.Create(TMapIdType(ituPtrSize), SizeOf(TObject)); StayOnTopList := TMap.Create(TMapIdType(ituPtrSize), SizeOf(TObject));
for i := 0 to Screen.CustomFormZOrderCount - 1 do for i := 0 to Screen.CustomFormZOrderCount - 1 do
begin begin
AForm := Screen.CustomFormsZOrdered[i]; AForm := Screen.CustomFormsZOrdered[i];
@ -353,7 +358,7 @@ begin
begin begin
W := TQtMainWindow(AForm.Handle); W := TQtMainWindow(AForm.Handle);
if (AForm.Parent = nil) and if (AForm.Parent = nil) and
(AForm.FormStyle in fsAllNonSystemStayOnTop) and W.GetVisible and (AForm.FormStyle in TQtTopForms[ASystemTopAlso]) and W.GetVisible and
not W.IsMdiChild and not W.IsModal and not w.isMinimized then not W.IsMdiChild and not W.IsModal and not w.isMinimized then
begin begin
Flags := W.windowFlags; Flags := W.windowFlags;
@ -383,13 +388,12 @@ begin
exit; exit;
for i := Screen.CustomFormZOrderCount - 1 downto 0 do for i := Screen.CustomFormZOrderCount - 1 downto 0 do
begin begin
// AForm := StayOnTopList.Items[i];
AForm := Screen.CustomFormsZOrdered[i]; AForm := Screen.CustomFormsZOrdered[i];
if AForm.HandleAllocated then if AForm.HandleAllocated then
begin begin
W := TQtMainWindow(AForm.Handle); W := TQtMainWindow(AForm.Handle);
if (AForm.Parent = nil) and if (AForm.Parent = nil) and
(AForm.FormStyle in fsAllNonSystemStayOnTop) and W.GetVisible and (AForm.FormStyle in TQtTopForms[ASystemTopAlso]) and W.GetVisible and
not W.IsMdiChild and not W.IsModal and not W.isMinimized then not W.IsMdiChild and not W.IsModal and not W.isMinimized then
begin begin
if StayOnTopList.HasId(W) then if StayOnTopList.HasId(W) then
@ -397,8 +401,8 @@ begin
W.BeginUpdate; W.BeginUpdate;
Flags := W.windowFlags; Flags := W.windowFlags;
W.setWindowFlags(Flags or QtWindowStaysOnTopHint); W.setWindowFlags(Flags or QtWindowStaysOnTopHint);
W.Show;
W.setAttribute(QtWA_ShowWithoutActivating, False); W.setAttribute(QtWA_ShowWithoutActivating, False);
W.Show;
W.EndUpdate; W.EndUpdate;
end; end;
end; end;
@ -421,11 +425,17 @@ begin
case QEvent_type(Event) of case QEvent_type(Event) of
QEventApplicationActivate: QEventApplicationActivate:
if Assigned(Application) then if Assigned(Application) then
begin
Application.IntfAppActivate; Application.IntfAppActivate;
QtRestoreStayOnTop;
end;
QEventApplicationDeactivate: QEventApplicationDeactivate:
if Assigned(Application) then if Assigned(Application) then
begin
Application.IntfAppDeactivate; Application.IntfAppDeactivate;
QtRemoveStayOnTop;
end;
QEventApplicationPaletteChange: QEventApplicationPaletteChange:
begin begin