Qt: Properly implement "Start Fullscreen"

This commit is contained in:
Connor McLaughlin 2020-03-12 13:53:58 +10:00
parent 2480624cbe
commit 8f39a0f154
12 changed files with 56 additions and 33 deletions

View File

@ -113,7 +113,7 @@ bool HostInterface::BootSystem(const SystemBootParameters& parameters)
void HostInterface::PauseSystem(bool paused) void HostInterface::PauseSystem(bool paused)
{ {
if (paused == m_paused) if (paused == m_paused || !m_system)
return; return;
m_paused = paused; m_paused = paused;

View File

@ -13,6 +13,7 @@ void Settings::Load(SettingsInterface& si)
speed_limiter_enabled = si.GetBoolValue("Main", "SpeedLimiterEnabled", true); speed_limiter_enabled = si.GetBoolValue("Main", "SpeedLimiterEnabled", true);
increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true); increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true);
start_paused = si.GetBoolValue("Main", "StartPaused", false); start_paused = si.GetBoolValue("Main", "StartPaused", false);
start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false);
save_state_on_exit = si.GetBoolValue("Main", "SaveStateOnExit", true); save_state_on_exit = si.GetBoolValue("Main", "SaveStateOnExit", true);
confim_power_off = si.GetBoolValue("Main", "ConfirmPowerOff", true); confim_power_off = si.GetBoolValue("Main", "ConfirmPowerOff", true);
@ -32,7 +33,6 @@ void Settings::Load(SettingsInterface& si)
.value_or(DisplayCropMode::None); .value_or(DisplayCropMode::None);
display_force_progressive_scan = si.GetBoolValue("Display", "ForceProgressiveScan", true); display_force_progressive_scan = si.GetBoolValue("Display", "ForceProgressiveScan", true);
display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true); display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
display_fullscreen = si.GetBoolValue("Display", "Fullscreen", false);
video_sync_enabled = si.GetBoolValue("Display", "VSync", true); video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true); cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true);
@ -71,6 +71,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Main", "SpeedLimiterEnabled", speed_limiter_enabled); si.SetBoolValue("Main", "SpeedLimiterEnabled", speed_limiter_enabled);
si.SetBoolValue("Main", "IncreaseTimerResolution", increase_timer_resolution); si.SetBoolValue("Main", "IncreaseTimerResolution", increase_timer_resolution);
si.SetBoolValue("Main", "StartPaused", start_paused); si.SetBoolValue("Main", "StartPaused", start_paused);
si.SetBoolValue("Main", "StartFullscreen", start_fullscreen);
si.SetBoolValue("Main", "SaveStateOnExit", save_state_on_exit); si.SetBoolValue("Main", "SaveStateOnExit", save_state_on_exit);
si.SetBoolValue("Main", "ConfirmPowerOff", confim_power_off); si.SetBoolValue("Main", "ConfirmPowerOff", confim_power_off);
@ -85,7 +86,6 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Display", "ForceProgressiveScan", display_force_progressive_scan); si.SetBoolValue("Display", "ForceProgressiveScan", display_force_progressive_scan);
si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering); si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
si.SetBoolValue("Display", "Fullscreen", display_fullscreen);
si.SetBoolValue("Display", "VSync", video_sync_enabled); si.SetBoolValue("Display", "VSync", video_sync_enabled);
si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread); si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread);

View File

@ -41,6 +41,7 @@ struct Settings
bool speed_limiter_enabled = true; bool speed_limiter_enabled = true;
bool increase_timer_resolution = true; bool increase_timer_resolution = true;
bool start_paused = false; bool start_paused = false;
bool start_fullscreen = false;
bool save_state_on_exit = true; bool save_state_on_exit = true;
bool confim_power_off = true; bool confim_power_off = true;
@ -53,7 +54,6 @@ struct Settings
DisplayCropMode display_crop_mode = DisplayCropMode::None; DisplayCropMode display_crop_mode = DisplayCropMode::None;
bool display_force_progressive_scan = false; bool display_force_progressive_scan = false;
bool display_linear_filtering = true; bool display_linear_filtering = true;
bool display_fullscreen = false;
bool video_sync_enabled = true; bool video_sync_enabled = true;
bool cdrom_read_thread = true; bool cdrom_read_thread = true;

View File

@ -26,6 +26,7 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToNormalizedSetting(m_host_interface, m_ui.emulationSpeed, "Main/EmulationSpeed", SettingWidgetBinder::BindWidgetToNormalizedSetting(m_host_interface, m_ui.emulationSpeed, "Main/EmulationSpeed",
100.0f); 100.0f);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "Main/StartPaused"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "Main/StartPaused");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startFullscreen, "Main/StartFullscreen");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, "Main/SaveStateOnExit"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, "Main/SaveStateOnExit");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, "Main/ConfirmPowerOff"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, "Main/ConfirmPowerOff");
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU/ExecutionMode", SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU/ExecutionMode",

View File

@ -154,13 +154,20 @@
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="startFullscreen">
<property name="text">
<string>Start Fullscreen</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="saveStateOnExit"> <widget class="QCheckBox" name="saveStateOnExit">
<property name="text"> <property name="text">
<string>Save State On Exit</string> <string>Save State On Exit</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="confirmPowerOff"> <widget class="QCheckBox" name="confirmPowerOff">
<property name="text"> <property name="text">
<string>Confirm Power Off</string> <string>Confirm Power Off</string>

View File

@ -18,7 +18,6 @@ GPUSettingsWidget::GPUSettingsWidget(QtHostInterface* host_interface, QWidget* p
"Display/ForceProgressiveScan"); "Display/ForceProgressiveScan");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayLinearFiltering, SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.displayLinearFiltering,
"Display/LinearFiltering"); "Display/LinearFiltering");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startFullscreen, "Display/Fullscreen");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.vsync, "Display/VSync"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.vsync, "Display/VSync");
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.resolutionScale, "GPU/ResolutionScale"); SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.resolutionScale, "GPU/ResolutionScale");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.trueColor, "GPU/TrueColor"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.trueColor, "GPU/TrueColor");

View File

@ -83,13 +83,6 @@
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="startFullscreen">
<property name="text">
<string>Start Fullscreen</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="vsync"> <widget class="QCheckBox" name="vsync">
<property name="text"> <property name="text">
<string>VSync</string> <string>VSync</string>

View File

@ -10,6 +10,7 @@
#include "qtsettingsinterface.h" #include "qtsettingsinterface.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "settingwidgetbinder.h" #include "settingwidgetbinder.h"
#include <QtCore/QDebug>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
@ -38,6 +39,7 @@ MainWindow::~MainWindow()
void MainWindow::reportError(const QString& message) void MainWindow::reportError(const QString& message)
{ {
QMessageBox::critical(this, tr("DuckStation"), message, QMessageBox::Ok); QMessageBox::critical(this, tr("DuckStation"), message, QMessageBox::Ok);
focusDisplayWidget();
} }
void MainWindow::reportMessage(const QString& message) void MainWindow::reportMessage(const QString& message)
@ -88,6 +90,9 @@ void MainWindow::destroyDisplayWindow()
void MainWindow::setFullscreen(bool fullscreen) void MainWindow::setFullscreen(bool fullscreen)
{ {
if (fullscreen == m_display_widget->isFullScreen())
return;
if (fullscreen) if (fullscreen)
{ {
m_ui.mainContainer->setCurrentIndex(0); m_ui.mainContainer->setCurrentIndex(0);

View File

@ -48,7 +48,11 @@ void QtHostInterface::ReportError(const char* message)
{ {
HostInterface::ReportError(message); HostInterface::ReportError(message);
emit setFullscreenRequested(false);
emit errorReported(QString::fromLocal8Bit(message)); emit errorReported(QString::fromLocal8Bit(message));
if (m_settings.start_fullscreen)
emit setFullscreenRequested(true);
} }
void QtHostInterface::ReportMessage(const char* message) void QtHostInterface::ReportMessage(const char* message)
@ -60,7 +64,14 @@ void QtHostInterface::ReportMessage(const char* message)
bool QtHostInterface::ConfirmMessage(const char* message) bool QtHostInterface::ConfirmMessage(const char* message)
{ {
return messageConfirmed(QString::fromLocal8Bit(message)); emit setFullscreenRequested(false);
const bool result = messageConfirmed(QString::fromLocal8Bit(message));
if (m_settings.start_fullscreen)
emit setFullscreenRequested(true);
return result;
} }
QVariant QtHostInterface::getSettingValue(const QString& name, const QVariant& default_value) QVariant QtHostInterface::getSettingValue(const QString& name, const QVariant& default_value)
@ -251,7 +262,7 @@ std::optional<CommonHostInterface::HostKeyCode> QtHostInterface::GetHostKeyCode(
void QtHostInterface::OnSystemCreated() void QtHostInterface::OnSystemCreated()
{ {
HostInterface::OnSystemCreated(); CommonHostInterface::OnSystemCreated();
wakeThread(); wakeThread();
destroyBackgroundControllerPollTimer(); destroyBackgroundControllerPollTimer();
@ -261,7 +272,7 @@ void QtHostInterface::OnSystemCreated()
void QtHostInterface::OnSystemPaused(bool paused) void QtHostInterface::OnSystemPaused(bool paused)
{ {
HostInterface::OnSystemPaused(paused); CommonHostInterface::OnSystemPaused(paused);
emit emulationPaused(paused); emit emulationPaused(paused);
@ -392,14 +403,7 @@ void QtHostInterface::pauseSystem(bool paused)
return; return;
} }
if (!m_system) CommonHostInterface::PauseSystem(paused);
return;
m_paused = paused;
m_audio_stream->PauseOutput(paused);
if (!paused)
wakeThread();
emit emulationPaused(paused);
} }
void QtHostInterface::changeDisc(const QString& new_disc_filename) void QtHostInterface::changeDisc(const QString& new_disc_filename)

View File

@ -301,7 +301,7 @@ std::unique_ptr<SDLHostInterface> SDLHostInterface::Create()
INISettingsInterface si(intf->GetSettingsFileName().c_str()); INISettingsInterface si(intf->GetSettingsFileName().c_str());
intf->m_settings_copy.Load(si); intf->m_settings_copy.Load(si);
intf->m_settings = intf->m_settings_copy; intf->m_settings = intf->m_settings_copy;
intf->m_fullscreen = intf->m_settings_copy.display_fullscreen; intf->m_fullscreen = intf->m_settings_copy.start_fullscreen;
if (!intf->CreateSDLWindow()) if (!intf->CreateSDLWindow())
{ {
@ -1105,6 +1105,7 @@ void SDLHostInterface::DrawSettingsWindow()
settings_changed |= ImGui::Checkbox("Enable Speed Limiter", &m_settings_copy.speed_limiter_enabled); settings_changed |= ImGui::Checkbox("Enable Speed Limiter", &m_settings_copy.speed_limiter_enabled);
settings_changed |= ImGui::Checkbox("Increase Timer Resolution", &m_settings_copy.increase_timer_resolution); settings_changed |= ImGui::Checkbox("Increase Timer Resolution", &m_settings_copy.increase_timer_resolution);
settings_changed |= ImGui::Checkbox("Pause On Start", &m_settings_copy.start_paused); settings_changed |= ImGui::Checkbox("Pause On Start", &m_settings_copy.start_paused);
settings_changed |= ImGui::Checkbox("Start Fullscreen", &m_settings_copy.start_fullscreen);
settings_changed |= ImGui::Checkbox("Save State On Exit", &m_settings_copy.save_state_on_exit); settings_changed |= ImGui::Checkbox("Save State On Exit", &m_settings_copy.save_state_on_exit);
} }
@ -1246,9 +1247,6 @@ void SDLHostInterface::DrawSettingsWindow()
settings_changed = true; settings_changed = true;
} }
if (ImGui::Checkbox("Start Fullscreen", &m_settings_copy.display_fullscreen))
settings_changed = true;
settings_changed |= ImGui::Checkbox("Use Debug Device", &m_settings_copy.gpu_use_debug_device); settings_changed |= ImGui::Checkbox("Use Debug Device", &m_settings_copy.gpu_use_debug_device);
settings_changed |= ImGui::Checkbox("Linear Filtering", &m_settings_copy.display_linear_filtering); settings_changed |= ImGui::Checkbox("Linear Filtering", &m_settings_copy.display_linear_filtering);
settings_changed |= ImGui::Checkbox("VSync", &m_settings_copy.video_sync_enabled); settings_changed |= ImGui::Checkbox("VSync", &m_settings_copy.video_sync_enabled);

View File

@ -47,6 +47,24 @@ std::unique_ptr<AudioStream> CommonHostInterface::CreateAudioStream(AudioBackend
} }
} }
void CommonHostInterface::OnSystemCreated()
{
HostInterface::OnSystemCreated();
if (m_settings.start_fullscreen)
SetFullscreen(true);
}
void CommonHostInterface::OnSystemPaused(bool paused)
{
HostInterface::OnSystemPaused(paused);
if (paused)
SetFullscreen(false);
else if (m_settings.start_fullscreen)
SetFullscreen(true);
}
void CommonHostInterface::SetDefaultSettings(SettingsInterface& si) void CommonHostInterface::SetDefaultSettings(SettingsInterface& si)
{ {
HostInterface::SetDefaultSettings(si); HostInterface::SetDefaultSettings(si);
@ -319,17 +337,12 @@ void CommonHostInterface::RegisterGeneralHotkeys()
{ {
if (m_settings.confim_power_off) if (m_settings.confim_power_off)
{ {
SetFullscreen(false);
SmallString confirmation_message("Are you sure you want to stop emulation?"); SmallString confirmation_message("Are you sure you want to stop emulation?");
if (m_settings.save_state_on_exit) if (m_settings.save_state_on_exit)
confirmation_message.AppendString("\n\nThe current state will be saved."); confirmation_message.AppendString("\n\nThe current state will be saved.");
if (!ConfirmMessage(confirmation_message)) if (!ConfirmMessage(confirmation_message))
{ {
if (m_settings.display_fullscreen)
SetFullscreen(true);
m_system->ResetPerformanceCounters(); m_system->ResetPerformanceCounters();
return; return;
} }

View File

@ -41,6 +41,9 @@ protected:
virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override; virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override;
virtual void OnSystemCreated() override;
virtual void OnSystemPaused(bool paused) override;
virtual void SetDefaultSettings(SettingsInterface& si) override; virtual void SetDefaultSettings(SettingsInterface& si) override;
virtual std::optional<HostKeyCode> GetHostKeyCode(const std::string_view key_code) const; virtual std::optional<HostKeyCode> GetHostKeyCode(const std::string_view key_code) const;