DolphinQt: remove non-render-to-main and add fullscreen.

This commit is contained in:
Augustin Cavalier 2014-12-12 14:29:48 -05:00
parent 7ebca647b3
commit d857306190
3 changed files with 65 additions and 57 deletions

View File

@ -21,6 +21,8 @@
#include "DolphinQt/Utils/Resources.h" #include "DolphinQt/Utils/Resources.h"
#include "DolphinQt/Utils/Utils.h" #include "DolphinQt/Utils/Utils.h"
#include "VideoCommon/VideoConfig.h"
// The "g_main_window" object as defined in MainWindow.h // The "g_main_window" object as defined in MainWindow.h
DMainWindow* g_main_window = nullptr; DMainWindow* g_main_window = nullptr;
@ -92,39 +94,34 @@ void DMainWindow::StartGame(const QString filename)
m_render_widget->setWindowTitle(tr("Dolphin")); // TODO m_render_widget->setWindowTitle(tr("Dolphin")); // TODO
m_render_widget->setWindowIcon(windowIcon()); m_render_widget->setWindowIcon(windowIcon());
// TODO: When rendering to main, this won't resize the parent window.. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen)
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{ {
connect(m_render_widget.get(), SIGNAL(Closed()), this, SLOT(OnStop())); m_render_widget->setWindowFlags(m_render_widget->windowFlags() | Qt::BypassWindowManagerHint);
m_render_widget->move(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos, g_Config.bFullscreen = !g_Config.bBorderlessFullscreen;
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos); m_render_widget->showFullScreen();
m_render_widget->resize(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth, // TODO: Make sure these are client sizes!
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight);
m_render_widget->show();
} }
else else
{ {
m_ui->centralWidget->addWidget(m_render_widget.get()); m_ui->centralWidget->addWidget(m_render_widget.get());
m_ui->centralWidget->setCurrentWidget(m_render_widget.get()); m_ui->centralWidget->setCurrentWidget(m_render_widget.get());
// TODO: When rendering to main, this won't resize the parent window...
m_render_widget->resize(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth,
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight);
} }
if (!BootManager::BootCore(filename.toStdString())) if (!BootManager::BootCore(filename.toStdString()))
{ {
QMessageBox::critical(this, tr("Fatal error"), tr("Failed to init Core"), QMessageBox::Ok); QMessageBox::critical(this, tr("Fatal error"), tr("Failed to init Core"), QMessageBox::Ok);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen)
m_ui->centralWidget->removeWidget(m_render_widget.get());
else
m_render_widget->close(); m_render_widget->close();
else
m_ui->centralWidget->removeWidget(m_render_widget.get());
m_render_widget.reset(); m_render_widget.reset();
} }
else else
{ {
// TODO: Disable screensaver! // TODO: Disable screensaver!
// TODO: Fullscreen
//DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
m_render_widget->focusWidget();
emit CoreStateChanged(Core::CORE_RUN); emit CoreStateChanged(Core::CORE_RUN);
} }
} }
@ -181,48 +178,53 @@ void DMainWindow::OnPlay()
} }
} }
void DMainWindow::OnStop() bool DMainWindow::OnStop()
{ {
if (Core::GetState() != Core::CORE_UNINITIALIZED && !m_isStopping) if (Core::GetState() == Core::CORE_UNINITIALIZED || m_isStopping)
{ return true; // We're already stopped/stopping
m_isStopping = true;
// Ask for confirmation in case the user accidentally clicked Stop / Escape // Ask for confirmation in case the user accidentally clicked Stop / Escape
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
{ {
int ret = QMessageBox::question(m_render_widget.get(), tr("Please confirm..."), // Pause emulation
Core::SetState(Core::CORE_PAUSE);
emit CoreStateChanged(Core::CORE_PAUSE);
QMessageBox::StandardButton ret = QMessageBox::question(m_render_widget.get(), tr("Please confirm..."),
tr("Do you want to stop the current emulation?"), tr("Do you want to stop the current emulation?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No); QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (ret == QMessageBox::No) if (ret == QMessageBox::No)
return; {
DoStartPause();
return false;
} }
}
m_isStopping = true;
// TODO: Movie stuff // TODO: Movie stuff
// TODO: Show the author/description dialog here // TODO: Show the author/description dialog here
// TODO: Show busy cursor
BootManager::Stop(); BootManager::Stop();
// TODO: Hide busy cursor again
// TODO: Allow screensaver again // TODO: Allow screensaver again
// TODO: Restore original window title // TODO: Restore original window title
// TODO: Return from fullscreen if necessary (DoFullscreen in the wx code)
// TODO: // TODO:
// If batch mode was specified on the command-line, exit now. // If batch mode was specified on the command-line, exit now.
//if (m_bBatchMode) //if (m_bBatchMode)
// Close(true); // Close(true);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen)
m_ui->centralWidget->removeWidget(m_render_widget.get());
else
m_render_widget->close(); m_render_widget->close();
else
m_ui->centralWidget->removeWidget(m_render_widget.get());
m_render_widget.reset(); m_render_widget.reset();
emit CoreStateChanged(Core::CORE_UNINITIALIZED); emit CoreStateChanged(Core::CORE_UNINITIALIZED);
}
m_isStopping = false; m_isStopping = false;
return true;
} }
void DMainWindow::OnGameListStyleChanged() void DMainWindow::OnGameListStyleChanged()

View File

@ -33,6 +33,10 @@ public:
signals: signals:
void CoreStateChanged(Core::EState state); void CoreStateChanged(Core::EState state);
public slots:
// Main toolbar (also used by DRenderWidget)
bool OnStop();
private slots: private slots:
// Emulation // Emulation
void StartGame(const QString filename); void StartGame(const QString filename);
@ -41,7 +45,6 @@ private slots:
// Main toolbar // Main toolbar
void OnOpen(); void OnOpen();
void OnPlay(); void OnPlay();
void OnStop();
// View menu // View menu
void OnGameListStyleChanged(); void OnGameListStyleChanged();

View File

@ -2,8 +2,10 @@
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <QCloseEvent>
#include <QMessageBox> #include <QMessageBox>
#include "DolphinQt/MainWindow.h"
#include "DolphinQt/VideoInterface/RenderWidget.h" #include "DolphinQt/VideoInterface/RenderWidget.h"
DRenderWidget::DRenderWidget(QWidget* parent_widget) DRenderWidget::DRenderWidget(QWidget* parent_widget)
@ -16,9 +18,10 @@ DRenderWidget::DRenderWidget(QWidget* parent_widget)
void DRenderWidget::closeEvent(QCloseEvent* e) void DRenderWidget::closeEvent(QCloseEvent* e)
{ {
// TODO: update render window positions in config if (!g_main_window->OnStop())
{
// TODO: Do this differently... e->ignore();
emit Closed(); return;
}
QWidget::closeEvent(e); QWidget::closeEvent(e);
} }