Merge pull request #5547 from ligfx/qthidecursor

DolphinQt2: support hiding cursor over render window
This commit is contained in:
shuffle2 2017-06-05 17:14:24 -07:00 committed by GitHub
commit 9994bee70b
7 changed files with 33 additions and 6 deletions

View File

@ -152,7 +152,6 @@ void SConfig::SaveInterfaceSettings(IniFile& ini)
interface->Set("UsePanicHandlers", bUsePanicHandlers);
interface->Set("OnScreenDisplayMessages", bOnScreenDisplayMessages);
interface->Set("HideCursor", bHideCursor);
interface->Set("AutoHideCursor", bAutoHideCursor);
interface->Set("MainWindowPosX", iPosX);
interface->Set("MainWindowPosY", iPosY);
interface->Set("MainWindowWidth", iWidth);
@ -458,7 +457,6 @@ void SConfig::LoadInterfaceSettings(IniFile& ini)
interface->Get("UsePanicHandlers", &bUsePanicHandlers, true);
interface->Get("OnScreenDisplayMessages", &bOnScreenDisplayMessages, true);
interface->Get("HideCursor", &bHideCursor, false);
interface->Get("AutoHideCursor", &bAutoHideCursor, false);
interface->Get("MainWindowPosX", &iPosX, INT_MIN);
interface->Get("MainWindowPosY", &iPosY, INT_MIN);
interface->Get("MainWindowWidth", &iWidth, -1);

View File

@ -132,7 +132,7 @@ struct SConfig : NonCopyable
// Interface settings
bool bConfirmStop = false;
bool bHideCursor = false, bAutoHideCursor = false;
bool bHideCursor = false;
bool bUsePanicHandlers = true;
bool bOnScreenDisplayMessages = true;
std::string theme_name;

View File

@ -6,6 +6,7 @@
#include "DolphinQt2/Host.h"
#include "DolphinQt2/RenderWidget.h"
#include "DolphinQt2/Settings.h"
RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
{
@ -17,6 +18,15 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen);
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle);
emit HandleChanged((void*)winId());
connect(&Settings::Instance(), &Settings::HideCursorChanged, this,
&RenderWidget::OnHideCursorChanged);
OnHideCursorChanged();
}
void RenderWidget::OnHideCursorChanged()
{
setCursor(Settings::Instance().GetHideCursor() ? Qt::BlankCursor : Qt::ArrowCursor);
}
bool RenderWidget::event(QEvent* event)

View File

@ -22,4 +22,7 @@ signals:
void HandleChanged(void* handle);
void FocusChanged(bool focus);
void StateChanged(bool fullscreen);
private:
void OnHideCursorChanged();
};

View File

@ -213,6 +213,17 @@ QSize Settings::GetRenderWindowSize() const
return value(QStringLiteral("Graphics/RenderWindowSize"), QSize(640, 480)).toSize();
}
void Settings::SetHideCursor(bool hide_cursor)
{
SConfig::GetInstance().bHideCursor = hide_cursor;
emit HideCursorChanged();
}
bool Settings::GetHideCursor() const
{
return SConfig::GetInstance().bHideCursor;
}
bool& Settings::BannerVisible() const
{
return SConfig::GetInstance().m_showBannerColumn;

View File

@ -71,6 +71,8 @@ public:
bool GetRenderToMain() const;
bool GetFullScreen() const;
QSize GetRenderWindowSize() const;
void SetHideCursor(bool hide_cursor);
bool GetHideCursor() const;
// Columns
bool& BannerVisible() const;
@ -111,6 +113,7 @@ public:
signals:
void PathAdded(const QString&);
void PathRemoved(const QString&);
void HideCursorChanged();
private:
Settings();

View File

@ -17,6 +17,8 @@
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "DolphinQt2/Settings.h"
InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent)
{
CreateLayout();
@ -113,7 +115,8 @@ void InterfacePane::ConnectLayout()
connect(m_checkbox_use_panic_handlers, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
connect(m_checkbox_enable_osd, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
connect(m_checkbox_pause_on_focus_lost, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
connect(m_checkbox_hide_mouse, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
connect(m_checkbox_hide_mouse, &QCheckBox::clicked, &Settings::Instance(),
&Settings::SetHideCursor);
}
void InterfacePane::LoadConfig()
@ -131,7 +134,7 @@ void InterfacePane::LoadConfig()
m_checkbox_enable_osd->setChecked(startup_params.bOnScreenDisplayMessages);
m_checkbox_show_active_title->setChecked(startup_params.m_show_active_title);
m_checkbox_pause_on_focus_lost->setChecked(startup_params.m_PauseOnFocusLost);
m_checkbox_hide_mouse->setChecked(startup_params.bAutoHideCursor);
m_checkbox_hide_mouse->setChecked(Settings::Instance().GetHideCursor());
}
void InterfacePane::OnSaveConfig()
@ -148,7 +151,6 @@ void InterfacePane::OnSaveConfig()
settings.bOnScreenDisplayMessages = m_checkbox_enable_osd->isChecked();
settings.m_show_active_title = m_checkbox_show_active_title->isChecked();
settings.m_PauseOnFocusLost = m_checkbox_pause_on_focus_lost->isChecked();
settings.bAutoHideCursor = m_checkbox_hide_mouse->isChecked();
settings.SaveSettings();
}