summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2016-02-26 08:36:33 -0500
committerGravatar bunnei2016-02-26 08:36:33 -0500
commitc28a48aa023b1617dfc94897d677f4f731f66db8 (patch)
tree86fb29d472d9b94e73d25ccedde01d658e47237d /src
parentMerge pull request #1424 from MerryMage/lut_init (diff)
parentAdd a configuration entry to enable/disable the check (diff)
downloadyuzu-c28a48aa023b1617dfc94897d677f4f731f66db8.tar.gz
yuzu-c28a48aa023b1617dfc94897d677f4f731f66db8.tar.xz
yuzu-c28a48aa023b1617dfc94897d677f4f731f66db8.zip
Merge pull request #1352 from LittleWhite-tb/exit_check
Add check before closure when emulation is running
Diffstat (limited to 'src')
-rw-r--r--src/citra_qt/main.cpp18
-rw-r--r--src/citra_qt/main.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 144f11117..da9ea6c91 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -171,6 +171,8 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
171 } 171 }
172 UpdateRecentFiles(); 172 UpdateRecentFiles();
173 173
174 confirm_before_closing = settings.value("confirmClose", true).toBool();
175
174 // Setup connections 176 // Setup connections
175 connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString))); 177 connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)));
176 connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); 178 connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile()));
@@ -497,7 +499,22 @@ void GMainWindow::OnConfigure() {
497 //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this); 499 //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this);
498} 500}
499 501
502bool GMainWindow::ConfirmClose() {
503 if (emu_thread == nullptr || !confirm_before_closing)
504 return true;
505
506 auto answer = QMessageBox::question(this, tr("Citra"),
507 tr("Are you sure you want to close Citra?"),
508 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
509 return answer != QMessageBox::No;
510}
511
500void GMainWindow::closeEvent(QCloseEvent* event) { 512void GMainWindow::closeEvent(QCloseEvent* event) {
513 if (!ConfirmClose()) {
514 event->ignore();
515 return;
516 }
517
501 // Save window layout 518 // Save window layout
502 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra"); 519 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra");
503 520
@@ -512,6 +529,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
512 settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked()); 529 settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked());
513 settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked()); 530 settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked());
514 settings.setValue("firstStart", false); 531 settings.setValue("firstStart", false);
532 settings.setValue("confirmClose", confirm_before_closing);
515 game_list->SaveInterfaceLayout(settings); 533 game_list->SaveInterfaceLayout(settings);
516 SaveHotkeys(settings); 534 SaveHotkeys(settings);
517 535
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index f6d429cd9..8c195f816 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -82,6 +82,13 @@ private:
82 */ 82 */
83 void UpdateRecentFiles(); 83 void UpdateRecentFiles();
84 84
85 /**
86 * If the emulation is running,
87 * asks the user if he really want to close the emulator
88 *
89 * @return true if the user confirmed
90 */
91 bool ConfirmClose();
85 void closeEvent(QCloseEvent* event) override; 92 void closeEvent(QCloseEvent* event) override;
86 93
87private slots: 94private slots:
@@ -122,6 +129,7 @@ private:
122 GPUCommandListWidget* graphicsCommandsWidget; 129 GPUCommandListWidget* graphicsCommandsWidget;
123 130
124 QAction* actions_recent_files[max_recent_files_item]; 131 QAction* actions_recent_files[max_recent_files_item];
132 bool confirm_before_closing;
125}; 133};
126 134
127#endif // _CITRA_QT_MAIN_HXX_ 135#endif // _CITRA_QT_MAIN_HXX_