From bdc59c4c21bebccd6b8497f8f3667c57574677b1 Mon Sep 17 00:00:00 2001
From: wwylele <wwylele@gmail.com>
Date: Fri, 2 Sep 2016 20:18:45 +0800
Subject: [PATCH] Qt: unify running detection

---
 src/citra_qt/configure_dialog.cpp | 8 ++------
 src/citra_qt/configure_dialog.h   | 3 +--
 src/citra_qt/configure_system.cpp | 6 ++++--
 src/citra_qt/configure_system.h   | 2 +-
 src/citra_qt/main.cpp             | 2 +-
 5 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/citra_qt/configure_dialog.cpp b/src/citra_qt/configure_dialog.cpp
index 7da8ad0674..016f201eff 100644
--- a/src/citra_qt/configure_dialog.cpp
+++ b/src/citra_qt/configure_dialog.cpp
@@ -9,10 +9,9 @@
 
 #include "core/settings.h"
 
-ConfigureDialog::ConfigureDialog(QWidget *parent, bool running) :
+ConfigureDialog::ConfigureDialog(QWidget *parent) :
     QDialog(parent),
-    ui(new Ui::ConfigureDialog),
-    emulation_running(running)
+    ui(new Ui::ConfigureDialog)
 {
     ui->setupUi(this);
     this->setConfiguration();
@@ -22,9 +21,6 @@ ConfigureDialog::~ConfigureDialog() {
 }
 
 void ConfigureDialog::setConfiguration() {
-    // System tab needs set manually
-    // depending on whether emulation is running
-    ui->systemTab->setConfiguration(emulation_running);
 }
 
 void ConfigureDialog::applyConfiguration() {
diff --git a/src/citra_qt/configure_dialog.h b/src/citra_qt/configure_dialog.h
index 305b33bdf4..e232699cd9 100644
--- a/src/citra_qt/configure_dialog.h
+++ b/src/citra_qt/configure_dialog.h
@@ -16,7 +16,7 @@ class ConfigureDialog : public QDialog
     Q_OBJECT
 
 public:
-    explicit ConfigureDialog(QWidget *parent, bool emulation_running);
+    explicit ConfigureDialog(QWidget *parent);
     ~ConfigureDialog();
 
     void applyConfiguration();
@@ -26,5 +26,4 @@ private:
 
 private:
     std::unique_ptr<Ui::ConfigureDialog> ui;
-    bool emulation_running;
 };
diff --git a/src/citra_qt/configure_system.cpp b/src/citra_qt/configure_system.cpp
index 4f0d4dbfef..55d9642427 100644
--- a/src/citra_qt/configure_system.cpp
+++ b/src/citra_qt/configure_system.cpp
@@ -8,6 +8,7 @@
 
 #include "core/hle/service/fs/archive.h"
 #include "core/hle/service/cfg/cfg.h"
+#include "core/system.h"
 
 static const std::array<int, 12> days_in_month = {{
     31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
@@ -17,6 +18,7 @@ ConfigureSystem::ConfigureSystem(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::ConfigureSystem) {
     ui->setupUi(this);
+    this->setConfiguration();
 
     connect(ui->combo_birthmonth, SIGNAL(currentIndexChanged(int)), SLOT(updateBirthdayComboBox(int)));
 }
@@ -24,8 +26,8 @@ ConfigureSystem::ConfigureSystem(QWidget *parent) :
 ConfigureSystem::~ConfigureSystem() {
 }
 
-void ConfigureSystem::setConfiguration(bool emulation_running) {
-    enabled = !emulation_running;
+void ConfigureSystem::setConfiguration() {
+    enabled = !System::IsPoweredOn();
 
     if (!enabled) {
         ReadSystemSettings();
diff --git a/src/citra_qt/configure_system.h b/src/citra_qt/configure_system.h
index 1f55770709..f02d2d9497 100644
--- a/src/citra_qt/configure_system.h
+++ b/src/citra_qt/configure_system.h
@@ -20,7 +20,7 @@ public:
     ~ConfigureSystem();
 
     void applyConfiguration();
-    void setConfiguration(bool emulation_running);
+    void setConfiguration();
 
 public slots:
     void updateBirthdayComboBox(int birthmonth_index);
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 9fd4482f6f..cf467532fe 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -510,7 +510,7 @@ void GMainWindow::ToggleWindowMode() {
 }
 
 void GMainWindow::OnConfigure() {
-    ConfigureDialog configureDialog(this, emulation_running);
+    ConfigureDialog configureDialog(this);
     auto result = configureDialog.exec();
     if (result == QDialog::Accepted)
     {