vcl/qt5/QtInstanceDrawingArea.cxx |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit c80e95cdc8fa9bc40406295b03b239a4ca4df4ff
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon May 12 23:40:38 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue May 13 08:18:50 2025 +0200

    tdf#130857 qt weld: Take content margins into account
    
    In QtInstanceDrawingArea::handleResizeEvent, take
    the QLabel's content margins into account when
    setting the new output size for the VirtualDevice
    when the QLabel was resized:
    The size that the VirtualDevice has available
    is not the full label size, but the content margins
    need to be subtracted.
    
    Not doing so was seen causing a resize loop for the
    ColorPickerDialog (cui/source/dialogs/colorpicker.cxx,
    UI file: cui/uiconfig/ui/colorpickerdialog.ui) in
    a WIP branch declaring support for that dialog using
    native Qt widgets with SAL_VCL_QT_USE_WELDED_WIDGETS=1.
    
    One way to trigger the dialog:
    
    * "Tools" -> "Options"
    * go to "Appearance" tab
    * in the "Customizations" section, click on the
      color picker next to the "Color" label
    * select "Custom Color"
    
    There are more aspects to address before the dialog
    can actually be declared as supported.
    
    Change-Id: Iaf183926abd8269297b8ae2d865568cc57fbf2cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185237
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceDrawingArea.cxx 
b/vcl/qt5/QtInstanceDrawingArea.cxx
index 345163849fd0..325f4e389668 100644
--- a/vcl/qt5/QtInstanceDrawingArea.cxx
+++ b/vcl/qt5/QtInstanceDrawingArea.cxx
@@ -143,9 +143,12 @@ void QtInstanceDrawingArea::handlePaintEvent()
 
 void QtInstanceDrawingArea::handleResizeEvent()
 {
-    const Size aSize = toSize(m_pLabel->size());
-    m_xDevice->SetOutputSizePixel(aSize);
-    m_aSizeAllocateHdl.Call(aSize);
+    const QMargins aMargins = m_pLabel->contentsMargins();
+    const QSize aMarginSize(aMargins.left() + aMargins.right(), aMargins.top() 
+ aMargins.bottom());
+    const QSize aLabelSize = m_pLabel->size();
+    const Size aOutputSize = toSize(aLabelSize - aMarginSize);
+    m_xDevice->SetOutputSizePixel(aOutputSize);
+    m_aSizeAllocateHdl.Call(toSize(aLabelSize));
 }
 
 bool QtInstanceDrawingArea::handleToolTipEvent(QHelpEvent& rEvent)

Reply via email to