mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
export: move exportProfile() function to exportfuncs.cpp
The exportProfile function uses the UI and therefore was supposed to be declared in backend-shared/* but defined separately for desktop and mobile. Currently, only the desktop version exists. The goal however should be that there is no need of the UI for this function. In a first step, move the function to the common backend-shared/* code and conditionally compile for desktop. In upcoming commits, the function will be made independent of the UI. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
811c8a441e
commit
8f0e2245c2
3 changed files with 28 additions and 32 deletions
|
@ -1,7 +1,5 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QtConcurrent>
|
||||
#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 <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QtConcurrent>
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -22,13 +22,4 @@ QFuture<int> 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
|
||||
|
|
|
@ -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?
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue