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

Added basic print/export formating options

This commit is contained in:
Martin Tůma 2016-12-16 02:30:58 +01:00
parent 2bc112c7b4
commit 0448ae5eea
9 changed files with 233 additions and 47 deletions

View File

@ -18,6 +18,7 @@
<file>icons/preferences-desktop-display.png</file>
<file>icons/flag_48.png</file>
<file>icons/system-run.png</file>
<file>icons/document-print-preview.png</file>
<file>lang/gpxsee_cs.qm</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -200,7 +200,7 @@
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="690"/>
<location filename="../src/gui.cpp" line="698"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
@ -457,8 +457,8 @@
<translation>Všechny soubory (*)</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="817"/>
<location filename="../src/gui.cpp" line="820"/>
<location filename="../src/gui.cpp" line="837"/>
<location filename="../src/gui.cpp" line="840"/>
<source>Date</source>
<translation>Datum</translation>
</message>
@ -468,12 +468,12 @@
<translation>Trasy</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="1017"/>
<location filename="../src/gui.cpp" line="1053"/>
<source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation>
</message>
<message numerus="yes">
<location filename="../src/gui.cpp" line="1021"/>
<location filename="../src/gui.cpp" line="1057"/>
<source>%n files</source>
<translation>
<numerusform>%n soubor</numerusform>
@ -552,21 +552,26 @@
<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="679"/>
<location filename="../src/gui.cpp" line="687"/>
<source>Error loading data file:</source>
<translation>Datový soubor nelze načíst:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="682"/>
<location filename="../src/gui.cpp" line="707"/>
<location filename="../src/gui.cpp" line="690"/>
<location filename="../src/gui.cpp" line="715"/>
<source>Line: %1</source>
<translation>Řádka: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="704"/>
<location filename="../src/gui.cpp" line="712"/>
<source>Error loading POI file:</source>
<translation>Soubor POI nelze načíst:</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="823"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="827"/>
<source>Tracks</source>
@ -595,13 +600,13 @@
</message>
<message>
<location filename="../src/gui.cpp" line="326"/>
<location filename="../src/gui.cpp" line="834"/>
<location filename="../src/gui.cpp" line="847"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="333"/>
<location filename="../src/gui.cpp" line="836"/>
<location filename="../src/gui.cpp" line="849"/>
<source>Time</source>
<translation>Čas</translation>
</message>
@ -684,12 +689,12 @@
<message>
<location filename="../src/optionsdialog.cpp" line="34"/>
<source>Base color:</source>
<translation>Základní barva</translation>
<translation>Základní barva:</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="35"/>
<source>Palette shift:</source>
<translation>Posun palety</translation>
<translation>Posun palety:</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="47"/>
@ -744,6 +749,7 @@
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="115"/>
<location filename="../src/optionsdialog.cpp" line="180"/>
<source>Graphs</source>
<translation>Grafy</translation>
</message>
@ -760,32 +766,72 @@
<message>
<location filename="../src/optionsdialog.cpp" line="134"/>
<source>POI radius:</source>
<translation>POI radius</translation>
<translation>POI radius:</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="140"/>
<location filename="../src/optionsdialog.cpp" line="184"/>
<location filename="../src/optionsdialog.cpp" line="225"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="147"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="149"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="151"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="153"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="155"/>
<source>Item count (&gt;1)</source>
<translation>Počet objektů (&gt;1)</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="169"/>
<source>Separate graph page</source>
<translation>Samostatná stránka s grafy</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="179"/>
<source>Header</source>
<translation>Záhlaví</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="187"/>
<source>Use OpenGL</source>
<translation>Používat OpenGL</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="167"/>
<location filename="../src/optionsdialog.cpp" line="185"/>
<location filename="../src/optionsdialog.cpp" line="207"/>
<location filename="../src/optionsdialog.cpp" line="228"/>
<source>System</source>
<translation>Systém</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="182"/>
<location filename="../src/optionsdialog.cpp" line="223"/>
<source>Appearance</source>
<translation>Vzhled</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="212"/>
<location filename="../src/optionsdialog.cpp" line="226"/>
<source>Print &amp; Export</source>
<translation>Tisk a export</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="255"/>
<source>Options</source>
<translation>Nastavení</translation>
</message>

View File

@ -668,6 +668,14 @@ bool GUI::loadFile(const QString &fileName)
_waypointCount += data.waypoints().count();
if (_pathName.isNull()) {
if (data.tracks().count() == 1 && !data.routes().count())
_pathName = data.tracks().first()->name();
else if (data.routes().count() == 1 && !data.tracks().count())
_pathName = data.routes().first()->routeData().name();
} else
_pathName = QString();
return true;
} else {
updateNavigationActions();
@ -811,7 +819,19 @@ void GUI::plot(QPrinter *printer)
qreal d = distance();
qreal t = time();
if (_dateRange.first.isValid()) {
if (!_pathName.isNull() && _options.printName)
info.insert(tr("Name"), _pathName);
if (_options.printItemCount) {
if (_trackCount > 1)
info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount > 1)
info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount > 2)
info.insert(tr("Waypoints"), QString::number(_waypointCount));
}
if (_dateRange.first.isValid() && _options.printDate) {
if (_dateRange.first == _dateRange.second) {
QString format = QLocale::system().dateFormat(QLocale::LongFormat);
info.insert(tr("Date"), _dateRange.first.toString(format));
@ -823,16 +843,9 @@ void GUI::plot(QPrinter *printer)
}
}
if (_trackCount > 1)
info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount > 1)
info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount > 2)
info.insert(tr("Waypoints"), QString::number(_waypointCount));
if (d > 0)
if (d > 0 && _options.printDistance)
info.insert(tr("Distance"), Format::distance(d, units));
if (t > 0)
if (t > 0 && _options.printTime)
info.insert(tr("Time"), Format::timeSpan(t));
@ -845,7 +858,7 @@ void GUI::plot(QPrinter *printer)
mh = ih / 2;
info.plot(&p, QRectF(0, 0, printer->width(), ih));
}
if (_graphTabWidget->isVisible()) {
if (_graphTabWidget->isVisible() && !_options.separateGraphPage) {
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
gh = (printer->width() > printer->height())
? 0.15 * r * (printer->height() - ih - 2*mh)
@ -857,6 +870,27 @@ void GUI::plot(QPrinter *printer)
gh = 0;
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
- (ih + 2*mh + gh)));
if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
printer->newPage();
int cnt = 0;
for (int i = 0; i < _tabs.size(); i++)
if (_tabs.at(i)->count())
cnt++;
qreal sp = ratio * 20;
gh = qMin((printer->height() - ((cnt - 1) * sp))/(qreal)cnt,
0.20 * printer->height());
qreal y = 0;
for (int i = 0; i < _tabs.size(); i++) {
if (_tabs.at(i)->count()) {
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh));
y += gh + sp;
}
}
}
}
void GUI::reloadFile()
@ -868,6 +902,7 @@ void GUI::reloadFile()
_routeDistance = 0;
_time = 0;
_dateRange = DateRange(QDate(), QDate());
_pathName = QString();
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear();
@ -901,6 +936,7 @@ void GUI::closeFiles()
_routeDistance = 0;
_time = 0;
_dateRange = DateRange(QDate(), QDate());
_pathName = QString();
_sliderPos = 0;
@ -1378,6 +1414,19 @@ void GUI::writeSettings()
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
if (_options.printName != PRINT_NAME_DEFAULT)
settings.setValue(PRINT_NAME_SETTING, _options.printName);
if (_options.printDate != PRINT_DATE_DEFAULT)
settings.setValue(PRINT_DATE_SETTING, _options.printDate);
if (_options.printDistance != PRINT_DISTANCE_DEFAULT)
settings.setValue(PRINT_DISTANCE_SETTING, _options.printDistance);
if (_options.printTime != PRINT_TIME_DEFAULT)
settings.setValue(PRINT_TIME_SETTING, _options.printTime);
if (_options.printItemCount != PRINT_ITEM_COUNT_DEFAULT)
settings.setValue(PRINT_ITEM_COUNT_SETTING, _options.printItemCount);
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
settings.setValue(SEPARATE_GRAPH_PAGE_SETTING,
_options.separateGraphPage);
settings.endGroup();
}
@ -1534,6 +1583,18 @@ void GUI::readSettings()
.toInt();
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
.toBool();
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
.toBool();
_options.printDate = settings.value(PRINT_DATE_SETTING, PRINT_DATE_DEFAULT)
.toBool();
_options.printDistance = settings.value(PRINT_DISTANCE_SETTING,
PRINT_DISTANCE_DEFAULT).toBool();
_options.printTime = settings.value(PRINT_TIME_SETTING, PRINT_TIME_DEFAULT)
.toBool();
_options.printItemCount = settings.value(PRINT_ITEM_COUNT_SETTING,
PRINT_ITEM_COUNT_DEFAULT).toBool();
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
_pathView->setPalette(_options.palette);
_pathView->setTrackWidth(_options.trackWidth);

View File

@ -189,6 +189,7 @@ private:
qreal _routeDistance;
qreal _time;
DateRange _dateRange;
QString _pathName;
qreal _sliderPos;

View File

@ -4,24 +4,25 @@
#define APP_ICON ":/icons/gpxsee.png"
// Toolbar/menu icons
#define OPEN_FILE_ICON ":/icons/document-open.png"
#define EXPORT_FILE_ICON ":/icons/document-export.png"
#define PRINT_FILE_ICON ":/icons/document-print.png"
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
#define SHOW_POI_ICON ":/icons/flag.png"
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
#define QUIT_ICON ":/icons/application-exit.png"
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
#define PREV_FILE_ICON ":/icons/arrow-left.png"
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
#define OPEN_FILE_ICON ":/icons/document-open.png"
#define EXPORT_FILE_ICON ":/icons/document-export.png"
#define PRINT_FILE_ICON ":/icons/document-print.png"
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
#define SHOW_POI_ICON ":/icons/flag.png"
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
#define QUIT_ICON ":/icons/application-exit.png"
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
#define PREV_FILE_ICON ":/icons/arrow-left.png"
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
// Options dialog icons
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
#define POI_ICON ":/icons/flag_48.png"
#define SYSTEM_ICON ":/icons/system-run.png"
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
#define POI_ICON ":/icons/flag_48.png"
#define SYSTEM_ICON ":/icons/system-run.png"
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
#endif /* ICONS_H */

View File

@ -142,6 +142,46 @@ QWidget *OptionsDialog::createPOIPage()
return poiPage;
}
QWidget *OptionsDialog::createExportPage()
{
_name = new QCheckBox(tr("Name"));
_name->setChecked(_options->printName);
_date = new QCheckBox(tr("Date"));
_date->setChecked(_options->printDate);
_distance = new QCheckBox(tr("Distance"));
_distance->setChecked(_options->printDistance);
_time = new QCheckBox(tr("Time"));
_time->setChecked(_options->printTime);
_itemCount = new QCheckBox(tr("Item count (>1)"));
_itemCount->setChecked(_options->printItemCount);
QFormLayout *headerTabLayout = new QFormLayout();
headerTabLayout->addWidget(_name);
headerTabLayout->addWidget(_date);
headerTabLayout->addWidget(_distance);
headerTabLayout->addWidget(_time);
headerTabLayout->addItem(new QSpacerItem(10, 10));
headerTabLayout->addWidget(_itemCount);
QWidget *headerTab = new QWidget();
headerTab->setLayout(headerTabLayout);
_separateGraphPage = new QCheckBox(tr("Separate graph page"));
_separateGraphPage->setChecked(_options->separateGraphPage);
QFormLayout *graphTabLayout = new QFormLayout();
graphTabLayout->addWidget(_separateGraphPage);
QWidget *graphTab = new QWidget();
graphTab->setLayout(graphTabLayout);
QTabWidget *exportPage = new QTabWidget();
exportPage->addTab(headerTab, tr("Header"));
exportPage->addTab(graphTab, tr("Graphs"));
return exportPage;
}
QWidget *OptionsDialog::createSystemPage()
{
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
@ -175,6 +215,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
QStackedWidget *pages = new QStackedWidget();
pages->addWidget(createAppearancePage());
pages->addWidget(createPOIPage());
pages->addWidget(createExportPage());
pages->addWidget(createSystemPage());
QListWidget *menu = new QListWidget();
@ -182,6 +223,8 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
menu);
new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu);
new QListWidgetItem(QIcon(QPixmap(PRINT_EXPORT_ICON)), tr("Print & Export"),
menu);
new QListWidgetItem(QIcon(QPixmap(SYSTEM_ICON)), tr("System"), menu);
QHBoxLayout *contentLayout = new QHBoxLayout();
@ -234,5 +277,12 @@ void OptionsDialog::accept()
_options->useOpenGL = _useOpenGL->isChecked();
_options->printName = _name->isChecked();
_options->printDate = _date->isChecked();
_options->printDistance = _distance->isChecked();
_options->printTime = _time->isChecked();
_options->printItemCount = _itemCount->isChecked();
_options->separateGraphPage = _separateGraphPage->isChecked();
QDialog::accept();
}

View File

@ -26,6 +26,13 @@ struct Options {
int poiRadius;
// System
bool useOpenGL;
// Print/Export
bool printName;
bool printDate;
bool printDistance;
bool printTime;
bool printItemCount;
bool separateGraphPage;
Units units;
};
@ -44,6 +51,7 @@ private:
QWidget *createAppearancePage();
QWidget *createPOIPage();
QWidget *createSystemPage();
QWidget *createExportPage();
Options *_options;
@ -58,6 +66,12 @@ private:
QCheckBox *_graphAA;
QDoubleSpinBox *_poiRadius;
QCheckBox *_useOpenGL;
QCheckBox *_name;
QCheckBox *_date;
QCheckBox *_distance;
QCheckBox *_time;
QCheckBox *_itemCount;
QCheckBox *_separateGraphPage;
};
#endif // OPTIONSDIALOG_H

View File

@ -92,5 +92,17 @@
#define POI_RADIUS_DEFAULT (IMPERIAL_UNITS() ? MIINM : KMINM)
#define USE_OPENGL_SETTING "useOpenGL"
#define USE_OPENGL_DEFAULT false
#define PRINT_NAME_SETTING "printName"
#define PRINT_NAME_DEFAULT true
#define PRINT_DATE_SETTING "printDate"
#define PRINT_DATE_DEFAULT true
#define PRINT_DISTANCE_SETTING "printDistance"
#define PRINT_DISTANCE_DEFAULT true
#define PRINT_TIME_SETTING "printTime"
#define PRINT_TIME_DEFAULT true
#define PRINT_ITEM_COUNT_SETTING "printItemCount"
#define PRINT_ITEM_COUNT_DEFAULT true
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
#define SEPARATE_GRAPH_PAGE_DEFAULT false
#endif // SETTINGS_H