mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-11 22:40:40 +01:00
Qt: fixed resize events of TQtTabWidget and accurate information about clientRect changes. issue #21805
git-svn-id: trunk@36925 -
This commit is contained in:
parent
c5ab7313c5
commit
362e4674d2
@ -260,6 +260,8 @@ const
|
|||||||
|
|
||||||
// needed by itemviews (TQtListWidget, TQtTreeWidget)
|
// needed by itemviews (TQtListWidget, TQtTreeWidget)
|
||||||
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
||||||
|
// used by TQtTabWidget
|
||||||
|
LCLQt_DelayLayoutRequest = QEventType(Ord(QEventUser) + $1009);
|
||||||
|
|
||||||
var
|
var
|
||||||
QtWidgetSet: TQtWidgetSet;
|
QtWidgetSet: TQtWidgetSet;
|
||||||
|
|||||||
@ -137,7 +137,55 @@ begin
|
|||||||
QtTabWidget.AttachEvents;
|
QtTabWidget.AttachEvents;
|
||||||
Result := TLCLIntfHandle(QtTabWidget);
|
Result := TLCLIntfHandle(QtTabWidget);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TQtWSCustomTabControl.GetDefaultClientRect(
|
||||||
|
const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
|
||||||
|
var aClientRect: TRect): boolean;
|
||||||
|
var
|
||||||
|
dx, dy: integer;
|
||||||
|
ATabWidget: TQtTabWidget;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if AWinControl.HandleAllocated then
|
||||||
|
begin
|
||||||
|
if TQtWidget(AWinControl.Handle).ChildOfComplexWidget <> ccwTTabControl then
|
||||||
|
begin
|
||||||
|
ATabWidget := TQtTabWidget(AWinControl.Handle);
|
||||||
|
if ATabWidget.testAttribute(QtWA_PendingResizeEvent) then
|
||||||
|
begin
|
||||||
|
// we must recalculate aclientrect since we have pending resize event
|
||||||
|
// and clientrect won't be accurate.issue #21805
|
||||||
|
Result := True;
|
||||||
|
dx := GetPixelMetric(QStylePM_DefaultFrameWidth, nil, nil);
|
||||||
|
|
||||||
|
if ATabWidget.getTabPosition in [QTabWidgetNorth, QTabWidgetSouth] then
|
||||||
|
begin
|
||||||
|
if ATabWidget.TabBar.getVisible then
|
||||||
|
dy := ATabWidget.TabBar.getHeight
|
||||||
|
else
|
||||||
|
dy := 0;
|
||||||
|
aClientRect := Rect(0, 0,
|
||||||
|
Max(0, aWidth - (dx * 2)),
|
||||||
|
Max(0, aHeight - dx - dy));
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
if ATabWidget.TabBar.getVisible then
|
||||||
|
dy := ATabWidget.TabBar.getWidth
|
||||||
|
else
|
||||||
|
dy := 0;
|
||||||
|
aClientRect := Rect(0,0,
|
||||||
|
Max(0, aWidth - dx - dy),
|
||||||
|
Max(0, aHeight - (dx * 2)));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
dx := GetPixelMetric(QStylePM_TabBarBaseHeight, nil, nil);
|
||||||
|
aClientRect := Rect(0,0, Max(0, aWidth - (dx * 2)), Max(0, aHeight - (dx * 2)));
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TQtWSCustomTabControl.AddPage(const ATabControl: TCustomTabControl;
|
class procedure TQtWSCustomTabControl.AddPage(const ATabControl: TCustomTabControl;
|
||||||
|
|||||||
@ -8723,12 +8723,13 @@ end;
|
|||||||
|
|
||||||
function TQtTabWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
function TQtTabWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
||||||
cdecl;
|
cdecl;
|
||||||
{$IFDEF QT_ENABLE_LCL_PAINT_TABS}
|
|
||||||
var
|
var
|
||||||
|
{$IFDEF QT_ENABLE_LCL_PAINT_TABS}
|
||||||
R: TRect;
|
R: TRect;
|
||||||
TabGeom: TRect;
|
TabGeom: TRect;
|
||||||
Pt: TPoint;
|
Pt: TPoint;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
ALCLEvent: QLCLMessageEventH;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -8743,13 +8744,11 @@ begin
|
|||||||
' LCLObject=', dbgsName(LCLObject),
|
' LCLObject=', dbgsName(LCLObject),
|
||||||
' Event=', EventTypeToStr(Event),' inUpdate=',inUpdate);
|
' Event=', EventTypeToStr(Event),' inUpdate=',inUpdate);
|
||||||
{$endif}
|
{$endif}
|
||||||
case QEvent_type(Event) of
|
{
|
||||||
QEventResize:
|
we don't use QEventResize and QEventLayoutRequest of StackedWidget anymore.
|
||||||
if LCLObject.ClientRectNeedsInterfaceUpdate then
|
see commited revision for issue #21805.
|
||||||
LCLObject.InvalidateClientRectCache(False);
|
We are leaving this part for debugging purposes.
|
||||||
// layoutRequest from stacked widget is very important !
|
}
|
||||||
QEventLayoutRequest: LCLObject.DoAdjustClientRectChange(False);
|
|
||||||
end;
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -8771,6 +8770,25 @@ begin
|
|||||||
QEvent_ignore(Event);
|
QEvent_ignore(Event);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
LCLQt_DelayLayoutRequest:
|
||||||
|
begin
|
||||||
|
if LCLObject.ClientRectNeedsInterfaceUpdate then
|
||||||
|
begin
|
||||||
|
{$IFDEF VerboseQtEvents}
|
||||||
|
DebugLn('<*><*> TQtTabWidget calling DoAdjustClientRectChange() from LCLQt_DelayLayoutRequest ...');
|
||||||
|
{$ENDIF}
|
||||||
|
LCLObject.DoAdjustClientRectChange(True);
|
||||||
|
end;
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
QEventLayoutRequest:
|
||||||
|
begin
|
||||||
|
//behaviour is changed because of issue #21805.
|
||||||
|
//we send delayed event so LCL can read clientRect at the right time.
|
||||||
|
ALCLEvent := QLCLMessageEvent_create(LCLQt_DelayLayoutRequest, 0,
|
||||||
|
0, 0, 0);
|
||||||
|
QCoreApplication_postEvent(Sender, ALCLEvent);
|
||||||
|
end;
|
||||||
QEventKeyPress,
|
QEventKeyPress,
|
||||||
QEventKeyRelease: QEvent_ignore(Event);
|
QEventKeyRelease: QEvent_ignore(Event);
|
||||||
QEventWheel:
|
QEventWheel:
|
||||||
@ -8829,7 +8847,7 @@ end;
|
|||||||
|
|
||||||
function TQtTabWidget.getClientBounds: TRect;
|
function TQtTabWidget.getClientBounds: TRect;
|
||||||
begin
|
begin
|
||||||
QWidget_contentsRect(StackWidget, @Result)
|
QWidget_contentsRect(StackWidget, @Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtTabWidget.getCurrentIndex: Integer;
|
function TQtTabWidget.getCurrentIndex: Integer;
|
||||||
@ -15285,10 +15303,21 @@ end;
|
|||||||
|
|
||||||
function TQtPage.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function TQtPage.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
begin
|
begin
|
||||||
if (QEvent_type(Event) = QEventResize) and
|
if (QEvent_type(Event) = QEventResize) then
|
||||||
LCLObject.Parent.ClientRectNeedsInterfaceUpdate then
|
begin
|
||||||
LCLObject.Parent.InvalidateClientRectCache(False);
|
//behaviour is changed because of issue #21805.
|
||||||
Result:=inherited EventFilter(Sender, Event);
|
if LCLObject.ClientRectNeedsInterfaceUpdate then
|
||||||
|
begin
|
||||||
|
{$IFDEF VerboseQtEvents}
|
||||||
|
DebugLn('<*><*> TQtPage resize event invalidating clientrect cache !!!');
|
||||||
|
{$ENDIF}
|
||||||
|
LCLObject.InvalidateClientRectCache(False);
|
||||||
|
|
||||||
|
if FChildOfComplexWidget = ccwTabWidget then
|
||||||
|
exit(False);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result := inherited EventFilter(Sender, Event);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtPage.getIcon: QIconH;
|
function TQtPage.getIcon: QIconH;
|
||||||
|
|||||||
@ -57,7 +57,9 @@ 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 function GetDefaultClientRect(const AWinControl: TWinControl;
|
||||||
|
const {%H-}aLeft, {%H-}aTop, aWidth, aHeight: integer; var aClientRect: TRect
|
||||||
|
): boolean; override;
|
||||||
class procedure AddPage(const ATabControl: TCustomTabControl;
|
class procedure AddPage(const ATabControl: TCustomTabControl;
|
||||||
const AChild: TCustomPage; const AIndex: integer); override;
|
const AChild: TCustomPage; const AIndex: integer); override;
|
||||||
class procedure MovePage(const ATabControl: TCustomTabControl;
|
class procedure MovePage(const ATabControl: TCustomTabControl;
|
||||||
@ -262,7 +264,7 @@ type
|
|||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses qtint;
|
uses qtint, math;
|
||||||
|
|
||||||
{$include qtpagecontrol.inc}
|
{$include qtpagecontrol.inc}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user