diff --git a/backend-shared/exportfuncs.cpp b/backend-shared/exportfuncs.cpp index 7ed13cf83..4a3f4d4ac 100644 --- a/backend-shared/exportfuncs.cpp +++ b/backend-shared/exportfuncs.cpp @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include -#include +#include "exportfuncs.h" #include "core/membuffer.h" #include "core/dive.h" #include "core/divesite.h" @@ -17,7 +15,11 @@ #include "core/sample.h" #include "core/selection.h" #include "core/taxonomy.h" -#include "exportfuncs.h" +#include "core/sample.h" +#include "profile-widget/profilewidget2.h" +#include +#include +#include // Default implementation of the export callback: do nothing / never cancel void ExportCallback::setProgress(int) @@ -30,6 +32,28 @@ bool ExportCallback::canceled() const } #if !defined(SUBSURFACE_MOBILE) + +#include "desktop-widgets/mainwindow.h" // Currently needed for profile printing. TODO: remove. + +static void exportProfile(const struct dive *dive, const QString filename) +{ + ProfileWidget2 *profile = MainWindow::instance()->graphics; + profile->setToolTipVisibile(false); + profile->setPrintMode(true); + double scale = profile->getFontPrintScale(); + profile->setFontPrintScale(4 * scale); + profile->plotDive(dive, 0, false, true); + QImage image = QImage(profile->size() * 4, QImage::Format_RGB32); + QPainter paint; + paint.begin(&image); + profile->render(&paint); + image.save(filename); + profile->setToolTipVisibile(true); + profile->setFontPrintScale(scale); + profile->setPrintMode(false); + profile->plotDive(dive, 0, true); // TODO: Shouldn't this plot the current dive? +} + void exportProfile(QString filename, bool selected_only, ExportCallback &cb) { struct dive *dive; diff --git a/backend-shared/exportfuncs.h b/backend-shared/exportfuncs.h index ed483f90d..716a740e4 100644 --- a/backend-shared/exportfuncs.h +++ b/backend-shared/exportfuncs.h @@ -22,13 +22,4 @@ QFuture exportUsingStyleSheet(QString filename, bool doExport, int units, Q // prepareDivesForUploadDiveLog // prepareDivesForUploadDiveShare -// WARNING -// exportProfile uses the UI and are therefore different between -// Desktop (UI) and Mobile (QML) -// In order to solve this difference, the actual implementations -// are done in -// desktop-widgets/divelogexportdialog.cpp and -// mobile-widgets/qmlmanager.cpp -void exportProfile(const struct dive *dive, const QString filename); - #endif // EXPORT_FUNCS_H diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index 164ae0434..391960c12 100644 --- a/desktop-widgets/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp @@ -253,22 +253,3 @@ void DiveLogExportDialog::on_buttonBox_accepted() } } } - -void exportProfile(const struct dive *dive, const QString filename) -{ - ProfileWidget2 *profile = MainWindow::instance()->graphics; - profile->setToolTipVisibile(false); - profile->setPrintMode(true); - double scale = profile->getFontPrintScale(); - profile->setFontPrintScale(4 * scale); - profile->plotDive(dive, 0, false, true); - QImage image = QImage(profile->size() * 4, QImage::Format_RGB32); - QPainter paint; - paint.begin(&image); - profile->render(&paint); - image.save(filename); - profile->setToolTipVisibile(true); - profile->setFontPrintScale(scale); - profile->setPrintMode(false); - profile->plotDive(dive, 0); // TODO: Shouldn't this plot the current dive? -}