Qt: Redraw screen when a status message is posted
Jeffrey Pfau jeffrey@endrift.com
Mon, 03 Aug 2015 20:28:46 -0700
6 files changed,
21 insertions(+),
3 deletions(-)
M
src/platform/qt/Display.cpp
→
src/platform/qt/Display.cpp
@@ -72,6 +72,9 @@ }
void Display::showMessage(const QString& message) { m_messagePainter.showMessage(message); + if (!isDrawing()) { + forceDraw(); + } } void Display::mouseMoveEvent(QMouseEvent*) {
M
src/platform/qt/Display.h
→
src/platform/qt/Display.h
@@ -33,6 +33,8 @@
bool isAspectRatioLocked() const { return m_lockAspectRatio; } bool isFiltered() const { return m_filter; } + virtual bool isDrawing() const = 0; + signals: void showCursor(); void hideCursor();
M
src/platform/qt/DisplayGL.cpp
→
src/platform/qt/DisplayGL.cpp
@@ -16,6 +16,7 @@ using namespace QGBA;
DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent) : Display(parent) + , m_isDrawing(false) , m_gl(new EmptyGLWidget(format, this)) , m_painter(new PainterGL(m_gl)) , m_drawThread(nullptr)@@ -33,6 +34,7 @@ void DisplayGL::startDrawing(GBAThread* thread) {
if (m_drawThread) { return; } + m_isDrawing = true; m_painter->setContext(thread); m_painter->setMessagePainter(messagePainter()); m_context = thread;@@ -55,6 +57,7 @@ }
void DisplayGL::stopDrawing() { if (m_drawThread) { + m_isDrawing = false; if (GBAThreadIsActive(m_context)) { GBAThreadInterrupt(m_context); }@@ -69,6 +72,7 @@ }
void DisplayGL::pauseDrawing() { if (m_drawThread) { + m_isDrawing = false; if (GBAThreadIsActive(m_context)) { GBAThreadInterrupt(m_context); }@@ -81,6 +85,7 @@ }
void DisplayGL::unpauseDrawing() { if (m_drawThread) { + m_isDrawing = true; if (GBAThreadIsActive(m_context)) { GBAThreadInterrupt(m_context); }
M
src/platform/qt/DisplayGL.h
→
src/platform/qt/DisplayGL.h
@@ -43,6 +43,8 @@ public:
DisplayGL(const QGLFormat& format, QWidget* parent = nullptr); ~DisplayGL(); + bool isDrawing() const override { return m_isDrawing; } + public slots: void startDrawing(GBAThread* context) override; void stopDrawing() override;@@ -60,6 +62,7 @@
private: void resizePainter(); + bool m_isDrawing; QGLWidget* m_gl; PainterGL* m_painter; QThread* m_drawThread;
M
src/platform/qt/DisplayQt.cpp
→
src/platform/qt/DisplayQt.cpp
@@ -15,11 +15,13 @@ using namespace QGBA;
DisplayQt::DisplayQt(QWidget* parent) : Display(parent) + , m_isDrawing(false) , m_backing(nullptr) { } void DisplayQt::startDrawing(GBAThread*) { + m_isDrawing = true; } void DisplayQt::lockAspectRatio(bool lock) {
M
src/platform/qt/DisplayQt.h
→
src/platform/qt/DisplayQt.h
@@ -21,11 +21,13 @@
public: DisplayQt(QWidget* parent = nullptr); + bool isDrawing() const override { return m_isDrawing; } + public slots: void startDrawing(GBAThread* context) override; - void stopDrawing() override {} - void pauseDrawing() override {} - void unpauseDrawing() override {} + void stopDrawing() override { m_isDrawing = false; } + void pauseDrawing() override { m_isDrawing = false; } + void unpauseDrawing() override { m_isDrawing = true; } void forceDraw() override { update(); } void lockAspectRatio(bool lock) override; void filter(bool filter) override;@@ -35,6 +37,7 @@ protected:
virtual void paintEvent(QPaintEvent*) override; private: + bool m_isDrawing; QImage m_backing; };