diff options
author | 2019-02-02 14:41:53 +0100 | |
---|---|---|
committer | 2019-04-08 09:54:19 +0300 | |
commit | c6732e9b269f977c08eb0d8b8d14b3822c3b5449 (patch) | |
tree | 71658658cac69107e9e909f7033fd59dc6aa6b5b /desktop-widgets/divelogexportdialog.cpp | |
parent | 3998cb82453ad9d41bedcd290af3925526cb1767 (diff) | |
download | subsurface-c6732e9b269f977c08eb0d8b8d14b3822c3b5449.tar.gz |
Export profile image
With Facebook support gone, we should offer a way to export
the profile image. This has been part of the TeX support
but this makes it explicit.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/divelogexportdialog.cpp')
-rw-r--r-- | desktop-widgets/divelogexportdialog.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index 5c337f0a5..12b73be2d 100644 --- a/desktop-widgets/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp @@ -167,6 +167,10 @@ void DiveLogExportDialog::on_buttonBox_accepted() filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)"); if (!filename.isNull() && !filename.isEmpty()) export_TeX(qPrintable(filename), ui->exportSelected->isChecked()); + } else if (ui->exportProfile->isChecked()) { + filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir); + if (!filename.isNull() && !filename.isEmpty()) + exportProfile(qPrintable(filename), ui->exportSelected->isChecked()); } break; case 1: @@ -227,6 +231,34 @@ void DiveLogExportDialog::export_depths(const char *filename, const bool selecte free_buffer(&buf); } +void DiveLogExportDialog::exportProfile(const QString filename, const bool selected_only) +{ + struct dive *dive; + int i; + int count = 0; + QFileInfo fi(filename); + + for_each_dive (i, dive) { + if (selected_only && !dive->selected) + continue; + if (count) + saveProfile(dive, fi.completeBaseName().append(QString("-%1.").arg(count)).append(fi.suffix())); + else + saveProfile(dive, filename); + ++count; + } +} + +void DiveLogExportDialog::saveProfile(const struct dive *dive, const QString filename) +{ + ProfileWidget2 *profile = MainWindow::instance()->graphics; + profile->plotDive(dive, true); + profile->setToolTipVisibile(false); + QPixmap pix = profile->grab(); + profile->setToolTipVisibile(true); + pix.save(filename); +} + void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_only) { FILE *f; @@ -275,14 +307,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o if (selected_only && !dive->selected) continue; - ProfileWidget2 *profile = MainWindow::instance()->graphics; - profile->plotDive(dive, true); - profile->setToolTipVisibile(false); - QPixmap pix = QPixmap::grabWidget(profile); - profile->setToolTipVisibile(true); - pix.save(texdir.filePath(QString("profile%1.png").arg(dive->number))); - - + saveProfile(dive, texdir.filePath(QString("profile%1.png").arg(dive->number))); struct tm tm; utc_mkdate(dive->when, &tm); |