mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c9d8b4f605
commit
fe4a230245
7 changed files with 51 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
- Export option for profile picture
|
||||||
- Desktop: remove support for the "Share on Facebook" feature.
|
- Desktop: remove support for the "Share on Facebook" feature.
|
||||||
Rationale: It is fairly easy to share images on Facebook, thus it was decided
|
Rationale: It is fairly easy to share images on Facebook, thus it was decided
|
||||||
that this feature is redundant and should be removed from Subsurface.
|
that this feature is redundant and should be removed from Subsurface.
|
||||||
|
|
|
@ -2759,6 +2759,8 @@ A dive log or part of it can be saved in several formats:
|
||||||
* _CSV dive profile_, that includes a large amount of detail for each dive, including
|
* _CSV dive profile_, that includes a large amount of detail for each dive, including
|
||||||
the depth profile, temperature and pressure information of each dive.
|
the depth profile, temperature and pressure information of each dive.
|
||||||
|
|
||||||
|
* _dive profile_, saves the Subsurface dive profile as a .png file
|
||||||
|
|
||||||
* _HTML_ format, in which the dive(s) are stored in HTML files, readable
|
* _HTML_ format, in which the dive(s) are stored in HTML files, readable
|
||||||
with an Internet browser. Most modern web browsers are supported, but JavaScript
|
with an Internet browser. Most modern web browsers are supported, but JavaScript
|
||||||
must be enabled. The HTML export cannot be changed or edited.
|
must be enabled. The HTML export cannot be changed or edited.
|
||||||
|
|
|
@ -169,6 +169,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)");
|
filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)");
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
export_TeX(qPrintable(filename), ui->exportSelected->isChecked(), ui->exportTeX->isChecked());
|
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;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -229,6 +233,34 @@ void DiveLogExportDialog::export_depths(const char *filename, const bool selecte
|
||||||
free_buffer(&buf);
|
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)
|
void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_only, bool plain)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -286,14 +318,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
||||||
if (selected_only && !dive->selected)
|
if (selected_only && !dive->selected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ProfileWidget2 *profile = MainWindow::instance()->graphics;
|
saveProfile(dive, texdir.filePath(QString("profile%1.png").arg(dive->number)));
|
||||||
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)));
|
|
||||||
|
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
utc_mkdate(dive->when, &tm);
|
utc_mkdate(dive->when, &tm);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ private:
|
||||||
void exportHtmlInit(const QString &filename);
|
void exportHtmlInit(const QString &filename);
|
||||||
void export_depths(const char *filename, const bool selected_only);
|
void export_depths(const char *filename, const bool selected_only);
|
||||||
void export_TeX(const char *filename, const bool selected_only, bool plain);
|
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
|
#endif // DIVELOGEXPORTDIALOG_H
|
||||||
|
|
|
@ -181,6 +181,16 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QRadioButton" name="exportWorldMap">
|
<widget class="QRadioButton" name="exportWorldMap">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -548,7 +548,7 @@ void ProfileWidget2::resetZoom()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently just one dive, but the plan is to enable All of the selected dives.
|
// Currently just one dive, but the plan is to enable All of the selected dives.
|
||||||
void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
|
void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPictures)
|
||||||
{
|
{
|
||||||
static bool firstCall = true;
|
static bool firstCall = true;
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
ProfileWidget2(QWidget *parent = 0);
|
ProfileWidget2(QWidget *parent = 0);
|
||||||
void resetZoom();
|
void resetZoom();
|
||||||
void scale(qreal sx, qreal sy);
|
void scale(qreal sx, qreal sy);
|
||||||
void plotDive(struct dive *d = 0, bool force = false, bool clearPictures = false);
|
void plotDive(const struct dive *d = 0, bool force = false, bool clearPictures = false);
|
||||||
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *vAxis, int vData, int hData, int zValue);
|
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *vAxis, int vData, int hData, int zValue);
|
||||||
void setPrintMode(bool mode, bool grayscale = false);
|
void setPrintMode(bool mode, bool grayscale = false);
|
||||||
bool getPrintMode();
|
bool getPrintMode();
|
||||||
|
|
Loading…
Add table
Reference in a new issue