mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
printing: pass current filename to dialog
Instead of accessing a global variable, pass the filename from the MainWindow to the dialog. This is supposed to cut down on the global variable mess. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3a1122048b
commit
37f2207f94
3 changed files with 8 additions and 6 deletions
|
@ -551,7 +551,8 @@ void MainWindow::on_actionPrint_triggered()
|
||||||
// When in planner, only print the planned dive.
|
// When in planner, only print the planned dive.
|
||||||
dive *singleDive = appState == ApplicationState::PlanDive ? plannerWidgets->getDive()
|
dive *singleDive = appState == ApplicationState::PlanDive ? plannerWidgets->getDive()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
PrintDialog dlg(singleDive, this);
|
QString filename = existing_filename ?: prefs.default_filename;
|
||||||
|
PrintDialog dlg(singleDive, filename, this);
|
||||||
|
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,9 +19,10 @@
|
||||||
|
|
||||||
template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_colors, custom_colors;
|
template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_colors, custom_colors;
|
||||||
|
|
||||||
PrintDialog::PrintDialog(dive *singleDive, QWidget *parent) :
|
PrintDialog::PrintDialog(dive *singleDive, const QString &filename, QWidget *parent) :
|
||||||
QDialog(parent, QFlag(0)),
|
QDialog(parent, QFlag(0)),
|
||||||
singleDive(singleDive),
|
singleDive(singleDive),
|
||||||
|
filename(filename),
|
||||||
printer(NULL),
|
printer(NULL),
|
||||||
qprinter(NULL)
|
qprinter(NULL)
|
||||||
{
|
{
|
||||||
|
@ -197,11 +198,10 @@ void PrintDialog::exportHtmlClicked(void)
|
||||||
{
|
{
|
||||||
createPrinterObj();
|
createPrinterObj();
|
||||||
QString saveFileName = printOptions.p_template;
|
QString saveFileName = printOptions.p_template;
|
||||||
QString filename = existing_filename ?: prefs.default_filename;
|
|
||||||
QFileInfo fi(filename);
|
QFileInfo fi(filename);
|
||||||
filename = fi.absolutePath().append(QDir::separator()).append(saveFileName);
|
QString printfilename = fi.absolutePath().append(QDir::separator()).append(saveFileName);
|
||||||
QString htmlExportFilename = QFileDialog::getSaveFileName(this, tr("Filename to export html to"),
|
QString htmlExportFilename = QFileDialog::getSaveFileName(this, tr("Filename to export html to"),
|
||||||
filename, tr("Html file") + " (*.html)");
|
printfilename, tr("Html file") + " (*.html)");
|
||||||
if (!htmlExportFilename.isEmpty()) {
|
if (!htmlExportFilename.isEmpty()) {
|
||||||
QFile file(htmlExportFilename);
|
QFile file(htmlExportFilename);
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
|
|
@ -20,11 +20,12 @@ class PrintDialog : public QDialog {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// If singleDive is non-null, print only that single dive
|
// If singleDive is non-null, print only that single dive
|
||||||
explicit PrintDialog(dive *singleDive, QWidget *parent = 0);
|
explicit PrintDialog(dive *singleDive, const QString &filename, QWidget *parent = 0);
|
||||||
~PrintDialog();
|
~PrintDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dive *singleDive;
|
dive *singleDive;
|
||||||
|
QString filename;
|
||||||
PrintOptions *optionsWidget;
|
PrintOptions *optionsWidget;
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
Printer *printer;
|
Printer *printer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue