Przeglądaj źródła

qt: Add message about not moving contents on dir change

Zach Hilman 7 lat temu
rodzic
commit
04397cd185
2 zmienionych plików z 23 dodań i 6 usunięć
  1. 17 4
      src/yuzu/main.cpp
  2. 6 2
      src/yuzu/main.h

+ 17 - 4
src/yuzu/main.cpp

@@ -12,6 +12,7 @@
 
 
 #define QT_NO_OPENGL
 #define QT_NO_OPENGL
 #include <QDesktopWidget>
 #include <QDesktopWidget>
+#include <QDialogButtonBox>
 #include <QFileDialog>
 #include <QFileDialog>
 #include <QMessageBox>
 #include <QMessageBox>
 #include <QtGui>
 #include <QtGui>
@@ -373,9 +374,9 @@ void GMainWindow::ConnectMenuEvents() {
     connect(ui.action_Select_Game_List_Root, &QAction::triggered, this,
     connect(ui.action_Select_Game_List_Root, &QAction::triggered, this,
             &GMainWindow::OnMenuSelectGameListRoot);
             &GMainWindow::OnMenuSelectGameListRoot);
     connect(ui.action_Select_NAND_Directory, &QAction::triggered, this,
     connect(ui.action_Select_NAND_Directory, &QAction::triggered, this,
-            [this] { OnMenuSelectEmulatedDirectory(false); });
+            [this] { OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget::NAND); });
     connect(ui.action_Select_SDMC_Directory, &QAction::triggered, this,
     connect(ui.action_Select_SDMC_Directory, &QAction::triggered, this,
-            [this] { OnMenuSelectEmulatedDirectory(true); });
+            [this] { OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget::SDMC); });
     connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close);
     connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close);
 
 
     // Emulation
     // Emulation
@@ -891,10 +892,22 @@ void GMainWindow::OnMenuSelectGameListRoot() {
     }
     }
 }
 }
 
 
-void GMainWindow::OnMenuSelectEmulatedDirectory(bool is_sdmc) {
+void GMainWindow::OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget target) {
+    const auto res = QMessageBox::information(
+        this, tr("Changing Emulated Directory"),
+        tr("You are about to change the emulated %1 directory of the system. Please note "
+           "that this does not also move the contents of the previous directory to the "
+           "new one and you will have to do that yourself.")
+            .arg(target == EmulatedDirectoryTarget::SDMC ? tr("SD card") : tr("NAND")),
+        QMessageBox::StandardButtons{QMessageBox::Ok, QMessageBox::Cancel});
+
+    if (res == QMessageBox::Cancel)
+        return;
+
     QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
     QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
     if (!dir_path.isEmpty()) {
     if (!dir_path.isEmpty()) {
-        FileUtil::GetUserPath(is_sdmc ? FileUtil::UserPath::SDMCDir : FileUtil::UserPath::NANDDir,
+        FileUtil::GetUserPath(target == EmulatedDirectoryTarget::SDMC ? FileUtil::UserPath::SDMCDir
+                                                                      : FileUtil::UserPath::NANDDir,
                               dir_path.toStdString());
                               dir_path.toStdString());
         Service::FileSystem::CreateFactories(vfs);
         Service::FileSystem::CreateFactories(vfs);
         game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
         game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);

+ 6 - 2
src/yuzu/main.h

@@ -32,6 +32,11 @@ namespace Tegra {
 class DebugContext;
 class DebugContext;
 }
 }
 
 
+enum class EmulatedDirectoryTarget {
+    NAND,
+    SDMC,
+};
+
 class GMainWindow : public QMainWindow {
 class GMainWindow : public QMainWindow {
     Q_OBJECT
     Q_OBJECT
 
 
@@ -138,8 +143,7 @@ private slots:
     /// Called whenever a user selects the "File->Select Game List Root" menu item
     /// Called whenever a user selects the "File->Select Game List Root" menu item
     void OnMenuSelectGameListRoot();
     void OnMenuSelectGameListRoot();
     /// Called whenever a user select the "File->Select -- Directory" where -- is NAND or SD Card
     /// Called whenever a user select the "File->Select -- Directory" where -- is NAND or SD Card
-    /// (false for nand, true for sdmc)
-    void OnMenuSelectEmulatedDirectory(bool is_sdmc);
+    void OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget target);
     void OnMenuRecentFile();
     void OnMenuRecentFile();
     void OnConfigure();
     void OnConfigure();
     void OnAbout();
     void OnAbout();