1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

PDF export dialog polishing

This commit is contained in:
Martin Tůma 2016-05-27 22:45:58 +02:00
parent 3592d9e68f
commit 498d33b77d
10 changed files with 275 additions and 150 deletions

View File

@ -42,7 +42,8 @@ HEADERS += src/config.h \
src/app.h \
src/trackinfo.h \
src/exportdialog.h \
src/fileselectwidget.h
src/fileselectwidget.h \
src/margins.h
SOURCES += src/main.cpp \
src/gui.cpp \
src/gpx.cpp \

View File

@ -59,74 +59,89 @@
<context>
<name>ExportDialog</name>
<message>
<location filename="../src/exportdialog.cpp" line="21"/>
<location filename="../src/exportdialog.cpp" line="122"/>
<source>Export to PDF</source>
<translation>Exportovat do PDF</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="25"/>
<location filename="../src/exportdialog.cpp" line="29"/>
<source>PDF files (*.pdf);;All files (*)</source>
<translation>Soubory PDF (*.pdf);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="38"/>
<location filename="../src/exportdialog.cpp" line="42"/>
<source>Portrait</source>
<translation>Na výšku</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="39"/>
<location filename="../src/exportdialog.cpp" line="43"/>
<source>Landscape</source>
<translation>Na šířku</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="48"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="50"/>
<location filename="../src/exportdialog.cpp" line="85"/>
<source>Page size:</source>
<translation>Velikost stránky:</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="51"/>
<location filename="../src/exportdialog.cpp" line="86"/>
<source>Orientation:</source>
<translation>Orientace:</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="52"/>
<source>Output file:</source>
<translation>Výstupní soubor:</translation>
<location filename="../src/exportdialog.cpp" line="82"/>
<source>Page Setup</source>
<translation>Nastavení stránky</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="55"/>
<source>in</source>
<translation>in</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="55"/>
<source>mm</source>
<translation>mm</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="87"/>
<source>Margins:</source>
<translation>Okraje:</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="93"/>
<source>File:</source>
<translation>Soubor:</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="99"/>
<source>Output file</source>
<translation>Výstupní soubor</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="106"/>
<source>Export</source>
<translation>Exportovat</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="59"/>
<source>Cancel</source>
<translation>Zrušit</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="77"/>
<location filename="../src/exportdialog.cpp" line="87"/>
<location filename="../src/exportdialog.cpp" line="92"/>
<location filename="../src/exportdialog.cpp" line="129"/>
<location filename="../src/exportdialog.cpp" line="139"/>
<location filename="../src/exportdialog.cpp" line="144"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="77"/>
<location filename="../src/exportdialog.cpp" line="129"/>
<source>No output file selected.</source>
<translation>Nebyl zvolen žádný výstupní soubor.</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="87"/>
<location filename="../src/exportdialog.cpp" line="139"/>
<source>%1 is a directory.</source>
<translation>%1 je adresář.</translation>
</message>
<message>
<location filename="../src/exportdialog.cpp" line="92"/>
<location filename="../src/exportdialog.cpp" line="144"/>
<source>%1 is not writable.</source>
<translation>%1 nelze zapsat.</translation>
</message>
@ -147,353 +162,353 @@
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="457"/>
<location filename="../src/gui.cpp" line="458"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="521"/>
<location filename="../src/gui.cpp" line="522"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="598"/>
<location filename="../src/gui.cpp" line="599"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="202"/>
<location filename="../src/gui.cpp" line="203"/>
<source>Open</source>
<translation>Otevřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="186"/>
<location filename="../src/gui.cpp" line="187"/>
<source>Quit</source>
<translation>Ukončit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="194"/>
<location filename="../src/gui.cpp" line="473"/>
<location filename="../src/gui.cpp" line="195"/>
<location filename="../src/gui.cpp" line="474"/>
<location filename="../src/gui.cpp" line="475"/>
<source>Keyboard controls</source>
<translation>Ovládací klávesy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="218"/>
<location filename="../src/gui.cpp" line="219"/>
<source>Close</source>
<translation>Zavřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="224"/>
<location filename="../src/gui.cpp" line="225"/>
<source>Reload</source>
<translation>Znovu načíst</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="380"/>
<location filename="../src/gui.cpp" line="381"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="321"/>
<location filename="../src/gui.cpp" line="374"/>
<location filename="../src/gui.cpp" line="322"/>
<location filename="../src/gui.cpp" line="375"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="192"/>
<location filename="../src/gui.cpp" line="496"/>
<location filename="../src/gui.cpp" line="193"/>
<location filename="../src/gui.cpp" line="497"/>
<location filename="../src/gui.cpp" line="498"/>
<source>Data sources</source>
<translation>Zdroje dat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="207"/>
<source>Print</source>
<translation>Tisknout</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="232"/>
<location filename="../src/gui.cpp" line="233"/>
<source>Load POI file</source>
<translation>Nahrát POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="235"/>
<location filename="../src/gui.cpp" line="236"/>
<source>Close POI files</source>
<translation>Zavřit POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="238"/>
<location filename="../src/gui.cpp" line="239"/>
<source>Show POIs</source>
<translation>Zobrazit POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="246"/>
<location filename="../src/gui.cpp" line="247"/>
<source>Show map</source>
<translation>Zobrazit mapu</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="252"/>
<location filename="../src/gui.cpp" line="253"/>
<source>Clear tile cache</source>
<translation>Vymazat mezipaměť dlaždic</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="261"/>
<location filename="../src/gui.cpp" line="265"/>
<location filename="../src/gui.cpp" line="483"/>
<location filename="../src/gui.cpp" line="262"/>
<location filename="../src/gui.cpp" line="266"/>
<location filename="../src/gui.cpp" line="484"/>
<source>Next map</source>
<translation>Následující mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="272"/>
<location filename="../src/gui.cpp" line="273"/>
<source>Show graphs</source>
<translation>Zobrazovat grafy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="278"/>
<location filename="../src/gui.cpp" line="279"/>
<source>Show toolbars</source>
<translation>Zobrazovat nástrojové lišty</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="284"/>
<location filename="../src/gui.cpp" line="285"/>
<source>Metric</source>
<translation>Metrické</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="289"/>
<location filename="../src/gui.cpp" line="290"/>
<source>Imperial</source>
<translation>Imperiální</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="295"/>
<location filename="../src/gui.cpp" line="296"/>
<source>Fullscreen mode</source>
<translation>Celoobrazovkový režim</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="303"/>
<location filename="../src/gui.cpp" line="304"/>
<source>Next</source>
<translation>Následující</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="306"/>
<location filename="../src/gui.cpp" line="307"/>
<source>Previous</source>
<translation>Předchozí</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="310"/>
<location filename="../src/gui.cpp" line="311"/>
<source>Last</source>
<translation>Poslední</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="313"/>
<location filename="../src/gui.cpp" line="314"/>
<source>First</source>
<translation>První</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="335"/>
<location filename="../src/gui.cpp" line="336"/>
<source>Map</source>
<translation>Mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="342"/>
<location filename="../src/gui.cpp" line="343"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="343"/>
<location filename="../src/gui.cpp" line="344"/>
<source>POI files</source>
<translation>POI soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="351"/>
<location filename="../src/gui.cpp" line="352"/>
<source>Settings</source>
<translation>Nastavení</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="352"/>
<location filename="../src/gui.cpp" line="353"/>
<source>Units</source>
<translation>Jednotky</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="361"/>
<location filename="../src/gui.cpp" line="362"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="485"/>
<location filename="../src/gui.cpp" line="486"/>
<source>Previous map</source>
<translation>Předchozí mapa</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="212"/>
<source>Export to PDF</source>
<translation>Exportovat do PDF</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="678"/>
<location filename="../src/gui.cpp" line="681"/>
<location filename="../src/gui.cpp" line="684"/>
<location filename="../src/gui.cpp" line="687"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="854"/>
<location filename="../src/gui.cpp" line="860"/>
<source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="419"/>
<location filename="../src/gui.cpp" line="420"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="420"/>
<location filename="../src/gui.cpp" line="421"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="421"/>
<location filename="../src/gui.cpp" line="422"/>
<source>Heart rate</source>
<translation>Tep</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="476"/>
<location filename="../src/gui.cpp" line="477"/>
<source>Next file</source>
<translation>Následující soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="453"/>
<location filename="../src/gui.cpp" line="454"/>
<source>Version </source>
<translation>Verze </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="477"/>
<location filename="../src/gui.cpp" line="208"/>
<source>Print...</source>
<translation>Tisknout...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="213"/>
<source>Export to PDF...</source>
<translation>Exportovat do PDF...</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="478"/>
<source>Previous file</source>
<translation>Předchozí soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="479"/>
<location filename="../src/gui.cpp" line="480"/>
<source>First file</source>
<translation>První soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="480"/>
<location filename="../src/gui.cpp" line="481"/>
<source>Last file</source>
<translation>Poslední soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="481"/>
<location filename="../src/gui.cpp" line="482"/>
<source>Append modifier</source>
<translation>Modifikátor nahradit/přidat</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="500"/>
<location filename="../src/gui.cpp" line="501"/>
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="503"/>
<location filename="../src/gui.cpp" line="504"/>
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="511"/>
<location filename="../src/gui.cpp" line="512"/>
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="522"/>
<location filename="../src/gui.cpp" line="523"/>
<source>GPX files (*.gpx);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="589"/>
<location filename="../src/gui.cpp" line="615"/>
<location filename="../src/gui.cpp" line="590"/>
<location filename="../src/gui.cpp" line="616"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="599"/>
<location filename="../src/gui.cpp" line="600"/>
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="684"/>
<source>Track count</source>
<location filename="../src/gui.cpp" line="690"/>
<source>Tracks</source>
<translation>Počet tras</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="690"/>
<location filename="../src/gui.cpp" line="869"/>
<location filename="../src/gui.cpp" line="696"/>
<location filename="../src/gui.cpp" line="875"/>
<source>mi</source>
<translation>mi</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="866"/>
<location filename="../src/gui.cpp" line="872"/>
<source>ft</source>
<translation>ft</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="197"/>
<location filename="../src/gui.cpp" line="451"/>
<location filename="../src/gui.cpp" line="198"/>
<location filename="../src/gui.cpp" line="452"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="384"/>
<location filename="../src/gui.cpp" line="385"/>
<source>Navigation</source>
<translation>Navigace</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="499"/>
<location filename="../src/gui.cpp" line="500"/>
<source>Map sources</source>
<translation>Mapové zdroje</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="510"/>
<location filename="../src/gui.cpp" line="511"/>
<source>POIs</source>
<translation>POI body</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="689"/>
<location filename="../src/gui.cpp" line="692"/>
<location filename="../src/gui.cpp" line="695"/>
<location filename="../src/gui.cpp" line="698"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="697"/>
<location filename="../src/gui.cpp" line="703"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="873"/>
<location filename="../src/gui.cpp" line="879"/>
<source>m</source>
<translation>m</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="861"/>
<location filename="../src/gui.cpp" line="867"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="693"/>
<location filename="../src/gui.cpp" line="876"/>
<location filename="../src/gui.cpp" line="699"/>
<location filename="../src/gui.cpp" line="882"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="591"/>
<location filename="../src/gui.cpp" line="616"/>
<location filename="../src/gui.cpp" line="592"/>
<location filename="../src/gui.cpp" line="617"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="586"/>
<location filename="../src/gui.cpp" line="587"/>
<source>Error loading GPX file:
%1</source>
<translation>Soubor GPX nelze otevřít:
%1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="612"/>
<location filename="../src/gui.cpp" line="613"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:

View File

@ -1,15 +1,19 @@
#include <QPrinter>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QGridLayout>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QComboBox>
#include <QRadioButton>
#include <QPushButton>
#include <QFileInfo>
#include <QDir>
#include <QMessageBox>
#include <QTabWidget>
#include <QDoubleSpinBox>
#include <QLocale>
#include "fileselectwidget.h"
#include "units.h"
#include "exportdialog.h"
@ -18,8 +22,8 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
{
int index;
setWindowTitle(tr("Export to PDF"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
_units = (QLocale::system().measurementSystem()
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
_fileSelect = new FileSelectWidget();
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
@ -45,30 +49,78 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
else
_landscape->setChecked(true);
QGroupBox *contentBox = new QGroupBox(tr("Settings"));
QFormLayout *contentLayout = new QFormLayout;
contentLayout->addRow(tr("Page size:"), _paperSize);
contentLayout->addRow(tr("Orientation:"), orientationLayout);
contentLayout->addRow(tr("Output file:"), _fileSelect);
contentBox->setLayout(contentLayout);
qreal top, bottom, left, right;
QPushButton *exportButton = new QPushButton(tr("Export"));
exportButton->setAutoDefault(true);
exportButton->setDefault(true);
connect(exportButton, SIGNAL(clicked()), this, SLOT(accept()));
QPushButton *cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
_printer->getPageMargins(&left, &top, &right, &bottom, _units);
QString us = _units == QPrinter::Inch ? tr("in") : tr("mm");
_topMargin = new QDoubleSpinBox();
_bottomMargin = new QDoubleSpinBox();
_leftMargin = new QDoubleSpinBox();
_rightMargin = new QDoubleSpinBox();
_topMargin->setValue(top);
_topMargin->setSuffix(UNIT_SPACE + us);
_bottomMargin->setValue(bottom);
_bottomMargin->setSuffix(UNIT_SPACE + us);
_leftMargin->setValue(left);
_leftMargin->setSuffix(UNIT_SPACE + us);
_rightMargin->setValue(right);
_rightMargin->setSuffix(UNIT_SPACE + us);
if (_units == QPrinter::Inch) {
_topMargin->setSingleStep(0.1);
_bottomMargin->setSingleStep(0.1);
_leftMargin->setSingleStep(0.1);
_rightMargin->setSingleStep(0.1);
}
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch();
buttonsLayout->addWidget(exportButton);
buttonsLayout->addWidget(cancelButton);
QGridLayout *marginsLayout = new QGridLayout();
marginsLayout->addWidget(_topMargin, 0, 0, 1, 2, Qt::AlignCenter);
marginsLayout->addWidget(_leftMargin, 1, 0, 1, 1, Qt::AlignCenter);
marginsLayout->addWidget(_rightMargin, 1, 1, 1, 1, Qt::AlignCenter);
marginsLayout->addWidget(_bottomMargin, 2, 0, 1, 2, Qt::AlignCenter);
#ifndef Q_OS_MAC
QGroupBox *pageSetupBox = new QGroupBox(tr("Page Setup"));
#endif // Q_OS_MAC
QFormLayout *pageSetupLayout = new QFormLayout;
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
#ifdef Q_OS_MAC
QFrame *line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
pageSetupLayout->addRow(line);
pageSetupLayout->addRow(tr("File:"), _fileSelect);
#else // Q_OS_MAC
pageSetupBox->setLayout(pageSetupLayout);
#endif // Q_OS_MAC
#ifndef Q_OS_MAC
QGroupBox *outputFileBox = new QGroupBox(tr("Output file"));
QHBoxLayout *outputFileLayout = new QHBoxLayout();
outputFileLayout->addWidget(_fileSelect);
outputFileBox->setLayout(outputFileLayout);
#endif // Q_OS_MAC
QDialogButtonBox *buttonBox = new QDialogButtonBox();
buttonBox->addButton(tr("Export"), QDialogButtonBox::AcceptRole);
buttonBox->addButton(QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(contentBox);
layout->addLayout(buttonsLayout);
#ifdef Q_OS_MAC
layout->addLayout(pageSetupLayout);
#else // Q_OS_MAC
layout->addWidget(pageSetupBox);
layout->addWidget(outputFileBox);
#endif // Q_OS_MAC
layout->addWidget(buttonBox);
setLayout(layout);
setWindowTitle(tr("Export to PDF"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
bool ExportDialog::checkFile()
@ -116,6 +168,8 @@ void ExportDialog::accept()
_printer->setOutputFileName(_fileSelect->file());
_printer->setPaperSize(paperSize);
_printer->setOrientation(orientation);
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
_rightMargin->value(), _bottomMargin->value(), _units);
QDialog::accept();
}

View File

@ -2,11 +2,12 @@
#define EXPORTDIALOG_H
#include <QDialog>
#include <QPrinter>
class QPrinter;
class QComboBox;
class QRadioButton;
class FileSelectWidget;
class QDoubleSpinBox;
class ExportDialog : public QDialog
{
@ -23,10 +24,16 @@ private:
QPrinter *_printer;
QPrinter::Unit _units;
FileSelectWidget *_fileSelect;
QComboBox *_paperSize;
QRadioButton *_portrait;
QRadioButton *_landscape;
QDoubleSpinBox *_topMargin;
QDoubleSpinBox *_bottomMargin;
QDoubleSpinBox *_leftMargin;
QDoubleSpinBox *_rightMargin;
};
#endif // EXPORTDIALOG_H

View File

@ -90,10 +90,11 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
readSettings();
_exportPaperSize = (QLocale::system().measurementSystem()
_exportPaperSize = (QLocale::system().measurementSystem()
== QLocale::ImperialSystem) ? QPrinter::Letter : QPrinter::A4;
_exportOrientation = QPrinter::Portrait;
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
}
GUI::~GUI()
@ -204,12 +205,12 @@ void GUI::createActions()
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
addAction(_openFileAction);
_printFileAction = new QAction(QIcon(QPixmap(PRINT_FILE_ICON)),
tr("Print"), this);
tr("Print..."), this);
_printFileAction->setActionGroup(_fileActionGroup);
connect(_printFileAction, SIGNAL(triggered()), this, SLOT(printFile()));
addAction(_printFileAction);
_exportFileAction = new QAction(QIcon(QPixmap(EXPORT_FILE_ICON)),
tr("Export to PDF"), this);
tr("Export to PDF..."), this);
_exportFileAction->setShortcut(EXPORT_SHORTCUT);
_exportFileAction->setActionGroup(_fileActionGroup);
connect(_exportFileAction, SIGNAL(triggered()), this, SLOT(exportFile()));
@ -651,16 +652,21 @@ void GUI::printFile()
void GUI::exportFile()
{
QPrinter printer(QPrinter::HighResolution);
printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION));
printer.setOrientation(_exportOrientation);
printer.setOutputFileName(_exportFileName);
printer.setPaperSize(_exportPaperSize);
printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION));
printer.setPageMargins(_exportMargins.left(), _exportMargins.top(),
_exportMargins.right(), _exportMargins.bottom(), QPrinter::Millimeter);
ExportDialog dialog(&printer, this);
if (dialog.exec() == QDialog::Accepted) {
_exportFileName = printer.outputFileName();
_exportPaperSize = printer.paperSize();
_exportOrientation = printer.orientation();
printer.getPageMargins(&(_exportMargins.rleft()),
&(_exportMargins.rtop()), &(_exportMargins.rright()),
&(_exportMargins.rbottom()), QPrinter::Millimeter);
plot(&printer);
}
}
@ -681,7 +687,7 @@ void GUI::plot(QPrinter *printer)
info.insert(tr("Date"), QString("%1 - %2")
.arg(_dateRange.first.toString(format),
_dateRange.second.toString(format)));
info.insert(tr("Track count"), QString::number(_trackCount));
info.insert(tr("Tracks"), QString::number(_trackCount));
}
}
if (_distance > 0) {

View File

@ -7,6 +7,7 @@
#include <QDate>
#include <QPrinter>
#include "poi.h"
#include "margins.h"
class QMenu;
class QToolBar;
@ -179,6 +180,7 @@ private:
QString _exportFileName;
QPrinter::PaperSize _exportPaperSize;
QPrinter::Orientation _exportOrientation;
MarginsF _exportMargins;
};
#endif // GUI_H

9
src/margins.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "margins.h"
QDebug operator<<(QDebug dbg, const MarginsF &margins)
{
dbg.nospace() << "MarginsF(" << margins.left() << ", " << margins.top()
<< ", " << margins.right() << margins.bottom() << ")";
return dbg.maybeSpace();
}

30
src/margins.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef MARGINS_H
#define MARGINS_H
#include <QtGlobal>
#include <QDebug>
class MarginsF
{
public:
MarginsF() {_left = 0; _top = 0; _right = 0; _bottom = 0;}
MarginsF(qreal left, qreal top, qreal right, qreal bottom)
{_left = left, _top = top; _right = right; _bottom = bottom;}
qreal left() const {return _left;}
qreal top() const {return _top;}
qreal right() const {return _right;}
qreal bottom() const {return _bottom;}
qreal &rleft() {return _left;}
qreal &rtop() {return _top;}
qreal &rright() {return _right;}
qreal &rbottom() {return _bottom;}
private:
qreal _left, _top, _right, _bottom;
};
QDebug operator<<(QDebug dbg, const MarginsF &margins);
#endif // MARGINS_H

View File

@ -354,14 +354,14 @@ void TrackView::plot(QPainter *painter, const QRectF &target)
orig = viewport()->rect();
if (target.width() > target.height()) {
ratio = target.width()/target.height();
diff = qAbs((orig.height() * ratio) - orig.width());
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
} else {
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
ratio = target.height()/target.width();
diff = qAbs((orig.width() * ratio) - orig.height());
diff = (orig.width() * ratio) - orig.height();
adj = orig.adjusted(0, -diff/2, 0, diff/2);
} else {
ratio = target.width() / target.height();
diff = (orig.height() * ratio) - orig.width();
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
}
setUpdatesEnabled(false);

View File

@ -12,13 +12,14 @@ enum Units {
#define MS2KMH 3.600000000000 // m/s -> km/h
#define MS2MIH 2.236936290000 // m/s -> mi/h
#define FT2MI 0.000189393939 // ft -> mi
#define MM2IN 0.039370100000 // mm -> in
#define KMINM 1000 // 1 km in m
#define MIINFT 5280 // 1 mi in ft
#define MIINM 1609.344 // 1mi in m
#ifdef Q_OS_WIN32
#define UNIT_SPACE " "
#define UNIT_SPACE QString(" ")
#else // Q_OS_WIN32
#define UNIT_SPACE QString::fromUtf8("\xE2\x80\x89")
#endif // Q_OS_WIN32