mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Tweak in code styling per Brad’s feedback, along with using SIGNAL and SLOT instead of function pointers directly.
This commit is contained in:
parent
4d5b4081e1
commit
4523ae742e
2 changed files with 12 additions and 7 deletions
|
@ -13,15 +13,18 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)), _throttleRendering(false), _idleRenderInterval(100) {
|
GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)),
|
||||||
|
_throttleRendering(false),
|
||||||
|
_idleRenderInterval(100)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::initializeGL() {
|
void GLCanvas::initializeGL() {
|
||||||
Application::getInstance()->initializeGL();
|
Application::getInstance()->initializeGL();
|
||||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
connect(Application::getInstance(), &Application::applicationStateChanged, this, &GLCanvas::activeChanged);
|
connect(Application::getInstance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeChanged(Qt::ApplicationState)));
|
||||||
connect(&_frameTimer, &QTimer::timeout, this, &GLCanvas::throttleRender);
|
connect(&_frameTimer, SIGNAL(timeout()), this, SLOT(throttleRender()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::paintGL() {
|
void GLCanvas::paintGL() {
|
||||||
|
@ -54,8 +57,8 @@ void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
Application::getInstance()->mouseReleaseEvent(event);
|
Application::getInstance()->mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::activeChanged() {
|
void GLCanvas::activeChanged(Qt::ApplicationState state) {
|
||||||
switch (Application::applicationState()) {
|
switch (state) {
|
||||||
case Qt::ApplicationActive:
|
case Qt::ApplicationActive:
|
||||||
// If we're active, stop the frame timer and the throttle.
|
// If we're active, stop the frame timer and the throttle.
|
||||||
_frameTimer.stop();
|
_frameTimer.stop();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
/// customized canvas that simply forwards requests/events to the singleton application
|
/// customized canvas that simply forwards requests/events to the singleton application
|
||||||
class GLCanvas : public QGLWidget {
|
class GLCanvas : public QGLWidget {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GLCanvas();
|
GLCanvas();
|
||||||
protected:
|
protected:
|
||||||
|
@ -39,8 +40,9 @@ protected:
|
||||||
|
|
||||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||||
virtual void dropEvent(QDropEvent* event);
|
virtual void dropEvent(QDropEvent* event);
|
||||||
|
|
||||||
void activeChanged();
|
private slots:
|
||||||
|
void activeChanged(Qt::ApplicationState state);
|
||||||
void throttleRender();
|
void throttleRender();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue