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()); m_host_interface->bootSystem(QString(), QString());
} }
void MainWindow::onExitActionTriggered() {}
void MainWindow::onGitHubRepositoryActionTriggered() {} void MainWindow::onGitHubRepositoryActionTriggered() {}
void MainWindow::onIssueTrackerActionTriggered() {} void MainWindow::onIssueTrackerActionTriggered() {}
@ -276,7 +274,7 @@ void MainWindow::connectSignals()
connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem); 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.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.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.actionFullscreen, &QAction::triggered, this, &MainWindow::toggleFullscreen);
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); }); connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); });
connect(m_ui.actionConsoleSettings, &QAction::triggered, 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 GameListWidget;
class QtHostInterface; class QtHostInterface;
class MainWindow : public QMainWindow class MainWindow final : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -35,11 +35,13 @@ private Q_SLOTS:
void onChangeDiscFromFileActionTriggered(); void onChangeDiscFromFileActionTriggered();
void onChangeDiscFromGameListActionTriggered(); void onChangeDiscFromGameListActionTriggered();
void onStartBiosActionTriggered(); void onStartBiosActionTriggered();
void onExitActionTriggered();
void onGitHubRepositoryActionTriggered(); void onGitHubRepositoryActionTriggered();
void onIssueTrackerActionTriggered(); void onIssueTrackerActionTriggered();
void onAboutActionTriggered(); void onAboutActionTriggered();
protected:
void closeEvent(QCloseEvent* event) override;
private: private:
void setupAdditionalUi(); void setupAdditionalUi();
void connectSignals(); void connectSignals();