a3400e0471
Implement simple drawing in QtInstanceDrawingArea by handling the QEvent::Resize and QEvent::Paint events for the QLabel widget. While the QLabel does not emit any signals when these events occur, it's possible to handle them by setting an event filter using QObject::installEventFilter [1]. Install QtInstanceDrawingArea as an event filter for its label, and implement handling of the Resize and Paint event in QtInstanceDrawingArea::eventFilter: On the QEvent::Resize event, adjust the output size of the output device and call the `weld::Widget::m_aSizeAllocateHdl` handler. (See also GtkInstanceDrawingArea::signal_size_allocate and SalInstanceDrawingArea::ResizeHdl to see what the gtk3 and VCL implementations do.) On the QEvent::Paint event, trigger drawing on the output device via the weld::DrawingArea::m_aDrawHdl handler, and get a QPixmap for what's painted on the output device and set that QPixmap for the label if it has changed. With this in place, the GtkDrawingArea in the "Help" -> "Show Tip of the Day" dialog displays the image as expected, and gets updated when moving to the next tip, once support for that dialog has been declared, which will be done in an upcoming commit. For more complex cases, a more performant solution might become necessary and can be investigated once support for these is implemented. For the "Tip of the Day" dialog, the `aRect` passed in QtInstanceDrawingArea::handlePaintEvent is irrelevant as CuiGraphicPreviewWindow::Paint doesn't make use of the passed rectangle. (This might also have to be reconsidered/adjusted in case a dialog actually making use of the rectangle doesn't work as expected.) [1] https://doc.qt.io/qt-6/qobject.html#installEventFilter Change-Id: I651e00043fac04a4c77aae921e6397e8d97cc69c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176173 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> |
||
---|---|---|
.. | ||
QtUtils.hxx |