mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-25 17:29:07 +02:00
Merged revision(s) 51358 #49d6dee15e, 51381 #a7f3bf4640, 51443-51444 #6e15c088bf-#6e15c088bf, 51476 #843fcd8da7 from trunk:
Qt: fixed painting on TGroupBox.issue #28155 ........ Qt: fixed hint changing of TTrayIcon. issue #29478 ........ Qt: proper resize QMDIArea if any of LCLObject child wincontrols are aligned alTop,alLeft,alBottom or alRight. issue #29529 ........ Qt: fix activate/deactivate signal on mdichild forms without any control. issue #29528 ........ Qt: fixed mouse events in TQtGroupBox. issue #29572 ........ git-svn-id: branches/fixes_1_6@51517 -
This commit is contained in:
parent
0ff9fdd2be
commit
b8058ec213
lcl/interfaces/qt
@ -986,11 +986,22 @@ var
|
||||
Assigned(TQtMainWindow(OldWidget).LCLObject) and
|
||||
not (csDesigning in TQtMainWindow(OldWidget).LCLObject.ComponentState))
|
||||
or MDIFocusFixNeeded then
|
||||
begin
|
||||
// DO NOT TRIGGER ANYTHING, THIS IS SPURIOUS EVENT FROM MDIAREA
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
Writeln('TQtWidgetSet.FocusChanged: *** DO NOT KILL FOCUS ***')
|
||||
{$ENDIF}
|
||||
else
|
||||
//issue #29528
|
||||
if TQtMainWindow(OldWidget).IsMdiChild and (TQtMainWindow(OldWidget).LCLObject.ControlCount = 0) then
|
||||
begin
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
Writeln('TQtWidgetSet.FocusChanged: *** SEND KILL FOCUS FOR MDICHILD WITH 0 CONTROLS ***');
|
||||
{$ENDIF}
|
||||
OldWidget.DeliverMessage(Msg);
|
||||
end else
|
||||
begin
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
Writeln('TQtWidgetSet.FocusChanged: *** DO NOT KILL FOCUS ***');
|
||||
{$ENDIF}
|
||||
end;
|
||||
end else
|
||||
if CheckIfActiveForm(OldWidget) then
|
||||
OldWidget.DeliverMessage(Msg)
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
@ -1111,11 +1122,26 @@ begin
|
||||
;
|
||||
|
||||
end else
|
||||
// if this happens then qt's mdi focus is real crap
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
writeln('TQtWidgetSet.FocusChanged: WE ARE COMPLETELY OUT OF MIND WHAT TO DO (1) .....')
|
||||
{$ENDIF}
|
||||
;
|
||||
begin
|
||||
// issue #29528
|
||||
if TQtMainWindow(NewWidget).LCLObject.ControlCount = 0 then
|
||||
begin
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
writeln('TQtWidgetSet.FocusChanged: setting focus to mdiChild with 0 controls .....');
|
||||
{$ENDIF}
|
||||
Msg.msg := LM_SETFOCUS;
|
||||
if OldWidget = NewWidget then
|
||||
OldWidget := nil;
|
||||
Msg.wParam := PtrInt(OldWidget);
|
||||
NewWidget.DeliverMessage(Msg);
|
||||
end else
|
||||
begin
|
||||
// if this happens then qt's mdi focus is real crap
|
||||
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||
writeln('TQtWidgetSet.FocusChanged: WE ARE COMPLETELY OUT OF MIND WHAT TO DO (1) .....');
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
end else
|
||||
begin
|
||||
|
@ -758,11 +758,16 @@ type
|
||||
function CanPaintBackground: Boolean; override;
|
||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||
function getClientBounds: TRect; override;
|
||||
function getClientOffset: TPoint; override;
|
||||
function getText: WideString; override;
|
||||
procedure preferredSize(var PreferredWidth, PreferredHeight: integer;
|
||||
{%H-}WithThemeSpace: Boolean); override;
|
||||
procedure setText(const W: WideString); override;
|
||||
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
|
||||
procedure Update(ARect: PRect = nil); override;
|
||||
procedure UpdateRegion(ARgn: QRegionH); override;
|
||||
procedure Repaint(ARect: PRect = nil); override;
|
||||
|
||||
property GroupBoxType: TQtGroupBoxType read FGroupBoxType write FGroupBoxType;
|
||||
property CheckBoxState: boolean read GetCheckBoxState write SetCheckBoxState;
|
||||
property CheckBoxVisible: boolean read GetCheckBoxVisible write SetCheckBoxVisible;
|
||||
@ -7400,8 +7405,8 @@ begin
|
||||
{TODO: find better way to find out which controls are top,left,right & bottom aligned ...}
|
||||
for i := 0 to LCLObject.ComponentCount - 1 do
|
||||
begin
|
||||
{find statusbars}
|
||||
if LCLObject.Components[i] is TStatusBar then
|
||||
if (LCLObject.Components[i] is TWinControl) and
|
||||
(TWinControl(LCLObject.Components[i]).Align in [alTop, alLeft, alRight, alBottom]) then
|
||||
begin
|
||||
R2 := TWinControl(LCLObject.Components[i]).BoundsRect;
|
||||
case TWinControl(LCLObject.Components[i]).Align of
|
||||
@ -7411,19 +7416,6 @@ begin
|
||||
alBottom: R.Bottom := R.Bottom - (R2.Bottom - R2.Top);
|
||||
end;
|
||||
end;
|
||||
|
||||
{find toolbars}
|
||||
if LCLObject.Components[i] is TToolBar then
|
||||
begin
|
||||
R2 := TWinControl(LCLObject.Components[i]).BoundsRect;
|
||||
case TWinControl(LCLObject.Components[i]).Align of
|
||||
alLeft: R.Left := R.Left + (R2.Right - R2.Left);
|
||||
alTop: R.Top := R.Top + (R2.Bottom - R2.Top);
|
||||
alRight: R.Right := R.Right - (R2.Right - R2.Left);
|
||||
alBottom: R.Bottom := R.Bottom - (R2.Bottom - R2.Top);
|
||||
end;
|
||||
end;
|
||||
|
||||
end; {components loop}
|
||||
QWidget_setGeometry(MDIAreaHandle.Widget, @R);
|
||||
end;
|
||||
@ -7760,8 +7752,8 @@ begin
|
||||
inherited AttachEvents;
|
||||
if FCentralWidget <> nil then
|
||||
begin
|
||||
// FCWEventHook := QObject_hook_create(FCentralWidget);
|
||||
// QObject_hook_hook_events(FCWEventHook, @EventFilter);
|
||||
FCWEventHook := QObject_hook_create(FCentralWidget);
|
||||
QObject_hook_hook_events(FCWEventHook, @EventFilter);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -7769,8 +7761,8 @@ procedure TQtGroupBox.DetachEvents;
|
||||
begin
|
||||
if FCWEventHook <> nil then
|
||||
begin
|
||||
// QObject_hook_destroy(FCWEventHook);
|
||||
// FCWEventHook := nil;
|
||||
QObject_hook_destroy(FCWEventHook);
|
||||
FCWEventHook := nil;
|
||||
end;
|
||||
inherited DetachEvents;
|
||||
end;
|
||||
@ -7778,8 +7770,7 @@ end;
|
||||
function TQtGroupBox.CanPaintBackground: Boolean;
|
||||
begin
|
||||
Result := CanSendLCLMessage and getEnabled and
|
||||
(LCLObject.Color <> clBtnFace) and (LCLObject.Color <> clBackground);
|
||||
// DO NOT REMOVE ! QGroupBox default = clBackground not clBtnFace !
|
||||
(LCLObject.Color <> clDefault);
|
||||
end;
|
||||
|
||||
function TQtGroupBox.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
||||
@ -7787,6 +7778,9 @@ function TQtGroupBox.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
||||
var
|
||||
ResizeEvent: QResizeEventH;
|
||||
NewSize, OldSize: TSize;
|
||||
R: TRect;
|
||||
APos, AGlobalPos: TQtPoint;
|
||||
ANewMouseEvent: QMouseEventH;
|
||||
begin
|
||||
Result := False;
|
||||
QEvent_accept(Event);
|
||||
@ -7795,10 +7789,71 @@ begin
|
||||
|
||||
if (Sender = FCentralWidget) then
|
||||
begin
|
||||
case QEvent_type(Event) of
|
||||
QEventPaint: Result := inherited EventFilter(Sender, Event);
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
|
||||
{about issue #29572: we must use main widget for mouse
|
||||
events, since using it in FCentralWidget above freezes
|
||||
application for some reason. Offsetting pos fixes problem.}
|
||||
case QEvent_type(Event) of
|
||||
QEventWheel: // issue #29572
|
||||
begin
|
||||
APos := QMouseEvent_pos(QMouseEventH(Event))^;
|
||||
AGlobalPos := QMouseEvent_globalPos(QMouseEventH(Event))^;
|
||||
QWidget_geometry(FCentralWidget, @R);
|
||||
inc(APos.X, -R.Left);
|
||||
inc(APos.Y, -R.Top);
|
||||
ANewMouseEvent := QMouseEvent_create(QEvent_type(Event), @APos, @AGlobalPos, QMouseEvent_button(QMouseEventH(Event)),
|
||||
QMouseEvent_buttons(QMouseEventH(Event)), QInputEvent_modifiers(QInputEventH(Event)));
|
||||
try
|
||||
Result := SlotMouseWheel(Sender, ANewMouseEvent);
|
||||
finally
|
||||
QMouseEvent_destroy(ANewMouseEvent);
|
||||
end;
|
||||
end;
|
||||
QEventMouseMove: // issue #29572
|
||||
begin
|
||||
APos := QMouseEvent_pos(QMouseEventH(Event))^;
|
||||
AGlobalPos := QMouseEvent_globalPos(QMouseEventH(Event))^;
|
||||
QWidget_geometry(FCentralWidget, @R);
|
||||
inc(APos.X, -R.Left);
|
||||
inc(APos.Y, -R.Top);
|
||||
ANewMouseEvent := QMouseEvent_create(QEvent_type(Event), @APos, @AGlobalPos, QMouseEvent_button(QMouseEventH(Event)),
|
||||
QMouseEvent_buttons(QMouseEventH(Event)), QInputEvent_modifiers(QInputEventH(Event)));
|
||||
try
|
||||
Result := SlotMouseMove(Sender, ANewMouseEvent);
|
||||
finally
|
||||
QMouseEvent_destroy(ANewMouseEvent);
|
||||
end;
|
||||
end;
|
||||
QEventMouseButtonPress,
|
||||
QEventMouseButtonRelease,
|
||||
QEventMouseButtonDblClick: // issue #29572
|
||||
begin
|
||||
APos := QMouseEvent_pos(QMouseEventH(Event))^;
|
||||
AGlobalPos := QMouseEvent_globalPos(QMouseEventH(Event))^;
|
||||
QWidget_geometry(FCentralWidget, @R);
|
||||
inc(APos.X, -R.Left);
|
||||
inc(APos.Y, -R.Top);
|
||||
ANewMouseEvent := QMouseEvent_create(QEvent_type(Event), @APos, @AGlobalPos, QMouseEvent_button(QMouseEventH(Event)),
|
||||
QMouseEvent_buttons(QMouseEventH(Event)), QInputEvent_modifiers(QInputEventH(Event)));
|
||||
try
|
||||
Result := SlotMouse(Sender, ANewMouseEvent);
|
||||
finally
|
||||
QMouseEvent_destroy(ANewMouseEvent);
|
||||
end;
|
||||
end;
|
||||
QEventPaint:
|
||||
begin
|
||||
Result := False;
|
||||
// paint complete background, like gtk2 does
|
||||
if CanPaintBackground then
|
||||
SlotPaintBg(Sender, Event);
|
||||
// issue #28155, we are painting our FCentralWidget, not QGroupBox
|
||||
// Result := inherited EventFilter(Sender, Event);
|
||||
end;
|
||||
QEventFontChange:
|
||||
begin
|
||||
Result := inherited EventFilter(Sender, Event);
|
||||
@ -7835,6 +7890,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQtGroupBox.getClientOffset: TPoint;
|
||||
begin
|
||||
Result:=inherited getClientOffset;
|
||||
// issue #28155
|
||||
// there's no client offset since FCentralWidget is at it's position 0,0
|
||||
if testAttribute(QtWA_Mapped) and QWidget_testAttribute(FCentralWidget, QtWA_Mapped) then
|
||||
Result := Point(0, 0);
|
||||
end;
|
||||
|
||||
function TQtGroupBox.getClientBounds: TRect;
|
||||
var
|
||||
R, R1: TRect;
|
||||
@ -7920,6 +7984,42 @@ begin
|
||||
inherited setFocusPolicy(APolicy);
|
||||
end;
|
||||
|
||||
procedure TQtGroupBox.Update(ARect: PRect);
|
||||
begin
|
||||
if Assigned(FCentralWidget) then
|
||||
begin
|
||||
if ARect <> nil then
|
||||
QWidget_update(FCentralWidget, ARect)
|
||||
else
|
||||
QWidget_update(FCentralWidget);
|
||||
end else
|
||||
inherited Update(ARect);
|
||||
end;
|
||||
|
||||
procedure TQtGroupBox.UpdateRegion(ARgn: QRegionH);
|
||||
begin
|
||||
if Assigned(FCentralWidget) then
|
||||
begin
|
||||
if ARgn <> nil then
|
||||
QWidget_update(FCentralWidget, ARgn)
|
||||
else
|
||||
QWidget_update(FCentralWidget);
|
||||
end else
|
||||
inherited UpdateRegion(ARgn);
|
||||
end;
|
||||
|
||||
procedure TQtGroupBox.Repaint(ARect: PRect);
|
||||
begin
|
||||
if Assigned(FCentralWidget) then
|
||||
begin
|
||||
if ARect <> nil then
|
||||
QWidget_repaint(FCentralWidget, ARect)
|
||||
else
|
||||
QWidget_repaint(FCentralWidget);
|
||||
end else
|
||||
inherited Repaint(ARect);
|
||||
end;
|
||||
|
||||
{ TQtFrame }
|
||||
|
||||
function TQtFrame.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||
|
@ -303,6 +303,7 @@ class procedure TQtWSCustomTrayIcon.InternalUpdate(const ATrayIcon: TCustomTrayI
|
||||
var
|
||||
SystemTrayIcon: TQtSystemTrayIcon;
|
||||
AIcon: QIconH;
|
||||
AHint: WideString;
|
||||
begin
|
||||
if (ATrayIcon.Handle = 0) then Exit;
|
||||
|
||||
@ -335,6 +336,9 @@ begin
|
||||
if TQtMenu(ATrayIcon.PopUpMenu.Handle).Widget <> nil then
|
||||
SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(ATrayIcon.PopUpMenu.Handle).Widget));
|
||||
|
||||
AHint := UTF8ToUTF16(ATrayIcon.Hint);
|
||||
SystemTrayIcon.setToolTip(AHint);
|
||||
|
||||
SystemTrayIcon.UpdateSystemTrayWidget;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user