Qt/RenderWidget: Draw background on pause

This commit is contained in:
spycrab 2018-03-24 23:50:03 +01:00
parent 328ac424c0
commit 3f1430587c
3 changed files with 20 additions and 2 deletions

View File

@ -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
{

View File

@ -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()

View File

@ -29,6 +29,7 @@ signals:
private:
void HandleCursorTimer();
void OnHideCursorChanged();
void SetFillBackground(bool fill);
static constexpr int MOUSE_HIDE_DELAY = 3000;
QTimer* m_mouse_timer;