Qt: Implement fullscreen

This commit is contained in:
Connor McLaughlin 2020-01-06 16:27:39 +10:00
parent 87889a13e0
commit 207c75e6eb
4 changed files with 29 additions and 23 deletions

View File

@ -52,6 +52,28 @@ void MainWindow::onEmulationPaused(bool paused)
m_ui.actionPause->setChecked(paused);
}
void MainWindow::toggleFullscreen()
{
const bool fullscreen = !m_display_widget->isFullScreen();
if (fullscreen)
{
m_ui.mainContainer->setCurrentIndex(0);
m_ui.mainContainer->removeWidget(m_display_widget);
m_display_widget->setParent(nullptr);
m_display_widget->showFullScreen();
}
else
{
m_ui.mainContainer->insertWidget(1, m_display_widget);
m_ui.mainContainer->setCurrentIndex(1);
}
m_display_widget->setFocus();
QSignalBlocker blocker(m_ui.actionFullscreen);
m_ui.actionFullscreen->setChecked(fullscreen);
}
void MainWindow::onStartDiscActionTriggered()
{
QString filename =
@ -94,8 +116,6 @@ void MainWindow::onOpenDirectoryActionTriggered() {}
void MainWindow::onExitActionTriggered() {}
void MainWindow::onFullscreenActionToggled(bool fullscreen) {}
void MainWindow::onGitHubRepositoryActionTriggered() {}
void MainWindow::onIssueTrackerActionTriggered() {}
@ -108,7 +128,7 @@ void MainWindow::setupAdditionalUi()
m_game_list_widget->initialize(m_host_interface);
m_ui.mainContainer->insertWidget(0, m_game_list_widget);
m_display_widget = m_host_interface->createDisplayWidget(m_ui.mainContainer);
m_display_widget = m_host_interface->createDisplayWidget(nullptr);
m_ui.mainContainer->insertWidget(1, m_display_widget);
m_ui.mainContainer->setCurrentIndex(0);
@ -156,7 +176,7 @@ void MainWindow::connectSignals()
connect(m_ui.actionReset, &QAction::triggered, m_host_interface, &QtHostInterface::resetSystem);
connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem);
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::onExitActionTriggered);
connect(m_ui.actionFullscreen, &QAction::toggled, this, &MainWindow::onFullscreenActionToggled);
connect(m_ui.actionFullscreen, &QAction::triggered, this, &MainWindow::toggleFullscreen);
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); });
connect(m_ui.actionGameListSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::GameListSettings); });
@ -173,6 +193,7 @@ void MainWindow::connectSignals()
connect(m_host_interface, &QtHostInterface::emulationStarted, this, &MainWindow::onEmulationStarted);
connect(m_host_interface, &QtHostInterface::emulationStopped, this, &MainWindow::onEmulationStopped);
connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused);
connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen);
connect(m_game_list_widget, &GameListWidget::bootEntryRequested, [this](const GameList::GameListEntry& entry) {
// if we're not running, boot the system, otherwise swap discs

View File

@ -19,18 +19,18 @@ public:
explicit MainWindow(QtHostInterface* host_interface);
~MainWindow();
public Q_SLOTS:
private Q_SLOTS:
void onEmulationStarting();
void onEmulationStarted();
void onEmulationStopped();
void onEmulationPaused(bool paused);
void toggleFullscreen();
void onStartDiscActionTriggered();
void onChangeDiscActionTriggered();
void onStartBiosActionTriggered();
void onOpenDirectoryActionTriggered();
void onExitActionTriggered();
void onFullscreenActionToggled(bool fullscreen);
void onGitHubRepositoryActionTriggered();
void onIssueTrackerActionTriggered();
void onAboutActionTriggered();

View File

@ -269,7 +269,7 @@ void QtHostInterface::updateHotkeyInputMap()
hk(QStringLiteral("Fullscreen"), [this](bool pressed) {
if (!pressed)
toggleFullscreen();
emit toggleFullscreenRequested();
});
hk(QStringLiteral("Pause"), [this](bool pressed) {
@ -313,8 +313,6 @@ void QtHostInterface::addButtonToInputMap(const QString& binding, InputButtonHan
}
}
void QtHostInterface::updateFullscreen() {}
void QtHostInterface::powerOffSystem()
{
if (!isOnWorkerThread())
@ -366,18 +364,6 @@ void QtHostInterface::pauseSystem(bool paused)
void QtHostInterface::changeDisc(QString new_disc_filename) {}
void QtHostInterface::toggleFullscreen()
{
if (!isOnWorkerThread())
{
QMetaObject::invokeMethod(this, "toggleFullscreen", Qt::QueuedConnection);
return;
}
m_settings.display_fullscreen = !m_settings.display_fullscreen;
updateFullscreen();
}
void QtHostInterface::doBootSystem(QString initial_filename, QString initial_save_state_filename)
{
if (!m_display_window->initializeDeviceContext())

View File

@ -65,13 +65,13 @@ Q_SIGNALS:
void emulationStopped();
void emulationPaused(bool paused);
void gameListRefreshed();
void toggleFullscreenRequested();
public Q_SLOTS:
void powerOffSystem();
void resetSystem();
void pauseSystem(bool paused);
void changeDisc(QString new_disc_filename);
void toggleFullscreen();
private Q_SLOTS:
void doStopThread();
@ -106,7 +106,6 @@ private:
void updateControllerInputMap();
void updateHotkeyInputMap();
void addButtonToInputMap(const QString& binding, InputButtonHandler handler);
void updateFullscreen();
void createThread();
void stopThread();
void threadEntryPoint();