From 511deada2e19a59e128260138cc18392ec455fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 15 May 2016 22:38:15 +0200 Subject: [PATCH] Added printing support "Save" is now "Export" --- gpxsee.qrc | 4 +- icons/document-export.png | Bin 0 -> 865 bytes icons/document-print.png | Bin 0 -> 880 bytes icons/document-save-as.png | Bin 1233 -> 0 bytes icons/document-save.png | Bin 798 -> 0 bytes lang/gpxsee_cs.ts | 211 +++++++++++++++++++------------------ src/gui.cpp | 77 +++++++++----- src/gui.h | 16 +-- src/icons.h | 4 +- src/keys.h | 3 +- 10 files changed, 172 insertions(+), 143 deletions(-) create mode 100644 icons/document-export.png create mode 100644 icons/document-print.png delete mode 100644 icons/document-save-as.png delete mode 100644 icons/document-save.png diff --git a/gpxsee.qrc b/gpxsee.qrc index 33194bcc..928d15e9 100644 --- a/gpxsee.qrc +++ b/gpxsee.qrc @@ -2,8 +2,8 @@ icons/dialog-close.png icons/document-open.png - icons/document-save-as.png - icons/document-save.png + icons/document-print.png + icons/document-export.png icons/flag.png icons/gpxsee.png icons/application-exit.png diff --git a/icons/document-export.png b/icons/document-export.png new file mode 100644 index 0000000000000000000000000000000000000000..71fb3a90c0f843eca241f64aa1f3d161af64edd2 GIT binary patch literal 865 zcmV-n1D^beP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L011Qu011Qvs^VjL00007bV*G`2iyS^ z05~*#7}vr800QAjL_t(I%e9rkPa8)Rhrc(wh5#;7s=AS?N ziJqH(fP2HWx#M2bOC^L7b3jN&=^?HhfrMzKhJZxab-lZ+y*sZ5cCEEzCn!=!8qLnz z-EZD|^LsP!KQ#fEo}R9RVfZbepURn;nRy)q!R7Fas(wP--{03}v#F}8z)BJ5W}^c9 z^X3hX<6w+IL=a;zA~(+>H{pq3M0ioJv$(j3?|HOZErz3YixbCnDY-5JNDj|{VoV?G z7(>Z*vDQ+lRJgdf0Qj=VG6RzgWQ@7-Ht&vu$?T5fAR;U;FSE0=gX1_(OAx>3izri)39yxQ=5^PfvN(Y|>~n`26l&Ha9mBknir_uk7yb9spnTRROH4>hJG7 z4<`c~V=!3?0463TxY;96RjewiiU93S2ep>j*;!sZe|}u8Rv);-dFiJj&u^aFYY_UyM5I3HiqW4z7B&&uU~fv8%7AkgjY?cT=5#t*=s zqt4ScRn_b3YwdQseTk)Ms%e_4wN|aQdVGAOs;bte8U!7?we=(hsvkP2-vj5G&7nz> z=*h{6s;YK69s6YK=NS0@V>iH>sty#yIB*yS_UY4KVqpC?SIhcsZVcb|wf1YR3#{Gh r&YPN=`YMW|2Y|iB_kRPgJ_h~|E1&!Vo*O>u00000NkvXXu0mjfKii!B literal 0 HcmV?d00001 diff --git a/icons/document-print.png b/icons/document-print.png new file mode 100644 index 0000000000000000000000000000000000000000..8eb1c6741b62ad70bdaf4fd75d2a535d93d6d03d GIT binary patch literal 880 zcmV-$1CRWPP)-)OT5&Bd)01nK7JB8bqz-B}zf9U63KHEki(1pi_*xiLTH^n0(~c)j8uv@d*IIQhv03tcxPJZvice5)F3M!lMp}vot>R17K_;3-9@2r z#EQfUKYTvR4hNV!Ij@+xoYULeYcDDbo~8&+c|4w0wWU%Cp->1jGas0E<*ZYLGi*sN z?L$XL2P>yV?9-T$8haHVdio5u_V)JB-`|giC>o8Tr>6(Dwlm-3MzF0-w(5f|ZcF^a zLo_utg}%N%*b*k2?Q??Zk@#DHEjBG24m+)&uiUb8&J_lk+SbP0o*Ffs8SD=RC==kqO})9D|Z#^GVX8l-sOBasLn7Ib$%mdjx^mgkhg z_rmtF)sNB9q_tQsm$NPtMW*{7L@J$80|SF)1t&h;b!2t*jg&qm?I@oPRS67$DId}dwiC$+izl!n*DbuVd@ms!P@@SkK}aB)77SIfMo`cMgrqGEv|LL|deDjb>}wO-dXwJ2mhDnW;QePoBuwu&p32l=l_rcU}Q(Aw6TX*rHYqwLtZgM$15gr*q=6$@;^O(0RB;#t>7Xy^tR z&CR3~&qrucIy*Zh*kI{cV3}vl0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{*4PG?2u(z_5g;VOAD8aw7p`WX!N!$7U3y z)%$lahKS`lwxbwZWN_5+_!@mc=*j!5m#W2>=df~K0gZYcdwV4u?C;xtA+jPk|3ZCEM{tNOtp60@AZm~eJ{B8GYng`i3x&h(8_~{NO`JnQcpEFK GUI - + GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at 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 - + Open file Otevřít soubor - - Save as - Uložit jako - - - + Open POI file Otevřít POI soubor - + Open Otevřít - + Quit Ukončit - - - + + + Keyboard controls Ovládací klávesy - - Save - Uložit - - - + Close Zavřít - + Reload Znovu načíst - + Show Zobrazit - - + + File Soubor - - - + + + Data sources Zdroje dat - + + Print + Tisknout + + + + Export + Exportovat + + + + Export as + Exportovat jako + + + Load POI file Nahrát POI soubor - + Close POI files Zavřit POI soubory - + Show POIs Zobrazit POI - + Show map Zobrazit mapu - + Clear tile cache Vymazat mezipaměť dlaždic - - - + + + Next map Následující mapa - + Show graphs Zobrazovat grafy - + Show toolbars Zobrazovat nástrojové lišty - + Metric Metrické - + Imperial Imperiální - + Fullscreen mode Celoobrazovkový režim - + Next Následující - + Previous Předchozí - + Last Poslední - + First První - + Map Mapa - + POI POI - + POI files POI soubory - + Settings Nastavení - + Units Jednotky - + Help Nápověda - + Previous map Předchozí mapa - + No GPX files loaded Nejsou načteny žádné GPX soubory - + Elevation Výška - + Speed Rychlost - + Heart rate Tep - + Next file Následující soubor - + Version Verze - + Previous file Předchozí soubor - + First file První soubor - + Last file Poslední soubor - + Append modifier Modifikátor nahradit/přidat - + Map (tiles) source URLs are read on program startup from the following file: URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru: - + 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: 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: - + To make GPXSee load a POI file automatically on startup, add the file to the following directory: POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře: - + GPX files (*.gpx);;All files (*) soubory GPX (*.gpx);;všechny soubory (*) - - + + Line: %1 Řádka: %1 - + GPX files (*.gpx);;CSV files (*.csv);;All files (*) soubory GPX (*.gpx);;soubory CSV (*.csv);;všechny soubory (*) - - + + mi mi - - - - - + + + + + ft ft - - + + Maximum Maximum - - + + Minimum Minimum - - + + About GPXSee O aplikaci GPXSee - + Navigation Navigace - + Map sources Mapové zdroje - + POIs POI body - - + + Distance Vzdálenost - - + + Time Čas - - + + Ascent Stoupání - - - - - + + + + + m m - - + + Descent Klesání - + %1 tracks Počet tras: %1 - - + + km km - - + + Error Chyba - + Error loading GPX file: %1 Soubor GPX nelze otevřít: %1 - + Error loading POI file: %1 Soubor POI nelze otevřít: diff --git a/src/gui.cpp b/src/gui.cpp index 1f822776..11bce180 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -202,18 +203,21 @@ void GUI::createActions() _openFileAction->setShortcut(OPEN_SHORTCUT); connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); addAction(_openFileAction); - _saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)), - tr("Save"), this); - _saveFileAction->setShortcut(SAVE_SHORTCUT); - _saveFileAction->setActionGroup(_fileActionGroup); - connect(_saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile())); - addAction(_saveFileAction); - _saveAsAction = new QAction(QIcon(QPixmap(SAVE_AS_ICON)), - tr("Save as"), this); - _saveAsAction->setShortcut(SAVE_AS_SHORTCUT); - _saveAsAction->setActionGroup(_fileActionGroup); - connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); - addAction(_saveAsAction); + _printFileAction = new QAction(QIcon(QPixmap(PRINT_FILE_ICON)), + 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"), this); + _exportFileAction->setShortcut(EXPORT_SHORTCUT); + _exportFileAction->setActionGroup(_fileActionGroup); + connect(_exportFileAction, SIGNAL(triggered()), this, SLOT(exportFile())); + addAction(_exportFileAction); + _exportAsAction = new QAction(QIcon(QPixmap(EXPORT_FILE_ICON)), + tr("Export as"), this); + _exportAsAction->setActionGroup(_fileActionGroup); + connect(_exportAsAction, SIGNAL(triggered()), this, SLOT(exportAs())); _closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)), tr("Close"), this); _closeFileAction->setShortcut(CLOSE_SHORTCUT); @@ -321,8 +325,9 @@ void GUI::createMenus() _fileMenu = menuBar()->addMenu(tr("File")); _fileMenu->addAction(_openFileAction); _fileMenu->addSeparator(); - _fileMenu->addAction(_saveFileAction); - _fileMenu->addAction(_saveAsAction); + _fileMenu->addAction(_printFileAction); + _fileMenu->addAction(_exportFileAction); + _fileMenu->addAction(_exportAsAction); _fileMenu->addSeparator(); _fileMenu->addAction(_reloadFileAction); _fileMenu->addSeparator(); @@ -375,9 +380,10 @@ void GUI::createToolBars() _fileToolBar = addToolBar(tr("File")); _fileToolBar->addAction(_openFileAction); - _fileToolBar->addAction(_saveFileAction); _fileToolBar->addAction(_reloadFileAction); _fileToolBar->addAction(_closeFileAction); + _fileToolBar->addAction(_exportFileAction); + _fileToolBar->addAction(_printFileAction); _showToolBar = addToolBar(tr("Show")); _showToolBar->addAction(_showPOIAction); @@ -629,26 +635,35 @@ void GUI::closePOIFiles() _poi.clear(); } -void GUI::saveAs() +void GUI::printFile() +{ + QPrinter printer(QPrinter::HighResolution); + QPrintDialog printDialog(&printer, this); + + if (printDialog.exec() == QDialog::Accepted) + plot(&printer); +} + +void GUI::exportAs() { QString fileName = QFileDialog::getSaveFileName(this, "Export to PDF", QString(), "*.pdf"); if (!fileName.isEmpty()) { - saveFile(fileName); - _saveFileName = fileName; + exportFile(fileName); + _exportFileName = fileName; } } -void GUI::saveFile() +void GUI::exportFile() { - if (_saveFileName.isEmpty()) - emit saveAs(); + if (_exportFileName.isEmpty()) + emit exportAs(); else - saveFile(_saveFileName); + exportFile(_exportFileName); } -void GUI::saveFile(const QString &fileName) +void GUI::exportFile(const QString &fileName) { QPrinter printer(QPrinter::HighResolution); printer.setPageSize(QPrinter::A4); @@ -656,9 +671,15 @@ void GUI::saveFile(const QString &fileName) printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(fileName); - QPainter p(&printer); + plot(&printer); +} + +void GUI::plot(QPrinter *printer) +{ + QPainter p(printer); TrackInfo info; + if (_imperialUnitsAction->isChecked()) { info.insert(tr("Distance"), QString::number(_distance * M2MI, 'f', 1) + UNIT_SPACE + tr("mi")); @@ -685,11 +706,11 @@ void GUI::saveFile(const QString &fileName) 0) + UNIT_SPACE + tr("m")); } - _track->plot(&p, QRectF(0, 300, printer.width(), (0.80 * printer.height()) + _track->plot(&p, QRectF(0, 300, printer->width(), (0.80 * printer->height()) - 400)); - _elevationGraph->plot(&p, QRectF(0, 0.80 * printer.height(), - printer.width(), printer.height() * 0.20)); - info.plot(&p, QRectF(0, 0, printer.width(), 200)); + _elevationGraph->plot(&p, QRectF(0, 0.80 * printer->height(), + printer->width(), printer->height() * 0.20)); + info.plot(&p, QRectF(0, 0, printer->width(), 200)); } void GUI::reloadFile() diff --git a/src/gui.h b/src/gui.h index d9ddbfde..af8ed76f 100644 --- a/src/gui.h +++ b/src/gui.h @@ -13,6 +13,7 @@ class QActionGroup; class QAction; class QLabel; class QSignalMapper; +class QPrinter; class FileBrowser; class GraphView; class ElevationGraph; @@ -35,8 +36,9 @@ private slots: void about(); void keys(); void dataSources(); - void saveFile(); - void saveAs(); + void printFile(); + void exportFile(); + void exportAs(); void openFile(); void closeAll(); void reloadFile(); @@ -71,6 +73,7 @@ private: void loadMaps(); void loadPOIs(); void closeFiles(); + void plot(QPrinter *printer); QAction *createPOIFileAction(int index); void createPOIFilesActions(); @@ -84,7 +87,7 @@ private: bool openPOIFile(const QString &fileName); bool loadFile(const QString &fileName); - void saveFile(const QString &fileName); + void exportFile(const QString &fileName); void updateStatusBarInfo(); void updateWindowTitle(); void updateNavigationActions(); @@ -118,8 +121,9 @@ private: QAction *_dataSourcesAction; QAction *_aboutAction; QAction *_aboutQtAction; - QAction *_saveFileAction; - QAction *_saveAsAction; + QAction *_printFileAction; + QAction *_exportFileAction; + QAction *_exportAsAction; QAction *_openFileAction; QAction *_closeFileAction; QAction *_reloadFileAction; @@ -159,7 +163,7 @@ private: FileBrowser *_browser; QList _files; - QString _saveFileName; + QString _exportFileName; Map *_currentMap; qreal _distance; diff --git a/src/icons.h b/src/icons.h index 4b6bcf93..0cf2ae06 100644 --- a/src/icons.h +++ b/src/icons.h @@ -3,8 +3,8 @@ #define APP_ICON ":/icons/gpxsee.png" #define OPEN_FILE_ICON ":/icons/document-open.png" -#define SAVE_FILE_ICON ":/icons/document-save.png" -#define SAVE_AS_ICON ":/icons/document-save-as.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" diff --git a/src/keys.h b/src/keys.h index 90ced003..42b81c60 100644 --- a/src/keys.h +++ b/src/keys.h @@ -12,10 +12,9 @@ #define QUIT_SHORTCUT QKeySequence::Quit #define OPEN_SHORTCUT QKeySequence::Open -#define SAVE_SHORTCUT QKeySequence::Save -#define SAVE_AS_SHORTCUT QKeySequence::SaveAs #define CLOSE_SHORTCUT QKeySequence::Close #define RELOAD_SHORTCUT QKeySequence::Refresh +#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E) #define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P) #define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M) #define NEXT_MAP_SHORTCUT QKeySequence::Forward