Qt: Power off system correctly when exiting

This commit is contained in:
Connor McLaughlin 2020-01-24 14:50:56 +10:00
parent 069bdd471c
commit 9456dc5d9b
2 changed files with 11 additions and 5 deletions

View file

@ -161,8 +161,6 @@ void MainWindow::onStartBiosActionTriggered()
m_host_interface->bootSystem(QString(), QString());
}
void MainWindow::onExitActionTriggered() {}
void MainWindow::onGitHubRepositoryActionTriggered() {}
void MainWindow::onIssueTrackerActionTriggered() {}
@ -276,7 +274,7 @@ void MainWindow::connectSignals()
connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem);
connect(m_ui.actionLoadState, &QAction::triggered, this, [this]() { m_ui.menuLoadState->exec(QCursor::pos()); });
connect(m_ui.actionSaveState, &QAction::triggered, this, [this]() { m_ui.menuSaveState->exec(QCursor::pos()); });
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::onExitActionTriggered);
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::close);
connect(m_ui.actionFullscreen, &QAction::triggered, this, &MainWindow::toggleFullscreen);
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); });
connect(m_ui.actionConsoleSettings, &QAction::triggered,
@ -403,3 +401,9 @@ void MainWindow::populateLoadSaveStateMenus(QString game_code)
}
}
}
void MainWindow::closeEvent(QCloseEvent* event)
{
m_host_interface->powerOffSystem(true, true);
QMainWindow::closeEvent(event);
}

View file

@ -12,7 +12,7 @@ class QLabel;
class GameListWidget;
class QtHostInterface;
class MainWindow : public QMainWindow
class MainWindow final : public QMainWindow
{
Q_OBJECT
@ -35,11 +35,13 @@ private Q_SLOTS:
void onChangeDiscFromFileActionTriggered();
void onChangeDiscFromGameListActionTriggered();
void onStartBiosActionTriggered();
void onExitActionTriggered();
void onGitHubRepositoryActionTriggered();
void onIssueTrackerActionTriggered();
void onAboutActionTriggered();
protected:
void closeEvent(QCloseEvent* event) override;
private:
void setupAdditionalUi();
void connectSignals();