aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelogexportdialog.cpp41
-rw-r--r--desktop-widgets/divelogexportdialog.h3
-rw-r--r--desktop-widgets/divelogexportdialog.ui10
3 files changed, 46 insertions, 8 deletions
diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp
index 15dd7d99f..37fb8cee4 100644
--- a/desktop-widgets/divelogexportdialog.cpp
+++ b/desktop-widgets/divelogexportdialog.cpp
@@ -169,6 +169,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(), ui->exportTeX->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:
@@ -229,6 +233,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, bool plain)
{
FILE *f;
@@ -286,14 +318,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);
diff --git a/desktop-widgets/divelogexportdialog.h b/desktop-widgets/divelogexportdialog.h
index f06ed23dd..d7905dd94 100644
--- a/desktop-widgets/divelogexportdialog.h
+++ b/desktop-widgets/divelogexportdialog.h
@@ -34,6 +34,9 @@ private:
void exportHtmlInit(const QString &filename);
void export_depths(const char *filename, const bool selected_only);
void export_TeX(const char *filename, const bool selected_only, bool plain);
+ void exportProfile(const QString filename, const bool selected_only);
+ void saveProfile(const struct dive *dive, const QString filename);
+
};
#endif // DIVELOGEXPORTDIALOG_H
diff --git a/desktop-widgets/divelogexportdialog.ui b/desktop-widgets/divelogexportdialog.ui
index edde0a6a1..fe4827060 100644
--- a/desktop-widgets/divelogexportdialog.ui
+++ b/desktop-widgets/divelogexportdialog.ui
@@ -182,6 +182,16 @@
</widget>
</item>
<item>
+ <widget class="QRadioButton" name="exportProfile">
+ <property name="text">
+ <string>dive profile</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">exportGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
<widget class="QRadioButton" name="exportWorldMap">
<property name="text">
<string>Worldmap</string>