From 811c8a441e8f996fa152dc16aca7e595966aab14 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 7 Apr 2021 08:04:56 +0200 Subject: [PATCH] printing: use independent profile instance for printing plan In analogy to normal printing, don't misuse the mainwindow's profile widget to do the printing. Signed-off-by: Berthold Stoeger --- desktop-widgets/diveplanner.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index 6b25cd844..f744aebfe 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -609,13 +609,15 @@ void PlannerWidgets::printDecoPlan() painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); - ProfileWidget2 *profile = MainWindow::instance()->graphics; - QSize origSize = profile->size(); + // TODO: Annoyingly, this still needs a parent window? Otherwise, + // the profile is shown as its own window, when calling show() below. + auto profile = std::make_unique(DivePlannerPointsModel::instance(), MainWindow::instance()); + profile->show(); // Ominous: if the scene isn't shown, parts of the plot are missing. Needs investigation. profile->resize(renderSize.toSize()); + profile->setPlanState(&displayed_dive, 0); + profile->plotDive(&displayed_dive, 0, true, true); profile->setPrintMode(true); profile->render(&painter); - profile->resize(origSize); - profile->setPrintMode(false); QByteArray byteArray; QBuffer buffer(&byteArray);