mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Merge pull request #6280 from spycrab/qt_screensaver
Qt: Toggle Screensaver
This commit is contained in:
@ -358,6 +358,7 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
|
||||
if (Core::GetState() == Core::State::Paused)
|
||||
{
|
||||
Core::SetState(Core::State::Running);
|
||||
EnableScreenSaver(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -365,6 +366,7 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
|
||||
if (selection)
|
||||
{
|
||||
StartGame(selection->GetFilePath(), savestate_path);
|
||||
EnableScreenSaver(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -372,6 +374,7 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
|
||||
if (!default_path.isEmpty() && QFile::exists(default_path))
|
||||
{
|
||||
StartGame(default_path, savestate_path);
|
||||
EnableScreenSaver(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -384,6 +387,7 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
|
||||
void MainWindow::Pause()
|
||||
{
|
||||
Core::SetState(Core::State::Paused);
|
||||
EnableScreenSaver(true);
|
||||
}
|
||||
|
||||
void MainWindow::OnStopComplete()
|
||||
@ -461,6 +465,7 @@ bool MainWindow::RequestStop()
|
||||
void MainWindow::ForceStop()
|
||||
{
|
||||
BootManager::Stop();
|
||||
EnableScreenSaver(true);
|
||||
}
|
||||
|
||||
void MainWindow::Reset()
|
||||
@ -821,6 +826,18 @@ void MainWindow::NetPlayQuit()
|
||||
Settings::Instance().ResetNetPlayServer();
|
||||
}
|
||||
|
||||
void MainWindow::EnableScreenSaver(bool enable)
|
||||
{
|
||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
UICommon::EnableScreenSaver(
|
||||
static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
|
||||
"display", windowHandle())),
|
||||
winId(), enable);
|
||||
#else
|
||||
UICommon::EnableScreenSaver(enable);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Close)
|
||||
|
Reference in New Issue
Block a user