Tweak in code styling per Brad’s feedback, along with using SIGNAL and SLOT instead of function pointers directly.

This commit is contained in:
Geenz 2014-03-13 18:51:14 -04:00
parent 4d5b4081e1
commit 4523ae742e
2 changed files with 12 additions and 7 deletions

View file

@ -13,15 +13,18 @@
#include <QUrl>
#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() {
Application::getInstance()->initializeGL();
setAttribute(Qt::WA_AcceptTouchEvents);
setAcceptDrops(true);
connect(Application::getInstance(), &Application::applicationStateChanged, this, &GLCanvas::activeChanged);
connect(&_frameTimer, &QTimer::timeout, this, &GLCanvas::throttleRender);
connect(Application::getInstance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeChanged(Qt::ApplicationState)));
connect(&_frameTimer, SIGNAL(timeout()), this, SLOT(throttleRender()));
}
void GLCanvas::paintGL() {
@ -54,8 +57,8 @@ void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
Application::getInstance()->mouseReleaseEvent(event);
}
void GLCanvas::activeChanged() {
switch (Application::applicationState()) {
void GLCanvas::activeChanged(Qt::ApplicationState state) {
switch (state) {
case Qt::ApplicationActive:
// If we're active, stop the frame timer and the throttle.
_frameTimer.stop();

View file

@ -14,6 +14,7 @@
/// customized canvas that simply forwards requests/events to the singleton application
class GLCanvas : public QGLWidget {
Q_OBJECT
public:
GLCanvas();
protected:
@ -39,8 +40,9 @@ protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent* event);
void activeChanged();
private slots:
void activeChanged(Qt::ApplicationState state);
void throttleRender();
};