diff --git a/drape_head/drape_head.pro b/drape_head/drape_head.pro index 3f90e8f1dc..bdf0f9f767 100644 --- a/drape_head/drape_head.pro +++ b/drape_head/drape_head.pro @@ -24,12 +24,13 @@ HEADERS += \ mainwindow.hpp \ glwidget.hpp \ qtoglcontext.hpp \ + qtoglcontextfactory.hpp \ + drape_surface.hpp \ SOURCES += \ mainwindow.cpp \ main.cpp \ glwidget.cpp \ qtoglcontext.cpp \ - -FORMS += \ - mainwindow.ui + qtoglcontextfactory.cpp \ + drape_surface.cpp \ diff --git a/drape_head/drape_surface.cpp b/drape_head/drape_surface.cpp new file mode 100644 index 0000000000..b5f4f26431 --- /dev/null +++ b/drape_head/drape_surface.cpp @@ -0,0 +1,25 @@ +#include "drape_surface.hpp" + +#include "../base/logging.hpp" + +DrapeSurface::DrapeSurface() + : m_contextFactory(NULL) +{ + setSurfaceType(QSurface::OpenGLSurface); +} + +DrapeSurface::~DrapeSurface() +{ + delete m_contextFactory; +} + +void DrapeSurface::exposeEvent(QExposeEvent *e) +{ + Q_UNUSED(e); + + if (isExposed() && m_contextFactory == NULL) + { + m_contextFactory = new QtOGLContextFactory(this); + CreateEngine(); + } +} diff --git a/drape_head/drape_surface.hpp b/drape_head/drape_surface.hpp new file mode 100644 index 0000000000..4f400c86d9 --- /dev/null +++ b/drape_head/drape_surface.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "qtoglcontextfactory.hpp" +#include + +class DrapeSurface : public QWindow +{ +public: + DrapeSurface(); + ~DrapeSurface(); + +protected: + void exposeEvent(QExposeEvent * e); + +private: + void CreateEngine() {} + +private: + QtOGLContextFactory * m_contextFactory; +}; diff --git a/drape_head/mainwindow.cpp b/drape_head/mainwindow.cpp index 4c2db8e6be..8131a45705 100644 --- a/drape_head/mainwindow.cpp +++ b/drape_head/mainwindow.cpp @@ -1,16 +1,16 @@ #include "mainwindow.hpp" -#include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) +#include "drape_surface.hpp" + +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) { - ui->setupUi(this); - m_widget = new GLWidget(); - setCentralWidget(m_widget); + DrapeSurface * surface = new DrapeSurface(); + setCentralWidget(QWidget::createWindowContainer(surface, this)); } MainWindow::~MainWindow() { - delete ui; } diff --git a/drape_head/mainwindow.hpp b/drape_head/mainwindow.hpp index 080a80492e..30336b2a3a 100644 --- a/drape_head/mainwindow.hpp +++ b/drape_head/mainwindow.hpp @@ -2,12 +2,6 @@ #include -#include "glwidget.hpp" - -namespace Ui { -class MainWindow; -} - class MainWindow : public QMainWindow { Q_OBJECT @@ -15,8 +9,4 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); - -private: - Ui::MainWindow *ui; - GLWidget * m_widget; }; diff --git a/drape_head/mainwindow.ui b/drape_head/mainwindow.ui deleted file mode 100644 index 6050363fa7..0000000000 --- a/drape_head/mainwindow.ui +++ /dev/null @@ -1,24 +0,0 @@ - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - - - - - - -