1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 03:29:16 +02:00

Added fullscreen mode

This commit is contained in:
2016-04-05 09:10:19 +02:00
parent 27ff3a9ba8
commit 339144f7f8
10 changed files with 174 additions and 104 deletions

View File

@ -5,7 +5,7 @@
#define APP_NAME "GPXSee"
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
#define APP_VERSION "2.11"
#define APP_VERSION "2.12"
#define FONT_FAMILY "Arial"
#define FONT_SIZE 12

View File

@ -180,6 +180,7 @@ void GUI::createActions()
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
_exitAction->setShortcut(QKeySequence::Quit);
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
addAction(_exitAction);
// Help & About
_dataSourcesAction = new QAction(tr("Data sources"), this);
@ -197,26 +198,31 @@ void GUI::createActions()
tr("Open"), this);
_openFileAction->setShortcut(QKeySequence::Open);
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
addAction(_openFileAction);
_saveFileAction = new QAction(QIcon(QPixmap(SAVE_FILE_ICON)),
tr("Save"), this);
_saveFileAction->setShortcut(QKeySequence::Save);
_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(QKeySequence::SaveAs);
_saveAsAction->setActionGroup(_fileActionGroup);
connect(_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
addAction(_saveAsAction);
_closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
tr("Close"), this);
_closeFileAction->setShortcut(QKeySequence::Close);
_closeFileAction->setActionGroup(_fileActionGroup);
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeAll()));
addAction(_closeFileAction);
_reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
tr("Reload"), this);
_reloadFileAction->setShortcut(QKeySequence::Refresh);
_reloadFileAction->setActionGroup(_fileActionGroup);
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
addAction(_reloadFileAction);
// POI actions
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
@ -230,6 +236,7 @@ void GUI::createActions()
_showPOIAction->setCheckable(true);
_showPOIAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
addAction(_showPOIAction);
createPOIFilesActions();
// Map actions
@ -238,6 +245,7 @@ void GUI::createActions()
_showMapAction->setCheckable(true);
_showMapAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
addAction(_showMapAction);
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
SLOT(clearMapCache()));
@ -256,6 +264,7 @@ void GUI::createActions()
_showGraphsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
SLOT(showGraphs(bool)));
addAction(_showGraphsAction);
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
_showToolbarsAction->setCheckable(true);
_showToolbarsAction->setChecked(true);
@ -274,6 +283,13 @@ void GUI::createActions()
_imperialUnitsAction->setActionGroup(ag);
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
SLOT(setImperialUnits()));
_fullscreenAction = new QAction(QIcon(QPixmap(FULLSCREEN_ICON)),
tr("Fullscreen mode"), this);
_fullscreenAction->setCheckable(true);
_fullscreenAction->setShortcut(QKeySequence("F11"));
connect(_fullscreenAction, SIGNAL(triggered(bool)), this,
SLOT(showFullscreen(bool)));
addAction(_fullscreenAction);
// Navigation actions
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
@ -331,6 +347,8 @@ void GUI::createMenus()
_settingsMenu->addSeparator();
_settingsMenu->addAction(_showToolbarsAction);
_settingsMenu->addAction(_showGraphsAction);
_settingsMenu->addSeparator();
_settingsMenu->addAction(_fullscreenAction);
_helpMenu = menuBar()->addMenu(tr("Help"));
_helpMenu->addAction(_dataSourcesAction);
@ -389,6 +407,7 @@ void GUI::createTrackGraphs()
_trackGraphs->setFixedHeight(200);
_trackGraphs->setSizePolicy(
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
_trackGraphs->setDocumentMode(true);
}
void GUI::createStatusBar()
@ -744,6 +763,37 @@ void GUI::showToolbars(bool checked)
}
}
void GUI::showFullscreen(bool checked)
{
if (checked) {
_contentsMargins = centralWidget()->layout()->contentsMargins();
_frameStyle = _track->frameStyle();
_showGraphs = _showGraphsAction->isChecked();
statusBar()->hide();
menuBar()->hide();
showToolbars(false);
showGraphs(false);
_showGraphsAction->setChecked(false);
centralWidget()->layout()->setContentsMargins(QMargins());
_track->setFrameStyle(QFrame::NoFrame);
showFullScreen();
} else {
statusBar()->show();
menuBar()->show();
if (_showToolbarsAction->isChecked())
showToolbars(true);
_showGraphsAction->setChecked(_showGraphs);
if (_showGraphsAction->isEnabled())
showGraphs(_showGraphs);
centralWidget()->layout()->setContentsMargins(_contentsMargins);
_track->setFrameStyle(_frameStyle);
showNormal();
}
}
void GUI::clearMapCache()
{
_currentMap->clearCache();
@ -854,17 +904,14 @@ void GUI::updateGraphTabs()
_trackGraphs->insertTab(i, gv, tabs[i].label);
}
for (int i = 0; i < (int)ARRAY_SIZE(tabs); i++) {
if (tabs[i].view->count()) {
if (_showGraphsAction->isChecked())
_trackGraphs->setHidden(false);
_showGraphsAction->setEnabled(true);
return;
}
if (_trackGraphs->count()) {
if (_showGraphsAction->isChecked())
_trackGraphs->setHidden(false);
_showGraphsAction->setEnabled(true);
} else {
_trackGraphs->setHidden(true);
_showGraphsAction->setEnabled(false);
}
_trackGraphs->setHidden(true);
_showGraphsAction->setEnabled(false);
}
void GUI::updateTrackView()

View File

@ -45,6 +45,7 @@ private slots:
void showMap(bool checked);
void showGraphs(bool checked);
void showToolbars(bool checked);
void showFullscreen(bool checked);
void clearMapCache();
void mapChanged(int);
@ -115,6 +116,7 @@ private:
QAction *_closePOIAction;
QAction *_showPOIAction;
QAction *_showMapAction;
QAction *_fullscreenAction;
QAction *_clearMapCacheAction;
QAction *_showGraphsAction;
QAction *_showToolbarsAction;
@ -151,6 +153,10 @@ private:
int _trackCount;
qreal _sliderPos;
int _frameStyle;
QMargins _contentsMargins;
bool _showGraphs;
};
#endif // GUI_H

View File

@ -16,6 +16,7 @@
#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"
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png"

View File

@ -308,6 +308,13 @@ void TrackView::redraw()
resetCachedContent();
}
void TrackView::rescale()
{
_zoom = qMin(scale2zoom(trackScale()), scale2zoom(waypointScale()));
rescale(mapScale(_zoom));
_mapScale->setZoom(_zoom);
}
void TrackView::wheelEvent(QWheelEvent *event)
{
if (_paths.isEmpty() && _locations.isEmpty())
@ -467,6 +474,8 @@ void TrackView::resizeEvent(QResizeEvent *e)
if (_paths.isEmpty() && _locations.isEmpty())
return;
rescale();
QRectF br = trackBoundingRect() | waypointBoundingRect();
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);

View File

@ -55,6 +55,7 @@ private:
qreal waypointScale() const;
qreal mapScale(int zoom) const;
void rescale(qreal scale);
void rescale();
void showMarkers(bool show);
void setTrackLineWidth(qreal width);