Skip to content
Permalink
Browse files
Merge pull request #6519 from spycrab/qt_rw_bg
Qt/RenderWidget: Draw background on pause
  • Loading branch information
leoetlino committed Mar 26, 2018
2 parents 2e1edb4 + 3f14305 commit b4e9bef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
@@ -655,6 +655,7 @@ void MainWindow::ShowRenderWidget()
m_rendering_to_main = true;
m_stack->setCurrentIndex(m_stack->addWidget(m_render_widget));
connect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
m_stack->repaint();
}
else
{
@@ -3,17 +3,20 @@
// Refer to the license.txt file included.

#include <QKeyEvent>
#include <QPalette>
#include <QTimer>

#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinQt2/Host.h"
#include "DolphinQt2/RenderWidget.h"
#include "DolphinQt2/Settings.h"

RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
{
setAttribute(Qt::WA_OpaquePaintEvent, true);
setAttribute(Qt::WA_NoSystemBackground, true);
QPalette p;
p.setColor(QPalette::Background, Qt::black);
setPalette(p);

connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle);
connect(Host::GetInstance(), &Host::RequestRenderSize, this, [this](int w, int h) {
@@ -23,6 +26,10 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
resize(w, h);
});

connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
SetFillBackground(SConfig::GetInstance().bRenderToMain && state == Core::State::Uninitialized);
});

// We have to use Qt::DirectConnection here because we don't want those signals to get queued
// (which results in them not getting called)
connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen,
@@ -43,6 +50,15 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
&RenderWidget::OnHideCursorChanged);
OnHideCursorChanged();
m_mouse_timer->start(MOUSE_HIDE_DELAY);

SetFillBackground(true);
}

void RenderWidget::SetFillBackground(bool fill)
{
setAttribute(Qt::WA_OpaquePaintEvent, !fill);
setAttribute(Qt::WA_NoSystemBackground, !fill);
setAutoFillBackground(fill);
}

void RenderWidget::OnHideCursorChanged()
@@ -29,6 +29,7 @@ class RenderWidget final : public QWidget
private:
void HandleCursorTimer();
void OnHideCursorChanged();
void SetFillBackground(bool fill);

static constexpr int MOUSE_HIDE_DELAY = 3000;
QTimer* m_mouse_timer;

0 comments on commit b4e9bef

Please sign in to comment.