Skip to content

Commit

Permalink
Merge pull request #5547 from ligfx/qthidecursor
Browse files Browse the repository at this point in the history
DolphinQt2: support hiding cursor over render window
  • Loading branch information
shuffle2 committed Jun 6, 2017
2 parents d712914 + 328333d commit 9994bee
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/DolphinQt2/RenderWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
{
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinQt2/RenderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ class RenderWidget final : public QWidget
void HandleChanged(void* handle);
void FocusChanged(bool focus);
void StateChanged(bool fullscreen);

private:
void OnHideCursorChanged();
};
11 changes: 11 additions & 0 deletions Source/Core/DolphinQt2/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinQt2/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class Settings final : public QSettings, NonCopyable
bool GetRenderToMain() const;
bool GetFullScreen() const;
QSize GetRenderWindowSize() const;
void SetHideCursor(bool hide_cursor);
bool GetHideCursor() const;

// Columns
bool& BannerVisible() const;
Expand Down Expand Up @@ -111,6 +113,7 @@ class Settings final : public QSettings, NonCopyable
signals:
void PathAdded(const QString&);
void PathRemoved(const QString&);
void HideCursorChanged();

private:
Settings();
Expand Down
8 changes: 5 additions & 3 deletions Source/Core/DolphinQt2/Settings/InterfacePane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"

#include "DolphinQt2/Settings.h"

InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent)
{
CreateLayout();
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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();
}

0 comments on commit 9994bee

Please sign in to comment.