diff --git a/gpxsee.pro b/gpxsee.pro index 772ebb34..f494cb18 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -5,7 +5,8 @@ QT += core \ network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport -lessThan(QT_VERSION, 5.4) : QT += opengl +lessThan(QT_VERSION, 5.4): QT += opengl +macx: QT += opengl HEADERS += src/config.h \ src/icons.h \ src/gui.h \ @@ -74,7 +75,8 @@ HEADERS += src/config.h \ src/nmeaparser.h \ src/optionsdialog.h \ src/colorbox.h \ - src/stylecombobox.h + src/stylecombobox.h \ + src/opengl.h SOURCES += src/main.cpp \ src/gui.cpp \ src/poi.cpp \ diff --git a/src/app.cpp b/src/app.cpp index fc66e1b1..e7ffc208 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -4,11 +4,7 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) -#include -#else // QT 5.4 -#include -#endif // QT 5.4 +#include "opengl.h" #include "gui.h" #include "app.h" @@ -26,18 +22,8 @@ App::App(int &argc, char **argv) : QApplication(argc, argv), #endif // Q_OS_MAC QNetworkProxyFactory::setUseSystemConfiguration(true); - -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - QGLFormat fmt; - fmt.setSamples(4); - QGLFormat::setDefaultFormat(fmt); -#else // QT 5.4 - QSurfaceFormat fmt; - fmt.setSamples(4); - QSurfaceFormat::setDefaultFormat(fmt); -#endif // QT 5.4 - QPixmapCache::setCacheLimit(65536); + OPENGL_SET_SAMPLES(4); _gui = new GUI(); } diff --git a/src/graphview.cpp b/src/graphview.cpp index febb5eb0..2529cc79 100644 --- a/src/graphview.cpp +++ b/src/graphview.cpp @@ -3,12 +3,8 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) -#include -#else // QT 5.4 -#include -#endif // QT 5.4 #include +#include "opengl.h" #include "config.h" #include "axisitem.h" #include "slideritem.h" @@ -466,11 +462,7 @@ void GraphView::useOpenGL(bool use) #ifdef Q_OS_WIN32 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) #endif // Q_OS_WIN32 -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - setViewport(new QGLWidget); -#else // QT 5.4 - setViewport(new QOpenGLWidget); -#endif // QT 5.4 + setViewport(new OPENGL_WIDGET); } else setViewport(new QWidget); } diff --git a/src/opengl.h b/src/opengl.h new file mode 100644 index 00000000..8a6ab71a --- /dev/null +++ b/src/opengl.h @@ -0,0 +1,26 @@ +#include +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) || defined(Q_OS_MAC) +#include +#include +#else +#include +#include +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) || defined(Q_OS_MAC) +#define OPENGL_WIDGET QGLWidget +#else +#define OPENGL_WIDGET QOpenGLWidget +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) || defined(Q_OS_MAC) +#define OPENGL_SET_SAMPLES(samples) \ + {QGLFormat fmt; \ + fmt.setSamples(samples); \ + QGLFormat::setDefaultFormat(fmt);} +#else +#define OPENGL_SET_SAMPLES(samples) \ + {QSurfaceFormat fmt; \ + fmt.setSamples(samples);\ + QSurfaceFormat::setDefaultFormat(fmt);} +#endif diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index eb305efc..2e29da5a 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -185,16 +185,12 @@ QWidget *OptionsDialog::createExportPage() QWidget *OptionsDialog::createSystemPage() { _useOpenGL = new QCheckBox(tr("Use OpenGL")); -#if defined(Q_OS_WIN32) || defined(Q_OS_MAC) #ifdef Q_OS_WIN32 if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) { -#endif // Q_OS_WIN32 _useOpenGL->setChecked(false); _useOpenGL->setEnabled(false); -#ifdef Q_OS_WIN32 } else #endif // Q_OS_WIN32 -#endif // Q_OS_WIN32 || Q_OS_MAC _useOpenGL->setChecked(_options->useOpenGL); QFormLayout *systemLayout = new QFormLayout(); diff --git a/src/pathview.cpp b/src/pathview.cpp index b2a39940..4c7ab4c9 100644 --- a/src/pathview.cpp +++ b/src/pathview.cpp @@ -1,12 +1,8 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) -#include -#else // QT 5.4 -#include -#endif // QT 5.4 #include +#include "opengl.h" #include "rd.h" #include "poi.h" #include "data.h" @@ -716,11 +712,7 @@ void PathView::useOpenGL(bool use) #ifdef Q_OS_WIN32 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) #endif // Q_OS_WIN32 -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - setViewport(new QGLWidget); -#else // QT 5.4 - setViewport(new QOpenGLWidget); -#endif // QT 5.4 + setViewport(new OPENGL_WIDGET); } else setViewport(new QWidget); }