From 0448ae5eeac5297900d7c9f54ce6187e40c8eedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 16 Dec 2016 02:30:58 +0100 Subject: [PATCH] Added basic print/export formating options --- gpxsee.qrc | 1 + icons/document-print-preview.png | Bin 0 -> 3385 bytes lang/gpxsee_cs.ts | 84 ++++++++++++++++++++++++------- src/gui.cpp | 83 ++++++++++++++++++++++++++---- src/gui.h | 1 + src/icons.h | 35 ++++++------- src/optionsdialog.cpp | 50 ++++++++++++++++++ src/optionsdialog.h | 14 ++++++ src/settings.h | 12 +++++ 9 files changed, 233 insertions(+), 47 deletions(-) create mode 100644 icons/document-print-preview.png diff --git a/gpxsee.qrc b/gpxsee.qrc index c27f8dd0..8b237f9b 100644 --- a/gpxsee.qrc +++ b/gpxsee.qrc @@ -18,6 +18,7 @@ icons/preferences-desktop-display.png icons/flag_48.png icons/system-run.png + icons/document-print-preview.png lang/gpxsee_cs.qm diff --git a/icons/document-print-preview.png b/icons/document-print-preview.png new file mode 100644 index 0000000000000000000000000000000000000000..614ffc46f74a201b9b65eab80d5154c11a7a81de GIT binary patch literal 3385 zcmV-94aV|`P)Px#32;bRa{vGo!vFvj!vPg=O+o+w00(qQO+^RU3KtC)JKNA-U;qFB24YJ`L;(K) z{{a7>y{D4^01UZFL_t(|+SOWVY*g13{@(L=X1t6y7_TfPEOBfTQi5wiK~89zfJ0h0 zrA?7Sm!Pz2iK0kR7C{vJi|maQDL<%aA_Y;bN=TSg5VuJig{38m*$lz49b+&!Ua+yp z_KfGv*7M!YbsiIN#u2WRE1kUOH+MPTIp0~{Blxxt15+DL5jUoH1S!)2z-5}|z0qjY z3m`UK29-1V<%~uE7Lpi_sQ{qzu~_WS(@F`$*hDWU3&6w_hPJ$bz%-62ZEoV*J*Ey| zx;!BC{Qm(6ha)_YKqxmw`A8&!Z!#QHS6&|$LrO{tBx~TCdQo4wAH_5s(+?mN3W#RWDiB=Ddjip5WM7$|63fpoSTAQ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VLcaBR&*-yu2Ibyy1Jh#7Cb21Z92IDS#& zS|I@4LNFt6l$Dh;D+oPisOyXwd158b9pPNI0c<1aZsoC_0Z9T9V|{~R{Pn#?c*li0 zk*I3fO^J`ze;&cn_6tZWo{Ma65!%mRREj_M+;htFGMIXG8kVb%3FFGag9n3-xOE34 zki}j8L=Uj=FeAkHMNWcWaahQfHNMdR&sNrc>Zzyj+H0?|t%wN-LxzCpm$g@i zbrzCIoBJpG2fxQ2dyD{BWfg_kr$-_o0j?C}VLU)O&{kTAbCk=Ai;Kamn`%VWXUAes z5wZ$O(b`lm!E7lH_jR7f$LIt_-9=`~qvK%v;KZ9?i3kwQe_`#}W2!+G;O3ygt=N?lsl9eLdm1GfHwrttb zqyQ{mzMKG9QKhuck}R{3ic@qN)x8q`=8HOCDOEZ>d-kk~hX)_H7Y+N~mES$c2ujNx zN(E$n+Rz9J{J@yM6C;<-;iav=70XBL$}_Vul``nrvzhX@A?Fyat*!qski?L578CCA zeO3bgX;f8x@0!mo2}8S`R#Tp6XlPKM)t9gMKI-2)gYHo`OjkZEw#-tv%mhdsDKT(bUwmLmIoMzZSrjEnBdC`*!{313usIZjUF+ zgCvH%x#OGKp+kohw=L6yt}9{mT^SaI({NW+86K=zA@eK(6;TmvFkq!23`y|P15U9% z_Zrx@Z{P2a9XoaqK)^uqBVFX7y?gg=l8vHBe%L=^gaQ8xjXjm*^u;Iu P00000NkvXXu0mjfH9TX- literal 0 HcmV?d00001 diff --git a/lang/gpxsee_cs.ts b/lang/gpxsee_cs.ts index d4e6dcad..385579f0 100644 --- a/lang/gpxsee_cs.ts +++ b/lang/gpxsee_cs.ts @@ -200,7 +200,7 @@ Otevřít soubor - + Open POI file Otevřít POI soubor @@ -457,8 +457,8 @@ Všechny soubory (*) - - + + Date Datum @@ -468,12 +468,12 @@ Trasy - + No GPX files loaded Nejsou načteny žádné GPX soubory - + %n files %n soubor @@ -552,21 +552,26 @@ POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře: - + Error loading data file: Datový soubor nelze načíst: - - + + Line: %1 Řádka: %1 - + Error loading POI file: Soubor POI nelze načíst: + + + Name + Název + Tracks @@ -595,13 +600,13 @@ - + Distance Vzdálenost - + Time Čas @@ -684,12 +689,12 @@ Base color: - Základní barva + Základní barva: Palette shift: - Posun palety + Posun palety: @@ -744,6 +749,7 @@ + Graphs Grafy @@ -760,32 +766,72 @@ POI radius: - POI radius + POI radius: - + POI POI + Name + Název + + + + Date + Datum + + + + Distance + Vzdálenost + + + + Time + Čas + + + + Item count (>1) + Počet objektů (>1) + + + + Separate graph page + Samostatná stránka s grafy + + + + Header + Záhlaví + + + Use OpenGL Používat OpenGL - - + + System Systém - + Appearance Vzhled - + + Print & Export + Tisk a export + + + Options Nastavení diff --git a/src/gui.cpp b/src/gui.cpp index 338e226a..788bfa92 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -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); diff --git a/src/gui.h b/src/gui.h index cc2c72ba..ba0371e7 100644 --- a/src/gui.h +++ b/src/gui.h @@ -189,6 +189,7 @@ private: qreal _routeDistance; qreal _time; DateRange _dateRange; + QString _pathName; qreal _sliderPos; diff --git a/src/icons.h b/src/icons.h index 94c48c23..1f0465d4 100644 --- a/src/icons.h +++ b/src/icons.h @@ -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 */ diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index 637f83de..eb305efc 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -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(); } diff --git a/src/optionsdialog.h b/src/optionsdialog.h index d667dc6b..13cbc543 100644 --- a/src/optionsdialog.h +++ b/src/optionsdialog.h @@ -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 diff --git a/src/settings.h b/src/settings.h index ed08c289..faf9e0c2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -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