Play-/Source/ui_unix/openglwindow.cpp

57 lines
1.1 KiB
C++
Raw Normal View History

2016-07-01 05:21:58 +03:00
#include "openglwindow.h"
#include <QResizeEvent>
OpenGLWindow::OpenGLWindow(QWindow *parent)
: QWindow(parent)
{
QSurfaceFormat format;
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
2016-07-01 05:28:39 +03:00
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
2016-07-01 05:21:58 +03:00
setSurfaceType(QWindow::OpenGLSurface);
setFormat(format);
2016-07-29 18:31:09 +01:00
connect(this, SIGNAL(activeChanged()), this, SLOT(activeStateChanged()));
2016-07-01 05:21:58 +03:00
}
OpenGLWindow::~OpenGLWindow()
{
}
void OpenGLWindow::keyPressEvent(QKeyEvent *ev)
{
emit keyDown(ev);
}
void OpenGLWindow::keyReleaseEvent(QKeyEvent *ev)
{
emit keyUp(ev);
}
2016-07-01 05:28:39 +03:00
void OpenGLWindow::exposeEvent(QExposeEvent* ev)
{
emit widthChanged(size().width());
QWindow::exposeEvent(ev);
}
2016-07-29 18:31:09 +01:00
void OpenGLWindow::focusOutEvent(QFocusEvent * event)
{
emit focusOut(event);
}
void OpenGLWindow::focusInEvent(QFocusEvent * event)
{
emit focusIn(event);
}
void OpenGLWindow::activeStateChanged()
{
if (isActive())
{
emit focusIn(new QFocusEvent(QEvent::FocusIn));
} else {
emit focusOut(new QFocusEvent(QEvent::FocusOut));
}
}