mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 09:23:17 +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 <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();
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue