Play-/Source/ui_qt/outputwindow.cpp

97 lines
1.8 KiB
C++
Raw Normal View History

#include "outputwindow.h"
#include <QResizeEvent>
2020-11-13 17:00:58 -05:00
#include <QTimer>
OutputWindow::OutputWindow(QWindow* parent)
: QWindow(parent)
{
2020-11-13 17:00:58 -05:00
m_fullScreenCursorTimer = new QTimer(this);
m_fullScreenCursorTimer->setSingleShot(true);
connect(m_fullScreenCursorTimer, &QTimer::timeout, [this]() { setCursor(Qt::BlankCursor); });
connect(this, SIGNAL(activeChanged()), this, SLOT(activeStateChanged()));
}
2020-11-13 17:00:58 -05:00
void OutputWindow::ShowFullScreenCursor()
{
m_fullScreenCursorTimer->start(2000);
m_fullScreenCursorActive = true;
setCursor(Qt::ArrowCursor);
}
void OutputWindow::DismissFullScreenCursor()
{
m_fullScreenCursorTimer->stop();
m_fullScreenCursorActive = false;
setCursor(Qt::ArrowCursor);
}
void OutputWindow::keyPressEvent(QKeyEvent* ev)
{
emit keyDown(ev);
}
void OutputWindow::keyReleaseEvent(QKeyEvent* ev)
{
emit keyUp(ev);
}
void OutputWindow::exposeEvent(QExposeEvent* ev)
{
if(!ev->region().isNull())
{
emit widthChanged(size().width());
}
QWindow::exposeEvent(ev);
}
void OutputWindow::focusOutEvent(QFocusEvent* event)
{
emit focusOut(event);
}
2023-03-01 20:15:27 -05:00
void OutputWindow::focusInEvent(QFocusEvent* event)
{
emit focusIn(event);
}
void OutputWindow::activeStateChanged()
{
if(isActive())
{
emit focusIn(new QFocusEvent(QEvent::FocusIn));
}
else
{
emit focusOut(new QFocusEvent(QEvent::FocusOut));
}
}
2020-11-13 17:00:58 -05:00
void OutputWindow::mouseMoveEvent(QMouseEvent* ev)
{
if(m_fullScreenCursorActive)
{
ShowFullScreenCursor();
}
2023-03-01 20:15:27 -05:00
emit mouseMove(ev);
2020-11-13 17:00:58 -05:00
}
2023-04-20 19:03:13 -04:00
void OutputWindow::mousePressEvent(QMouseEvent* ev)
{
2023-04-20 19:03:13 -04:00
emit mousePress(ev);
}
2023-04-20 19:03:13 -04:00
void OutputWindow::mouseReleaseEvent(QMouseEvent* ev)
{
2023-04-20 19:03:13 -04:00
emit mouseRelease(ev);
}
void OutputWindow::mouseDoubleClickEvent(QMouseEvent* ev)
{
emit doubleClick(ev);
}
void OutputWindow::wheelEvent(QWheelEvent* ev)
{
2023-03-01 20:15:27 -05:00
emit mouseWheel(ev);
}